diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h --- a/flang/include/flang/Parser/parse-tree.h +++ b/flang/include/flang/Parser/parse-tree.h @@ -3781,7 +3781,7 @@ u; }; -// Parse tree nodes for OpenACC 3.0 directives and clauses +// Parse tree nodes for OpenACC 3.1 directives and clauses struct AccObject { UNION_CLASS_BOILERPLATE(AccObject); diff --git a/flang/lib/Parser/openacc-parsers.cpp b/flang/lib/Parser/openacc-parsers.cpp --- a/flang/lib/Parser/openacc-parsers.cpp +++ b/flang/lib/Parser/openacc-parsers.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// Top-level grammar specification for OpenACC 3.0. +// Top-level grammar specification for OpenACC 3.1. #include "basic-parsers.h" #include "expr-parsers.h" diff --git a/flang/lib/Semantics/check-acc-structure.h b/flang/lib/Semantics/check-acc-structure.h --- a/flang/lib/Semantics/check-acc-structure.h +++ b/flang/lib/Semantics/check-acc-structure.h @@ -4,7 +4,7 @@ // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -// OpenACC structure validity check list +// OpenACC 3.1 structure validity check list // 1. invalid clauses on directive // 2. invalid repeated clauses on directive // 3. invalid nesting of regions diff --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp --- a/flang/lib/Semantics/check-acc-structure.cpp +++ b/flang/lib/Semantics/check-acc-structure.cpp @@ -23,14 +23,11 @@ namespace Fortran::semantics { static constexpr inline AccClauseSet - parallelAndKernelsOnlyAllowedAfterDeviceTypeClauses{ + computeConstructOnlyAllowedAfterDeviceTypeClauses{ llvm::acc::Clause::ACCC_async, llvm::acc::Clause::ACCC_wait, llvm::acc::Clause::ACCC_num_gangs, llvm::acc::Clause::ACCC_num_workers, llvm::acc::Clause::ACCC_vector_length}; -static constexpr inline AccClauseSet serialOnlyAllowedAfterDeviceTypeClauses{ - llvm::acc::Clause::ACCC_async, llvm::acc::Clause::ACCC_wait}; - static constexpr inline AccClauseSet loopOnlyAllowedAfterDeviceTypeClauses{ llvm::acc::Clause::ACCC_auto, llvm::acc::Clause::ACCC_collapse, llvm::acc::Clause::ACCC_independent, llvm::acc::Clause::ACCC_gang, @@ -80,27 +77,19 @@ switch (blockDir.v) { case llvm::acc::Directive::ACCD_kernels: case llvm::acc::Directive::ACCD_parallel: - // Restriction - 880-881 (KERNELS) - // Restriction - 843-844 (PARALLEL) - CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, - parallelAndKernelsOnlyAllowedAfterDeviceTypeClauses); - // Restriction - 877 (KERNELS) - // Restriction - 840 (PARALLEL) - CheckNoBranching(block, GetContext().directive, blockDir.source); - break; case llvm::acc::Directive::ACCD_serial: - // Restriction - 919 + // Restriction - line 1004-1005 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, - serialOnlyAllowedAfterDeviceTypeClauses); - // Restriction - 916 - CheckNoBranching(block, llvm::acc::Directive::ACCD_serial, blockDir.source); + computeConstructOnlyAllowedAfterDeviceTypeClauses); + // Restriction - line 1001 + CheckNoBranching(block, GetContext().directive, blockDir.source); break; case llvm::acc::Directive::ACCD_data: - // Restriction - 1117-1118 + // Restriction - line 1249-1250 CheckRequireAtLeastOneOf(); break; case llvm::acc::Directive::ACCD_host_data: - // Restriction - 1578 + // Restriction - line 1746 CheckRequireAtLeastOneOf(); break; default: @@ -117,7 +106,7 @@ void AccStructureChecker::Leave( const parser::OpenACCStandaloneDeclarativeConstruct &) { - // Restriction - 2075 + // Restriction - line 2409 CheckAtLeastOneClause(); dirContext_.pop_back(); } @@ -144,18 +133,10 @@ switch (combinedDir.v) { case llvm::acc::Directive::ACCD_kernels_loop: case llvm::acc::Directive::ACCD_parallel_loop: - // Restriction - 1962 -> (880-881) (KERNELS LOOP) - // Restriction - 1962 -> (843-844) (PARALLEL LOOP) - CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, - {llvm::acc::Clause::ACCC_async, llvm::acc::Clause::ACCC_wait, - llvm::acc::Clause::ACCC_num_gangs, - llvm::acc::Clause::ACCC_num_workers, - llvm::acc::Clause::ACCC_vector_length}); - break; case llvm::acc::Directive::ACCD_serial_loop: - // Restriction - 1962 -> (919) (SERIAL LOOP) + // Restriction - line 1004-1005 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, - {llvm::acc::Clause::ACCC_async, llvm::acc::Clause::ACCC_wait}); + computeConstructOnlyAllowedAfterDeviceTypeClauses); break; default: break; @@ -173,10 +154,10 @@ const auto &beginDir{std::get(x.t)}; const auto &loopDir{std::get(beginDir.t)}; if (loopDir.v == llvm::acc::Directive::ACCD_loop) { - // Restriction - 1615-1616 + // Restriction - line 1818-1819 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, loopOnlyAllowedAfterDeviceTypeClauses); - // Restriction - 1622 + // Restriction - line 1834 CheckNotAllowedIfClause(llvm::acc::Clause::ACCC_seq, {llvm::acc::Clause::ACCC_gang, llvm::acc::Clause::ACCC_vector, llvm::acc::Clause::ACCC_worker}); @@ -195,15 +176,15 @@ case llvm::acc::Directive::ACCD_enter_data: case llvm::acc::Directive::ACCD_exit_data: case llvm::acc::Directive::ACCD_set: - // Restriction - 1117-1118 (ENTER DATA) - // Restriction - 1161-1162 (EXIT DATA) - // Restriction - 2254 (SET) + // Restriction - line 1310-1311 (ENTER DATA) + // Restriction - line 1312-1313 (EXIT DATA) + // Restriction - line 2610 (SET) CheckRequireAtLeastOneOf(); break; case llvm::acc::Directive::ACCD_update: // Restriction - line 2636 CheckRequireAtLeastOneOf(); - // Restriction - 2301 + // Restriction - line 2669 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, updateOnlyAllowedAfterDeviceTypeClauses); break; @@ -217,9 +198,9 @@ PushContextAndClauseSets(x.source, llvm::acc::Directive::ACCD_routine); } void AccStructureChecker::Leave(const parser::OpenACCRoutineConstruct &) { - // Restriction - 2409 + // Restriction - line 2790 CheckRequireAtLeastOneOf(); - // Restriction - 2407-2408 + // Restriction - line 2788-2789 CheckOnlyAllowedAfter(llvm::acc::Clause::ACCC_device_type, routineOnlyAllowedAfterDeviceTypeClauses); dirContext_.pop_back(); diff --git a/flang/tools/f18/f18.cpp b/flang/tools/f18/f18.cpp --- a/flang/tools/f18/f18.cpp +++ b/flang/tools/f18/f18.cpp @@ -489,7 +489,7 @@ driver.warnOnNonstandardUsage = true; } else if (arg == "-fopenacc") { options.features.Enable(Fortran::common::LanguageFeature::OpenACC); - options.predefinitions.emplace_back("_OPENACC", "201911"); + options.predefinitions.emplace_back("_OPENACC", "202011"); } else if (arg == "-fopenmp") { options.features.Enable(Fortran::common::LanguageFeature::OpenMP); options.predefinitions.emplace_back("_OPENMP", "201511"); diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// // -// This is the definition file for OpenACC directives and clauses. +// This is the definition file for OpenACC 3.1 directives and clauses. // //===----------------------------------------------------------------------===// @@ -38,10 +38,10 @@ let isValueOptional = true; } -// 2.9.6 +// 2.9.7 def ACCC_Auto : Clause<"auto"> {} -// 2.7.11 +// 2.7.12 def ACCC_Attach : Clause<"attach"> { let flangClassValue = "AccObjectList"; } @@ -60,41 +60,41 @@ let flangClassValue = "ScalarIntConstantExpr"; } -// 2.7.5 +// 2.7.6 def ACCC_Copy : Clause<"copy"> { let flangClassValue = "AccObjectList"; } -// 2.7.6 +// 2.7.7 def ACCC_Copyin : Clause<"copyin"> { let flangClassValue = "AccObjectListWithModifier"; } -// 2.7.7 +// 2.7.8 def ACCC_Copyout : Clause<"copyout"> { let flangClassValue = "AccObjectListWithModifier"; } -// 2.7.8 +// 2.7.9 def ACCC_Create : Clause<"create"> { let flangClassValue = "AccObjectListWithModifier"; } -// 2.5.14 +// 2.5.15 def ACCC_Default : Clause<"default"> { let flangClassValue = "AccDefaultClause"; } -// 2.4.12 +// 2.14.3 def ACCC_DefaultAsync : Clause<"default_async"> { let flangClassValue = "ScalarIntExpr"; } -// 2.7.10 +// 2.7.11 def ACCC_Delete : Clause<"delete"> { let flangClassValue = "AccObjectList"; } -// 2.7.12 +// 2.7.13 def ACCC_Detach : Clause<"detach"> { let flangClassValue = "AccObjectList"; } @@ -104,17 +104,17 @@ let flangClassValue = "AccObjectList"; } -// 2.14.1 +// 2.14.1 - 2.14.2 def ACCC_DeviceNum : Clause<"device_num"> { let flangClassValue = "ScalarIntExpr"; } -// 2.7.3 +// 2.7.4 def ACCC_DevicePtr : Clause<"deviceptr"> { let flangClassValue = "AccObjectList"; } -// 2.13 +// 2.13.1 def ACCC_DeviceResident : Clause<"device_resident"> { let flangClassValue = "AccObjectList"; } @@ -130,7 +130,7 @@ // 2.6.6 def ACCC_Finalize : Clause<"finalize"> {} -// 2.5.12 +// 2.5.13 def ACCC_FirstPrivate : Clause<"firstprivate"> { let flangClassValue = "AccObjectList"; } @@ -146,7 +146,7 @@ let flangClassValue = "AccObjectList"; } -// 2.5.4 +// 2.5.5 def ACCC_If : Clause <"if"> { let flangClassValue = "ScalarLogicalExpr"; } @@ -154,15 +154,15 @@ // 2.14.4 def ACCC_IfPresent : Clause<"if_present"> {} -// 2.9.9 +// 2.9.6 def ACCC_Independent : Clause<"independent"> {} -// 2.13 +// 2.13.3 def ACCC_Link : Clause<"link"> { let flangClassValue = "AccObjectList"; } -// 2.7.9 +// 2.7.10 def ACCC_NoCreate : Clause<"no_create"> { let flangClassValue = "AccObjectList"; } @@ -170,27 +170,27 @@ // 2.15.1 def ACCC_NoHost : Clause<"nohost"> {} -// 2.5.8 +// 2.5.9 def ACCC_NumGangs : Clause<"num_gangs"> { let flangClassValue = "ScalarIntExpr"; } -// 2.5.9 +// 2.5.10 def ACCC_NumWorkers : Clause<"num_workers"> { let flangClassValue = "ScalarIntExpr"; } -// 2.7.4 +// 2.7.5 def ACCC_Present : Clause<"present"> { let flangClassValue = "AccObjectList"; } -// 2.5.11 +// 2.5.12 def ACCC_Private : Clause<"private"> { let flangClassValue = "AccObjectList"; } -// 2.9.7 +// 2.9.8 def ACCC_Tile : Clause <"tile"> { let flangClassValue = "AccTileExprList"; } @@ -203,12 +203,12 @@ // 2.12 def ACCC_Read : Clause<"read"> {} -// 2.5.13 +// 2.5.14 def ACCC_Reduction : Clause<"reduction"> { let flangClassValue = "AccObjectListWithReduction"; } -// 2.5.5 +// 2.5.6 def ACCC_Self : Clause<"self"> { let flangClassValue = "AccSelfClause"; } @@ -222,7 +222,7 @@ let isValueOptional = true; } -// 2.5.10 +// 2.5.11 def ACCC_VectorLength : Clause<"vector_length"> { let flangClassValue = "ScalarIntExpr"; } @@ -286,7 +286,7 @@ ]; } -// 2.5.2 +// 2.5.3 def ACC_Kernels : Directive<"kernels"> { let allowedClauses = [ VersionedClause, @@ -339,7 +339,7 @@ ]; } -// 2.5.3 +// 2.5.2 def ACC_Serial : Directive<"serial"> { let allowedClauses = [ VersionedClause, @@ -493,6 +493,8 @@ VersionedClause ]; } + +// 2.8 def ACC_HostData : Directive<"host_data"> { let allowedClauses = [ VersionedClause, diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h --- a/mlir/include/mlir/Dialect/OpenACC/OpenACC.h +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACC.h @@ -26,7 +26,7 @@ namespace acc { /// Enumeration used to encode the execution mapping on a loop construct. -/// They refer directly to the OpenACC 3.0 standard: +/// They refer directly to the OpenACC 3.1 standard: /// 2.9.2. gang /// 2.9.3. worker /// 2.9.4. vector diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td --- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td +++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td @@ -21,7 +21,7 @@ let summary = "An OpenACC dialect for MLIR."; let description = [{ - This dialect models the construct from the OpenACC 3.0 directive language. + This dialect models the construct from the OpenACC 3.1 directive language. }]; let cppNamespace = "::mlir::acc";