summaryrefslogtreecommitdiff
path: root/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
diff options
context:
space:
mode:
authorGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>2019-05-15 20:18:21 +0000
committerGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>2019-05-15 20:18:21 +0000
commit380ba985dc7af04efad4a774b11cb87ecf32e0ad (patch)
treec21f1e8a5ba45eaa6c639c31743303feb2dd7a51 /test/Headers/nvptx_device_cmath_functions_cxx17.cpp
parentf977b591a1a0d3168beaab1b27ac023d55d683b7 (diff)
downloadclang-380ba985dc7af04efad4a774b11cb87ecf32e0ad.tar.gz
[OpenMP][bugfix] Fix issues with C++ 17 compilation when handling math functions
Summary: In OpenMP device offloading we must ensure that unde C++ 17, the inclusion of cstdlib will works correctly. Reviewers: ABataev, tra, jdoerfert, hfinkel, caomhin Reviewed By: jdoerfert Subscribers: Hahnfeld, guansong, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61949 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360804 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Headers/nvptx_device_cmath_functions_cxx17.cpp')
-rw-r--r--test/Headers/nvptx_device_cmath_functions_cxx17.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Headers/nvptx_device_cmath_functions_cxx17.cpp b/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
new file mode 100644
index 0000000000..89b997aba3
--- /dev/null
+++ b/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -0,0 +1,22 @@
+// Test calling of device math functions.
+///==========================================================================///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -std=c++17
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -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 -std=c++17 -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include <cmath>
+#include <cstdlib>
+
+void test_sqrt(double a1) {
+ #pragma omp target
+ {
+ // CHECK-YES: call double @__nv_sqrt(double
+ double l1 = sqrt(a1);
+ // CHECK-YES: call double @__nv_pow(double
+ double l2 = pow(a1, a1);
+ // CHECK-YES: call double @__nv_modf(double
+ double l3 = modf(a1 + 3.5, &a1);
+ }
+}