2016-12-20 20:10:05 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2017-12-30 02:07:07 +08:00
|
|
|
|
|
|
|
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
|
|
|
|
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
|
2014-09-19 16:19:49 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
#ifndef HEADER
|
|
|
|
#define HEADER
|
|
|
|
|
|
|
|
void foo() {}
|
|
|
|
|
|
|
|
template <typename T, int C>
|
|
|
|
T tmain(T argc, T *argv) {
|
2017-05-03 23:28:48 +08:00
|
|
|
T i, j, a[20], always;
|
2014-09-19 16:19:49 +08:00
|
|
|
#pragma omp target
|
|
|
|
foo();
|
2015-09-03 16:45:56 +08:00
|
|
|
#pragma omp target if (target:argc > 0)
|
2014-09-19 16:19:49 +08:00
|
|
|
foo();
|
|
|
|
#pragma omp target if (C)
|
|
|
|
foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
#pragma omp target map(i)
|
|
|
|
foo();
|
|
|
|
#pragma omp target map(a[0:10], i)
|
|
|
|
foo();
|
|
|
|
#pragma omp target map(to: i) map(from: j)
|
|
|
|
foo();
|
|
|
|
#pragma omp target map(always,alloc: i)
|
|
|
|
foo();
|
2017-05-03 23:28:48 +08:00
|
|
|
#pragma omp target map(always from: i)
|
|
|
|
foo();
|
|
|
|
#pragma omp target map(always)
|
|
|
|
{always++;}
|
|
|
|
#pragma omp target map(always,i)
|
|
|
|
{always++;i++;}
|
2016-01-22 06:18:28 +08:00
|
|
|
#pragma omp target nowait
|
|
|
|
foo();
|
2016-01-22 08:49:21 +08:00
|
|
|
#pragma omp target depend(in : argc, argv[i:argc], a[:])
|
|
|
|
foo();
|
2016-01-27 00:37:23 +08:00
|
|
|
#pragma omp target defaultmap(tofrom: scalar)
|
|
|
|
foo();
|
2014-09-19 16:19:49 +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, a[20]
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target
|
|
|
|
// CHECK-NEXT: foo();
|
2015-09-03 16:45:56 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target if(target: argc > 0)
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target if(C)
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: i)
|
|
|
|
// CHECK-NEXT: foo()
|
2017-05-03 23:28:48 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(always,from: i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always,i)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: i++;
|
|
|
|
// CHECK-NEXT: }
|
2016-01-22 06:18:28 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target nowait
|
|
|
|
// CHECK-NEXT: foo()
|
2016-01-22 08:49:21 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
|
|
|
|
// CHECK-NEXT: foo()
|
2016-01-27 00:37:23 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
|
|
|
|
// CHECK-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, a[20]
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target
|
|
|
|
// CHECK-NEXT: foo();
|
2015-09-03 16:45:56 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target if(target: argc > 0)
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target if(5)
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: i)
|
|
|
|
// CHECK-NEXT: foo()
|
2017-05-03 23:28:48 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(always,from: i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always,i)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: i++;
|
|
|
|
// CHECK-NEXT: }
|
2016-01-22 06:18:28 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target nowait
|
|
|
|
// CHECK-NEXT: foo()
|
2016-01-22 08:49:21 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
|
|
|
|
// CHECK-NEXT: foo()
|
2016-01-27 00:37:23 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
|
|
|
|
// CHECK-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, a[20]
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target
|
|
|
|
// CHECK-NEXT: foo();
|
2015-09-03 16:45:56 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target if(target: argc > 0)
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2016-11-10 16:49:37 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target if(1)
|
2014-09-19 16:19:49 +08:00
|
|
|
// CHECK-NEXT: foo()
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: i)
|
|
|
|
// CHECK-NEXT: foo()
|
2017-05-03 23:28:48 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target map(always,from: i)
|
|
|
|
// CHECK-NEXT: foo()
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always,i)
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: i++;
|
|
|
|
// CHECK-NEXT: }
|
2016-01-22 06:18:28 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target nowait
|
|
|
|
// CHECK-NEXT: foo()
|
2016-01-22 08:49:21 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
|
|
|
|
// CHECK-NEXT: foo()
|
2016-01-27 00:37:23 +08:00
|
|
|
// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
|
|
|
|
// CHECK-NEXT: foo()
|
2014-09-19 16:19:49 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: int main(int argc, char **argv) {
|
|
|
|
int main (int argc, char **argv) {
|
2017-05-03 23:28:48 +08:00
|
|
|
int i, j, a[20], always;
|
2015-11-23 13:32:03 +08:00
|
|
|
// CHECK-NEXT: int i, j, a[20]
|
2014-09-19 16:19:49 +08:00
|
|
|
#pragma omp target
|
|
|
|
// CHECK-NEXT: #pragma omp target
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
#pragma omp target if (argc > 0)
|
|
|
|
// CHECK-NEXT: #pragma omp target if(argc > 0)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
2015-11-23 13:32:03 +08:00
|
|
|
|
|
|
|
#pragma omp target map(i) if(argc>0)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: i) if(argc > 0)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target map(i)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: i)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target map(a[0:10], i)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: a[0:10],i)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target map(to: i) map(from: j)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(to: i) map(from: j)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target map(always,alloc: i)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,alloc: i)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2017-05-03 23:28:48 +08:00
|
|
|
#pragma omp target map(always from: i)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(always,from: i)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
|
|
|
#pragma omp target map(always)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always)
|
|
|
|
{always++;}
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
|
|
|
#pragma omp target map(always,i)
|
|
|
|
// CHECK-NEXT: #pragma omp target map(tofrom: always,i)
|
|
|
|
{always++;i++;}
|
|
|
|
// CHECK-NEXT: {
|
|
|
|
// CHECK-NEXT: always++;
|
|
|
|
// CHECK-NEXT: i++;
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
2016-01-22 06:18:28 +08:00
|
|
|
#pragma omp target nowait
|
|
|
|
// CHECK-NEXT: #pragma omp target nowait
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2016-01-22 08:49:21 +08:00
|
|
|
#pragma omp target depend(in : argc, argv[i:argc], a[:])
|
|
|
|
// CHECK-NEXT: #pragma omp target depend(in : argc,argv[i:argc],a[:])
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2016-01-27 00:37:23 +08:00
|
|
|
#pragma omp target defaultmap(tofrom: scalar)
|
|
|
|
// CHECK-NEXT: #pragma omp target defaultmap(tofrom: scalar)
|
|
|
|
foo();
|
|
|
|
// CHECK-NEXT: foo();
|
|
|
|
|
2014-09-19 16:19:49 +08:00
|
|
|
return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|