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 20 #define __CUDA__ 21 #define __OPENMP_NVPTX__ 22 #include <__clang_cuda_complex_builtins.h> 23 #undef __OPENMP_NVPTX__ 24 #endif 25 26 // Grab the host header too. 27 #include_next <complex> 28 29 30 #ifdef __cplusplus 31 32 // If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set 33 // after including <cmath> above. Since the complex header we use is a 34 // simplified version of the libc++, we don't need it in this case. If we 35 // compile against libstdc++, or any other standard library, we will overload 36 // the (hopefully template) functions in the <complex> header with the ones we 37 // got from libc++ which decomposes math functions, like `std::sin`, into 38 // arithmetic and calls to non-complex functions, all of which we can then 39 // handle. 40 #ifndef _LIBCPP_STD_VER 41 42 #pragma omp begin declare variant match( \ 43 device = {arch(nvptx, nvptx64)}, \ 44 implementation = {extension(match_any, allow_templates)}) 45 46 #include <complex_cmath.h> 47 48 #pragma omp end declare variant 49 50 #endif 51 52 #endif 53