diff options
author | Sandra Loosemore <sloosemore@baylibre.com> | 2024-09-06 20:58:13 +0000 |
---|---|---|
committer | Sandra Loosemore <sloosemore@baylibre.com> | 2024-09-24 15:04:08 +0000 |
commit | 96246bff0bcd9e5cdec9e6cf811ee3db4997f6d4 (patch) | |
tree | d41609ae565965c5a885121ac658efd8fb0fca49 /gcc/testsuite/c-c++-common/gomp | |
parent | 2114243c23ec5168cd54633cd4995ab123d92573 (diff) | |
download | gcc-96246bff0bcd9e5cdec9e6cf811ee3db4997f6d4.zip gcc-96246bff0bcd9e5cdec9e6cf811ee3db4997f6d4.tar.gz gcc-96246bff0bcd9e5cdec9e6cf811ee3db4997f6d4.tar.bz2 |
OpenMP: Check additional restrictions on context selector properties
TR13 (pre-6.0) of the OpenMP spec says:
"Each trait-property may only be specified once in a trait selector
other than those in the construct selector set."
and
"If trait-property any is specified in the kind trait-selector of the
device selector set or the target_device selector sets, no other
trait-property may be specified in the same selector set."
These restrictions (with slightly different wording) date back to
OpenMP 5.1, but were not in 5.0 which was the basis for GCC's
implementation.
This patch adds a diagnostic, adds new testcases, and fixes some older
testcases that include now-invalid selectors.
gcc/ChangeLog
* omp-general.cc (omp_check_context_selector): Reject other
properties in the same selector set with kind(any). Also reject
duplicate name-list properties.
gcc/testsuite/ChangeLog
* c-c++-common/gomp/declare-variant-10.c: Fix broken tests.
* c-c++-common/gomp/declare-variant-3.c: Likewise.
* c-c++-common/gomp/declare-variant-9.c: Likewise.
* c-c++-common/gomp/declare-variant-any.c: New.
* c-c++-common/gomp/declare-variant-duplicates.c: New.
* gfortran.dg/gomp/declare-variant-10.f90: Fix broken tests.
* gfortran.dg/gomp/declare-variant-3.f90: Likewise.
* gfortran.dg/gomp/declare-variant-9.f90: Likewise.
* gfortran.dg/gomp/declare-variant-any.f90: New.
* gfortran.dg/gomp/declare-variant-duplicates.f90: New.
Diffstat (limited to 'gcc/testsuite/c-c++-common/gomp')
5 files changed, 37 insertions, 11 deletions
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c index 2b8a394..e776934 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-10.c @@ -7,7 +7,7 @@ void f01 (void); #pragma omp declare variant (f01) match (device={isa(avx512f,avx512bw)}) void f02 (void); void f03 (void); -#pragma omp declare variant (f03) match (device={kind("any"),arch(x86_64),isa(avx512f,avx512bw)}) +#pragma omp declare variant (f03) match (device={arch(x86_64),isa(avx512f,avx512bw)}) void f04 (void); void f05 (void); #pragma omp declare variant (f05) match (device={kind(gpu)}) @@ -28,7 +28,7 @@ void f15 (void); #pragma omp declare variant (f15) match (device={isa(sse4,ssse3),arch(i386)}) void f16 (void); void f17 (void); -#pragma omp declare variant (f17) match (device={kind(any,fpga)}) +#pragma omp declare variant (f17) match (device={kind(fpga)}) void f18 (void); #pragma omp declare target diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c index f5d7797..0d772d7 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-3.c @@ -29,13 +29,13 @@ void f17 (void); void f18 (void); #pragma omp declare variant (f13) match (device={kind(fpga)}) void f19 (void); -#pragma omp declare variant (f13) match (device={kind(any,any)}) +#pragma omp declare variant (f13) match (device={kind(any)}) void f20 (void); #pragma omp declare variant (f13) match (device={kind(host,nohost)}) void f21 (void); #pragma omp declare variant (f13) match (device={kind("cpu","gpu","fpga")}) void f22 (void); -#pragma omp declare variant (f13) match (device={kind(any,cpu,nohost)}) +#pragma omp declare variant (f13) match (device={kind(cpu,nohost)}) void f23 (void); #pragma omp declare variant (f13) match (device={isa(avx)}) void f24 (void); @@ -139,12 +139,8 @@ void f72 (void); void f73 (void); #pragma omp declare variant (f13) match (user={condition(score(25):1)}) void f74 (void); -#pragma omp declare variant (f13) match (device={kind(any,"any")}) +#pragma omp declare variant (f13) match (device={kind("any")}) void f75 (void); -#pragma omp declare variant (f13) match (device={kind("any","any")}) -void f76 (void); -#pragma omp declare variant (f13) match (device={kind("any",any)}) -void f77 (void); #pragma omp declare variant (f13) match (implementation={vendor(nvidia)}) void f78 (void); #pragma omp declare variant (f13) match (user={condition(score(0):0)}) diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c index 5ee7589..da96c81 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-9.c @@ -7,7 +7,7 @@ void f01 (void); #pragma omp declare variant (f01) match (device={isa("avx512f",avx512bw)}) void f02 (void); void f03 (void); -#pragma omp declare variant (f03) match (device={kind(any),arch(x86_64),isa("avx512f","avx512bw")}) +#pragma omp declare variant (f03) match (device={arch(x86_64),isa("avx512f","avx512bw")}) void f04 (void); void f05 (void); #pragma omp declare variant (f05) match (device={kind(gpu)}) @@ -28,7 +28,7 @@ void f15 (void); #pragma omp declare variant (f15) match (device={isa(sse4,ssse3),arch(i386)}) void f16 (void); void f17 (void); -#pragma omp declare variant (f17) match (device={kind("any","fpga")}) +#pragma omp declare variant (f17) match (device={kind("fpga")}) void f18 (void); void diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-any.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-any.c new file mode 100644 index 0000000..cddf73b --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-any.c @@ -0,0 +1,17 @@ +/* Check that errors are detected if other trait-properties are given with + kind(any). */ + +extern int f1 (int); +extern int f2 (int); +extern int f3 (int); +extern int f4 (int); +extern int f5 (int); +extern int f6 (int); + +#pragma omp declare variant (f1) match (device={kind(any,gpu)}) /* { dg-error "no other trait-property may be specified" } */ +#pragma omp declare variant (f2) match (device={kind(cpu,"any")}) /* { dg-error "no other trait-property may be specified" } */ +#pragma omp declare variant (f3) match (device={kind("any"),arch(x86_64)}) /* { dg-error "no other trait-property may be specified" } */ +#pragma omp declare variant (f4) match (device={arch(x86_64),kind(any)}) /* { dg-error "no other trait-property may be specified" } */ +#pragma omp declare variant (f5) match (device={kind(any,"any")}) /* { dg-error "trait-property .any. specified more than once" } */ +#pragma omp declare variant (f6) match (device={kind("any",any)}) /* { dg-error "trait-property .any. specified more than once" } */ +int f (int); diff --git a/gcc/testsuite/c-c++-common/gomp/declare-variant-duplicates.c b/gcc/testsuite/c-c++-common/gomp/declare-variant-duplicates.c new file mode 100644 index 0000000..47d34fc --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/declare-variant-duplicates.c @@ -0,0 +1,13 @@ +/* Check that errors are detected if duplicates appear in name-list + properties. */ + +extern int f1 (int); +extern int f2 (int); +extern int f3 (int); +extern int f4 (int); + +#pragma omp declare variant (f1) match (device={kind(cpu,gpu,"cpu")}) /* { dg-error "trait-property .cpu. specified more than once" } */ +#pragma omp declare variant (f2) match (device={isa(sse4,"avx",avx)}) /* { dg-error "trait-property .avx. specified more than once" } */ +#pragma omp declare variant (f3) match (device={arch(x86_64,i386,aarch64,"i386")}) /* { dg-error "trait-property .i386. specified more than once" } */ +#pragma omp declare variant (f4) match (implementation={vendor(llvm,gnu,"arm",gnu)}) /* { dg-error "trait-property .gnu. specified more than once" } */ +int f (int); |