brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 58b1c8b Raw
137 lines · cpp
1// RUN: %clang_cc1 %s -fopenacc -verify2 3template<typename Int, typename NotInt, typename ConvertsToInt>4void TemplUses(Int I, NotInt NI, ConvertsToInt CTI) {5#pragma acc loop vector(I)6  for(int j = 0; j < 5; ++j);7 8#pragma acc parallel9#pragma acc loop vector(length: I)10  for(int j = 0; j < 5; ++j);11 12#pragma acc kernels13#pragma acc loop vector(CTI)14  for(int j = 0; j < 5; ++j);15 16  // expected-error@+2{{OpenACC clause 'vector' requires expression of integer type ('NoConvert' invalid)}}17#pragma acc kernels18#pragma acc loop vector(length: NI)19  for(int j = 0; j < 5; ++j);20 21  // expected-error@+2{{'length' argument on 'vector' clause is not permitted on a 'loop' construct associated with a 'serial' compute construct}}22#pragma acc serial23#pragma acc loop vector(length: I)24  for(int j = 0; j < 5; ++j);25 26  // expected-error@+3{{'length' argument to 'vector' clause not allowed on a 'loop' construct associated with a 'kernels' construct that has a 'vector_length' clause}}27  // expected-note@+1{{previous 'vector_length' clause is here}}28#pragma acc kernels vector_length(I)29#pragma acc loop vector(length: CTI)30  for(int j = 0; j < 5; ++j);31 32#pragma acc loop vector33  for(int i = 0; i < 5; ++i) {34    for(int j = 0; j < 5; ++j);35    // expected-error@+2{{loop with a 'vector' clause may not exist in the region of a 'vector' clause}}36    // expected-note@-4{{previous 'vector' clause is here}}37#pragma acc loop vector38    for(int j = 0; j < 5; ++j);39    for(int j = 0; j < 5; ++j);40  }41 42#pragma acc loop vector43  for(int i = 0; i < 5; ++i) {44    for(int j = 0; j < 5; ++j);45    // expected-error@+4{{loop with a 'vector' clause may not exist in the region of a 'vector' clause}}46    // expected-error@+3{{loop with a 'worker' clause may not exist in the region of a 'vector' clause}}47    // expected-error@+2{{loop with a 'gang' clause may not exist in the region of a 'vector' clause}}48    // expected-note@-6 3{{previous 'vector' clause is here}}49#pragma acc loop vector, worker, gang50    for(int j = 0; j < 5; ++j);51    for(int j = 0; j < 5; ++j);52  }53 54#pragma acc loop vector55  for(int i = 0; i < 5; ++i) {56#pragma acc serial57#pragma acc loop vector58    for(int j = 0; j < 5; ++j);59  }60}61 62struct NoConvert{};63struct Converts{64  operator int();65};66 67void uses() {68  TemplUses(5, NoConvert{}, Converts{}); // expected-note{{in instantiation of function template specialization}}69 70  unsigned i;71  NoConvert NI;72  Converts CTI;73 74#pragma acc loop vector(i)75  for(int j = 0; j < 5; ++j);76 77#pragma acc parallel78#pragma acc loop vector(length: i)79  for(int j = 0; j < 5; ++j);80 81#pragma acc kernels82#pragma acc loop vector(CTI)83  for(int j = 0; j < 5; ++j);84 85  // expected-error@+2{{OpenACC clause 'vector' requires expression of integer type ('NoConvert' invalid)}}86#pragma acc kernels87#pragma acc loop vector(length: NI)88  for(int j = 0; j < 5; ++j);89 90  // expected-error@+2{{'length' argument on 'vector' clause is not permitted on a 'loop' construct associated with a 'serial' compute construct}}91#pragma acc serial92#pragma acc loop vector(length: i)93  for(int j = 0; j < 5; ++j);94 95  // expected-error@+3{{'length' argument to 'vector' clause not allowed on a 'loop' construct associated with a 'kernels' construct that has a 'vector_length' clause}}96  // expected-note@+1{{previous 'vector_length' clause is here}}97#pragma acc kernels vector_length(i)98#pragma acc loop vector(length: i)99  for(int j = 0; j < 5; ++j);100 101#pragma acc loop vector102  for(int i = 0; i < 5; ++i) {103    for(int j = 0; j < 5; ++j);104    // expected-error@+2{{loop with a 'vector' clause may not exist in the region of a 'vector' clause}}105    // expected-note@-4{{previous 'vector' clause is here}}106#pragma acc loop vector107    for(int j = 0; j < 5; ++j);108    for(int j = 0; j < 5; ++j);109  }110 111#pragma acc loop vector112  for(int i = 0; i < 5; ++i) {113#pragma acc serial114#pragma acc loop vector115    for(int j = 0; j < 5; ++j);116  }117 118#pragma acc loop vector119  for(int i = 0; i < 5; ++i) {120    for(int j = 0; j < 5; ++j);121    // expected-error@+4{{loop with a 'vector' clause may not exist in the region of a 'vector' clause}}122    // expected-error@+3{{loop with a 'worker' clause may not exist in the region of a 'vector' clause}}123    // expected-error@+2{{loop with a 'gang' clause may not exist in the region of a 'vector' clause}}124    // expected-note@-6 3{{previous 'vector' clause is here}}125#pragma acc loop vector, worker, gang126    for(int j = 0; j < 5; ++j);127    for(int j = 0; j < 5; ++j);128  }129 130#pragma acc loop vector131  for(int i = 0; i < 5; ++i) {132#pragma acc serial133#pragma acc loop vector, worker, gang134    for(int j = 0; j < 5; ++j);135  }136}137