[OpenACC] Audit/add tests to ensure we enforce appertainment correctly

I apparently missed a few other clauses as well when doing my initial
implementation, so this adds tests for all, and fixes up the few that
had problems.

This is something that I'll do better to keep an eye on, though
shouldn't be necessary once the rest of the clauses are implemented and
we can remove the 'default' case.
This commit is contained in:
erichkeane 2024-05-31 12:37:06 -07:00
parent 5849cbad0f
commit 6119340e0b
20 changed files with 178 additions and 0 deletions

View File

@ -170,6 +170,57 @@ bool doesClauseApplyToDirective(OpenACCDirectiveKind DirectiveKind,
default:
return false;
}
case OpenACCClauseKind::CopyIn:
case OpenACCClauseKind::PCopyIn:
case OpenACCClauseKind::PresentOrCopyIn:
switch (DirectiveKind) {
case OpenACCDirectiveKind::Parallel:
case OpenACCDirectiveKind::Serial:
case OpenACCDirectiveKind::Kernels:
case OpenACCDirectiveKind::Data:
case OpenACCDirectiveKind::EnterData:
case OpenACCDirectiveKind::Declare:
case OpenACCDirectiveKind::ParallelLoop:
case OpenACCDirectiveKind::SerialLoop:
case OpenACCDirectiveKind::KernelsLoop:
return true;
default:
return false;
}
case OpenACCClauseKind::CopyOut:
case OpenACCClauseKind::PCopyOut:
case OpenACCClauseKind::PresentOrCopyOut:
switch (DirectiveKind) {
case OpenACCDirectiveKind::Parallel:
case OpenACCDirectiveKind::Serial:
case OpenACCDirectiveKind::Kernels:
case OpenACCDirectiveKind::Data:
case OpenACCDirectiveKind::ExitData:
case OpenACCDirectiveKind::Declare:
case OpenACCDirectiveKind::ParallelLoop:
case OpenACCDirectiveKind::SerialLoop:
case OpenACCDirectiveKind::KernelsLoop:
return true;
default:
return false;
}
case OpenACCClauseKind::Create:
case OpenACCClauseKind::PCreate:
case OpenACCClauseKind::PresentOrCreate:
switch (DirectiveKind) {
case OpenACCDirectiveKind::Parallel:
case OpenACCDirectiveKind::Serial:
case OpenACCDirectiveKind::Kernels:
case OpenACCDirectiveKind::Data:
case OpenACCDirectiveKind::EnterData:
case OpenACCDirectiveKind::ParallelLoop:
case OpenACCDirectiveKind::SerialLoop:
case OpenACCDirectiveKind::KernelsLoop:
return true;
default:
return false;
}
case OpenACCClauseKind::Attach:
switch (DirectiveKind) {
case OpenACCDirectiveKind::Parallel:

View File

@ -38,4 +38,9 @@ void Test() {
#pragma acc kernels async(SomeE)
while(1);
// expected-error@+2{{OpenACC 'async' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop async(1)
for(;;);
}

View File

@ -58,4 +58,9 @@ void uses() {
#pragma acc parallel attach(s.PtrMem)
while (1);
// expected-error@+2{{OpenACC 'attach' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop attach(LocalInt)
for(;;);
}

View File

@ -59,4 +59,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 copy((float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'copy' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop copy(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'pcopy' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop pcopy(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'present_or_copy' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop present_or_copy(LocalInt)
for(;;);
}

View File

@ -65,4 +65,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 copyin(invalid:(float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'copyin' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop copyin(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'pcopyin' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop pcopyin(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'present_or_copyin' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop present_or_copyin(LocalInt)
for(;;);
}

View File

@ -65,4 +65,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 copyout(invalid:(float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'copyout' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop copyout(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'pcopyout' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop pcopyout(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'present_or_copyout' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop present_or_copyout(LocalInt)
for(;;);
}

View File

@ -66,4 +66,17 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 create(invalid:(float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'create' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop create(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'pcreate' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop pcreate(LocalInt)
for(;;);
// expected-error@+2{{OpenACC 'present_or_create' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop present_or_create(LocalInt)
for(;;);
}

View File

@ -52,4 +52,9 @@ void SingleOnly() {
// expected-error@+1{{OpenACC 'default' clause is not valid on 'wait' directive}}
#pragma acc wait default(none)
while(0);
// expected-error@+2{{OpenACC 'default' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop default(present)
for(;;);
}

View File

@ -58,4 +58,9 @@ void uses() {
#pragma acc parallel deviceptr(s.PtrMem)
while (1);
// expected-error@+2{{OpenACC 'deviceptr' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop deviceptr(LocalInt)
for(;;);
}

View File

@ -52,4 +52,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 firstprivate((float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'firstprivate' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop firstprivate(LocalInt)
for(;;);
}

View File

@ -59,4 +59,9 @@ void BoolExpr(int *I, float *F) {
// expected-warning@+1{{OpenACC clause 'if' not yet implemented}}
#pragma acc kernels loop if (*I < *F)
while(0);
// expected-error@+2{{OpenACC 'if' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop if(I)
for(;;);
}

View File

@ -51,4 +51,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 no_create((float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'no_create' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop no_create(LocalInt)
for(;;);
}

View File

@ -51,4 +51,9 @@ void Test() {
// expected-error@+1{{too many integer expression arguments provided to OpenACC 'num_gangs' clause: 'parallel' directive expects maximum of 3, 4 were provided}}
#pragma acc parallel num_gangs(getS(), 1, getS(), 1)
while(1);
// expected-error@+2{{OpenACC 'num_gangs' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop num_gangs(1)
for(;;);
}

View File

@ -30,4 +30,9 @@ void Test() {
#pragma acc kernels num_workers(SomeE)
while(1);
// expected-error@+2{{OpenACC 'num_workers' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop num_workers(1)
for(;;);
}

View File

@ -51,4 +51,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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 present((float)ArrayParam[2])
while(1);
// expected-error@+2{{OpenACC 'present' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop present(LocalInt)
for(;;);
}

View File

@ -134,4 +134,9 @@ void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete Compo
// 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);
// expected-error@+2{{OpenACC 'private' clause is not valid on 'init' directive}}
// expected-warning@+1{{OpenACC construct 'init' not yet implemented}}
#pragma acc init private(LocalInt)
for(;;);
}

View File

@ -104,4 +104,9 @@ void uses(unsigned Parm) {
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, or composite variable member}}
#pragma acc parallel reduction(&:HA.array[1:2])
while (1);
// expected-error@+2{{OpenACC 'reduction' clause is not valid on 'init' directive}}
// expected-warning@+1{{OpenACC construct 'init' not yet implemented}}
#pragma acc init reduction(+:I)
for(;;);
}

View File

@ -79,4 +79,9 @@ void WarnMaybeNotUsed(int val1, int val2) {
// expected-error@+1{{use of undeclared identifier 'invalid'}}
#pragma acc parallel if(invalid) self(val1)
while(0);
// expected-error@+2{{OpenACC 'self' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop self
for(;;);
}

View File

@ -30,4 +30,9 @@ void Test() {
#pragma acc kernels vector_length(SomeE)
while(1);
// expected-error@+2{{OpenACC 'vector_length' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop vector_length(1)
for(;;);
}

View File

@ -35,4 +35,9 @@ void uses() {
// expected-error@+1{{OpenACC clause 'wait' requires expression of integer type ('struct NotConvertible' invalid)}}
#pragma acc parallel wait(devnum:arr : queues: arr, NC, 5)
while(1);
// expected-error@+2{{OpenACC 'wait' clause is not valid on 'loop' directive}}
// expected-warning@+1{{OpenACC construct 'loop' not yet implemented}}
#pragma acc loop wait
for(;;);
}