forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute-construct-private-clause.c
137 lines (123 loc) · 4.97 KB
/
compute-construct-private-clause.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// RUN: %clang_cc1 %s -fopenacc -verify
struct Incomplete;
enum SomeE{ A };
typedef struct IsComplete {
struct S { int A; } CompositeMember;
int ScalarMember;
float ArrayMember[5];
enum SomeE EnumMember;
void *PointerMember;
} Complete;
int GlobalInt;
float GlobalArray[5];
short *GlobalPointer;
Complete GlobalComposite;
void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) {
int LocalInt;
short *LocalPointer;
float LocalArray[5];
Complete LocalComposite;
// Check Appertainment:
#pragma acc parallel private(LocalInt)
while(1);
#pragma acc serial private(LocalInt)
while(1);
// expected-error@+1{{OpenACC 'private' clause is not valid on 'kernels' directive}}
#pragma acc kernels private(LocalInt)
while(1);
// Valid cases:
#pragma acc parallel private(LocalInt, LocalPointer, LocalArray)
while(1);
#pragma acc parallel private(LocalArray)
while(1);
#pragma acc parallel private(LocalArray[:])
while(1);
#pragma acc parallel private(LocalArray[:5])
while(1);
#pragma acc parallel private(LocalArray[2:])
while(1);
#pragma acc parallel private(LocalArray[2:1])
while(1);
#pragma acc parallel private(LocalArray[2])
while(1);
#pragma acc parallel private(LocalComposite)
while(1);
#pragma acc parallel private(LocalComposite.EnumMember)
while(1);
#pragma acc parallel private(LocalComposite.ScalarMember)
while(1);
#pragma acc parallel private(LocalComposite.ArrayMember)
while(1);
#pragma acc parallel private(LocalComposite.ArrayMember[5])
while(1);
#pragma acc parallel private(LocalComposite.PointerMember)
while(1);
#pragma acc parallel private(GlobalInt, GlobalArray, GlobalPointer, GlobalComposite)
while(1);
#pragma acc parallel private(GlobalArray[2], GlobalPointer[2], GlobalComposite.CompositeMember.A)
while(1);
#pragma acc parallel private(LocalComposite, GlobalComposite)
while(1);
#pragma acc parallel private(IntParam, PointerParam, ArrayParam, CompositeParam)
while(1);
#pragma acc parallel private(PointerParam[IntParam], ArrayParam[IntParam], CompositeParam.CompositeMember.A)
while(1);
#pragma acc parallel private(LocalArray) private(LocalArray[2])
while(1);
#pragma acc parallel private(LocalArray, LocalArray[2])
while(1);
#pragma acc parallel private(LocalComposite, LocalComposite.ScalarMember)
while(1);
#pragma acc parallel private(LocalComposite.CompositeMember.A, LocalComposite.ScalarMember)
while(1);
#pragma acc parallel private(LocalComposite.CompositeMember.A) private(LocalComposite.ScalarMember)
while(1);
Complete LocalComposite2;
#pragma acc parallel private(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember)
while(1);
// Invalid cases, arbitrary expressions.
struct Incomplete *I;
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
#pragma acc parallel private(*I)
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
#pragma acc parallel private(GlobalInt + IntParam)
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
#pragma acc parallel private(+GlobalInt)
while(1);
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
#pragma acc parallel private(PointerParam[:])
while(1);
#pragma acc parallel private(PointerParam[:5])
while(1);
#pragma acc parallel private(PointerParam[:IntParam])
while(1);
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
#pragma acc parallel private(PointerParam[2:])
while(1);
#pragma acc parallel private(PointerParam[2:5])
while(1);
#pragma acc parallel private(PointerParam[2])
while(1);
#pragma acc parallel private(ArrayParam[:])
while(1);
#pragma acc parallel private(ArrayParam[:5])
while(1);
#pragma acc parallel private(ArrayParam[:IntParam])
while(1);
#pragma acc parallel private(ArrayParam[2:])
while(1);
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel private(ArrayParam[2:5])
while(1);
#pragma acc parallel private(ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
#pragma acc parallel private((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
#pragma acc parallel private((float)ArrayParam[2])
while(1);
}