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 // RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -DCMATH -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
5 
6 #ifdef CMATH
7 #include <cmath>
8 #else
9 #include <math.h>
10 #endif
11 
12 // 4 calls to sincos(f), all translated to __nv_sincos calls:
13 
14 // CHECK-NOT: _Z.sincos
15 // CHECK: call void @__nv_sincos(double
16 // CHECK-NOT: _Z.sincos
17 // CHECK: call void @__nv_sincosf(float
18 // CHECK-NOT: _Z.sincos
19 // CHECK: call void @__nv_sincos(double
20 // CHECK-NOT: _Z.sincos
21 // CHECK: call void @__nv_sincosf(float
22 // CHECK-NOT: _Z.sincos
23 
24 // single precision wrapper
sincos(float x,float * __restrict__ sin,float * __restrict__ cos)25 inline void sincos(float x, float* __restrict__ sin, float* __restrict__ cos)
26 {
27   sincosf(x, sin, cos);
28 }
29 
30 template<typename T>
test_sincos(T x)31 void test_sincos(T x)
32 {
33   T res_sin, res_cos;
34 
35   #pragma omp target map(from: res_sin, res_cos)
36   {
37     sincos(x, &res_sin, &res_cos);
38   }
39 
40 }
41 
main(int argc,char ** argv)42 int main(int argc, char **argv)
43 {
44 
45 #if !defined(C_ONLY)
46   test_sincos<double>(0.0);
47   test_sincos<float>(0.0);
48 #endif
49 
50   #pragma omp target
51   {
52     double s, c;
53     sincos(0, &s, &c);
54   }
55 
56   #pragma omp target
57   {
58     float s, c;
59     sincosf(0.f, &s, &c);
60   }
61 
62   return 0;
63 }
64