[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Headers / nvptx_device_math_sincos.cpp
blob1a8645be23308d845097dc24c1032b8b557e94ee
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
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-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
6 #ifdef CMATH
7 #include <cmath>
8 #else
9 #include <math.h>
10 #endif
12 // 4 calls to sincos(f), all translated to __nv_sincos calls:
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
24 // single precision wrapper
25 inline void sincos(float x, float* __restrict__ sin, float* __restrict__ cos)
27 sincosf(x, sin, cos);
30 template<typename T>
31 void test_sincos(T x)
33 T res_sin, res_cos;
35 #pragma omp target map(from: res_sin, res_cos)
37 sincos(x, &res_sin, &res_cos);
42 int main(int argc, char **argv)
45 #if !defined(C_ONLY)
46 test_sincos<double>(0.0);
47 test_sincos<float>(0.0);
48 #endif
50 #pragma omp target
52 double s, c;
53 sincos(0, &s, &c);
56 #pragma omp target
58 float s, c;
59 sincosf(0.f, &s, &c);
62 return 0;