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