Home | History | Annotate | Line # | Download | only in openmp_wrappers
      1  1.1.1.2  joerg /*===-- __clang_openmp_device_functions.h - OpenMP math declares ------ c++ -===
      2      1.1  joerg  *
      3      1.1  joerg  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
      4      1.1  joerg  * See https://llvm.org/LICENSE.txt for license information.
      5      1.1  joerg  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
      6      1.1  joerg  *
      7      1.1  joerg  *===-----------------------------------------------------------------------===
      8      1.1  joerg  */
      9      1.1  joerg 
     10  1.1.1.2  joerg #ifndef __CLANG_OPENMP_CMATH_H__
     11  1.1.1.2  joerg #define __CLANG_OPENMP_CMATH_H__
     12  1.1.1.2  joerg 
     13  1.1.1.2  joerg #ifndef _OPENMP
     14  1.1.1.2  joerg #error "This file is for OpenMP compilation only."
     15  1.1.1.2  joerg #endif
     16      1.1  joerg 
     17      1.1  joerg #include_next <cmath>
     18  1.1.1.2  joerg 
     19  1.1.1.2  joerg // Make sure we include our math.h overlay, it probably happend already but we
     20  1.1.1.2  joerg // need to be sure.
     21  1.1.1.2  joerg #include <math.h>
     22  1.1.1.2  joerg 
     23  1.1.1.2  joerg // We (might) need cstdlib because __clang_cuda_cmath.h below declares `abs`
     24  1.1.1.2  joerg // which might live in cstdlib.
     25  1.1.1.2  joerg #include <cstdlib>
     26  1.1.1.2  joerg 
     27  1.1.1.2  joerg // We need limits because __clang_cuda_cmath.h below uses `std::numeric_limit`.
     28  1.1.1.2  joerg #include <limits>
     29  1.1.1.2  joerg 
     30  1.1.1.2  joerg #pragma omp begin declare variant match(                                       \
     31  1.1.1.2  joerg     device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any, allow_templates)})
     32  1.1.1.2  joerg 
     33  1.1.1.2  joerg #define __CUDA__
     34  1.1.1.2  joerg #define __OPENMP_NVPTX__
     35  1.1.1.2  joerg #include <__clang_cuda_cmath.h>
     36  1.1.1.2  joerg #undef __OPENMP_NVPTX__
     37  1.1.1.2  joerg #undef __CUDA__
     38  1.1.1.2  joerg 
     39  1.1.1.2  joerg // Overloads not provided by the CUDA wrappers but by the CUDA system headers.
     40  1.1.1.2  joerg // Since we do not include the latter we define them ourselves.
     41  1.1.1.2  joerg #define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
     42  1.1.1.2  joerg 
     43  1.1.1.2  joerg __DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
     44  1.1.1.2  joerg __DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
     45  1.1.1.2  joerg __DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
     46  1.1.1.2  joerg __DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
     47  1.1.1.2  joerg __DEVICE__ float erf(float __x) { return ::erff(__x); }
     48  1.1.1.2  joerg __DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
     49  1.1.1.2  joerg __DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
     50  1.1.1.2  joerg __DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
     51  1.1.1.2  joerg __DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
     52  1.1.1.2  joerg __DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
     53  1.1.1.2  joerg __DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
     54  1.1.1.2  joerg __DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
     55  1.1.1.2  joerg __DEVICE__ long long int llrint(float __x) { return ::llrintf(__x); }
     56  1.1.1.2  joerg __DEVICE__ long long int llround(float __x) { return ::llroundf(__x); }
     57  1.1.1.2  joerg __DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
     58  1.1.1.2  joerg __DEVICE__ float log2(float __x) { return ::log2f(__x); }
     59  1.1.1.2  joerg __DEVICE__ float logb(float __x) { return ::logbf(__x); }
     60  1.1.1.2  joerg __DEVICE__ long int lrint(float __x) { return ::lrintf(__x); }
     61  1.1.1.2  joerg __DEVICE__ long int lround(float __x) { return ::lroundf(__x); }
     62  1.1.1.2  joerg __DEVICE__ float nextafter(float __x, float __y) {
     63  1.1.1.2  joerg   return ::nextafterf(__x, __y);
     64  1.1.1.2  joerg }
     65  1.1.1.2  joerg __DEVICE__ float remainder(float __x, float __y) {
     66  1.1.1.2  joerg   return ::remainderf(__x, __y);
     67  1.1.1.2  joerg }
     68  1.1.1.2  joerg __DEVICE__ float scalbln(float __x, long int __y) {
     69  1.1.1.2  joerg   return ::scalblnf(__x, __y);
     70  1.1.1.2  joerg }
     71  1.1.1.2  joerg __DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
     72  1.1.1.2  joerg __DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
     73  1.1.1.2  joerg 
     74  1.1.1.2  joerg #undef __DEVICE__
     75  1.1.1.2  joerg 
     76  1.1.1.2  joerg #pragma omp end declare variant
     77  1.1.1.2  joerg 
     78      1.1  joerg #endif
     79