From: Valentin Clement Date: Wed, 7 Oct 2020 01:26:13 +0000 (-0400) Subject: [flang][openacc] Fix device_num and device_type clauses for init directive X-Git-Tag: llvmorg-13-init~9948 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f40e20613758b3e11a15494c09f4b6973673d6b;p=platform%2Fupstream%2Fllvm.git [flang][openacc] Fix device_num and device_type clauses for init directive This patch fix the device_num and device_type clauses used in the init clause. device_num was not spelled correctly in the parser and was to restrictive with scalarIntConstantExpr instead of scalarIntExpr. device_type is now taking a list of ScalarIntExpr. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D88571 --- diff --git a/flang/lib/Parser/openacc-parsers.cpp b/flang/lib/Parser/openacc-parsers.cpp index 01c2583..686259b 100644 --- a/flang/lib/Parser/openacc-parsers.cpp +++ b/flang/lib/Parser/openacc-parsers.cpp @@ -57,17 +57,17 @@ TYPE_PARSER("AUTO" >> construct(construct()) || parenthesized(Parser{}))) || "DEVICEPTR" >> construct(construct( parenthesized(Parser{}))) || - "DEVICENUM" >> construct(construct( - parenthesized(scalarIntConstantExpr))) || + "DEVICE_NUM" >> construct(construct( + parenthesized(scalarIntExpr))) || "DEVICE_RESIDENT" >> construct(construct( parenthesized(Parser{}))) || ("DEVICE_TYPE"_tok || "DTYPE"_tok) >> construct(construct(parenthesized( - "*" >> construct>>()))) || + "*" >> construct>>()))) || ("DEVICE_TYPE"_tok || "DTYPE"_tok) >> construct(construct( - parenthesized(maybe(nonemptyList(name))))) || + parenthesized(maybe(nonemptyList(scalarIntExpr))))) || "FINALIZE" >> construct(construct()) || "FIRSTPRIVATE" >> construct(construct( parenthesized(Parser{}))) || diff --git a/flang/test/Semantics/acc-clause-validity.f90 b/flang/test/Semantics/acc-clause-validity.f90 index 9683a4e..9a7bfe9 100644 --- a/flang/test/Semantics/acc-clause-validity.f90 +++ b/flang/test/Semantics/acc-clause-validity.f90 @@ -25,11 +25,21 @@ program openacc_clause_validity real :: reduction_r logical :: reduction_l real(8), dimension(N, N) :: aa + logical :: ifCondition = .TRUE. !ERROR: At least one clause is required on the DECLARE directive !$acc declare real(8), dimension(N) :: a + !$acc init + !$acc init if(.TRUE.) + !$acc init if(ifCondition) + !$acc init device_num(1) + !$acc init device_num(i) + !$acc init device_type(i) + !$acc init device_type(2, i, j) + !$acc init device_num(i) device_type(i, j) if(ifCondition) + !ERROR: At least one of ATTACH, COPYIN, CREATE clause must appear on the ENTER DATA directive !$acc enter data diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td index b15f834..879bbc2 100644 --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -106,7 +106,7 @@ def ACCC_Device : Clause<"device"> { // 2.14.1 def ACCC_DeviceNum : Clause<"device_num"> { - let flangClassValue = "ScalarIntConstantExpr"; + let flangClassValue = "ScalarIntExpr"; } // 2.7.3 @@ -121,7 +121,7 @@ def ACCC_DeviceResident : Clause<"device_resident"> { // 2.4 def ACCC_DeviceType : Clause<"device_type"> { - let flangClassValue = "Name"; + let flangClassValue = "ScalarIntExpr"; let defaultValue = "*"; let isValueOptional = 1; let isValueList = 1;