| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify |
| 2 |
|
| 3 |
struct CompositeOfScalars { |
| 4 |
int I; |
| 5 |
float F; |
| 6 |
short J; |
| 7 |
char C; |
| 8 |
double D; |
| 9 |
_Complex float CF; |
| 10 |
_Complex double CD; |
| 11 |
}; |
| 12 |
|
| 13 |
struct CompositeHasComposite { |
| 14 |
int I; |
| 15 |
float F; |
| 16 |
short J; |
| 17 |
char C; |
| 18 |
double D; |
| 19 |
_Complex float CF; |
| 20 |
_Complex double CD; |
| 21 |
struct CompositeOfScalars COS; // #COS_FIELD |
| 22 |
}; |
| 23 |
|
| 24 |
void uses(unsigned Parm) { |
| 25 |
float Var; |
| 26 |
int IVar; |
| 27 |
|
| 28 |
#pragma acc parallel reduction(+:Parm) |
| 29 |
while (1); |
| 30 |
#pragma acc serial reduction(+:Parm) |
| 31 |
while (1); |
| 32 |
// expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} |
| 33 |
#pragma acc kernels reduction(+:Parm) |
| 34 |
while (1); |
| 35 |
|
| 36 |
// On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on |
| 37 |
// 'serial', but 'reduction' not valid on 'kernels', other combos cannot be |
| 38 |
// tested. |
| 39 |
#pragma acc parallel reduction(+:Parm) num_gangs(IVar) |
| 40 |
while (1); |
| 41 |
#pragma acc parallel num_gangs(IVar) reduction(+:Var) |
| 42 |
while (1); |
| 43 |
|
| 44 |
// expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} |
| 45 |
// expected-note@+1{{previous clause is here}} |
| 46 |
#pragma acc parallel reduction(+:Parm) num_gangs(Parm, IVar) |
| 47 |
while (1); |
| 48 |
|
| 49 |
// expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} |
| 50 |
// expected-note@+1{{previous clause is here}} |
| 51 |
#pragma acc parallel num_gangs(Parm, IVar) reduction(+:Var) |
| 52 |
while (1); |
| 53 |
|
| 54 |
#pragma acc parallel reduction(+:Parm) reduction(+:Parm) |
| 55 |
while (1); |
| 56 |
|
| 57 |
struct CompositeOfScalars CoS; |
| 58 |
struct CompositeOfScalars *CoSPtr; |
| 59 |
struct CompositeHasComposite ChC; |
| 60 |
struct CompositeHasComposite *ChCPtr; |
| 61 |
|
| 62 |
int I; |
| 63 |
float F; |
| 64 |
int Array[5]; |
| 65 |
|
| 66 |
// Vars in a reduction must be a scalar or a composite of scalars. |
| 67 |
#pragma acc parallel reduction(&: CoS, I, F) |
| 68 |
while (1); |
| 69 |
// expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} |
| 70 |
// expected-note@#COS_FIELD{{invalid field is here}} |
| 71 |
#pragma acc parallel reduction(&: ChC) |
| 72 |
while (1); |
| 73 |
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} |
| 74 |
#pragma acc parallel reduction(&: Array) |
| 75 |
while (1); |
| 76 |
|
| 77 |
#pragma acc parallel reduction(&: CoS, Array[I], Array[0:I]) |
| 78 |
while (1); |
| 79 |
|
| 80 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 81 |
#pragma acc parallel reduction(&: CoS.I) |
| 82 |
while (1); |
| 83 |
|
| 84 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 85 |
#pragma acc parallel reduction(&: CoSPtr->I) |
| 86 |
|
| 87 |
while (1); |
| 88 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 89 |
#pragma acc parallel reduction(&: ChC.COS) |
| 90 |
while (1); |
| 91 |
|
| 92 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 93 |
#pragma acc parallel reduction(&: ChCPtr->COS) |
| 94 |
while (1); |
| 95 |
} |
| 96 |
|
| 97 |
template<typename T, typename U, typename V> |
| 98 |
void TemplUses(T Parm, U CoS, V ChC) { |
| 99 |
T Var; |
| 100 |
U *CoSPtr; |
| 101 |
V *ChCPtr; |
| 102 |
|
| 103 |
#pragma acc parallel reduction(+:Parm) |
| 104 |
while (1); |
| 105 |
#pragma acc serial reduction(+:Parm) |
| 106 |
while (1); |
| 107 |
// expected-error@+1{{OpenACC 'reduction' clause is not valid on 'kernels' directive}} |
| 108 |
#pragma acc kernels reduction(+:Parm) |
| 109 |
while (1); |
| 110 |
|
| 111 |
// On a 'parallel', 'num_gangs' cannot have >1 args. num_gangs not valid on |
| 112 |
// 'serial', but 'reduction' not valid on 'kernels', other combos cannot be |
| 113 |
// tested. |
| 114 |
#pragma acc parallel reduction(+:Parm) num_gangs(Var) |
| 115 |
while (1); |
| 116 |
#pragma acc parallel num_gangs(Var) reduction(+:Var) |
| 117 |
while (1); |
| 118 |
|
| 119 |
// expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} |
| 120 |
// expected-note@+1{{previous clause is here}} |
| 121 |
#pragma acc parallel reduction(+:Parm) num_gangs(Parm, Var) |
| 122 |
while (1); |
| 123 |
|
| 124 |
// expected-error@+2{{OpenACC 'reduction' clause may not appear on a 'parallel' construct with a 'num_gangs' clause with more than 1 argument, have 2}} |
| 125 |
// expected-note@+1{{previous clause is here}} |
| 126 |
#pragma acc parallel num_gangs(Parm, Var) reduction(+:Var) |
| 127 |
while (1); |
| 128 |
|
| 129 |
#pragma acc parallel reduction(+:Parm) reduction(+:Parm) |
| 130 |
while (1); |
| 131 |
|
| 132 |
int NonDep; |
| 133 |
int NonDepArray[5]; |
| 134 |
T Array[5]; |
| 135 |
|
| 136 |
// Vars in a reduction must be a scalar or a composite of scalars. |
| 137 |
#pragma acc parallel reduction(&: CoS, Var, Parm) |
| 138 |
while (1); |
| 139 |
// expected-error@+2{{OpenACC 'reduction' composite variable must not have non-scalar field}} |
| 140 |
// expected-note@#COS_FIELD{{invalid field is here}} |
| 141 |
#pragma acc parallel reduction(&: ChC) |
| 142 |
while (1); |
| 143 |
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} |
| 144 |
#pragma acc parallel reduction(&: Array) |
| 145 |
while (1); |
| 146 |
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}} |
| 147 |
#pragma acc parallel reduction(&: NonDepArray) |
| 148 |
while (1); |
| 149 |
|
| 150 |
#pragma acc parallel reduction(&: CoS, Array[Var], Array[0:Var]) |
| 151 |
while (1); |
| 152 |
|
| 153 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 154 |
#pragma acc parallel reduction(&: CoS.I) |
| 155 |
while (1); |
| 156 |
|
| 157 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 158 |
#pragma acc parallel reduction(&: CoSPtr->I) |
| 159 |
|
| 160 |
while (1); |
| 161 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 162 |
#pragma acc parallel reduction(&: ChC.COS) |
| 163 |
while (1); |
| 164 |
|
| 165 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}} |
| 166 |
#pragma acc parallel reduction(&: ChCPtr->COS) |
| 167 |
while (1); |
| 168 |
} |
| 169 |
|
| 170 |
void inst() { |
| 171 |
CompositeOfScalars CoS; |
| 172 |
CompositeHasComposite ChC; |
| 173 |
// expected-note@+1{{in instantiation of function template specialization}} |
| 174 |
TemplUses(5, CoS, ChC); |
| 175 |
} |