1 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
2 // RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
3 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
4 // RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
5 
6 #ifdef __cplusplus
7 #include <cmath>
8 #else
9 #include <math.h>
10 #endif
11 
test_math_f64(double x)12 void test_math_f64(double x) {
13 // CHECK-LABEL: define {{.*}}test_math_f64
14 #pragma omp target
15   {
16     // CHECK: call double @__ocml_sin_f64
17     double l1 = sin(x);
18     // CHECK: call double @__ocml_cos_f64
19     double l2 = cos(x);
20     // CHECK: call double @__ocml_fabs_f64
21     double l3 = fabs(x);
22   }
23 }
24 
test_math_f32(float x)25 void test_math_f32(float x) {
26 // CHECK-LABEL: define {{.*}}test_math_f32
27 #pragma omp target
28   {
29     // CHECK-C: call double @__ocml_sin_f64
30     // CHECK-CPP: call float @__ocml_sin_f32
31     float l1 = sin(x);
32     // CHECK-C: call double @__ocml_cos_f64
33     // CHECK-CPP: call float @__ocml_cos_f32
34     float l2 = cos(x);
35     // CHECK-C: call double @__ocml_fabs_f64
36     // CHECK-CPP: call float @__ocml_fabs_f32
37     float l3 = fabs(x);
38   }
39 }
test_math_f32_suffix(float x)40 void test_math_f32_suffix(float x) {
41 // CHECK-LABEL: define {{.*}}test_math_f32_suffix
42 #pragma omp target
43   {
44     // CHECK: call float @__ocml_sin_f32
45     float l1 = sinf(x);
46     // CHECK: call float @__ocml_cos_f32
47     float l2 = cosf(x);
48     // CHECK: call float @__ocml_fabs_f32
49     float l3 = fabsf(x);
50   }
51 }
52