Skip to content

Commit 1b44c3a

Browse files
committed
[OpenACC] enable 'async' clause for combined constructs
No additional work required over what we did for other constructs, so this is just adding the tests and enabling the clauses.
1 parent c7605bf commit 1b44c3a

7 files changed

+207
-24
lines changed

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,11 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
798798

799799
OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
800800
SemaOpenACC::OpenACCParsedClause &Clause) {
801-
// Restrictions only properly implemented on 'compute' constructs, and
802-
// 'compute' constructs are the only construct that can do anything with
803-
// this yet, so skip/treat as unimplemented in this case.
804-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
801+
// Restrictions only properly implemented on 'compute'/'combined' constructs,
802+
// and 'compute'/'combined' constructs are the only construct that can do
803+
// anything with this yet, so skip/treat as unimplemented in this case.
804+
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
805+
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
805806
return isNotImplemented();
806807

807808
// There is no prose in the standard that says duplicates aren't allowed,

clang/test/AST/ast-print-openacc-combined-construct.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 -fopenacc -Wno-openacc-deprecated-clause-alias -ast-print %s -o - | FileCheck %s
22

33
void foo() {
4+
int *iPtr;
45
// CHECK: #pragma acc parallel loop
56
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
67
// CHECK-NEXT: ;
@@ -98,11 +99,27 @@ void foo() {
9899
for(int i = 0;i<5;++i);
99100

100101
// CHECK: #pragma acc parallel loop private(i, array[1], array, array[1:2])
102+
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
103+
// CHECK-NEXT: ;
101104
#pragma acc parallel loop private(i, array[1], array, array[1:2])
102105
for(int i = 0;i<5;++i);
103106

104107
// CHECK: #pragma acc serial loop firstprivate(i, array[1], array, array[1:2])
108+
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
109+
// CHECK-NEXT: ;
105110
#pragma acc serial loop firstprivate(i, array[1], array, array[1:2])
106111
for(int i = 0;i<5;++i);
107112

113+
// CHECK: #pragma acc kernels loop async(*iPtr)
114+
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
115+
// CHECK-NEXT: ;
116+
#pragma acc kernels loop async(*iPtr)
117+
for(int i = 0;i<5;++i);
118+
119+
// CHECK: #pragma acc kernels loop async
120+
// CHECK-NEXT: for (int i = 0; i < 5; ++i)
121+
// CHECK-NEXT: ;
122+
#pragma acc kernels loop async
123+
for(int i = 0;i<5;++i);
124+
108125
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// RUN: %clang_cc1 %s -fopenacc -verify
2+
3+
short getS();
4+
5+
void Test() {
6+
#pragma acc parallel loop async
7+
for (int i = 5; i < 10; ++i);
8+
#pragma acc parallel loop async(1)
9+
for (int i = 5; i < 10; ++i);
10+
#pragma acc kernels loop async(1)
11+
for (int i = 5; i < 10; ++i);
12+
#pragma acc kernels loop async(-51)
13+
for (int i = 5; i < 10; ++i);
14+
15+
#pragma acc serial loop async(1)
16+
for (int i = 5; i < 10; ++i);
17+
18+
// expected-error@+2{{expected ')'}}
19+
// expected-note@+1{{to match this '('}}
20+
#pragma acc serial loop async(1, 2)
21+
for (int i = 5; i < 10; ++i);
22+
23+
struct NotConvertible{} NC;
24+
// expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid)}}
25+
#pragma acc parallel loop async(NC)
26+
for (int i = 5; i < 10; ++i);
27+
28+
#pragma acc kernels loop async(getS())
29+
for (int i = 5; i < 10; ++i);
30+
31+
struct Incomplete *SomeIncomplete;
32+
33+
// expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct Incomplete' invalid)}}
34+
#pragma acc kernels loop async(*SomeIncomplete)
35+
for (int i = 5; i < 10; ++i);
36+
37+
enum E{A} SomeE;
38+
39+
#pragma acc kernels loop async(SomeE)
40+
for (int i = 5; i < 10; ++i);
41+
42+
// expected-error@+1{{OpenACC 'async' clause is not valid on 'loop' directive}}
43+
#pragma acc loop async(1)
44+
for(int i = 5; i < 10;++i);
45+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// RUN: %clang_cc1 %s -fopenacc -verify
2+
3+
struct NotConvertible{} NC;
4+
struct Incomplete *SomeIncomplete; // #INCOMPLETE
5+
enum E{} SomeE;
6+
enum class E2{} SomeE2;
7+
8+
struct CorrectConvert {
9+
operator int();
10+
} Convert;
11+
12+
struct ExplicitConvertOnly {
13+
explicit operator int() const; // #EXPL_CONV
14+
} Explicit;
15+
16+
struct AmbiguousConvert{
17+
operator int(); // #AMBIG_INT
18+
operator short(); // #AMBIG_SHORT
19+
operator float();
20+
} Ambiguous;
21+
22+
void Test() {
23+
#pragma acc parallel loop async
24+
for (int i = 5; i < 10; ++i);
25+
#pragma acc parallel loop async(1)
26+
for (int i = 5; i < 10; ++i);
27+
#pragma acc kernels loop async(-51)
28+
for (int i = 5; i < 10; ++i);
29+
#pragma acc serial loop async(2)
30+
for (int i = 5; i < 10; ++i);
31+
32+
// expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('struct NotConvertible' invalid}}
33+
#pragma acc parallel loop async(NC)
34+
for (int i = 5; i < 10; ++i);
35+
36+
// expected-error@+2{{OpenACC integer expression has incomplete class type 'struct Incomplete'}}
37+
// expected-note@#INCOMPLETE{{forward declaration of 'Incomplete'}}
38+
#pragma acc kernels loop async(*SomeIncomplete)
39+
for (int i = 5; i < 10; ++i);
40+
41+
#pragma acc parallel loop async(SomeE)
42+
for (int i = 5; i < 10; ++i);
43+
44+
// expected-error@+1{{OpenACC clause 'async' requires expression of integer type ('enum E2' invalid}}
45+
#pragma acc kernels loop async(SomeE2)
46+
for (int i = 5; i < 10; ++i);
47+
48+
#pragma acc parallel loop async(Convert)
49+
for (int i = 5; i < 10; ++i);
50+
51+
// expected-error@+2{{OpenACC integer expression type 'struct ExplicitConvertOnly' requires explicit conversion to 'int'}}
52+
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
53+
#pragma acc kernels loop async(Explicit)
54+
for (int i = 5; i < 10; ++i);
55+
56+
// expected-error@+3{{multiple conversions from expression type 'struct AmbiguousConvert' to an integral type}}
57+
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
58+
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
59+
#pragma acc parallel loop async(Ambiguous)
60+
for (int i = 5; i < 10; ++i);
61+
}
62+
63+
struct HasInt {
64+
using IntTy = int;
65+
using ShortTy = short;
66+
static constexpr int value = 1;
67+
static constexpr AmbiguousConvert ACValue;
68+
static constexpr ExplicitConvertOnly EXValue;
69+
70+
operator char();
71+
};
72+
73+
template<typename T>
74+
void TestInst() {
75+
76+
// expected-error@+1{{no member named 'Invalid' in 'HasInt'}}
77+
#pragma acc parallel loop async(HasInt::Invalid)
78+
for (int i = 5; i < 10; ++i);
79+
80+
// expected-error@+2{{no member named 'Invalid' in 'HasInt'}}
81+
// expected-note@#INST{{in instantiation of function template specialization 'TestInst<HasInt>' requested here}}
82+
#pragma acc kernels loop async(T::Invalid)
83+
for (int i = 5; i < 10; ++i);
84+
85+
// expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
86+
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
87+
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
88+
#pragma acc parallel loop async(HasInt::ACValue)
89+
for (int i = 5; i < 10; ++i);
90+
91+
// expected-error@+3{{multiple conversions from expression type 'const AmbiguousConvert' to an integral type}}
92+
// expected-note@#AMBIG_INT{{conversion to integral type 'int'}}
93+
// expected-note@#AMBIG_SHORT{{conversion to integral type 'short'}}
94+
#pragma acc kernels loop async(T::ACValue)
95+
for (int i = 5; i < 10; ++i);
96+
97+
// expected-error@+2{{OpenACC integer expression type 'const ExplicitConvertOnly' requires explicit conversion to 'int'}}
98+
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
99+
#pragma acc parallel loop async(HasInt::EXValue)
100+
for (int i = 5; i < 10; ++i);
101+
102+
// expected-error@+2{{OpenACC integer expression type 'const ExplicitConvertOnly' requires explicit conversion to 'int'}}
103+
// expected-note@#EXPL_CONV{{conversion to integral type 'int'}}
104+
#pragma acc kernels loop async(T::EXValue)
105+
for (int i = 5; i < 10; ++i);
106+
107+
#pragma acc parallel loop async(HasInt::value)
108+
for (int i = 5; i < 10; ++i);
109+
110+
#pragma acc kernels loop async(T::value)
111+
for (int i = 5; i < 10; ++i);
112+
113+
#pragma acc parallel loop async(HasInt::IntTy{})
114+
for (int i = 5; i < 10; ++i);
115+
116+
#pragma acc kernels loop async(typename T::ShortTy{})
117+
for (int i = 5; i < 10; ++i);
118+
119+
#pragma acc parallel loop async(HasInt::IntTy{})
120+
for (int i = 5; i < 10; ++i);
121+
122+
#pragma acc kernels loop async(typename T::ShortTy{})
123+
for (int i = 5; i < 10; ++i);
124+
125+
HasInt HI{};
126+
T MyT{};
127+
128+
#pragma acc parallel loop async(HI)
129+
for (int i = 5; i < 10; ++i);
130+
131+
#pragma acc kernels loop async(MyT)
132+
for (int i = 5; i < 10; ++i);
133+
}
134+
135+
void Inst() {
136+
TestInst<HasInt>(); // #INST
137+
}

clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ void uses() {
190190
for(unsigned i = 0; i < 5; ++i);
191191
#pragma acc parallel loop auto dtype(*)
192192
for(unsigned i = 0; i < 5; ++i);
193-
// TODOexpected-error@+1{{OpenACC 'async' clause is not valid on 'parallel loop' directive}}
194-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented}}
195193
#pragma acc parallel loop auto async
196194
for(unsigned i = 0; i < 5; ++i);
197195
// expected-warning@+1{{OpenACC clause 'tile' not yet implemented}}
@@ -355,8 +353,6 @@ void uses() {
355353
for(unsigned i = 0; i < 5; ++i);
356354
#pragma acc parallel loop dtype(*) auto
357355
for(unsigned i = 0; i < 5; ++i);
358-
// TODOexpected-error@+1{{OpenACC 'async' clause is not valid on 'parallel loop' directive}}
359-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented}}
360356
#pragma acc parallel loop async auto
361357
for(unsigned i = 0; i < 5; ++i);
362358
// expected-warning@+1{{OpenACC clause 'tile' not yet implemented}}
@@ -521,8 +517,6 @@ void uses() {
521517
for(unsigned i = 0; i < 5; ++i);
522518
#pragma acc parallel loop independent dtype(*)
523519
for(unsigned i = 0; i < 5; ++i);
524-
// TODOexpected-error@+1{{OpenACC 'async' clause is not valid on 'parallel loop' directive}}
525-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented}}
526520
#pragma acc parallel loop independent async
527521
for(unsigned i = 0; i < 5; ++i);
528522
// expected-warning@+1{{OpenACC clause 'tile' not yet implemented}}
@@ -686,8 +680,6 @@ void uses() {
686680
for(unsigned i = 0; i < 5; ++i);
687681
#pragma acc parallel loop dtype(*) independent
688682
for(unsigned i = 0; i < 5; ++i);
689-
// TODOexpected-error@+1{{OpenACC 'async' clause is not valid on 'parallel loop' directive}}
690-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented}}
691683
#pragma acc parallel loop async independent
692684
for(unsigned i = 0; i < 5; ++i);
693685
// expected-warning@+1{{OpenACC clause 'tile' not yet implemented}}
@@ -858,8 +850,6 @@ void uses() {
858850
for(unsigned i = 0; i < 5; ++i);
859851
#pragma acc parallel loop seq dtype(*)
860852
for(unsigned i = 0; i < 5; ++i);
861-
// TODOexpected-error@+1{{OpenACC 'async' clause is not valid on 'parallel loop' directive}}
862-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented}}
863853
#pragma acc parallel loop seq async
864854
for(unsigned i = 0; i < 5; ++i);
865855
// expected-warning@+1{{OpenACC clause 'tile' not yet implemented}}
@@ -1029,8 +1019,6 @@ void uses() {
10291019
for(unsigned i = 0; i < 5; ++i);
10301020
#pragma acc parallel loop dtype(*) seq
10311021
for(unsigned i = 0; i < 5; ++i);
1032-
// TODOexpected-error@+1{{OpenACC 'async' clause is not valid on 'parallel loop' directive}}
1033-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented}}
10341022
#pragma acc parallel loop async seq
10351023
for(unsigned i = 0; i < 5; ++i);
10361024
// expected-warning@+1{{OpenACC clause 'tile' not yet implemented}}

