Sasha Smundak | 4b1f33a | 2021-01-11 15:05:07 -0800 | [diff] [blame] | 1 | /*===-- complex --- OpenMP complex wrapper for target regions --------- c++ -=== |
| 2 | * |
| 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | * See https://llvm.org/LICENSE.txt for license information. |
| 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | * |
| 7 | *===-----------------------------------------------------------------------=== |
| 8 | */ |
| 9 | |
| 10 | #ifndef __CLANG_OPENMP_COMPLEX__ |
| 11 | #define __CLANG_OPENMP_COMPLEX__ |
| 12 | |
| 13 | #ifndef _OPENMP |
| 14 | #error "This file is for OpenMP compilation only." |
| 15 | #endif |
| 16 | |
| 17 | // We require std::math functions in the complex builtins below. |
| 18 | #include <cmath> |
| 19 | |
Pirama Arumuga Nainar | 494f645 | 2021-12-02 10:42:14 -0800 | [diff] [blame] | 20 | #ifdef __NVPTX__ |
Pirama Arumuga Nainar | 986b880 | 2021-06-03 16:00:34 -0700 | [diff] [blame] | 21 | #define __OPENMP_NVPTX__ |
Sasha Smundak | 4b1f33a | 2021-01-11 15:05:07 -0800 | [diff] [blame] | 22 | #include <__clang_cuda_complex_builtins.h> |
Pirama Arumuga Nainar | 986b880 | 2021-06-03 16:00:34 -0700 | [diff] [blame] | 23 | #undef __OPENMP_NVPTX__ |
Pirama Arumuga Nainar | 494f645 | 2021-12-02 10:42:14 -0800 | [diff] [blame] | 24 | #endif // __NVPTX__ |
| 25 | |
| 26 | #ifdef __AMDGCN__ |
| 27 | #define __OPENMP_AMDGCN__ |
| 28 | #include <__clang_cuda_complex_builtins.h> |
| 29 | #undef __OPENMP_AMDGCN__ |
| 30 | #endif // __AMDGCN__ |
| 31 | |
Sasha Smundak | 4b1f33a | 2021-01-11 15:05:07 -0800 | [diff] [blame] | 32 | #endif |
| 33 | |
| 34 | // Grab the host header too. |
| 35 | #include_next <complex> |
| 36 | |
Sasha Smundak | 4b1f33a | 2021-01-11 15:05:07 -0800 | [diff] [blame] | 37 | // If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set |
| 38 | // after including <cmath> above. Since the complex header we use is a |
| 39 | // simplified version of the libc++, we don't need it in this case. If we |
| 40 | // compile against libstdc++, or any other standard library, we will overload |
| 41 | // the (hopefully template) functions in the <complex> header with the ones we |
| 42 | // got from libc++ which decomposes math functions, like `std::sin`, into |
| 43 | // arithmetic and calls to non-complex functions, all of which we can then |
| 44 | // handle. |
| 45 | #ifndef _LIBCPP_STD_VER |
| 46 | |
| 47 | #pragma omp begin declare variant match( \ |
Pirama Arumuga Nainar | ec8c89d | 2022-02-23 09:26:16 -0800 | [diff] [blame] | 48 | device = {arch(amdgcn, nvptx, nvptx64)}, \ |
Sasha Smundak | 4b1f33a | 2021-01-11 15:05:07 -0800 | [diff] [blame] | 49 | implementation = {extension(match_any, allow_templates)}) |
| 50 | |
| 51 | #include <complex_cmath.h> |
| 52 | |
| 53 | #pragma omp end declare variant |
| 54 | |
Pirama Arumuga Nainar | 494f645 | 2021-12-02 10:42:14 -0800 | [diff] [blame] | 55 | #endif // _LIBCPP_STD_VER |