brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.9 KiB · f2dd928 Raw
381 lines · cpp
1// RUN: %clang_cc1 %s -fopenacc -verify2 3struct CompositeOfScalars {4  int I;5  float F;6  short J;7  char C;8  double D;9};10 11struct CompositeHasComposite {12  int I;13  float F;14  short J;15  char C;16  double D;17  struct CompositeOfScalars COS; // #COS_FIELD18};19void uses() {20 21  int I;22  float F;23  int Array[5];24  CompositeOfScalars CoS;25  CompositeHasComposite ChC;26 27#pragma acc serial28  {29#pragma acc loop reduction(+:CoS, I, F)30    for(int i = 0; i < 5; ++i){}31  }32 33#pragma acc serial34  {35#pragma acc loop reduction(+:Array)36    for(int i = 0; i < 5; ++i){}37  }38 39#pragma acc serial40  {41  // expected-error@+3{{invalid type 'struct CompositeOfScalars' used in OpenACC 'reduction' variable reference; type is not a scalar value}}42  // expected-note@#COS_FIELD{{used as field 'COS' of composite 'CompositeHasComposite'}}43  // expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}44#pragma acc loop reduction(+:ChC)45    for(int i = 0; i < 5; ++i){}46  }47 48#pragma acc serial49  {50#pragma acc loop reduction(+:I)51    for(int i = 0; i < 5; ++i) {52    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}53    // expected-note@-3{{previous 'reduction' clause is here}}54#pragma acc loop reduction(&:I)55      for(int i = 0; i < 5; ++i) {56      }57    }58  }59 60#pragma acc serial61  {62#pragma acc loop reduction(+:I)63    for(int i = 0; i < 5; ++i) {64    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}65    // expected-note@-3{{previous 'reduction' clause is here}}66#pragma acc loop reduction(&:I)67      for(int i = 0; i < 5; ++i) {68      }69    }70  }71 72#pragma acc serial73  {74#pragma acc loop reduction(+:I)75    for(int i = 0; i < 5; ++i) {76#pragma acc serial77    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}78    // expected-note@-4{{previous 'reduction' clause is here}}79#pragma acc loop reduction(&:I)80      for(int i = 0; i < 5; ++i) {81      }82    }83  }84 85#pragma acc serial reduction(+:I)86    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}87    // expected-note@-2{{previous 'reduction' clause is here}}88#pragma acc loop reduction(&:I)89  for(int i = 0; i < 5; ++i){}90 91#pragma acc serial92#pragma acc loop reduction(&:I)93  for(int i = 0; i < 5; ++i) {94    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (+ vs &)}}95    // expected-note@-3{{previous 'reduction' clause is here}}96#pragma acc serial reduction(+:I)97    ;98  }99 100#pragma acc parallel101  {102#pragma acc loop reduction(+:I) gang(dim:1)103    for(int i = 0; i < 5; ++i) {104    }105  }106 107#pragma acc parallel108  {109  // expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'loop' construct as a 'reduction' clause}}110  // expected-note@+1{{previous 'reduction' clause is here}}111#pragma acc loop reduction(+:I) gang(dim:2)112    for(int i = 0; i < 5; ++i) {113    }114  }115 116#pragma acc parallel117  {118  // expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}119  // expected-note@+1{{previous 'gang' clause is here}}120#pragma acc loop gang(dim:2) reduction(+:I)121    for(int i = 0; i < 5; ++i) {122    }123  }124 125#pragma acc parallel126  {127  // expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}128  // expected-note@+1{{previous 'gang' clause is here}}129#pragma acc loop gang gang(dim:1) gang(dim:2) reduction(+:I)130    for(int i = 0; i < 5; ++i) {131    }132  }133 134#pragma acc parallel num_gangs(1, 2)135  {136    // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}137    // expected-note@+2{{previous 'gang' clause is here}}138    // expected-note@-4{{previous 'num_gangs' clause is here}}139#pragma acc loop gang(dim:1) reduction(+:I)140    for(int i = 0; i < 5; ++i) {141    }142  }143 144#pragma acc parallel num_gangs(2, 3)145  {146    // expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}147    // expected-note@+2{{previous 'reduction' clause is here}}148    // expected-note@-4{{previous 'num_gangs' clause is here}}149#pragma acc loop reduction(+:I) gang(dim:1)150    for(int i = 0; i < 5; ++i) {151    }152  }153 154  CompositeHasComposite CoCArr[5];155  // expected-error@+4{{invalid type 'struct CompositeOfScalars' used in OpenACC 'reduction' variable reference; type is not a scalar value}}156  // expected-note@+3{{used as element type of array type 'CompositeHasComposite[5]'}}157  // expected-note@#COS_FIELD{{used as field 'COS' of composite 'CompositeHasComposite'}}158  // expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}159#pragma acc loop reduction(+:CoCArr)160    for(int i = 0; i < 5; ++i);161  // expected-error@+3{{invalid type 'struct CompositeOfScalars' used in OpenACC 'reduction' variable reference; type is not a scalar value}}162  // expected-note@#COS_FIELD{{used as field 'COS' of composite 'CompositeHasComposite'}}163  // expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}164#pragma acc loop reduction(+:CoCArr[3])165    for(int i = 0; i < 5; ++i);166  // expected-error@+3{{invalid type 'struct CompositeOfScalars' used in OpenACC 'reduction' variable reference; type is not a scalar value}}167  // expected-note@#COS_FIELD{{used as field 'COS' of composite 'CompositeHasComposite'}}168  // expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}169#pragma acc loop reduction(+:CoCArr[1:1])170    for(int i = 0; i < 5; ++i);171}172 173template<typename IntTy, typename CoSTy, typename ChCTy, unsigned One,174         unsigned Two>175void templ_uses() {176  IntTy I;177  IntTy Array[5];178  CoSTy CoS;179  ChCTy ChC;180 181#pragma acc serial182  {183#pragma acc loop reduction(+:CoS, I)184    for(int i = 0; i < 5; ++i){}185  }186 187#pragma acc serial188  {189#pragma acc loop reduction(+:Array)190    for(int i = 0; i < 5; ++i){}191  }192 193#pragma acc serial194  {195  // expected-error@+3{{invalid type 'struct CompositeOfScalars' used in OpenACC 'reduction' variable reference; type is not a scalar value}}196  // expected-note@#COS_FIELD{{used as field 'COS' of composite 'CompositeHasComposite'}}197  // expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}198#pragma acc loop reduction(+:ChC)199    for(int i = 0; i < 5; ++i){}200  }201 202#pragma acc serial203  {204#pragma acc loop reduction(+:I)205    for(int i = 0; i < 5; ++i) {206    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}207    // expected-note@-3{{previous 'reduction' clause is here}}208#pragma acc loop reduction(&:I)209      for(int i = 0; i < 5; ++i) {210      }211    }212  }213 214#pragma acc serial215  {216#pragma acc loop reduction(+:Array[3])217    for(int i = 0; i < 5; ++i) {218    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}219    // expected-note@-3{{previous 'reduction' clause is here}}220#pragma acc loop reduction(&:Array[3])221      for(int i = 0; i < 5; ++i) {222      }223    }224  }225 226#pragma acc serial227  {228#pragma acc loop reduction(+:Array[0:3])229    for(int i = 0; i < 5; ++i) {230    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}231    // expected-note@-3{{previous 'reduction' clause is here}}232#pragma acc loop reduction(&:Array[1:4])233      for(int i = 0; i < 5; ++i) {234      }235    }236  }237 238#pragma acc serial239  {240#pragma acc loop reduction(+:I)241    for(int i = 0; i < 5; ++i) {242    // expected-error@+2{{OpenACC 'reduction' variable must have the same operator in all nested constructs (& vs +)}}243    // expected-note@-3{{previous 'reduction' clause is here}}244#pragma acc serial reduction(&:I)245      for(int i = 0; i < 5; ++i) {246      }247    }248  }249 250#pragma acc parallel251  {252#pragma acc loop reduction(+:I) gang(dim:One)253    for(int i = 0; i < 5; ++i) {254    }255  }256 257#pragma acc parallel258  {259  // expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'loop' construct as a 'reduction' clause}}260  // expected-note@+1{{previous 'reduction' clause is here}}261#pragma acc loop reduction(+:I) gang(dim:2)262    for(int i = 0; i < 5; ++i) {263    }264  }265 266#pragma acc parallel267  {268  // expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}269  // expected-note@+1{{previous 'gang' clause is here}}270#pragma acc loop gang(dim:2) reduction(+:I)271    for(int i = 0; i < 5; ++i) {272    }273  }274#pragma acc parallel275  {276  // expected-error@+2{{OpenACC 'gang' clause with a 'dim' value greater than 1 cannot appear on the same 'loop' construct as a 'reduction' clause}}277  // expected-note@+1{{previous 'reduction' clause is here}}278#pragma acc loop reduction(+:I) gang(dim:Two)279    for(int i = 0; i < 5; ++i) {280    }281  }282 283#pragma acc parallel284  {285  // expected-error@+2{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause with a 'dim' value greater than 1}}286  // expected-note@+1{{previous 'gang' clause is here}}287#pragma acc loop gang(dim:Two) reduction(+:I)288    for(int i = 0; i < 5; ++i) {289    }290  }291 292 293#pragma acc parallel num_gangs(One)294  {295#pragma acc loop reduction(+:I) gang(dim:One)296    for(int i = 0; i < 5; ++i) {297    }298  }299 300#pragma acc parallel num_gangs(Two, 1)301  {302    // expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}303    // expected-note@+2{{previous 'reduction' clause is here}}304    // expected-note@-4{{previous 'num_gangs' clause is here}}305#pragma acc loop reduction(+:I) gang(dim:One)306    for(int i = 0; i < 5; ++i) {307    }308  }309 310#pragma acc parallel num_gangs(Two, 1)311  {312    // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}313    // expected-note@+2{{previous 'gang' clause is here}}314    // expected-note@-4{{previous 'num_gangs' clause is here}}315#pragma acc loop gang(dim:One) reduction(+:I)316    for(int i = 0; i < 5; ++i) {317    }318  }319 320#pragma acc parallel num_gangs(One)321  {322#pragma acc loop reduction(+:I) gang(dim:1)323    for(int i = 0; i < 5; ++i) {324    }325  }326 327#pragma acc parallel num_gangs(Two, 1)328  {329    // expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}330    // expected-note@+2{{previous 'reduction' clause is here}}331    // expected-note@-4{{previous 'num_gangs' clause is here}}332#pragma acc loop reduction(+:I) gang(dim:1)333    for(int i = 0; i < 5; ++i) {334    }335  }336 337#pragma acc parallel num_gangs(Two, 1)338  {339    // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}340    // expected-note@+2{{previous 'gang' clause is here}}341    // expected-note@-4{{previous 'num_gangs' clause is here}}342#pragma acc loop gang(dim:1) reduction(+:I)343    for(int i = 0; i < 5; ++i) {344    }345  }346 347#pragma acc parallel num_gangs(1)348  {349#pragma acc loop reduction(+:I) gang(dim:One)350    for(int i = 0; i < 5; ++i) {351    }352  }353 354#pragma acc parallel num_gangs(2, 1)355  {356    // expected-error@+3{{OpenACC 'gang' clause cannot appear on the same 'loop' construct as a 'reduction' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}357    // expected-note@+2{{previous 'reduction' clause is here}}358    // expected-note@-4{{previous 'num_gangs' clause is here}}359#pragma acc loop reduction(+:I) gang(dim:One)360    for(int i = 0; i < 5; ++i) {361    }362  }363 364#pragma acc parallel num_gangs(2, 1)365  {366    // expected-error@+3{{OpenACC 'reduction' clause cannot appear on the same 'loop' construct as a 'gang' clause inside a compute construct with a 'num_gangs' clause with more than one argument}}367    // expected-note@+2{{previous 'gang' clause is here}}368    // expected-note@-4{{previous 'num_gangs' clause is here}}369#pragma acc loop gang(dim:One) reduction(+:I)370    for(int i = 0; i < 5; ++i) {371    }372  }373}374 375void inst() {376  // expected-note@+1{{in instantiation of function template specialization}}377  templ_uses<int, CompositeOfScalars, CompositeHasComposite, 1, 2>();378}379 380 381