clang/test/SemaOpenACC/combined-construct-default-clause.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,24 @@ void SingleOnly() {
77

88
int i;
99

10-
// expected-warning@+3{{OpenACC clause 'async' not yet implemented, clause ignored}}
1110
// expected-error@+2{{OpenACC 'default' clause cannot appear more than once on a 'parallel loop' directive}}
1211
// expected-note@+1{{previous clause is here}}
1312
#pragma acc parallel loop default(present) async default(none)
1413
for (unsigned I = 0; I < 5; ++I);
1514

16-
// expected-warning@+4{{OpenACC clause 'copy' not yet implemented, clause ignored}}
17-
// expected-warning@+3{{OpenACC clause 'async' not yet implemented, clause ignored}}
15+
// expected-warning@+3{{OpenACC clause 'copy' not yet implemented, clause ignored}}
1816
// expected-error@+2{{OpenACC 'default' clause cannot appear more than once on a 'serial loop' directive}}
1917
// expected-note@+1{{previous clause is here}}
2018
#pragma acc serial loop async default(present) copy(i) default(none) self
2119
for (unsigned I = 0; I < 5; ++I);
2220

23-
// expected-warning@+4{{OpenACC clause 'copy' not yet implemented, clause ignored}}
24-
// expected-warning@+3{{OpenACC clause 'async' not yet implemented, clause ignored}}
21+
// expected-warning@+3{{OpenACC clause 'copy' not yet implemented, clause ignored}}
2522
// expected-error@+2{{OpenACC 'default' clause cannot appear more than once on a 'kernels loop' directive}}
2623
// expected-note@+1{{previous clause is here}}
2724
#pragma acc kernels loop async default(present) copy(i) default(none) self
2825
for (unsigned I = 0; I < 5; ++I);
2926

30-
// expected-warning@+3{{OpenACC clause 'copy' not yet implemented, clause ignored}}
31-
// expected-warning@+2{{OpenACC clause 'async' not yet implemented, clause ignored}}
27+
// expected-warning@+2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
3228
// expected-error@+1{{expected '('}}
3329
#pragma acc parallel loop async default(none) copy(i) default self
3430
for (unsigned I = 0; I < 5; ++I);

clang/test/SemaOpenACC/combined-construct-device_type-clause.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ void uses() {
207207
// expected-note@+1{{previous clause is here}}
208208
#pragma acc serial loop device_type(*) default_async(1)
209209
for(int i = 0; i < 5; ++i);
210-
// expected-warning@+1{{OpenACC clause 'async' not yet implemented, clause ignored}}
211210
#pragma acc parallel loop device_type(*) async
212211
for(int i = 0; i < 5; ++i);
213212

0 commit comments

Comments
 (0)