Skip to content

[OpenMP] Allow OMP6.0 features. #122108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4173,7 +4173,7 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
}
}

// Check if -fopenmp is specified and set default version to 5.0.
// Check if -fopenmp is specified and set default version to 5.1.
Opts.OpenMP = Args.hasArg(OPT_fopenmp) ? 51 : 0;
// Check if -fopenmp-simd is specified.
bool IsSimdSpecified =
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,9 +1460,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
case 50:
Builder.defineMacro("_OPENMP", "201811");
break;
case 51:
Builder.defineMacro("_OPENMP", "202011");
break;
case 52:
Builder.defineMacro("_OPENMP", "202111");
break;
case 60:
Builder.defineMacro("_OPENMP", "202411");
break;
default: // case 51:
// Default version is OpenMP 5.1
Builder.defineMacro("_OPENMP", "202011");
Expand Down
20 changes: 11 additions & 9 deletions clang/test/OpenMP/declare_mapper_messages.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// RUN: %clang_cc1 -verify=omp50,expected -fopenmp -fopenmp-version=50 -ferror-limit 100 -DOMP50 %s
// RUN: %clang_cc1 -verify=omp51,expected -fopenmp -ferror-limit 100 %s
// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -ferror-limit 100 -DOMP52 %s
// RUN: %clang_cc1 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -ferror-limit 100 -DOMP52 %s

// RUN: %clang_cc1 -verify=omp50,expected -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -DOMP50 %s
// RUN: %clang_cc1 -verify=omp51-simd,expected -fopenmp-simd -ferror-limit 100 %s
// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -ferror-limit 100 -DOMP52 %s
// RUN: %clang_cc1 -verify=expected,omp60-simd -fopenmp-simd -fopenmp-version=60 -ferror-limit 100 -DOMP52 %s

int temp; // expected-note {{'temp' declared here}}

