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