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