[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. Herald added subscribers: cfe-commits, guansong. Add the capability to nest multiple declare target directives - including header files within a declare target region. Repository: rC Clang https://reviews.llvm.org/D51378 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/Inputs/declare_target_include.h clang/test/OpenMP/declare_target_ast_print.cpp clang/test/OpenMP/declare_target_messages.cpp Index: clang/test/OpenMP/declare_target_messages.cpp === --- clang/test/OpenMP/declare_target_messages.cpp +++ clang/test/OpenMP/declare_target_messages.cpp @@ -59,8 +59,19 @@ } } +#pragma omp declare target + void abc(); +#pragma omp end declare target +void cba(); +#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} -#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} +#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} + #pragma omp declare target +void def(); + #pragma omp end declare target + void fed(); + +#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} // expected-error {{expected '#pragma omp end declare target'}} #pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}} extern int b; int g; Index: clang/test/OpenMP/declare_target_ast_print.cpp === --- clang/test/OpenMP/declare_target_ast_print.cpp +++ clang/test/OpenMP/declare_target_ast_print.cpp @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s -// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s -// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp-simd -I %S/Inputs -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s // expected-no-diagnostics #ifndef HEADER @@ -169,6 +169,32 @@ // CHECK: #pragma omp end declare target // CHECK: int b; +#pragma omp declare target + #include "declare_target_include.h" + void xyz(); +#pragma omp end declare target + +// CHECK: #pragma omp declare target +// CHECK: void zyx(); +// CHECK: #pragma omp end declare target +// CHECK: #pragma omp declare target +// CHECK: void xyz(); +// CHECK: #pragma omp end declare target + +#pragma omp declare target + #pragma omp declare target +void abc(); + #pragma omp end declare target + void cba(); +#pragma omp end declare target + +// CHECK: #pragma omp declare target +// CHECK: void abc(); +// CHECK: #pragma omp end declare target +// CHECK: #pragma omp declare target +// CHECK: void cba(); +// CHECK: #pragma omp end declare target + int main (int argc, char **argv) { foo(); foo_c(); Index: clang/test/OpenMP/Inputs/declare_target_include.h === --- /dev/null +++ clang/test/OpenMP/Inputs/declare_target_include.h @@ -0,0 +1,3 @@ +#pragma omp declare target + void zyx(); +#pragma omp end declare target Index: clang/lib/Sema/SemaOpenMP.cpp === --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -12870,19 +12870,14 @@ Diag(Loc, diag::err_omp_region_not_file_context); return false; } - if (IsInOpenMPDeclareTargetContext) { -Diag(Loc, diag::err_omp_enclosed_declare_target); -return false; - } - - IsInOpenMPDeclareTargetContext = true; + ++DeclareTargetNestingLevel; return true; } void Sema::ActOnFinishOpenMPDeclareTargetDirective() { - assert(IsInOpenMPDeclareTargetContext && + assert(DeclareTargetNestingLevel > 0 && "Unexpected ActOnFinishOpenMPDeclareTargetDirective"); - IsInOpenMPDeclareTargetContext = false; + --DeclareTargetNestingLevel; } void Sema::ActOnOpenMPDeclareTargetName(Scope *CurScope, Index: clang/include/clang/Sema/S
[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives
patricklyster added a comment. In https://reviews.llvm.org/D51378#1216600, @RaviNarayanaswamy wrote: > Is there a way to tell if the header files have matching omp declare > target/omp end declare target. > The reason is if one of the header files is missing a matching omp end > declare target all files which include it will end up having everything > marked with declare target Are you suggesting to throw a warning/error at the end of the header file should there be a hanging `omp declare target`? Wouldn't this still be the same issue with each file that includes it still getting the same warning/error? There is a corner case when the header file is missing the `end declare target` and the file that includes it has an extra `end declare target`. In this case no error will be thrown and all code in between the directives will be associated with the declare target. However, I don't know if this is something worth checking for. Repository: rC Clang https://reviews.llvm.org/D51378 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives
patricklyster added a comment. In https://reviews.llvm.org/D51378#1218184, @RaviNarayanaswamy wrote: > We should just go with generating an error if the DeclareTargetNestingLevel > is not 0 at the end of compilation unit. > Hard to detect if user accidentally forgot to have end declare in header > file and had it in the include file or it was intentional. This is the current behaviour Repository: rC Clang https://reviews.llvm.org/D51378 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives
patricklyster added a comment. In https://reviews.llvm.org/D51378#1219474, @RaviNarayanaswamy wrote: > I did not see the code where check is done if Nestingdepth is 0 at end of > compilation. Sorry I should clarify. You will get an error if you have an unmatched `#pragma omp declare target` once you reach the end of the compilation unit (not the header file) because execution will exit the while loop in ParseOpenMP.cpp:774 when it encounters a `tok::eof` and fall into the `else` statement on ParseOpenMP.cpp:812 which emits the diagnostic. So it is not explicitly checking if DeclareTargetNestingLevel > 0 but you will see an appropriate diagnostic anyways. Repository: rC Clang https://reviews.llvm.org/D51378 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D51378: [OPENMP] Add support for nested 'declare target' directives
patricklyster updated this revision to Diff 164037. patricklyster added a comment. Previous implementation only supported immediately nested declare targets such as below: #pragma omp declare target #pragma omp declare target int foo(); #pragma omp end declare target int bar(); #pragma omp end declare target Update allows for nesting in this format: #pragma omp declare target int foo(); #pragma omp declare target int bar(); #pragma omp end declare target #pragma omp end declare target https://reviews.llvm.org/D51378 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/Inputs/declare_target_include.h clang/test/OpenMP/declare_target_ast_print.cpp clang/test/OpenMP/declare_target_messages.cpp Index: clang/test/OpenMP/declare_target_messages.cpp === --- clang/test/OpenMP/declare_target_messages.cpp +++ clang/test/OpenMP/declare_target_messages.cpp @@ -59,8 +59,19 @@ } } +#pragma omp declare target + void abc(); +#pragma omp end declare target +void cba(); +#pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} -#pragma omp declare target // expected-note {{to match this '#pragma omp declare target'}} +#pragma omp declare target + #pragma omp declare target +void def(); + #pragma omp end declare target + void fed(); + +#pragma omp declare target #pragma omp threadprivate(a) // expected-note {{defined as threadprivate or thread local}} extern int b; int g; @@ -100,9 +111,12 @@ f(); c(); } -#pragma omp declare target // expected-error {{expected '#pragma omp end declare target'}} +#pragma omp declare target void foo1() {} #pragma omp end declare target + +#pragma omp end declare target +#pragma omp end declare target #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}} int C::method() { Index: clang/test/OpenMP/declare_target_ast_print.cpp === --- clang/test/OpenMP/declare_target_ast_print.cpp +++ clang/test/OpenMP/declare_target_ast_print.cpp @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s -// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp -I %S/Inputs -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s -// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s -// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s -// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s +// RUN: %clang_cc1 -verify -fopenmp-simd -I %S/Inputs -ast-print %s | FileCheck %s +// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -I %S/Inputs -emit-pch -o %t %s +// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -I %S/Inputs -verify %s -ast-print | FileCheck %s // expected-no-diagnostics #ifndef HEADER @@ -169,6 +169,32 @@ // CHECK: #pragma omp end declare target // CHECK: int b; +#pragma omp declare target + #include "declare_target_include.h" + void xyz(); +#pragma omp end declare target + +// CHECK: #pragma omp declare target +// CHECK: void zyx(); +// CHECK: #pragma omp end declare target +// CHECK: #pragma omp declare target +// CHECK: void xyz(); +// CHECK: #pragma omp end declare target + +#pragma omp declare target + #pragma omp declare target +void abc(); + #pragma omp end declare target + void cba(); +#pragma omp end declare target + +// CHECK: #pragma omp declare target +// CHECK: void abc(); +// CHECK: #pragma omp end declare target +// CHECK: #pragma omp declare target +// CHECK: void cba(); +// CHECK: #pragma omp end declare target + int main (int argc, char **argv) { foo(); foo_c(); Index: clang/test/OpenMP/Inputs/declare_target_include.h === --- /dev/null +++ clang/test/OpenMP/Inputs/declare_target_include.h @@ -0,0 +1,3 @@ +#pragma omp declare target + void zyx(); +#pragma omp end declare target Index: clang/lib/Sema/SemaOpenMP.cpp === --- clang/lib/Sema/SemaOpenMP.cpp +++ clang/lib/Sema/SemaOpenMP.cpp @@ -12870,19 +12870,14 @@ Diag(Loc, diag::err_omp_region_not_file_context); return false; } - if (IsInOpenMPDeclareTargetContext) { -Diag(Loc, diag::err_omp_enclosed_declare_target); -return false; - } - - IsInOpenMPDeclare
[PATCH] D52097: [OPENMP] Move OMPClauseReader/Writer classes to ASTReader/Writer - NFC
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: OpenMP, clang. Herald added subscribers: cfe-commits, jfb, guansong. Move declarations for `OMPClauseReader`, `OMPClauseWriter` to ASTReader.h and ASTWriter.h and move implementation to ASTReader.cpp and ASTWriter.cpp. This NFC will help generalize the serialization of OpenMP clauses and will be used in the future implementation of new OpenMP directives (e.g. `omp requires`). Repository: rC Clang https://reviews.llvm.org/D52097 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/StmtVisitor.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ASTWriter.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterStmt.cpp Index: clang/lib/Serialization/ASTWriterStmt.cpp === --- clang/lib/Serialization/ASTWriterStmt.cpp +++ clang/lib/Serialization/ASTWriterStmt.cpp @@ -1803,485 +1803,6 @@ } //===--===// -// OpenMP Clauses. -//===--===// - -namespace clang { -class OMPClauseWriter : public OMPClauseVisitor { - ASTRecordWriter &Record; -public: - OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {} -#define OPENMP_CLAUSE(Name, Class)\ - void Visit##Class(Class *S); -#include "clang/Basic/OpenMPKinds.def" - void writeClause(OMPClause *C); - void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C); - void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C); -}; -} - -void OMPClauseWriter::writeClause(OMPClause *C) { - Record.push_back(C->getClauseKind()); - Visit(C); - Record.AddSourceLocation(C->getBeginLoc()); - Record.AddSourceLocation(C->getEndLoc()); -} - -void OMPClauseWriter::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { - Record.push_back(C->getCaptureRegion()); - Record.AddStmt(C->getPreInitStmt()); -} - -void OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getPostUpdateExpr()); -} - -void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) { - VisitOMPClauseWithPreInit(C); - Record.push_back(C->getNameModifier()); - Record.AddSourceLocation(C->getNameModifierLoc()); - Record.AddSourceLocation(C->getColonLoc()); - Record.AddStmt(C->getCondition()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) { - Record.AddStmt(C->getCondition()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { - VisitOMPClauseWithPreInit(C); - Record.AddStmt(C->getNumThreads()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPSafelenClause(OMPSafelenClause *C) { - Record.AddStmt(C->getSafelen()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPSimdlenClause(OMPSimdlenClause *C) { - Record.AddStmt(C->getSimdlen()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) { - Record.AddStmt(C->getNumForLoops()); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) { - Record.push_back(C->getDefaultKind()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getDefaultKindKwLoc()); -} - -void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) { - Record.push_back(C->getProcBindKind()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getProcBindKindKwLoc()); -} - -void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *C) { - VisitOMPClauseWithPreInit(C); - Record.push_back(C->getScheduleKind()); - Record.push_back(C->getFirstScheduleModifier()); - Record.push_back(C->getSecondScheduleModifier()); - Record.AddStmt(C->getChunkSize()); - Record.AddSourceLocation(C->getLParenLoc()); - Record.AddSourceLocation(C->getFirstScheduleModifierLoc()); - Record.AddSourceLocation(C->getSecondScheduleModifierLoc()); - Record.AddSourceLocation(C->getScheduleKindLoc()); - Record.AddSourceLocation(C->getCommaLoc()); -} - -void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) { - Record.push_back(C->getLoopNumIterations().size()); - Record.AddStmt(C->getNumForLoops()); - for (Expr *NumIter : C->getLoopNumIterations()) -Record.AddStmt(NumIter); - for (unsigned I = 0, E = C->getLoopNumIterations().size(); I getLoopCunter(I)); - Record.AddSourceLocation(C->getLParenLoc()); -} - -void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {} - -void O
[PATCH] D53079: [OPENMP] Add 'dynamic_allocators' clause to OMP5.0 'requires' directive
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added a project: clang. Herald added subscribers: cfe-commits, arphaman, guansong. Added new `dynamic_allocators` clause to existing OMP5.0 `requires` directive. Repository: rC Clang https://reviews.llvm.org/D53079 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Sema/Sema.h clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/OpenMP/requires_unified_address_ast_print.cpp clang/test/OpenMP/requires_unified_address_messages.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp === --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -2216,6 +2216,9 @@ void OMPClauseEnqueue::VisitOMPReverseOffloadClause( const OMPReverseOffloadClause *) {} +void OMPClauseEnqueue::VisitOMPDynamicAllocatorsClause( +const OMPDynamicAllocatorsClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } Index: clang/test/OpenMP/requires_unified_address_messages.cpp === --- clang/test/OpenMP/requires_unified_address_messages.cpp +++ clang/test/OpenMP/requires_unified_address_messages.cpp @@ -14,6 +14,11 @@ #pragma omp requires reverse_offload, reverse_offload // expected-error {{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'reverse_offload' clause}} +#pragma omp requires dynamic_allocators // expected-note {{dynamic_allocators clause previously used here}} expected-note {{dynamic_allocators clause previously used here}} + +#pragma omp requires dynamic_allocators, dynamic_allocators // expected-error {{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'dynamic_allocators' clause}} + + #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} @@ -24,7 +29,7 @@ #pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires unified_shared_memory, unified_address, reverse_offload // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_shared_memory, unified_address, reverse_offload, dynamic_allocators // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error{{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}} namespace A { #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} Index: clang/test/OpenMP/requires_unified_address_ast_print.cpp === --- clang/test/OpenMP/requires_unified_address_ast_print.cpp +++ clang/test/OpenMP/requires_unified_address_ast_print.cpp @@ -19,4 +19,7 @@ #pragma omp requires reverse_offload // CHECK:#pragma omp requires reverse_offload +#pragma omp requires dynamic_allocators +// CHECK:#pragma omp requires dynamic_allocators + #endif Index: clang/lib/Serialization/ASTWriter.cpp === --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -6937,3 +6937
[PATCH] D53079: [OPENMP] Add 'dynamic_allocators' clause to OMP5.0 'requires' directive
patricklyster closed this revision. patricklyster added a comment. Closed by commit https://reviews.llvm.org/rL344249 sha: 851f70b951e5e068b0afa6f69ec58e0e80b0a1a4 Repository: rC Clang https://reviews.llvm.org/D53079 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D53513: [OPENMP] Add support for 'atomic_default_mem_order' clause on requires directive
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: clang, OpenMP. Herald added subscribers: cfe-commits, jfb, arphaman, guansong. Added new `atomic_default_mem_order` clause with `seq_cst`, `acq_rel` and `relaxed` modifiers to OMP5.0 `requires` directive. Renamed test files relating to requires tests. Repository: rC Clang https://reviews.llvm.org/D53513 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Basic/OpenMPKinds.h clang/include/clang/Sema/Sema.h clang/lib/AST/DeclPrinter.cpp clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/OpenMP/requires_acq_rel_print.cpp clang/test/OpenMP/requires_ast_print.cpp clang/test/OpenMP/requires_messages.cpp clang/test/OpenMP/requires_relaxed_print.cpp clang/test/OpenMP/requires_unified_address_ast_print.cpp clang/test/OpenMP/requires_unified_address_messages.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp === --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -2219,6 +2219,9 @@ void OMPClauseEnqueue::VisitOMPDynamicAllocatorsClause( const OMPDynamicAllocatorsClause *) {} +void OMPClauseEnqueue::VisitOMPAtomicDefaultMemOrderClause( +const OMPAtomicDefaultMemOrderClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } Index: clang/test/OpenMP/requires_unified_address_messages.cpp === --- clang/test/OpenMP/requires_unified_address_messages.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s - -#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note{{unified_address clause previously used here}} - -#pragma omp requires unified_shared_memory // expected-note {{unified_shared_memory clause previously used here}} expected-note{{unified_shared_memory clause previously used here}} - -#pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} - -#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} - -#pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} - -#pragma omp requires reverse_offload // expected-note {{reverse_offload clause previously used here}} expected-note {{reverse_offload clause previously used here}} - -#pragma omp requires reverse_offload, reverse_offload // expected-error {{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'reverse_offload' clause}} - -#pragma omp requires dynamic_allocators // expected-note {{dynamic_allocators clause previously used here}} expected-note {{dynamic_allocators clause previously used here}} - -#pragma omp requires dynamic_allocators, dynamic_allocators // expected-error {{Only one dynamic_allocators clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'dynamic_allocators' clause}} - - -#pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} - -#pragma omp requires invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} - -#pragma omp requires nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp requires'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} - -#pragma omp requ
[PATCH] D53513: [OPENMP] Add support for 'atomic_default_mem_order' clause on requires directive
patricklyster added inline comments. Comment at: clang/include/clang/AST/OpenMPClause.h:930 + /// Returns location of clause kind. + SourceLocation getAtomicDefaultMemOrderKindKwLoc() const { return KindKwLoc; } + ABataev wrote: > Again, probably too long line. None of these lines are longer than 80 symbols - hard to see this on Phabricator though. All this code was formatted using the clang-format tool. Would you still like me to change it? Repository: rC Clang https://reviews.llvm.org/D53513 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54493: [OPENMP] Check target architecture supports unified shared memory for requires directive
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: OpenMP, clang. Herald added subscribers: cfe-commits, guansong, jholewinski. Restriction on `unified_shared_memory` clause on OpenMP5.0 `requires` directive states that target architecture must support unified addressing (>=sm_70). This patch implements this restriction. Repository: rC Clang https://reviews.llvm.org/D54493 Files: clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGOpenMPRuntime.h clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h clang/test/OpenMP/requires_codegen.cpp Index: clang/test/OpenMP/requires_codegen.cpp === --- /dev/null +++ clang/test/OpenMP/requires_codegen.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -DREGION_HOST +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_20 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_21 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_30 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_32 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_35 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_37 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_50 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_52 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_53 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_60 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_61 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_62 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_70 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE_NO_ERR +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_72 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE_NO_ERR +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -target-cpu sm_75 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t-out.ll -DREGION_DEVICE_NO_ERR + +#if defined(REGION_HOST) || defined(REGION_DEVICE_NO_ERR) +// expected-no-diagnostics +#pragma omp requires unified_shared_memory +#endif + +#ifdef REGION_DEVICE +#pragma omp requires unified_shared_memory // expected-error {{Target architecture does not support unified addressing}} +#endif Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h === --- clang/lib/CodeGen/CGOpenMPRun
[PATCH] D52359: [OPENMP] Add support for OMP5 requires directive + unified_address clause
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: clang, OpenMP. Herald added subscribers: cfe-commits, jfb, guansong, jholewinski. Add support for new OMP5.0 `requires` directive and `unified_address` clause. Patches to follow will include support for additional clauses. Repository: rC Clang https://reviews.llvm.org/D52359 Files: clang/include/clang/AST/DeclOpenMP.h clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/DeclNodes.td clang/include/clang/Basic/DiagnosticParseKinds.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/ASTDumper.cpp clang/lib/AST/DeclBase.cpp clang/lib/AST/DeclOpenMP.cpp clang/lib/AST/DeclPrinter.cpp clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTCommon.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterDecl.cpp clang/test/OpenMP/requires_unified_address_ast_print.cpp clang/test/OpenMP/requires_unified_address_messages.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp === --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -2207,6 +2207,9 @@ void OMPClauseEnqueue::VisitOMPNogroupClause(const OMPNogroupClause *) {} +void OMPClauseEnqueue::VisitOMPUnifiedAddressClause( +const OMPUnifiedAddressClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } @@ -6220,6 +6223,7 @@ case Decl::Import: case Decl::OMPThreadPrivate: case Decl::OMPDeclareReduction: + case Decl::OMPRequires: case Decl::ObjCTypeParam: case Decl::BuiltinTemplate: case Decl::PragmaComment: Index: clang/test/OpenMP/requires_unified_address_messages.cpp === --- /dev/null +++ clang/test/OpenMP/requires_unified_address_messages.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s + +#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} + +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} + +#pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} + +#pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} + +#pragma omp requires invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} + +#pragma omp requires nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp requires'}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} + +#pragma omp requires unified_address, invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} + +#pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} + +namespace A { + #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} + namespace B { +#pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation u
[PATCH] D52625: [OPENMP] Add 'unified_shared_memory' clause to OMP5 'requires' directive
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: clang, OpenMP. Herald added a subscriber: guansong. Added new `unified_shared_memory` clause to existing OMP5.0 `requires` directive Repository: rC Clang https://reviews.llvm.org/D52625 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Sema/Sema.h clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/OpenMP/requires_unified_address_messages.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp === --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -2210,6 +2210,9 @@ void OMPClauseEnqueue::VisitOMPUnifiedAddressClause( const OMPUnifiedAddressClause *) {} +void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause( +const OMPUnifiedSharedMemoryClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } Index: clang/test/OpenMP/requires_unified_address_messages.cpp === --- clang/test/OpenMP/requires_unified_address_messages.cpp +++ clang/test/OpenMP/requires_unified_address_messages.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} +#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note{{unified_address clause previously used here}} + +#pragma omp requires unified_shared_memory // expected-note {{unified_shared_memory clause previously used here}} expected-note{{unified_shared_memory clause previously used here}} + +#pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} @@ -16,6 +20,8 @@ #pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires unified_shared_memory, unified_address // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} + namespace A { #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} namespace B { Index: clang/lib/Serialization/ASTWriter.cpp === --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -6932,3 +6932,6 @@ } void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {} + +void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause( +OMPUnifiedSharedMemoryClause *) {} Index: clang/lib/Serialization/ASTReader.cpp === --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -11723,6 +11723,9 @@ case OMPC_unified_address: C = new (Context) OMPUnifiedAddressClause(); break; + case OMPC_unified_shared_memory: +C = new (Context) OMPUnifiedSharedMemoryClause(); +break; case OMPC_private: C = OMPPrivateClause::CreateEmpty(Context, Record.readInt()); break; @@ -11953,6 +11956,9 @@ void OMPClauseReader::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClau
[PATCH] D52625: [OPENMP] Add 'unified_shared_memory' clause to OMP5 'requires' directive
patricklyster added a comment. In https://reviews.llvm.org/D52625#1248436, @ABataev wrote: > I forgot to mention that you need an ast print test (the positive test) Thanks for the reminder. I will add that Repository: rC Clang https://reviews.llvm.org/D52625 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D52625: [OPENMP] Add 'unified_shared_memory' clause to OMP5 'requires' directive
patricklyster updated this revision to Diff 167459. patricklyster added a comment. Added AST print test for `unified_shared_memory https://reviews.llvm.org/D52625 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Sema/Sema.h clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/OpenMP/requires_unified_address_ast_print.cpp clang/test/OpenMP/requires_unified_address_messages.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp === --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -2210,6 +2210,9 @@ void OMPClauseEnqueue::VisitOMPUnifiedAddressClause( const OMPUnifiedAddressClause *) {} +void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause( +const OMPUnifiedSharedMemoryClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } Index: clang/test/OpenMP/requires_unified_address_messages.cpp === --- clang/test/OpenMP/requires_unified_address_messages.cpp +++ clang/test/OpenMP/requires_unified_address_messages.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} +#pragma omp requires unified_address // expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note {{unified_address clause previously used here}} expected-note{{unified_address clause previously used here}} + +#pragma omp requires unified_shared_memory // expected-note {{unified_shared_memory clause previously used here}} expected-note{{unified_shared_memory clause previously used here}} + +#pragma omp requires unified_shared_memory, unified_shared_memory // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_shared_memory' clause}} #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} @@ -16,6 +20,8 @@ #pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} +#pragma omp requires unified_shared_memory, unified_address // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} + namespace A { #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} namespace B { Index: clang/test/OpenMP/requires_unified_address_ast_print.cpp === --- clang/test/OpenMP/requires_unified_address_ast_print.cpp +++ clang/test/OpenMP/requires_unified_address_ast_print.cpp @@ -13,4 +13,7 @@ #pragma omp requires unified_address // CHECK:#pragma omp requires unified_address +#pragma omp requires unified_shared_memory +// CHECK:#pragma omp requires unified_shared_memory + #endif Index: clang/lib/Serialization/ASTWriter.cpp === --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -6932,3 +6932,6 @@ } void OMPClauseWriter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {} + +void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause( +OMPUnifiedSharedMemoryClause *) {} Index: clang/lib/Serialization/ASTReader.cpp === --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -11723,6 +11723,9 @@ case OMPC_unified_address: C = new (Context) OMPUnifiedAddres
[PATCH] D52780: [OPENMP] Add 'reverse_offload' clause to OMP5.0 'requires' directive
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: clang, OpenMP. Herald added subscribers: cfe-commits, arphaman, guansong. Added new `reverse_offload` clause to existing OMP5.0 `requires` directive Repository: rC Clang https://reviews.llvm.org/D52780 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/Basic/OpenMPKinds.def clang/include/clang/Sema/Sema.h clang/lib/AST/OpenMPClause.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/Basic/OpenMPKinds.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/OpenMP/requires_unified_address_ast_print.cpp clang/test/OpenMP/requires_unified_address_messages.cpp clang/tools/libclang/CIndex.cpp Index: clang/tools/libclang/CIndex.cpp === --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -2213,6 +2213,9 @@ void OMPClauseEnqueue::VisitOMPUnifiedSharedMemoryClause( const OMPUnifiedSharedMemoryClause *) {} +void OMPClauseEnqueue::VisitOMPReverseOffloadClause( +const OMPReverseOffloadClause *) {} + void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) { Visitor->AddStmt(C->getDevice()); } Index: clang/test/OpenMP/requires_unified_address_messages.cpp === --- clang/test/OpenMP/requires_unified_address_messages.cpp +++ clang/test/OpenMP/requires_unified_address_messages.cpp @@ -10,6 +10,10 @@ #pragma omp requires unified_address, unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'unified_address' clause}} +#pragma omp requires reverse_offload // expected-note {{reverse_offload clause previously used here}} expected-note {{reverse_offload clause previously used here}} + +#pragma omp requires reverse_offload, reverse_offload // expected-error {{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} expected-error {{directive '#pragma omp requires' cannot contain more than one 'reverse_offload' clause}} + #pragma omp requires // expected-error {{expected at least one clause on '#pragma omp requires' directive}} #pragma omp requires invalid_clause // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} @@ -20,7 +24,7 @@ #pragma omp requires invalid_clause unified_address // expected-warning {{extra tokens at the end of '#pragma omp requires' are ignored}} expected-error {{expected at least one clause on '#pragma omp requires' directive}} -#pragma omp requires unified_shared_memory, unified_address // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} +#pragma omp requires unified_shared_memory, unified_address, reverse_offload // expected-error {{Only one unified_shared_memory clause can appear on a requires directive in a single translation unit}} expected-error{{Only one unified_address clause can appear on a requires directive in a single translation unit}} expected-error{{Only one reverse_offload clause can appear on a requires directive in a single translation unit}} namespace A { #pragma omp requires unified_address // expected-error {{Only one unified_address clause can appear on a requires directive in a single translation unit}} Index: clang/test/OpenMP/requires_unified_address_ast_print.cpp === --- clang/test/OpenMP/requires_unified_address_ast_print.cpp +++ clang/test/OpenMP/requires_unified_address_ast_print.cpp @@ -16,4 +16,7 @@ #pragma omp requires unified_shared_memory // CHECK:#pragma omp requires unified_shared_memory +#pragma omp requires reverse_offload +// CHECK:#pragma omp requires reverse_offload + #endif Index: clang/lib/Serialization/ASTWriter.cpp === --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -6935,3 +6935,5 @@ void OMPClauseWriter::VisitOMPUnifiedSharedMemoryClause( OMPUnifiedSharedMemoryClause *) {} + +void OMPClauseWriter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {} Index: clang/lib/Serialization/ASTReader.cpp ===
[PATCH] D55982: [OPENMP] Add support for explicit mapping of classes using 'this' pointer
patricklyster created this revision. patricklyster added reviewers: ABataev, Hahnfeld, RaviNarayanaswamy, mikerice, kkwli0, hfinkel, gtbercea. patricklyster added projects: clang, OpenMP. Herald added subscribers: cfe-commits, guansong. Add support for explicit mapping of `this` pointer in OpenMP 5.0. Example use case: class S { int a; void foo() { #pragma omp target map (this[0]) a = 1; } }; Repository: rC Clang https://reviews.llvm.org/D55982 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/target_ast_print.cpp clang/test/OpenMP/target_codegen.cpp clang/test/OpenMP/target_messages.cpp Index: clang/test/OpenMP/target_messages.cpp === --- clang/test/OpenMP/target_messages.cpp +++ clang/test/OpenMP/target_messages.cpp @@ -43,6 +43,18 @@ void foo() { } +class S { + public: + void zee() { +#pragma omp target map(this[:2]) // expected-note {{expected length on mapping of 'this' array section expression to be '1'}} // expected-error {{invalid 'this' expression on 'map' clause}} + int a; +#pragma omp target map(this[1:1]) // expected-note {{expected lower bound on mapping of 'this' array section expression to be '0' or null}} // expected-error {{invalid 'this' expression on 'map' clause}} + int b; +#pragma omp target map(this[1]) // expected-note {{expected 'this' subscript expression on map clause to be 'this[0]'}} // expected-error {{invalid 'this' expression on 'map' clause}} + int c; + } +}; + #pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}} int main(int argc, char **argv) { Index: clang/test/OpenMP/target_codegen.cpp === --- clang/test/OpenMP/target_codegen.cpp +++ clang/test/OpenMP/target_codegen.cpp @@ -40,6 +40,7 @@ // CHECK-DAG: [[TT:%.+]] = type { i64, i8 } // CHECK-DAG: [[S1:%.+]] = type { double } +// CHECK-DAG: [[S2:%.+]] = type { i32, i32, i32 } // CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 } // CHECK-DAG: [[DEVTY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* } // CHECK-DAG: [[DSCTY:%.+]] = type { i32, [[DEVTY]]*, [[ENTTY]]*, [[ENTTY]]* } @@ -48,8 +49,8 @@ // CHECK-DAG: $[[REGFN:\.omp_offloading\..+]] = comdat -// We have 8 target regions, but only 7 that actually will generate offloading -// code and have mapped arguments, and only 5 have all-constant map sizes. +// We have 9 target regions, but only 8 that actually will generate offloading +// code and have mapped arguments, and only 6 have all-constant map sizes. // CHECK-DAG: [[SIZET:@.+]] = private unnamed_addr constant [2 x i[[SZ]]] [i[[SZ]] 0, i[[SZ]] 4] // CHECK-DAG: [[MAPT:@.+]] = private unnamed_addr constant [2 x i64] [i64 544, i64 800] @@ -63,6 +64,9 @@ // CHECK-DAG: [[SIZET6:@.+]] = private unnamed_addr constant [4 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 1, i[[SZ]] 40] // CHECK-DAG: [[MAPT6:@.+]] = private unnamed_addr constant [4 x i64] [i64 800, i64 800, i64 800, i64 547] // CHECK-DAG: [[MAPT7:@.+]] = private unnamed_addr constant [6 x i64] [i64 32, i64 281474976711171, i64 800, i64 288, i64 288, i64 547] +// CHECK-DAG: [[SIZET9:@.+]] = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 12] +// CHECK-DAG: [[MAPT10:@.+]] = private unnamed_addr constant [1 x i64] [i64 35] +// CHECK-DAG: @{{.*}} = weak constant i8 0 // CHECK-DAG: @{{.*}} = weak constant i8 0 // CHECK-DAG: @{{.*}} = weak constant i8 0 // CHECK-DAG: @{{.*}} = weak constant i8 0 @@ -80,6 +84,7 @@ // TCHECK: @{{.+}} = weak constant [[ENTTY]] // TCHECK: @{{.+}} = weak constant [[ENTTY]] // TCHECK: @{{.+}} = weak constant [[ENTTY]] +// TCHECK: @{{.+}} = weak constant [[ENTTY]] // TCHECK-NOT: @{{.+}} = weak constant [[ENTTY]] // Check if offloading descriptor is created. @@ -691,6 +696,31 @@ // CHECK: [[IFEND]] +// CHECK: define {{.*}}@{{.*}}zee{{.*}} + +// CHECK: [[LOCAL_THIS:%.+]] = alloca [[S2]]* +// CHECK: [[BP:%.+]] = alloca [1 x i8*] +// CHECK: [[P:%.+]] = alloca [1 x i8*] +// CHECK: [[LOCAL_THIS1:%.+]] = load [[S2]]*, [[S2]]** [[LOCAL_THIS]] +// CHECK: [[ARR_IDX:%.+]] = getelementptr inbounds [[S2]], [[S2]]* [[LOCAL_THIS1]], i[[SZ]] 0 +// CHECK: [[ARR_IDX2:%.+]] = getelementptr inbounds [[S2]], [[S2]]* [[LOCAL_THIS1]], i[[SZ]] 0 + +// CHECK-DAG: [[BPADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BP]], i32 0, i32 0 +// CHECK-DAG: [[PADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[P]], i32 0, i32 0 +// CHECK-DAG: [[CBPADDR0:%.+]] = bitcast i8** [[BPADDR0]] to [[S2]]** +// CHECK-DAG: [[CPADDR0:%.+]] = bitcast i8** [[PADDR0]] to [[S2]]** +// CHECK-DAG: store [[S2]]* [[ARR_IDX]], [[S2]]** [[CBPADDR0]] +// CHECK-DAG: store [[S2]]* [[ARR_IDX2]], [[S2]]** [[CPADDR0]] + +// CHECK: