15ffd83dbSDimitry Andric/*===-- complex --- OpenMP complex wrapper for target regions --------- c++ -=== 25ffd83dbSDimitry Andric * 35ffd83dbSDimitry Andric * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45ffd83dbSDimitry Andric * See https://llvm.org/LICENSE.txt for license information. 55ffd83dbSDimitry Andric * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65ffd83dbSDimitry Andric * 75ffd83dbSDimitry Andric *===-----------------------------------------------------------------------=== 85ffd83dbSDimitry Andric */ 95ffd83dbSDimitry Andric 105ffd83dbSDimitry Andric#ifndef __CLANG_OPENMP_COMPLEX__ 115ffd83dbSDimitry Andric#define __CLANG_OPENMP_COMPLEX__ 125ffd83dbSDimitry Andric 135ffd83dbSDimitry Andric#ifndef _OPENMP 145ffd83dbSDimitry Andric#error "This file is for OpenMP compilation only." 155ffd83dbSDimitry Andric#endif 165ffd83dbSDimitry Andric 175ffd83dbSDimitry Andric// We require std::math functions in the complex builtins below. 185ffd83dbSDimitry Andric#include <cmath> 195ffd83dbSDimitry Andric 20*349cc55cSDimitry Andric#ifdef __NVPTX__ 21eaeb601bSDimitry Andric#define __OPENMP_NVPTX__ 225ffd83dbSDimitry Andric#include <__clang_cuda_complex_builtins.h> 23eaeb601bSDimitry Andric#undef __OPENMP_NVPTX__ 24*349cc55cSDimitry Andric#endif // __NVPTX__ 25*349cc55cSDimitry Andric 26*349cc55cSDimitry Andric#ifdef __AMDGCN__ 27*349cc55cSDimitry Andric#define __OPENMP_AMDGCN__ 28*349cc55cSDimitry Andric#include <__clang_cuda_complex_builtins.h> 29*349cc55cSDimitry Andric#undef __OPENMP_AMDGCN__ 30*349cc55cSDimitry Andric#endif // __AMDGCN__ 31*349cc55cSDimitry Andric 325ffd83dbSDimitry Andric#endif 335ffd83dbSDimitry Andric 345ffd83dbSDimitry Andric// Grab the host header too. 355ffd83dbSDimitry Andric#include_next <complex> 36e8d8bef9SDimitry Andric 37e8d8bef9SDimitry Andric// If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set 38e8d8bef9SDimitry Andric// after including <cmath> above. Since the complex header we use is a 39e8d8bef9SDimitry Andric// simplified version of the libc++, we don't need it in this case. If we 40e8d8bef9SDimitry Andric// compile against libstdc++, or any other standard library, we will overload 41e8d8bef9SDimitry Andric// the (hopefully template) functions in the <complex> header with the ones we 42e8d8bef9SDimitry Andric// got from libc++ which decomposes math functions, like `std::sin`, into 43e8d8bef9SDimitry Andric// arithmetic and calls to non-complex functions, all of which we can then 44e8d8bef9SDimitry Andric// handle. 45e8d8bef9SDimitry Andric#ifndef _LIBCPP_STD_VER 46e8d8bef9SDimitry Andric 47e8d8bef9SDimitry Andric#pragma omp begin declare variant match( \ 488c6f6c0cSDimitry Andric device = {arch(amdgcn, nvptx, nvptx64)}, \ 49e8d8bef9SDimitry Andric implementation = {extension(match_any, allow_templates)}) 50e8d8bef9SDimitry Andric 51e8d8bef9SDimitry Andric#include <complex_cmath.h> 52e8d8bef9SDimitry Andric 53e8d8bef9SDimitry Andric#pragma omp end declare variant 54e8d8bef9SDimitry Andric 55*349cc55cSDimitry Andric#endif // _LIBCPP_STD_VER 56