2020-03-31 04:06:01 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2017-12-30 02:07:07 +08:00
|
|
|
|
2020-03-31 04:06:01 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2020-07-22 22:14:00 +08:00
|
|
|
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// RUN: %clang_cc1 -DOMP51 -DOMPX -verify -fopenmp -fopenmp-version=51 -fopenmp-extensions -ast-print %s | FileCheck -check-prefixes=CHECK,OMP51,OMPX %s
|
|
|
|
// RUN: %clang_cc1 -DOMP51 -DOMPX -fopenmp -fopenmp-version=51 -fopenmp-extensions -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -DOMP51 -DOMPX -fopenmp -fopenmp-version=51 -fopenmp-extensions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes=CHECK,OMP51,OMPX %s
|
2020-07-22 22:14:00 +08:00
|
|
|
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// RUN: %clang_cc1 -DOMP51 -DOMPX -verify -fopenmp-simd -fopenmp-version=51 -fopenmp-extensions -ast-print %s | FileCheck -check-prefixes=CHECK,OMP51,OMPX %s
|
|
|
|
// RUN: %clang_cc1 -DOMP51 -DOMPX -fopenmp-simd -fopenmp-version=51 -fopenmp-extensions -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -DOMP51 -DOMPX -fopenmp-simd -fopenmp-version=51 -fopenmp-extensions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck -check-prefixes=CHECK,OMP51,OMPX %s
|
2015-07-21 21:44:28 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
|
|
|
void foo() {}
|
|
|
|
|
2015-11-23 13:32:03 +08:00
|
|
|
template <typename T, int C>
|
|
|
|
T tmain(T argc, T *argv) {
|
|
|
|
T i, j, b, c, d, e, x[20];
|
|
|
|
|
2016-01-22 03:57:55 +08:00
|
|
|
#pragma omp target data map(to: c)
|
2015-11-23 13:32:03 +08:00
|
|
|
i = argc;
|
|
|
|
|
2016-01-22 03:57:55 +08:00
|
|
|
#pragma omp target data map(to: c) if (target data: j > 0)
|
2015-11-23 13:32:03 +08:00
|
|
|
foo();
|
|
|
|
|
2016-01-22 03:57:55 +08:00
|
|
|
#pragma omp target data map(to: c) if (b)
|
2015-11-23 13:32:03 +08:00
|
|
|
foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(c)
|
|
|
|
foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(c) if(b>e)
|
|
|
|
foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(x[0:10], c)
|
|
|
|
foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(to: c) map(from: d)
|
|
|
|
foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(always,alloc: e)
|
|
|
|
foo();
|
|
|
|
|
2018-12-19 06:18:41 +08:00
|
|
|
#pragma omp target data map(close,alloc: e)
|
|
|
|
foo();
|
|
|
|
|
2020-07-22 22:14:00 +08:00
|
|
|
#ifdef OMP51
|
|
|
|
#pragma omp target data map(present,alloc: e)
|
|
|
|
foo();
|
|
|
|
#endif
|
|
|
|
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
#ifdef OMPX
|
|
|
|
#pragma omp target data map(ompx_hold,alloc: e)
|
|
|
|
foo();
|
|
|
|
#endif
|
|
|
|
|
2015-11-23 13:32:03 +08:00
|
|
|
// nesting a target region
|
|
|
|
#pragma omp target data map(e)
|
|
|
|
{
|
|
|
|
#pragma omp target map(always, alloc: e)
|
|
|
|
foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
#pragma omp target map(close, alloc: e)
|
|
|
|
foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
#ifdef OMP51
|
|
|
|
#pragma omp target map(present, alloc: e)
|
|
|
|
foo();
|
|
|
|
#endif
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
#ifdef OMPX
|
|
|
|
#pragma omp target map(ompx_hold, alloc: e)
|
|
|
|
foo();
|
|
|
|
#endif
|
2015-11-23 13:32:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
|
|
|
|
// CHECK-NEXT: T i, j, b, c, d, e, x[20];
|
2018-02-15 01:38:47 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c){{$}}
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: i = argc;
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) if(target data: j > 0)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: foo();
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) if(b)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c) if(b > e)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: x[0:10],c)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) map(from: d)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target data map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target data map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: e)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
|
|
|
|
// CHECK-NEXT: int i, j, b, c, d, e, x[20];
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: i = argc;
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) if(target data: j > 0)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: foo();
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) if(b)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c) if(b > e)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: x[0:10],c)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) map(from: d)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target data map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target data map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: e)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK: template<> char tmain<char, 1>(char argc, char *argv) {
|
|
|
|
// CHECK-NEXT: char i, j, b, c, d, e, x[20];
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: i = argc;
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) if(target data: j > 0)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: foo();
|
2016-01-22 03:57:55 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) if(b)
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c) if(b > e)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: x[0:10],c)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) map(from: d)
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target data map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target data map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: e)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
|
2015-07-21 21:44:28 +08:00
|
|
|
int main (int argc, char **argv) {
|
2015-11-23 13:32:03 +08:00
|
|
|
int b = argc, c, d, e, f, g, x[20];
|
2015-07-21 21:44:28 +08:00
|
|
|
static int a;
|
|
|
|
// CHECK: static int a;
|
|
|
|
|
2020-03-31 04:06:01 +08:00
|
|
|
#pragma omp target data map(to: ([argc][3][a])argv)
|
|
|
|
// CHECK: #pragma omp target data map(to: ([argc][3][a])argv)
|
2016-01-22 03:57:55 +08:00
|
|
|
#pragma omp target data map(to: c)
|
|
|
|
// CHECK: #pragma omp target data map(to: c)
|
2015-07-21 21:44:28 +08:00
|
|
|
a=2;
|
|
|
|
// CHECK-NEXT: a = 2;
|
2016-01-22 03:57:55 +08:00
|
|
|
#pragma omp target data map(to: c) if (target data: b)
|
|
|
|
// CHECK: #pragma omp target data map(to: c) if(target data: b)
|
2015-07-21 21:44:28 +08:00
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2016-01-22 03:57:55 +08:00
|
|
|
#pragma omp target data map(to: c) if (b > g)
|
|
|
|
// CHECK: #pragma omp target data map(to: c) if(b > g)
|
2015-07-21 21:44:28 +08:00
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2015-11-23 13:32:03 +08:00
|
|
|
#pragma omp target data map(c)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(c) if(b>g)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: c) if(b > g)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(x[0:10], c)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: x[0:10],c)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(to: c) map(from: d)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(to: c) map(from: d)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target data map(always,alloc: e)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(always,alloc: e)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2018-12-19 06:18:41 +08:00
|
|
|
#pragma omp target data map(close,alloc: e)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(close,alloc: e)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2020-07-22 22:14:00 +08:00
|
|
|
// OMP51-NEXT: #pragma omp target data map(present,alloc: e)
|
|
|
|
// OMP51-NEXT: foo();
|
|
|
|
#ifdef OMP51
|
|
|
|
#pragma omp target data map(present,alloc: e)
|
|
|
|
foo();
|
|
|
|
#endif
|
|
|
|
|
[OpenMP][OpenACC] Implement `ompx_hold` map type modifier extension in Clang (1/2)
This patch implements Clang support for an original OpenMP extension
we have developed to support OpenACC: the `ompx_hold` map type
modifier. The next patch in this series, D106510, implements OpenMP
runtime support.
Consider the following example:
```
#pragma omp target data map(ompx_hold, tofrom: x) // holds onto mapping of x
{
foo(); // might have map(delete: x)
#pragma omp target map(present, alloc: x) // x is guaranteed to be present
printf("%d\n", x);
}
```
The `ompx_hold` map type modifier above specifies that the `target
data` directive holds onto the mapping for `x` throughout the
associated region regardless of any `target exit data` directives
executed during the call to `foo`. Thus, the presence assertion for
`x` at the enclosed `target` construct cannot fail. (As usual, the
standard OpenMP reference count for `x` must also reach zero before
the data is unmapped.)
Justification for inclusion in Clang and LLVM's OpenMP runtime:
* The `ompx_hold` modifier supports OpenACC functionality (structured
reference count) that cannot be achieved in standard OpenMP, as of
5.1.
* The runtime implementation for `ompx_hold` (next patch) will thus be
used by Flang's OpenACC support.
* The Clang implementation for `ompx_hold` (this patch) as well as the
runtime implementation are required for the Clang OpenACC support
being developed as part of the ECP Clacc project, which translates
OpenACC to OpenMP at the directive AST level. These patches are the
first step in upstreaming OpenACC functionality from Clacc.
* The Clang implementation for `ompx_hold` is also used by the tests
in the runtime implementation. That syntactic support makes the
tests more readable than low-level runtime calls can. Moreover,
upstream Flang and Clang do not yet support OpenACC syntax
sufficiently for writing the tests.
* More generally, the Clang implementation enables a clean separation
of concerns between OpenACC and OpenMP development in LLVM. That
is, LLVM's OpenMP developers can discuss, modify, and debug LLVM's
extended OpenMP implementation and test suite without directly
considering OpenACC's language and execution model, which can be
handled by LLVM's OpenACC developers.
* OpenMP users might find the `ompx_hold` modifier useful, as in the
above example.
See new documentation introduced by this patch in `openmp/docs` for
more detail on the functionality of this extension and its
relationship with OpenACC. For example, it explains how the runtime
must support two reference counts, as specified by OpenACC.
Clang recognizes `ompx_hold` unless `-fno-openmp-extensions`, a new
command-line option introduced by this patch, is specified.
Reviewed By: ABataev, jdoerfert, protze.joachim, grokos
Differential Revision: https://reviews.llvm.org/D106509
2021-09-01 03:17:07 +08:00
|
|
|
// OMPX-NEXT: #pragma omp target data map(ompx_hold,alloc: e)
|
|
|
|
// OMPX-NEXT: foo();
|
|
|
|
#ifdef OMPX
|
|
|
|
#pragma omp target data map(ompx_hold,alloc: e)
|
|
|
|
foo();
|
|
|
|
#endif
|
|
|
|
|
2015-11-23 13:32:03 +08:00
|
|
|
// nesting a target region
|
|
|
|
#pragma omp target data map(e)
|
|
|
|
// CHECK-NEXT: #pragma omp target data map(tofrom: e)
|
|
|
|
{
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
#pragma omp target map(always, alloc: e)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: e)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
2018-12-19 06:18:41 +08:00
|
|
|
#pragma omp target map(close, alloc: e)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(close,alloc: e)
|
|
|
|
foo();
|
2020-07-22 22:14:00 +08:00
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
#pragma omp target map(always, alloc: e)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: e)
|
|
|
|
foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
}
|
2018-12-19 06:18:41 +08:00
|
|
|
|
2015-11-23 13:32:03 +08:00
|
|
|
return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
|
2015-07-21 21:44:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|