diff options
author | Carlo Bertolli <cbertol@us.ibm.com> | 2016-06-27 14:55:37 +0000 |
---|---|---|
committer | Carlo Bertolli <cbertol@us.ibm.com> | 2016-06-27 14:55:37 +0000 |
commit | 9925f15661624adb8c812f9a59b5b52caa31eb89 (patch) | |
tree | f2817baf9315001c31b1e2e202fc0916ac3e21ef /clang/lib/Parse/ParseOpenMP.cpp | |
parent | b8dc8485c3a6e86730ac06ba40de47345e1ec278 (diff) | |
download | llvm-9925f15661624adb8c812f9a59b5b52caa31eb89.zip llvm-9925f15661624adb8c812f9a59b5b52caa31eb89.tar.gz llvm-9925f15661624adb8c812f9a59b5b52caa31eb89.tar.bz2 |
Resubmission of http://reviews.llvm.org/D21564 after fixes.
[OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'
This patch is an initial implementation for #distribute parallel for.
The main differences that affect other pragmas are:
The implementation of 'distribute parallel for' requires blocking of the associated loop, where blocks are "distributed" to different teams and iterations within each block are scheduled to parallel threads within each team. To implement blocking, sema creates two additional worksharing directive fields that are used to pass the team assigned block lower and upper bounds through the outlined function resulting from 'parallel'. In this way, scheduling for 'for' to threads can use those bounds.
As a consequence of blocking, the stride of 'distribute' is not 1 but it is equal to the blocking size. This is returned by the runtime and sema prepares a DistIncrExpr variable to hold that value.
As a consequence of blocking, the global upper bound (EnsureUpperBound) expression of the 'for' is not the original loop upper bound (e.g. in for(i = 0 ; i < N; i++) this is 'N') but it is the team-assigned block upper bound. Sema creates a new expression holding the calculation of the actual upper bound for 'for' as UB = min(UB, PrevUB), where UB is the loop upper bound, and PrevUB is the team-assigned block upper bound.
llvm-svn: 273884
Diffstat (limited to 'clang/lib/Parse/ParseOpenMP.cpp')
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index b1635cf..8a15cf6 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -40,6 +40,7 @@ enum OpenMPDirectiveKindEx { OMPD_target_enter, OMPD_target_exit, OMPD_update, + OMPD_distribute_parallel }; class ThreadprivateListParserHelper final { @@ -87,6 +88,8 @@ static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) { { OMPD_declare, OMPD_reduction, OMPD_declare_reduction }, { OMPD_declare, OMPD_simd, OMPD_declare_simd }, { OMPD_declare, OMPD_target, OMPD_declare_target }, + { OMPD_distribute, OMPD_parallel, OMPD_distribute_parallel }, + { OMPD_distribute_parallel, OMPD_for, OMPD_distribute_parallel_for }, { OMPD_end, OMPD_declare, OMPD_end_declare }, { OMPD_end_declare, OMPD_target, OMPD_end_declare_target }, { OMPD_target, OMPD_data, OMPD_target_data }, @@ -730,6 +733,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( case OMPD_distribute: case OMPD_end_declare_target: case OMPD_target_update: + case OMPD_distribute_parallel_for: Diag(Tok, diag::err_omp_unexpected_directive) << getOpenMPDirectiveName(DKind); break; @@ -761,7 +765,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl( /// 'taskgroup' | 'teams' | 'taskloop' | 'taskloop simd' | /// 'distribute' | 'target enter data' | 'target exit data' | /// 'target parallel' | 'target parallel for' | -/// 'target update' {clause} +/// 'target update' | 'distribute parallel for' {clause} /// annot_pragma_openmp_end /// StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( @@ -865,7 +869,8 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( case OMPD_target_parallel_for: case OMPD_taskloop: case OMPD_taskloop_simd: - case OMPD_distribute: { + case OMPD_distribute: + case OMPD_distribute_parallel_for: { ConsumeToken(); // Parse directive name of the 'critical' directive if any. if (DKind == OMPD_critical) { |