1 // REQUIRES: nvptx-registered-target
2 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
3 // RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
4 
5 #include <cmath>
6 
7 // 6 calls to sin/cos(f), all translated to __nv_sin/__nv_cos calls:
8 
9 // CHECK-NOT: _Z.sin
10 // CHECK-NOT: _Z.cos
11 // CHECK: call double @__nv_sin(double
12 // CHECK-NOT: _Z.sin
13 // CHECK-NOT: _Z.cos
14 // CHECK: call float @__nv_sinf(float
15 // CHECK-NOT: _Z.sin
16 // CHECK-NOT: _Z.cos
17 // CHECK: call double @__nv_sin(double
18 // CHECK-NOT: _Z.sin
19 // CHECK-NOT: _Z.cos
20 // CHECK: call double @__nv_cos(double
21 // CHECK-NOT: _Z.sin
22 // CHECK-NOT: _Z.cos
23 // CHECK: call float @__nv_sinf(float
24 // CHECK-NOT: _Z.sin
25 // CHECK-NOT: _Z.cos
26 // CHECK: call float @__nv_cosf(float
27 // CHECK-NOT: _Z.sin
28 // CHECK-NOT: _Z.cos
29 
30 template<typename T>
test_sin_cos(T x)31 void test_sin_cos(T x)
32 {
33   T res_sin, res_cos;
34 
35   #pragma omp target map(from: res_sin, res_cos)
36   {
37     res_sin = std::sin(x);
38     res_cos = std::cos(x);
39   }
40 }
41 
main()42 int main()
43 {
44 
45 #if !defined(C_ONLY)
46   test_sin_cos<double>(0.0);
47   test_sin_cos<float>(0.0);
48 #endif
49 
50   #pragma omp target
51   {
52     double res;
53     res = sin(1.0);
54   }
55 
56   #pragma omp target
57   {
58     float res;
59     res = sinf(1.0f);
60   }
61 
62   return 0;
63 }
64