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