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