@@ -4911,28 +4911,18 @@ emitNumTeamsForTargetDirective(CGOpenMPRuntime &OMPRuntime,
4911
4911
" teams directive expected to be "
4912
4912
" emitted only for the host!" );
4913
4913
4914
- auto &Bld = CGF.Builder ;
4915
-
4916
- // If the target directive is combined with a teams directive:
4917
- // Return the value in the num_teams clause, if any.
4918
- // Otherwise, return 0 to denote the runtime default.
4919
- if (isOpenMPTeamsDirective (D.getDirectiveKind ())) {
4920
- if (const auto *NumTeamsClause = D.getSingleClause <OMPNumTeamsClause>()) {
4921
- CodeGenFunction::RunCleanupsScope NumTeamsScope (CGF);
4922
- auto NumTeams = CGF.EmitScalarExpr (NumTeamsClause->getNumTeams (),
4923
- /* IgnoreResultAssign*/ true );
4924
- return Bld.CreateIntCast (NumTeams, CGF.Int32Ty ,
4925
- /* IsSigned=*/ true );
4926
- }
4927
-
4928
- // The default value is 0.
4929
- return Bld.getInt32 (0 );
4930
- }
4931
-
4932
4914
// If the target directive is combined with a parallel directive but not a
4933
4915
// teams directive, start one team.
4934
- if (isOpenMPParallelDirective (D.getDirectiveKind ()))
4935
- return Bld.getInt32 (1 );
4916
+ if (isOpenMPParallelDirective (D.getDirectiveKind ()) &&
4917
+ !isOpenMPTeamsDirective (D.getDirectiveKind ()))
4918
+ return CGF.Builder .getInt32 (1 );
4919
+
4920
+ // FIXME: For the moment we do not support combined directives with target and
4921
+ // teams, so we do not expect to get any num_teams clause in the provided
4922
+ // directive. Once we support that, this assertion can be replaced by the
4923
+ // actual emission of the clause expression.
4924
+ assert (D.getSingleClause <OMPNumTeamsClause>() == nullptr &&
4925
+ " Not expecting clause in directive." );
4936
4926
4937
4927
// If the current target region has a teams region enclosed, we need to get
4938
4928
// the number of teams to pass to the runtime function call. This is done
@@ -4950,13 +4940,13 @@ emitNumTeamsForTargetDirective(CGOpenMPRuntime &OMPRuntime,
4950
4940
CGOpenMPInnerExprInfo CGInfo (CGF, CS);
4951
4941
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII (CGF, &CGInfo);
4952
4942
llvm::Value *NumTeams = CGF.EmitScalarExpr (NTE->getNumTeams ());
4953
- return Bld .CreateIntCast (NumTeams, CGF.Int32Ty ,
4954
- /* IsSigned=*/ true );
4943
+ return CGF. Builder .CreateIntCast (NumTeams, CGF.Int32Ty ,
4944
+ /* IsSigned=*/ true );
4955
4945
}
4956
4946
4957
4947
// If we have an enclosed teams directive but no num_teams clause we use
4958
4948
// the default value 0.
4959
- return Bld .getInt32 (0 );
4949
+ return CGF. Builder .getInt32 (0 );
4960
4950
}
4961
4951
4962
4952
// No teams associated with the directive.
@@ -4996,20 +4986,9 @@ emitNumThreadsForTargetDirective(CGOpenMPRuntime &OMPRuntime,
4996
4986
//
4997
4987
// If this is not a teams directive return nullptr.
4998
4988
4999
- if (isOpenMPTeamsDirective (D.getDirectiveKind ()) ||
5000
- isOpenMPParallelDirective (D.getDirectiveKind ())) {
4989
+ if (isOpenMPParallelDirective (D.getDirectiveKind ())) {
5001
4990
llvm::Value *DefaultThreadLimitVal = Bld.getInt32 (0 );
5002
4991
llvm::Value *NumThreadsVal = nullptr ;
5003
- llvm::Value *ThreadLimitVal = nullptr ;
5004
-
5005
- if (const auto *ThreadLimitClause =
5006
- D.getSingleClause <OMPThreadLimitClause>()) {
5007
- CodeGenFunction::RunCleanupsScope ThreadLimitScope (CGF);
5008
- auto ThreadLimit = CGF.EmitScalarExpr (ThreadLimitClause->getThreadLimit (),
5009
- /* IgnoreResultAssign*/ true );
5010
- ThreadLimitVal = Bld.CreateIntCast (ThreadLimit, CGF.Int32Ty ,
5011
- /* IsSigned=*/ true );
5012
- }
5013
4992
5014
4993
if (const auto *NumThreadsClause =
5015
4994
D.getSingleClause <OMPNumThreadsClause>()) {
@@ -5021,22 +5000,16 @@ emitNumThreadsForTargetDirective(CGOpenMPRuntime &OMPRuntime,
5021
5000
Bld.CreateIntCast (NumThreads, CGF.Int32Ty , /* IsSigned=*/ true );
5022
5001
}
5023
5002
5024
- // Select the lesser of thread_limit and num_threads.
5025
- if (NumThreadsVal)
5026
- ThreadLimitVal = ThreadLimitVal
5027
- ? Bld.CreateSelect (Bld.CreateICmpSLT (NumThreadsVal,
5028
- ThreadLimitVal),
5029
- NumThreadsVal, ThreadLimitVal)
5030
- : NumThreadsVal;
5031
-
5032
- // Set default value passed to the runtime if either teams or a target
5033
- // parallel type directive is found but no clause is specified.
5034
- if (!ThreadLimitVal)
5035
- ThreadLimitVal = DefaultThreadLimitVal;
5036
-
5037
- return ThreadLimitVal;
5003
+ return NumThreadsVal ? NumThreadsVal : DefaultThreadLimitVal;
5038
5004
}
5039
5005
5006
+ // FIXME: For the moment we do not support combined directives with target and
5007
+ // teams, so we do not expect to get any thread_limit clause in the provided
5008
+ // directive. Once we support that, this assertion can be replaced by the
5009
+ // actual emission of the clause expression.
5010
+ assert (D.getSingleClause <OMPThreadLimitClause>() == nullptr &&
5011
+ " Not expecting clause in directive." );
5012
+
5040
5013
// If the current target region has a teams region enclosed, we need to get
5041
5014
// the thread limit to pass to the runtime function call. This is done
5042
5015
// by generating the expression in a inlined region. This is required because
@@ -6244,10 +6217,6 @@ void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S,
6244
6217
CodeGenFunction::EmitOMPTargetParallelDeviceFunction (
6245
6218
CGM, ParentName, cast<OMPTargetParallelDirective>(*S));
6246
6219
break ;
6247
- case Stmt::OMPTargetTeamsDirectiveClass:
6248
- CodeGenFunction::EmitOMPTargetTeamsDeviceFunction (
6249
- CGM, ParentName, cast<OMPTargetTeamsDirective>(*S));
6250
- break ;
6251
6220
default :
6252
6221
llvm_unreachable (" Unknown target directive for OpenMP device codegen." );
6253
6222
}
0 commit comments