1 // RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic
2 // RUN: %libomptarget-compilexx-generic -O3 && %libomptarget-run-generic
3 // RUN: %libomptarget-compilexx-generic -O3 -ffast-math && \
4 // RUN: %libomptarget-run-generic
6 // FIXME: This fails to link due to missing math symbols. We should provide the
7 // needed math functions in the GPU `libm` and require the GPU C library.
8 // UNSUPPORTED: amdgcn-amd-amdhsa
14 template <typename T
> void test_map() {
15 std::complex<T
> a(0.2, 1), a_check
;
16 #pragma omp target map(from : a_check)
19 assert(std::abs(a
- a_check
) < 1e-6);
22 template <typename RT
, typename AT
, typename BT
> void test_plus(AT a
, BT b
) {
23 std::complex<RT
> c
, c_host
;
26 #pragma omp target map(from : c)
29 assert(std::abs(c
- c_host
) < 1e-6);
32 template <typename RT
, typename AT
, typename BT
> void test_minus(AT a
, BT b
) {
33 std::complex<RT
> c
, c_host
;
36 #pragma omp target map(from : c)
39 assert(std::abs(c
- c_host
) < 1e-6);
42 template <typename RT
, typename AT
, typename BT
> void test_mul(AT a
, BT b
) {
43 std::complex<RT
> c
, c_host
;
46 #pragma omp target map(from : c)
49 assert(std::abs(c
- c_host
) < 1e-6);
52 template <typename RT
, typename AT
, typename BT
> void test_div(AT a
, BT b
) {
53 std::complex<RT
> c
, c_host
;
56 #pragma omp target map(from : c)
59 assert(std::abs(c
- c_host
) < 1e-6);
62 template <typename T
> void test_complex() {
65 test_plus
<T
>(std::complex<T
>(0, 1), std::complex<T
>(0.5, 0.3));
66 test_plus
<T
>(std::complex<T
>(0, 1), T(0.5));
67 test_plus
<T
>(T(0.5), std::complex<T
>(0, 1));
69 test_minus
<T
>(std::complex<T
>(0, 1), std::complex<T
>(0.5, 0.3));
70 test_minus
<T
>(std::complex<T
>(0, 1), T(0.5));
71 test_minus
<T
>(T(0.5), std::complex<T
>(0, 1));
73 test_mul
<T
>(std::complex<T
>(0, 1), std::complex<T
>(0.5, 0.3));
74 test_mul
<T
>(std::complex<T
>(0, 1), T(0.5));
75 test_mul
<T
>(T(0.5), std::complex<T
>(0, 1));
77 test_div
<T
>(std::complex<T
>(0, 1), std::complex<T
>(0.5, 0.3));
78 test_div
<T
>(std::complex<T
>(0, 1), T(0.5));
79 test_div
<T
>(T(0.5), std::complex<T
>(0, 1));
83 std::cout
<< "Testing float" << std::endl
;
84 test_complex
<float>();
85 std::cout
<< "Testing double" << std::endl
;
86 test_complex
<double>();