Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli added a comment. Resubmitted at rev255498 Repository: rL LLVM http://reviews.llvm.org/D15125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli closed this revision. carlo.bertolli added a comment. This was committed in r255001. Many thanks for all your help. Repository: rL LLVM http://reviews.llvm.org/D15125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
ABataev added inline comments. Comment at: include/clang-c/Index.h:2263-2267 @@ -2262,3 +2262,7 @@ - CXCursor_LastStmt = CXCursor_OMPTaskLoopDirective, + /** \brief OpenMP distribute directive. + */ + CXCursor_OMPDistributeDirective= 259, + + CXCursor_LastStmt = CXCursor_OMPDistributeDirective, Update it to the latest changes Comment at: include/clang/AST/OpenMPClause.h:708-709 @@ -707,4 +707,4 @@ public: - /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size - /// expression \a ChunkSize. + /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk + /// size expression \a ChunkSize. /// Revert back these changes, this comment should not be modified Comment at: include/clang/AST/StmtOpenMP.h:2282 @@ +2281,3 @@ +/// +class OMPDistributeDirective : public OMPLoopDirective { + friend class ASTStmtReader; You forget to modify OMPLoopDirective::classof() Comment at: lib/Basic/OpenMPKinds.cpp:460 @@ -449,4 +459,3 @@ DKind == OMPD_single || DKind == OMPD_parallel_for || - DKind == OMPD_parallel_for_simd || - DKind == OMPD_parallel_sections; // TODO add next directives. + DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections; // TODO add next directives. } Revert these changes back Comment at: lib/Parse/ParseOpenMP.cpp:162 @@ -160,3 +161,3 @@ /// 'for simd' | 'parallel for simd' | 'target' | 'target data' | -/// 'taskgroup' | 'teams' {clause} +/// 'taskgroup' | 'teams' {clause} | 'distribute' {clause} /// annot_pragma_openmp_end Remove {clause} after 'teams' Comment at: lib/Parse/ParseOpenMP.cpp:402 @@ -399,3 +401,3 @@ /// simdlen-clause | threads-clause | simd-clause | num_teams-clause | -/// thread_limit-clause | priority-clause +/// thread_limit-clause | priority-clause /// Revert back these changes Comment at: lib/Parse/ParseOpenMP.cpp:684 @@ -681,3 +683,3 @@ bool NeedAnExpression = - (Kind == OMPC_schedule && DelimLoc.isValid()) || Kind == OMPC_if; + (Kind == OMPC_schedule && DelimLoc.isValid()) ||Kind == OMPC_if; if (NeedAnExpression) { Revert back these changes Repository: rL LLVM http://reviews.llvm.org/D15125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli updated this revision to Diff 41980. carlo.bertolli marked 7 inline comments as done. carlo.bertolli added a comment. This updated patch includes taskloop simd changes form the trunk and it addresses the second round of comments. Repository: rL LLVM http://reviews.llvm.org/D15125 Files: include/clang-c/Index.h include/clang/AST/RecursiveASTVisitor.h include/clang/AST/StmtOpenMP.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/OpenMPKinds.def include/clang/Basic/OpenMPKinds.h include/clang/Basic/StmtNodes.td include/clang/Sema/Sema.h include/clang/Serialization/ASTBitCodes.h lib/AST/StmtOpenMP.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtProfile.cpp lib/Basic/OpenMPKinds.cpp lib/CodeGen/CGStmt.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.h lib/Parse/ParseOpenMP.cpp lib/Sema/SemaOpenMP.cpp lib/Sema/TreeTransform.h lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterStmt.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp test/OpenMP/distribute_ast_print.cpp test/OpenMP/distribute_collapse_messages.cpp test/OpenMP/distribute_firstprivate_messages.cpp test/OpenMP/distribute_private_messages.cpp test/OpenMP/nesting_of_regions.cpp tools/libclang/CIndex.cpp tools/libclang/CXCursor.cpp Index: tools/libclang/CXCursor.cpp === --- tools/libclang/CXCursor.cpp +++ tools/libclang/CXCursor.cpp @@ -613,6 +613,9 @@ case Stmt::OMPTaskLoopSimdDirectiveClass: K = CXCursor_OMPTaskLoopSimdDirective; break; + case Stmt::OMPDistributeDirectiveClass: +K = CXCursor_OMPDistributeDirective; +break; } CXCursor C = { K, 0, { Parent, S, TU } }; Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -1944,6 +1944,7 @@ void VisitOMPTeamsDirective(const OMPTeamsDirective *D); void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D); void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D); + void VisitOMPDistributeDirective(const OMPDistributeDirective *D); private: void AddDeclarationNameInfo(const Stmt *S); @@ -2622,6 +2623,11 @@ VisitOMPLoopDirective(D); } +void EnqueueVisitor::VisitOMPDistributeDirective( +const OMPDistributeDirective *D) { + VisitOMPLoopDirective(D); +} + void CursorVisitor::EnqueueWorkList(VisitorWorkList , const Stmt *S) { EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S); } @@ -4482,6 +4488,8 @@ return cxstring::createRef("OMPTaskLoopDirective"); case CXCursor_OMPTaskLoopSimdDirective: return cxstring::createRef("OMPTaskLoopSimdDirective"); + case CXCursor_OMPDistributeDirective: +return cxstring::createRef("OMPDistributeDirective"); case CXCursor_OverloadCandidate: return cxstring::createRef("OverloadCandidate"); case CXCursor_TypeAliasTemplateDecl: Index: test/OpenMP/nesting_of_regions.cpp === --- test/OpenMP/nesting_of_regions.cpp +++ test/OpenMP/nesting_of_regions.cpp @@ -106,6 +106,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp parallel + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} +for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -239,6 +245,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} +for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -395,6 +407,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} +for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -528,6 +546,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp for simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} +for (int j = 0; j < 10; ++j) + ; + } // SECTIONS DIRECTIVE #pragma omp sections @@ -691,6 +715,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp sections + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} +for (int i = 0; i < 10; ++i) + ; + } // SECTION DIRECTIVE #pragma omp section // expected-error {{orphaned 'omp section'
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli added inline comments. Comment at: lib/Basic/OpenMPKinds.cpp:460 @@ -449,4 +459,3 @@ DKind == OMPD_single || DKind == OMPD_parallel_for || - DKind == OMPD_parallel_for_simd || - DKind == OMPD_parallel_sections; // TODO add next directives. + DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections; // TODO add next directives. } ABataev wrote: > Revert these changes back This changed due to taskloop. I have added distribute after taskloop and placed the comment in the same way as is in the current trunk for taskloop. Repository: rL LLVM http://reviews.llvm.org/D15125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli updated this revision to Diff 41712. carlo.bertolli marked 15 inline comments as done. carlo.bertolli added a comment. Thanks very much for your kind comments and patience at some trivial errors on my side. This new version of the patch addresses all your concerns and it removes dist_schedule from the patch. There is only one check in semantic analysis that was non trivial: the description of my solution is addressed in my answer to the related comment. I will generate a new independent patch for dist_schedule, but in the meantime I look forward to your new comments. Repository: rL LLVM http://reviews.llvm.org/D15125 Files: include/clang-c/Index.h include/clang/AST/OpenMPClause.h include/clang/AST/RecursiveASTVisitor.h include/clang/AST/StmtOpenMP.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/OpenMPKinds.def include/clang/Basic/OpenMPKinds.h include/clang/Basic/StmtNodes.td include/clang/Sema/Sema.h include/clang/Serialization/ASTBitCodes.h lib/AST/StmtOpenMP.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtProfile.cpp lib/Basic/OpenMPKinds.cpp lib/CodeGen/CGStmt.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.h lib/Parse/ParseOpenMP.cpp lib/Sema/SemaOpenMP.cpp lib/Sema/TreeTransform.h lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterStmt.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp test/OpenMP/distribute_ast_print.cpp test/OpenMP/distribute_collapse_messages.cpp test/OpenMP/distribute_firstprivate_messages.cpp test/OpenMP/distribute_private_messages.cpp test/OpenMP/nesting_of_regions.cpp tools/libclang/CIndex.cpp tools/libclang/CXCursor.cpp Index: tools/libclang/CXCursor.cpp === --- tools/libclang/CXCursor.cpp +++ tools/libclang/CXCursor.cpp @@ -607,9 +607,12 @@ case Stmt::OMPCancelDirectiveClass: K = CXCursor_OMPCancelDirective; break; - case Stmt::OMPTaskLoopDirectiveClass: + case Stmt::OMPTaskLoopDirectiveClass: K = CXCursor_OMPTaskLoopDirective; break; + case Stmt::OMPDistributeDirectiveClass: +K = CXCursor_OMPDistributeDirective; +break; } CXCursor C = { K, 0, { Parent, S, TU } }; Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -1942,7 +1942,8 @@ void VisitOMPTargetDirective(const OMPTargetDirective *D); void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D); void VisitOMPTeamsDirective(const OMPTeamsDirective *D); - void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D); + void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D); + void VisitOMPDistributeDirective(const OMPDistributeDirective *D); private: void AddDeclarationNameInfo(const Stmt *S); @@ -2616,6 +2617,11 @@ VisitOMPLoopDirective(D); } +void EnqueueVisitor::VisitOMPDistributeDirective( +const OMPDistributeDirective *D) { + VisitOMPLoopDirective(D); +} + void CursorVisitor::EnqueueWorkList(VisitorWorkList , const Stmt *S) { EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S); } @@ -4474,6 +4480,8 @@ return cxstring::createRef("OMPCancelDirective"); case CXCursor_OMPTaskLoopDirective: return cxstring::createRef("OMPTaskLoopDirective"); + case CXCursor_OMPDistributeDirective: +return cxstring::createRef("OMPDistributeDirective"); case CXCursor_OverloadCandidate: return cxstring::createRef("OverloadCandidate"); case CXCursor_TypeAliasTemplateDecl: Index: test/OpenMP/nesting_of_regions.cpp === --- test/OpenMP/nesting_of_regions.cpp +++ test/OpenMP/nesting_of_regions.cpp @@ -106,6 +106,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp parallel + { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} +for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -239,6 +245,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} +for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -395,6 +407,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} +for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -528,6 +546,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp for simd + for (int i = 0; i <
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli added inline comments. Comment at: include/clang/AST/OpenMPClause.h:667 @@ -666,3 +666,3 @@ OpenMPScheduleClauseKind Kind; - /// \brief Start location of the schedule ind in source code. + /// \brief Start location of the schedule kind in source code. SourceLocation KindLoc; ABataev wrote: > This must be in a separate patch OK - I will create a patch dependent on this one for dist_schedule. Comment at: include/clang/AST/OpenMPClause.h:708 @@ -707,3 +707,3 @@ public: - /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size - /// expression \a ChunkSize. + /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk + /// size expression \a ChunkSize. kkwli0 wrote: > ABataev wrote: > > I think this is wrong, this is not for dist_schedule, but for schedule > > clause > Is it 'schedule'? Done Comment at: include/clang/AST/OpenMPClause.h:708-709 @@ -707,4 +707,4 @@ public: - /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size - /// expression \a ChunkSize. + /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk + /// size expression \a ChunkSize. /// carlo.bertolli wrote: > kkwli0 wrote: > > ABataev wrote: > > > I think this is wrong, this is not for dist_schedule, but for schedule > > > clause > > Is it 'schedule'? > Done Done Comment at: include/clang/AST/OpenMPClause.h:835 @@ +834,3 @@ +public: + /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size + /// expression \a ChunkSize. kkwli0 wrote: > 'dist_schedule' Done Comment at: lib/Parse/ParseOpenMP.cpp:162 @@ -160,3 +161,3 @@ /// 'for simd' | 'parallel for simd' | 'target' | 'target data' | -/// 'taskgroup' | 'teams' {clause} +/// 'taskgroup' | 'teams' {clause} | 'distribute' /// annot_pragma_openmp_end ABataev wrote: > 'distribute' misses clauses, put your changes right after 'teams' Add {clause} after distribute, but I see that distribute is already after teams in this comment. Where else should I move it? Comment at: lib/Parse/ParseOpenMP.cpp:670 @@ -666,1 +669,3 @@ DelimLoc = ConsumeAnyToken(); + } else if (Kind == OMPC_dist_schedule) { +Arg = getOpenMPSimpleClauseType( kkwli0 wrote: > Can we merge it with the OMPC_schedule block? The code is similar. Yes, I also believe that this is the right thing to do as schedule type "static" is the same for dist_schedule and schedule. Comment at: lib/Sema/SemaOpenMP.cpp:1989 @@ -1979,2 +1988,3 @@ // | teams| taskloop| + | + // | teams| distribute | !! | // +--+-++ ABataev wrote: > Add rules for distribute to all other directives Done and added rules for distribute itself when containing other directives. Comment at: lib/Sema/SemaOpenMP.cpp:2026-2027 @@ -2015,3 +2025,4 @@ ShouldBeInOrderedRegion, - ShouldBeInTargetRegion + ShouldBeInTargetRegion, + ShouldBeInTeamsRegion } Recommend = NoRecommend; ABataev wrote: > I don't think this change is required I added this to specifically express that distribute needs to be closely nested inside teams, but then reverted to do something different. Following your next comment I made changes that made this necessary again. Please check my answer to your next comment and the associated change in the new patch. Comment at: lib/Sema/SemaOpenMP.cpp:2062-2072 @@ -2050,2 +2061,13 @@ return false; +if (isOpenMPDistributeDirective(CurrentRegion)) { + // OpenMP 4.5 [2.17 Nesting of Regions] + // The region associated with the distribute construct must be strictly + // nested inside a teams region + if (ParentRegion != OMPD_teams) { +SemaRef.Diag(StartLoc, + diag::err_omp_distribute_strictly_nested_in_teams); +return true; + } + return false; +} if (CurrentRegion == OMPD_cancellation_point || ABataev wrote: > This must be handled in lines 2173-2181 Those lines (2173-2181) check that teams contains the right directives. It means that we look at the parent and we enter the if-then branch only if the parent region is a teams. What I am trying to do here is instead check if the parent of any distribute directive is a teams region. If not, I raise an error. This is different form lines 2173-2181 because I need to prove that I am *not* in a teams region. Anyway, I do agree with you that this should be done elsewhere. I added a new if after the lines you indicated that check the condition
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
kkwli0 added inline comments. Comment at: include/clang/AST/OpenMPClause.h:708 @@ -707,3 +707,3 @@ public: - /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size - /// expression \a ChunkSize. + /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk + /// size expression \a ChunkSize. Is it 'schedule'? Comment at: include/clang/AST/OpenMPClause.h:835 @@ +834,3 @@ +public: + /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size + /// expression \a ChunkSize. 'dist_schedule' Comment at: lib/Parse/ParseOpenMP.cpp:670 @@ -666,1 +669,3 @@ DelimLoc = ConsumeAnyToken(); + } else if (Kind == OMPC_dist_schedule) { +Arg = getOpenMPSimpleClauseType( Can we merge it with the OMPC_schedule block? The code is similar. Comment at: lib/Sema/SemaOpenMP.cpp:5780 @@ +5779,3 @@ + if (ChunkSize) { +if (!ChunkSize->isValueDependent() && !ChunkSize->isTypeDependent() && +!ChunkSize->isInstantiationDependent() && Is the IsNotNegativeIntegerValue useful in this case? Comment at: tools/libclang/CIndex.cpp:4489 @@ -4477,1 +4488,3 @@ + case CXCursor_OMPDistributeDirective: +return cxstring::createRef("OMPForDirective"); case CXCursor_OverloadCandidate: "OMPDistributeDirective" Repository: rL LLVM http://reviews.llvm.org/D15125 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
ABataev added inline comments. Comment at: include/clang/AST/OpenMPClause.h:667 @@ -666,3 +666,3 @@ OpenMPScheduleClauseKind Kind; - /// \brief Start location of the schedule ind in source code. + /// \brief Start location of the schedule kind in source code. SourceLocation KindLoc; This must be in a separate patch Comment at: include/clang/AST/OpenMPClause.h:708-709 @@ -707,4 +707,4 @@ public: - /// \brief Build 'schedule' clause with schedule kind \a Kind and chunk size - /// expression \a ChunkSize. + /// \brief Build 'dist_schedule' clause with schedule kind \a Kind and chunk + /// size expression \a ChunkSize. /// I think this is wrong, this is not for dist_schedule, but for schedule clause Comment at: include/clang/AST/OpenMPClause.h:779 @@ -778,1 +778,3 @@ +/// \brief This represents 'dist_schedule' clause in the '#pragma omp ...' +/// directive. This must be in a separate patch Comment at: include/clang/AST/RecursiveASTVisitor.h:2732-2738 @@ -2727,1 +2731,9 @@ template +bool RecursiveASTVisitor::VisitOMPDistScheduleClause( +OMPDistScheduleClause *C) { + TRY_TO(TraverseStmt(C->getChunkSize())); + TRY_TO(TraverseStmt(C->getHelperChunkSize())); + return true; +} + +template separate patch Comment at: include/clang/AST/StmtOpenMP.h:2279 @@ +2278,3 @@ + /// \brief true if current directive has inner cancel directive. + bool HasCancel; + Distribute directive cannot have inner cancel Comment at: include/clang/Basic/OpenMPKinds.h:89-95 @@ -88,2 +88,9 @@ +/// \brief OpenMP attributes for 'dist_schedule' clause. +enum OpenMPDistScheduleClauseKind { +#define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name, +#include "clang/Basic/OpenMPKinds.def" + OMPC_DIST_SCHEDULE_unknown +}; + OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str); Separate patch Comment at: lib/AST/StmtPrinter.cpp:882 @@ +881,3 @@ +void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) { + OS << "schedule(" << getOpenMPSimpleClauseTypeName( + OMPC_dist_schedule, Node->getDistScheduleKind()); dist_schedule, not schedule Comment at: lib/Basic/OpenMPKinds.cpp:475 @@ -452,1 +474,3 @@ + DKind == OMPD_parallel_for_simd || DKind == OMPD_parallel_sections || + DKind == OMPD_distribute; // TODO add next directives. } distribute is not a worksharing directive Comment at: lib/Parse/ParseOpenMP.cpp:162 @@ -160,3 +161,3 @@ /// 'for simd' | 'parallel for simd' | 'target' | 'target data' | -/// 'taskgroup' | 'teams' {clause} +/// 'taskgroup' | 'teams' {clause} | 'distribute' /// annot_pragma_openmp_end 'distribute' misses clauses, put your changes right after 'teams' Comment at: lib/Parse/ParseOpenMP.cpp:239 @@ -238,1 +238,3 @@ + case OMPD_distribute: + case OMPD_target_data: { ConsumeToken(); Restore the order of target_data and taskloop directives, put distribute right after taskloop Comment at: lib/Sema/SemaOpenMP.cpp:1530 @@ -1521,2 +1529,3 @@ // | Parent directive | Child directive | Closely (!), No-Closely(+), Both(*)| + // | | | Strictly (!!) | // +--+-++ It is not required, closely without no-closely means strictly Comment at: lib/Sema/SemaOpenMP.cpp:1989 @@ -1979,2 +1988,3 @@ // | teams| taskloop| + | + // | teams| distribute | !! | // +--+-++ Add rules for distribute to all other directives Comment at: lib/Sema/SemaOpenMP.cpp:2026-2027 @@ -2015,3 +2025,4 @@ ShouldBeInOrderedRegion, - ShouldBeInTargetRegion + ShouldBeInTargetRegion, + ShouldBeInTeamsRegion } Recommend = NoRecommend; I don't think this change is required Comment at: lib/Sema/SemaOpenMP.cpp:2062-2072 @@ -2050,2 +2061,13 @@ return false; +if (isOpenMPDistributeDirective(CurrentRegion)) { + // OpenMP 4.5 [2.17 Nesting of Regions] + // The region associated with the distribute construct must be strictly + // nested inside a teams region + if (ParentRegion != OMPD_teams) { +SemaRef.Diag(StartLoc, + diag::err_omp_distribute_strictly_nested_in_teams); +return true; + } + return false; +} if (CurrentRegion == OMPD_cancellation_point ||
[PATCH] D15125: [OPENMP] 'omp distribute' directive basic support.
carlo.bertolli created this revision. carlo.bertolli added reviewers: hfinkel, ABataev, rjmccall. carlo.bertolli added subscribers: sfantao, cfe-commits. carlo.bertolli set the repository for this revision to rL LLVM. This patch includes parsing and semantic analysis for 'omp distribute' directive for OpenMP 4.5 and regression tests. All clauses present in OpenMP 4.5 for the 'omp distribute' directive are present. Repository: rL LLVM http://reviews.llvm.org/D15125 Files: include/clang-c/Index.h include/clang/AST/OpenMPClause.h include/clang/AST/RecursiveASTVisitor.h include/clang/AST/StmtOpenMP.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/OpenMPKinds.def include/clang/Basic/OpenMPKinds.h include/clang/Basic/StmtNodes.td include/clang/Sema/Sema.h include/clang/Serialization/ASTBitCodes.h lib/AST/StmtOpenMP.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtProfile.cpp lib/Basic/OpenMPKinds.cpp lib/CodeGen/CGStmt.cpp lib/CodeGen/CGStmtOpenMP.cpp lib/CodeGen/CodeGenFunction.h lib/Parse/ParseOpenMP.cpp lib/Sema/SemaOpenMP.cpp lib/Sema/TreeTransform.h lib/Serialization/ASTReaderStmt.cpp lib/Serialization/ASTWriterStmt.cpp lib/StaticAnalyzer/Core/ExprEngine.cpp test/OpenMP/distribute_ast_print.cpp test/OpenMP/distribute_collapse_messages.cpp test/OpenMP/distribute_dist_schedule_messages.cpp test/OpenMP/distribute_firstprivate_messages.cpp test/OpenMP/distribute_private_messages.cpp test/OpenMP/nesting_of_regions.cpp tools/libclang/CIndex.cpp tools/libclang/CXCursor.cpp Index: tools/libclang/CXCursor.cpp === --- tools/libclang/CXCursor.cpp +++ tools/libclang/CXCursor.cpp @@ -607,9 +607,12 @@ case Stmt::OMPCancelDirectiveClass: K = CXCursor_OMPCancelDirective; break; - case Stmt::OMPTaskLoopDirectiveClass: + case Stmt::OMPTaskLoopDirectiveClass: K = CXCursor_OMPTaskLoopDirective; break; + case Stmt::OMPDistributeDirectiveClass: +K = CXCursor_OMPDistributeDirective; +break; } CXCursor C = { K, 0, { Parent, S, TU } }; Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -1942,7 +1942,8 @@ void VisitOMPTargetDirective(const OMPTargetDirective *D); void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D); void VisitOMPTeamsDirective(const OMPTeamsDirective *D); - void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D); + void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D); + void VisitOMPDistributeDirective(const OMPDistributeDirective *D); private: void AddDeclarationNameInfo(const Stmt *S); @@ -2195,6 +2196,11 @@ VisitOMPClauseList(C); } } +void OMPClauseEnqueue::VisitOMPDistScheduleClause( +const OMPDistScheduleClause *C) { + Visitor->AddStmt(C->getChunkSize()); + Visitor->AddStmt(C->getHelperChunkSize()); +} void EnqueueVisitor::EnqueueChildren(const OMPClause *S) { unsigned size = WL.size(); @@ -2616,6 +2622,11 @@ VisitOMPLoopDirective(D); } +void EnqueueVisitor::VisitOMPDistributeDirective( +const OMPDistributeDirective *D) { + VisitOMPLoopDirective(D); +} + void CursorVisitor::EnqueueWorkList(VisitorWorkList , const Stmt *S) { EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU,RegionOfInterest)).Visit(S); } @@ -4474,6 +4485,8 @@ return cxstring::createRef("OMPCancelDirective"); case CXCursor_OMPTaskLoopDirective: return cxstring::createRef("OMPTaskLoopDirective"); + case CXCursor_OMPDistributeDirective: +return cxstring::createRef("OMPForDirective"); case CXCursor_OverloadCandidate: return cxstring::createRef("OverloadCandidate"); case CXCursor_TypeAliasTemplateDecl: Index: test/OpenMP/nesting_of_regions.cpp === --- test/OpenMP/nesting_of_regions.cpp +++ test/OpenMP/nesting_of_regions.cpp @@ -106,6 +106,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp parallel + { +#pragma omp distribute // expected-error {{'#pragma omp distribute' must be strictly nested in '#pragma omp teams'}} +for (int i = 0; i < 10; ++i) + ; + } // SIMD DIRECTIVE #pragma omp simd @@ -239,6 +245,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp simd + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} +for (int j = 0; j < 10; ++j) + ; + } // FOR DIRECTIVE #pragma omp for @@ -395,6 +407,12 @@ for (int i = 0; i < 10; ++i) ++a; } +#pragma omp for + for (int i = 0; i < 10; ++i) { +#pragma omp distribute // expected-error {{'#pragma omp distribute' must be strictly nested in '#pragma omp teams'}} +for (int j = 0; j < 10; ++j) + ; + } // FOR SIMD DIRECTIVE #pragma omp for simd @@ -528,6 +546,12 @@ for (int i = 0;