Expand Down Expand Up @@ -33,10 +35,10 @@ struct vec { // expec
#pragma omp declare mapper(int v) map(v) // expected-error {{mapper type must be of struct, union or class type}}

#ifndef OMP52
// omp51-simd-error@+6 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present', 'ompx_hold'}}
// omp50-error@+5 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'ompx_hold'}}
// omp51-error@+4 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present', 'ompx_hold'}}
// expected-error@+3 {{only variable 'vvec' is allowed in map clauses of this 'omp declare mapper' directive}}
// omp51-simd-error@+6 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present', 'ompx_hold'}}
// omp50-error@+5 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'ompx_hold'}}
// omp51-error@+4 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present', 'ompx_hold'}}
// expected-error@+3 {{only variable 'vvec' is allowed in map clauses of this 'omp declare mapper' directive}}
// expected-error@+2 {{expected at least one clause on '#pragma omp declare mapper' directive}}
// expected-note@+1 {{'it' declared here}}
#pragma omp declare mapper(id2: struct vec vvec) map(iterator(it=0:vvec.len:2), tofrom:vvec.data[it])
Expand Down Expand Up @@ -68,15 +70,15 @@ int fun(int arg) {
{}
#pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-error {{call to undeclared function 'mapper'}} expected-note {{to match this '('}}
{}
#pragma omp target map(mapper(ab) :vv) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}}
#pragma omp target map(mapper(ab) :vv) // omp50-error {{missing map type}} omp51-error {{missing map type}} omp52-error {{missing map type}} omp51-simd-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}}
{}
#pragma omp target map(mapper(ab) :arr[0:2]) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}}
#pragma omp target map(mapper(ab) :arr[0:2]) // omp50-error {{missing map type}} omp51-error {{missing map type}} omp52-error {{missing map type}} omp51-simd-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'struct vec' with name 'ab'}}
{}
#pragma omp target map(mapper(aa) :vv) // expected-error {{missing map type}}
#pragma omp target map(mapper(aa) :vv) // omp50-error {{missing map type}} omp51-error {{missing map type}} omp52-error {{missing map type}} omp51-simd-error {{missing map type}}
{}
#pragma omp target map(mapper(aa) to:d) // expected-error {{mapper type must be of struct, union or class type}} omp52-error{{missing ',' after map type modifier}}
#pragma omp target map(mapper(aa) to:d) // expected-error {{mapper type must be of struct, union or class type}} omp52-error{{missing ',' after map type modifier}} omp60-error{{missing ',' after map type modifier}} omp60-simd-error{{missing ',' after map type modifier}}
{}
#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0]) // omp52-error 4 {{missing ',' after map type modifier}}
#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0]) // omp52-error 4 {{missing ',' after map type modifier}} omp60-error 4 {{missing ',' after map type modifier}} omp60-simd-error 4 {{missing ',' after map type modifier}}
{}

#pragma omp target update to(mapper) // expected-error {{expected '(' after 'mapper'}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
Expand Down
20 changes: 12 additions & 8 deletions clang/test/OpenMP/declare_mapper_messages.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// RUN: %clang_cc1 -verify=omp50,expected,cxx17 -fopenmp -fopenmp-version=50 -ferror-limit 100 %std_cxx17- %s
// RUN: %clang_cc1 -verify=omp60,expected,cxx17 -fopenmp -fopenmp-version=60 -ferror-limit 100 %std_cxx17- %s

// RUN: %clang_cc1 -verify=omp50,expected,precxx17 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %std_cxx98-14 %s

// RUN: %clang_cc1 -verify=omp60,expected,precxx17 -fopenmp-simd -fopenmp-version=60 -ferror-limit 100 %std_cxx98-14 %s

// RUN: %clang_cc1 -verify=omp51,expected,cxx17 -fopenmp -ferror-limit 100 %std_cxx17- %s
// RUN: %clang_cc1 -verify=omp51,expected,precxx17 -fopenmp-simd -ferror-limit 100 %std_cxx98-14 %s

Expand Down Expand Up @@ -72,21 +76,21 @@ int fun(int arg) {
{}
#pragma omp target map(mapper(aa :vv) // expected-error {{use of undeclared identifier 'aa'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
{}
#pragma omp target map(mapper(ab) :vv) // expected-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}}
#pragma omp target map(mapper(ab) :vv) // omp50-error {{missing map type}} omp51-error {{missing map type}} expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}}
{}
#pragma omp target map(mapper(N2::) :vv) // expected-error {{use of undeclared identifier 'N2'}} expected-error {{illegal OpenMP user-defined mapper identifier}}
{}
#pragma omp target map(mapper(N1::) :vv) // expected-error {{illegal OpenMP user-defined mapper identifier}}
{}
#pragma omp target map(mapper(aa) :vv) // expected-error {{missing map type}}
#pragma omp target map(mapper(aa) :vv) // omp50-error {{missing map type}} omp51-error {{missing map type}}
{}
#pragma omp target map(mapper(N1::aa) alloc:vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
#pragma omp target map(mapper(N1::aa) alloc:vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} omp60-error {{missing ',' after map type modifier}}
{}
#pragma omp target map(mapper(N1::aa) alloc:arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}}
#pragma omp target map(mapper(N1::aa) alloc:arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} omp60-error {{missing ',' after map type modifier}}
{}
#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0])
#pragma omp target map(mapper(aa) to:vv) map(close mapper(aa) from:v1) map(mapper(aa) to:arr[0]) // omp60-error 4 {{missing ',' after map type modifier}}
{}
#pragma omp target map(mapper(N1::stack<int>::id) to:vv)
#pragma omp target map(mapper(N1::stack<int>::id) to:vv) // omp60-error {{missing ',' after map type modifier}}
{}

#pragma omp target update to(mapper) // expected-error {{expected '(' after 'mapper'}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
Expand All @@ -99,7 +103,7 @@ int fun(int arg) {
#pragma omp target update to(mapper(N1::aa) :vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
#pragma omp target update to(mapper(ab):vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
#pragma omp target update to(mapper(ab):arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
#pragma omp target update to(mapper(aa) a:vv) // omp51-warning {{missing ':' after motion modifier - ignoring}} omp50-warning {{missing ':' after ) - ignoring}}
#pragma omp target update to(mapper(aa) a:vv) // omp51-warning {{missing ':' after motion modifier - ignoring}} omp50-warning {{missing ':' after ) - ignoring}} omp60-warning {{missing ':' after motion modifier - ignoring}}
#pragma omp target update to(mapper(aa):vv) to(mapper(aa):arr[0])
#pragma omp target update to(mapper(N1::stack<int>::id) :vv)

Expand All @@ -113,7 +117,7 @@ int fun(int arg) {
#pragma omp target update from(mapper(N1::aa) :vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'aa'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
#pragma omp target update from(mapper(ab):vv) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
#pragma omp target update from(mapper(ab):arr[0:2]) // expected-error {{cannot find a valid user-defined mapper for type 'vec' with name 'ab'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
#pragma omp target update from(mapper(aa) a:vv) // omp51-warning {{missing ':' after motion modifier - ignoring}} omp50-warning {{missing ':' after ) - ignoring}}
#pragma omp target update from(mapper(aa) a:vv) // omp51-warning {{missing ':' after motion modifier - ignoring}} omp50-warning {{missing ':' after ) - ignoring}} omp60-warning {{missing ':' after motion modifier - ignoring}}
#pragma omp target update from(mapper(aa):vv) from(mapper(aa):arr[0])
#pragma omp target update from(mapper(N1::stack<int>::id) :vv)
}
Expand Down
2 changes: 0 additions & 2 deletions clang/test/OpenMP/declare_simd_ast_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

#pragma omp declare simd aligned(b : 64)
#pragma omp declare simd simdlen(32) aligned(d, b)
#pragma omp declare simd inbranch, uniform(d) linear(val(s1, s2) : 32)
#pragma omp declare simd notinbranch simdlen(2), uniform(s1, s2) linear(d: s1)
void add_1(float *d, int s1, float *s2, double b[]) __attribute__((cold));

// CHECK: #pragma omp declare simd notinbranch simdlen(2) uniform(s1, s2) linear(val(d): s1){{$}}
// CHECK-NEXT: #pragma omp declare simd inbranch uniform(d) linear(val(s1): 32) linear(val(s2): 32){{$}}
// CHECK-NEXT: #pragma omp declare simd simdlen(32) aligned(d) aligned(b){{$}}
// CHECK-NEXT: #pragma omp declare simd aligned(b: 64){{$}}
// CHECK-NEXT: void add_1(float *d, int s1, float *s2, double b[]) __attribute__((cold))
Expand Down
22 changes: 11 additions & 11 deletions clang/test/OpenMP/declare_simd_ast_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ class VV {
// CHECK-NEXT: int add(int a, int b) __attribute__((cold)) {
// CHECK-NEXT: return a + b;
// CHECK-NEXT: }
#pragma omp declare simd uniform(this, a) linear(val(b): a)
#pragma omp declare simd uniform(this, a) linear(b: a)
int add(int a, int b) __attribute__((cold)) { return a + b; }

// CHECK: #pragma omp declare simd aligned(b: 4) aligned(a) linear(ref(b): 4) linear(val(this)) linear(val(a))
// CHECK: #pragma omp declare simd aligned(b: 4) aligned(a) linear(val(b): 4) linear(val(this)) linear(val(a))
// CHECK-NEXT: float taddpf(float *a, float *&b) {
// CHECK-NEXT: return *a + *b;
// CHECK-NEXT: }
#pragma omp declare simd aligned (b: 4) aligned(a) linear(ref(b): 4) linear(this, a)
#pragma omp declare simd aligned (b: 4) aligned(a) linear(b: 4) linear(this, a)
float taddpf(float *a, float *&b) { return *a + *b; }

// CHECK: #pragma omp declare simd aligned(b: 8)
// CHECK-NEXT: #pragma omp declare simd linear(uval(c): 8)
// CHECK-NEXT: #pragma omp declare simd linear(val(c): 8)
// CHECK-NEXT: int tadd(int (&b)[], int &c) {
// CHECK-NEXT: return this->x[b[0]] + b[0];
// CHECK-NEXT: }
#pragma omp declare simd linear(uval(c): 8)
#pragma omp declare simd linear(c: 8)
#pragma omp declare simd aligned(b : 8)
int tadd(int (&b)[], int &c) { return x[b[0]] + b[0]; }

Expand All @@ -89,7 +89,7 @@ class VV {
// CHECK: template <int X, typename T> class TVV {
// CHECK: #pragma omp declare simd simdlen(X)
// CHECK-NEXT: int tadd(int a, int b) {
// CHECK: #pragma omp declare simd aligned(a: X * 2) aligned(b) linear(ref(b): X)
// CHECK: #pragma omp declare simd aligned(a: X * 2) aligned(b) linear(val(b): X)
// CHECK-NEXT: float taddpf(float *a, T *&b) {
// CHECK-NEXT: return *a + *b;
// CHECK-NEXT: }
Expand All @@ -109,10 +109,10 @@ class TVV {
// CHECK: #pragma omp declare simd simdlen(16)
// CHECK-NEXT: int tadd(int a, int b);

#pragma omp declare simd aligned(a : X * 2) aligned(b) linear(ref(b): X)
#pragma omp declare simd aligned(a : X * 2) aligned(b) linear(b: X)
float taddpf(float *a, T *&b) { return *a + *b; }

// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) linear(ref(b): 16)
// CHECK: #pragma omp declare simd aligned(a: 16 * 2) aligned(b) linear(val(b): 16)
// CHECK-NEXT: float taddpf(float *a, float *&b) {
// CHECK-NEXT: return *a + *b;
// CHECK-NEXT: }
Expand All @@ -132,11 +132,11 @@ class TVV {
};
// CHECK: };

// CHECK: #pragma omp declare simd simdlen(N) aligned(b: N * 2) linear(uval(c): N)
// CHECK: #pragma omp declare simd simdlen(N) aligned(b: N * 2) linear(val(c): N)
// CHECK: template <int N> void foo(int (&b)[N], float *&c)
// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) linear(uval(c): 64)
// CHECK: #pragma omp declare simd simdlen(64) aligned(b: 64 * 2) linear(val(c): 64)
// CHECK: template<> void foo<64>(int (&b)[64], float *&c)
#pragma omp declare simd simdlen(N) aligned(b : N * 2) linear(uval(c): N)
#pragma omp declare simd simdlen(N) aligned(b : N * 2) linear(c: N)
template <int N>
void foo(int (&b)[N], float *&c);

Expand Down
Loading
Loading