[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Headers / nvptx_device_math_sin_cos.cpp
blob9be082802303b989fea0c27e5e900b2644d7975c
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-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
5 #include <cmath>
7 // 6 calls to sin/cos(f), all translated to __nv_sin/__nv_cos calls:
9 // CHECK-NOT: _Z.sin
10 // CHECK-NOT: _Z.cos
11 // CHECK: call noundef double @__nv_sin(double
12 // CHECK-NOT: _Z.sin
13 // CHECK-NOT: _Z.cos
14 // CHECK: call noundef float @__nv_sinf(float
15 // CHECK-NOT: _Z.sin
16 // CHECK-NOT: _Z.cos
17 // CHECK: call noundef double @__nv_sin(double
18 // CHECK-NOT: _Z.sin
19 // CHECK-NOT: _Z.cos
20 // CHECK: call noundef double @__nv_cos(double
21 // CHECK-NOT: _Z.sin
22 // CHECK-NOT: _Z.cos
23 // CHECK: call noundef float @__nv_sinf(float
24 // CHECK-NOT: _Z.sin
25 // CHECK-NOT: _Z.cos
26 // CHECK: call noundef float @__nv_cosf(float
27 // CHECK-NOT: _Z.sin
28 // CHECK-NOT: _Z.cos
30 template<typename T>
31 void test_sin_cos(T x)
33 T res_sin, res_cos;
35 #pragma omp target map(from: res_sin, res_cos)
37 res_sin = std::sin(x);
38 res_cos = std::cos(x);
42 int main()
45 #if !defined(C_ONLY)
46 test_sin_cos<double>(0.0);
47 test_sin_cos<float>(0.0);
48 #endif
50 #pragma omp target
52 double res;
53 res = sin(1.0);
56 #pragma omp target
58 float res;
59 res = sinf(1.0f);
62 return 0;