86 lines · cpp
1// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-x86-host.bc2// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -aux-triple x86_64-unknown-unknown -o - | FileCheck %s3// expected-no-diagnostics4 5#include <cmath>6#include <complex>7 8// CHECK: define weak {{.*}} @__muldc39// CHECK-DAG: call i32 @__ocml_isnan_f64(10// CHECK-DAG: call i32 @__ocml_isinf_f64(11 12// CHECK: define weak {{.*}} @__mulsc313// CHECK-DAG: call i32 @__ocml_isnan_f32(14// CHECK-DAG: call i32 @__ocml_isinf_f32(15// CHECK-DAG: call float @__ocml_copysign_f32(16 17// CHECK: define weak {{.*}} @__divdc318// CHECK-DAG: call i32 @__ocml_isnan_f64(19// CHECK-DAG: call i32 @__ocml_isinf_f64(20// CHECK-DAG: call i32 @__ocml_isfinite_f64(21// CHECK-DAG: call double @__ocml_copysign_f64(22// CHECK-DAG: call double @__ocml_scalbn_f64(23// CHECK-DAG: call double @__ocml_fabs_f64(24// CHECK-DAG: call double @__ocml_logb_f64(25 26// CHECK: define weak {{.*}} @__divsc327// CHECK-DAG: call i32 @__ocml_isnan_f32(28// CHECK-DAG: call i32 @__ocml_isinf_f32(29// CHECK-DAG: call i32 @__ocml_isfinite_f32(30// CHECK-DAG: call float @__ocml_copysign_f32(31// CHECK-DAG: call float @__ocml_scalbn_f32(32// CHECK-DAG: call float @__ocml_fabs_f32(33// CHECK-DAG: call float @__ocml_logb_f32(34 35// We actually check that there are no declarations of non-OpenMP functions.36// That is, as long as we don't call an unkown function with a name that37// doesn't start with '__' we are good :)38 39// CHECK-NOT: declare.*@[^_]40 41void test_scmplx(std::complex<float> a) {42#pragma omp target43 {44 (void)(a * (a / a));45 }46}47 48void test_dcmplx(std::complex<double> a) {49#pragma omp target50 {51 (void)(a * (a / a));52 }53}54 55template <typename T>56std::complex<T> test_template_math_calls(std::complex<T> a) {57 decltype(a) r = a;58#pragma omp target59 {60 r = std::sin(r);61 r = std::cos(r);62 r = std::exp(r);63 r = std::atan(r);64 r = std::acos(r);65 }66 return r;67}68 69std::complex<float> test_scall(std::complex<float> a) {70 decltype(a) r;71#pragma omp target72 {73 r = std::sin(a);74 }75 return test_template_math_calls(r);76}77 78std::complex<double> test_dcall(std::complex<double> a) {79 decltype(a) r;80#pragma omp target81 {82 r = std::exp(a);83 }84 return test_template_math_calls(r);85}86