| 
 | 1 | +//===----------------------------------------------------------------------===//  | 
 | 2 | +//  | 
 | 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.  | 
 | 4 | +// See https://llvm.org/LICENSE.txt for license information.  | 
 | 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception  | 
 | 6 | +//  | 
 | 7 | +//===----------------------------------------------------------------------===//  | 
 | 8 | +///  | 
 | 9 | +/// \file  | 
 | 10 | +/// This file contains the implementation of the device kernels that wrap the  | 
 | 11 | +/// math functions from the cuda-math provider.  | 
 | 12 | +///  | 
 | 13 | +//===----------------------------------------------------------------------===//  | 
 | 14 | + | 
 | 15 | +#ifdef CUDA_MATH_FOUND  | 
 | 16 | + | 
 | 17 | +#include "Conformance/device_code/DeviceAPIs.hpp"  | 
 | 18 | +#include "Conformance/device_code/KernelRunner.hpp"  | 
 | 19 | + | 
 | 20 | +#include <gpuintrin.h>  | 
 | 21 | +#include <stddef.h>  | 
 | 22 | + | 
 | 23 | +using namespace kernels;  | 
 | 24 | + | 
 | 25 | +//===----------------------------------------------------------------------===//  | 
 | 26 | +// Helpers  | 
 | 27 | +//===----------------------------------------------------------------------===//  | 
 | 28 | + | 
 | 29 | +static inline float sincosfSin(float X) {  | 
 | 30 | +  float SinX, CosX;  | 
 | 31 | +  __nv_sincosf(X, &SinX, &CosX);  | 
 | 32 | +  return SinX;  | 
 | 33 | +}  | 
 | 34 | + | 
 | 35 | +static inline float sincosfCos(float X) {  | 
 | 36 | +  float SinX, CosX;  | 
 | 37 | +  __nv_sincosf(X, &SinX, &CosX);  | 
 | 38 | +  return CosX;  | 
 | 39 | +}  | 
 | 40 | + | 
 | 41 | +//===----------------------------------------------------------------------===//  | 
 | 42 | +// Kernels  | 
 | 43 | +//===----------------------------------------------------------------------===//  | 
 | 44 | + | 
 | 45 | +extern "C" {  | 
 | 46 | + | 
 | 47 | +__gpu_kernel void acosfKernel(const float *X, float *Out,  | 
 | 48 | +                              size_t NumElements) noexcept {  | 
 | 49 | +  runKernelBody<__nv_acosf>(NumElements, Out, X);  | 
 | 50 | +}  | 
 | 51 | + | 
 | 52 | +__gpu_kernel void acoshfKernel(const float *X, float *Out,  | 
 | 53 | +                               size_t NumElements) noexcept {  | 
 | 54 | +  runKernelBody<__nv_acoshf>(NumElements, Out, X);  | 
 | 55 | +}  | 
 | 56 | + | 
 | 57 | +__gpu_kernel void asinfKernel(const float *X, float *Out,  | 
 | 58 | +                              size_t NumElements) noexcept {  | 
 | 59 | +  runKernelBody<__nv_asinf>(NumElements, Out, X);  | 
 | 60 | +}  | 
 | 61 | + | 
 | 62 | +__gpu_kernel void asinhfKernel(const float *X, float *Out,  | 
 | 63 | +                               size_t NumElements) noexcept {  | 
 | 64 | +  runKernelBody<__nv_asinhf>(NumElements, Out, X);  | 
 | 65 | +}  | 
 | 66 | + | 
 | 67 | +__gpu_kernel void atanfKernel(const float *X, float *Out,  | 
 | 68 | +                              size_t NumElements) noexcept {  | 
 | 69 | +  runKernelBody<__nv_atanf>(NumElements, Out, X);  | 
 | 70 | +}  | 
 | 71 | + | 
 | 72 | +__gpu_kernel void atanhfKernel(const float *X, float *Out,  | 
 | 73 | +                               size_t NumElements) noexcept {  | 
 | 74 | +  runKernelBody<__nv_atanhf>(NumElements, Out, X);  | 
 | 75 | +}  | 
 | 76 | + | 
 | 77 | +__gpu_kernel void cbrtfKernel(const float *X, float *Out,  | 
 | 78 | +                              size_t NumElements) noexcept {  | 
 | 79 | +  runKernelBody<__nv_cbrtf>(NumElements, Out, X);  | 
 | 80 | +}  | 
 | 81 | + | 
 | 82 | +__gpu_kernel void cosfKernel(const float *X, float *Out,  | 
 | 83 | +                             size_t NumElements) noexcept {  | 
 | 84 | +  runKernelBody<__nv_cosf>(NumElements, Out, X);  | 
 | 85 | +}  | 
 | 86 | + | 
 | 87 | +__gpu_kernel void coshfKernel(const float *X, float *Out,  | 
 | 88 | +                              size_t NumElements) noexcept {  | 
 | 89 | +  runKernelBody<__nv_coshf>(NumElements, Out, X);  | 
 | 90 | +}  | 
 | 91 | + | 
 | 92 | +__gpu_kernel void cospifKernel(const float *X, float *Out,  | 
 | 93 | +                               size_t NumElements) noexcept {  | 
 | 94 | +  runKernelBody<__nv_cospif>(NumElements, Out, X);  | 
 | 95 | +}  | 
 | 96 | + | 
 | 97 | +__gpu_kernel void erffKernel(const float *X, float *Out,  | 
 | 98 | +                             size_t NumElements) noexcept {  | 
 | 99 | +  runKernelBody<__nv_erff>(NumElements, Out, X);  | 
 | 100 | +}  | 
 | 101 | + | 
 | 102 | +__gpu_kernel void expfKernel(const float *X, float *Out,  | 
 | 103 | +                             size_t NumElements) noexcept {  | 
 | 104 | +  runKernelBody<__nv_expf>(NumElements, Out, X);  | 
 | 105 | +}  | 
 | 106 | + | 
 | 107 | +__gpu_kernel void exp10fKernel(const float *X, float *Out,  | 
 | 108 | +                               size_t NumElements) noexcept {  | 
 | 109 | +  runKernelBody<__nv_exp10f>(NumElements, Out, X);  | 
 | 110 | +}  | 
 | 111 | + | 
 | 112 | +__gpu_kernel void exp2fKernel(const float *X, float *Out,  | 
 | 113 | +                              size_t NumElements) noexcept {  | 
 | 114 | +  runKernelBody<__nv_exp2f>(NumElements, Out, X);  | 
 | 115 | +}  | 
 | 116 | + | 
 | 117 | +__gpu_kernel void expm1fKernel(const float *X, float *Out,  | 
 | 118 | +                               size_t NumElements) noexcept {  | 
 | 119 | +  runKernelBody<__nv_expm1f>(NumElements, Out, X);  | 
 | 120 | +}  | 
 | 121 | + | 
 | 122 | +__gpu_kernel void logfKernel(const float *X, float *Out,  | 
 | 123 | +                             size_t NumElements) noexcept {  | 
 | 124 | +  runKernelBody<__nv_logf>(NumElements, Out, X);  | 
 | 125 | +}  | 
 | 126 | + | 
 | 127 | +__gpu_kernel void log10fKernel(const float *X, float *Out,  | 
 | 128 | +                               size_t NumElements) noexcept {  | 
 | 129 | +  runKernelBody<__nv_log10f>(NumElements, Out, X);  | 
 | 130 | +}  | 
 | 131 | + | 
 | 132 | +__gpu_kernel void log1pfKernel(const float *X, float *Out,  | 
 | 133 | +                               size_t NumElements) noexcept {  | 
 | 134 | +  runKernelBody<__nv_log1pf>(NumElements, Out, X);  | 
 | 135 | +}  | 
 | 136 | + | 
 | 137 | +__gpu_kernel void log2fKernel(const float *X, float *Out,  | 
 | 138 | +                              size_t NumElements) noexcept {  | 
 | 139 | +  runKernelBody<__nv_log2f>(NumElements, Out, X);  | 
 | 140 | +}  | 
 | 141 | + | 
 | 142 | +__gpu_kernel void sinfKernel(const float *X, float *Out,  | 
 | 143 | +                             size_t NumElements) noexcept {  | 
 | 144 | +  runKernelBody<__nv_sinf>(NumElements, Out, X);  | 
 | 145 | +}  | 
 | 146 | + | 
 | 147 | +__gpu_kernel void sincosfSinKernel(const float *X, float *Out,  | 
 | 148 | +                                   size_t NumElements) noexcept {  | 
 | 149 | +  runKernelBody<sincosfSin>(NumElements, Out, X);  | 
 | 150 | +}  | 
 | 151 | + | 
 | 152 | +__gpu_kernel void sincosfCosKernel(const float *X, float *Out,  | 
 | 153 | +                                   size_t NumElements) noexcept {  | 
 | 154 | +  runKernelBody<sincosfCos>(NumElements, Out, X);  | 
 | 155 | +}  | 
 | 156 | + | 
 | 157 | +__gpu_kernel void sinhfKernel(const float *X, float *Out,  | 
 | 158 | +                              size_t NumElements) noexcept {  | 
 | 159 | +  runKernelBody<__nv_sinhf>(NumElements, Out, X);  | 
 | 160 | +}  | 
 | 161 | + | 
 | 162 | +__gpu_kernel void sinpifKernel(const float *X, float *Out,  | 
 | 163 | +                               size_t NumElements) noexcept {  | 
 | 164 | +  runKernelBody<__nv_sinpif>(NumElements, Out, X);  | 
 | 165 | +}  | 
 | 166 | + | 
 | 167 | +__gpu_kernel void tanfKernel(const float *X, float *Out,  | 
 | 168 | +                             size_t NumElements) noexcept {  | 
 | 169 | +  runKernelBody<__nv_tanf>(NumElements, Out, X);  | 
 | 170 | +}  | 
 | 171 | + | 
 | 172 | +__gpu_kernel void tanhfKernel(const float *X, float *Out,  | 
 | 173 | +                              size_t NumElements) noexcept {  | 
 | 174 | +  runKernelBody<__nv_tanhf>(NumElements, Out, X);  | 
 | 175 | +}  | 
 | 176 | +} // extern "C"  | 
 | 177 | + | 
 | 178 | +#endif // CUDA_MATH_FOUND  | 
0 commit comments