|
12 | 12 | ///
|
13 | 13 | //===----------------------------------------------------------------------===//
|
14 | 14 |
|
| 15 | +#include "Conformance/device_code/Common.hpp" |
| 16 | + |
15 | 17 | #include <gpuintrin.h>
|
16 | 18 | #include <math.h>
|
17 | 19 | #include <stddef.h>
|
18 |
| -#include <stdint.h> |
19 | 20 |
|
20 |
| -typedef _Float16 float16; |
| 21 | +using namespace common; |
| 22 | + |
| 23 | +//===----------------------------------------------------------------------===// |
| 24 | +// Helpers |
| 25 | +//===----------------------------------------------------------------------===// |
| 26 | + |
| 27 | +static inline float sincosfSin(float X) { |
| 28 | + float SinX, CosX; |
| 29 | + sincosf(X, &SinX, &CosX); |
| 30 | + return SinX; |
| 31 | +} |
| 32 | + |
| 33 | +static inline float sincosfCos(float X) { |
| 34 | + float SinX, CosX; |
| 35 | + sincosf(X, &SinX, &CosX); |
| 36 | + return CosX; |
| 37 | +} |
| 38 | + |
| 39 | +//===----------------------------------------------------------------------===// |
| 40 | +// Kernels |
| 41 | +//===----------------------------------------------------------------------===// |
21 | 42 |
|
22 | 43 | extern "C" {
|
23 | 44 |
|
| 45 | +__gpu_kernel void acosfKernel(const float *X, float *Out, |
| 46 | + size_t NumElements) noexcept { |
| 47 | + runKernelBody<acosf>(NumElements, Out, X); |
| 48 | +} |
| 49 | + |
| 50 | +__gpu_kernel void acoshfKernel(const float *X, float *Out, |
| 51 | + size_t NumElements) noexcept { |
| 52 | + runKernelBody<acoshf>(NumElements, Out, X); |
| 53 | +} |
| 54 | + |
| 55 | +__gpu_kernel void asinfKernel(const float *X, float *Out, |
| 56 | + size_t NumElements) noexcept { |
| 57 | + runKernelBody<asinf>(NumElements, Out, X); |
| 58 | +} |
| 59 | + |
| 60 | +__gpu_kernel void asinhfKernel(const float *X, float *Out, |
| 61 | + size_t NumElements) noexcept { |
| 62 | + runKernelBody<asinhf>(NumElements, Out, X); |
| 63 | +} |
| 64 | + |
| 65 | +__gpu_kernel void atanfKernel(const float *X, float *Out, |
| 66 | + size_t NumElements) noexcept { |
| 67 | + runKernelBody<atanf>(NumElements, Out, X); |
| 68 | +} |
| 69 | + |
| 70 | +__gpu_kernel void atanhfKernel(const float *X, float *Out, |
| 71 | + size_t NumElements) noexcept { |
| 72 | + runKernelBody<atanhf>(NumElements, Out, X); |
| 73 | +} |
| 74 | + |
| 75 | +__gpu_kernel void cbrtfKernel(const float *X, float *Out, |
| 76 | + size_t NumElements) noexcept { |
| 77 | + runKernelBody<cbrtf>(NumElements, Out, X); |
| 78 | +} |
| 79 | + |
| 80 | +__gpu_kernel void cosfKernel(const float *X, float *Out, |
| 81 | + size_t NumElements) noexcept { |
| 82 | + runKernelBody<cosf>(NumElements, Out, X); |
| 83 | +} |
| 84 | + |
| 85 | +__gpu_kernel void coshfKernel(const float *X, float *Out, |
| 86 | + size_t NumElements) noexcept { |
| 87 | + runKernelBody<coshf>(NumElements, Out, X); |
| 88 | +} |
| 89 | + |
| 90 | +__gpu_kernel void cospifKernel(const float *X, float *Out, |
| 91 | + size_t NumElements) noexcept { |
| 92 | + runKernelBody<cospif>(NumElements, Out, X); |
| 93 | +} |
| 94 | + |
| 95 | +__gpu_kernel void erffKernel(const float *X, float *Out, |
| 96 | + size_t NumElements) noexcept { |
| 97 | + runKernelBody<erff>(NumElements, Out, X); |
| 98 | +} |
| 99 | + |
| 100 | +__gpu_kernel void expfKernel(const float *X, float *Out, |
| 101 | + size_t NumElements) noexcept { |
| 102 | + runKernelBody<expf>(NumElements, Out, X); |
| 103 | +} |
| 104 | + |
| 105 | +__gpu_kernel void exp10fKernel(const float *X, float *Out, |
| 106 | + size_t NumElements) noexcept { |
| 107 | + runKernelBody<exp10f>(NumElements, Out, X); |
| 108 | +} |
| 109 | + |
| 110 | +__gpu_kernel void exp2fKernel(const float *X, float *Out, |
| 111 | + size_t NumElements) noexcept { |
| 112 | + runKernelBody<exp2f>(NumElements, Out, X); |
| 113 | +} |
| 114 | + |
| 115 | +__gpu_kernel void expm1fKernel(const float *X, float *Out, |
| 116 | + size_t NumElements) noexcept { |
| 117 | + runKernelBody<expm1f>(NumElements, Out, X); |
| 118 | +} |
| 119 | + |
24 | 120 | __gpu_kernel void hypotf16Kernel(const float16 *X, float16 *Y, float16 *Out,
|
25 |
| - size_t NumElements) { |
26 |
| - uint32_t Index = |
27 |
| - __gpu_num_threads_x() * __gpu_block_id_x() + __gpu_thread_id_x(); |
| 121 | + size_t NumElements) noexcept { |
| 122 | + runKernelBody<hypotf16>(NumElements, Out, X, Y); |
| 123 | +} |
| 124 | + |
| 125 | +__gpu_kernel void logfKernel(const float *X, float *Out, |
| 126 | + size_t NumElements) noexcept { |
| 127 | + runKernelBody<logf>(NumElements, Out, X); |
| 128 | +} |
| 129 | + |
| 130 | +__gpu_kernel void log10fKernel(const float *X, float *Out, |
| 131 | + size_t NumElements) noexcept { |
| 132 | + runKernelBody<log10f>(NumElements, Out, X); |
| 133 | +} |
28 | 134 |
|
29 |
| - if (Index < NumElements) |
30 |
| - Out[Index] = hypotf16(X[Index], Y[Index]); |
| 135 | +__gpu_kernel void log1pfKernel(const float *X, float *Out, |
| 136 | + size_t NumElements) noexcept { |
| 137 | + runKernelBody<log1pf>(NumElements, Out, X); |
31 | 138 | }
|
32 | 139 |
|
33 |
| -__gpu_kernel void logfKernel(const float *X, float *Out, size_t NumElements) { |
34 |
| - uint32_t Index = |
35 |
| - __gpu_num_threads_x() * __gpu_block_id_x() + __gpu_thread_id_x(); |
| 140 | +__gpu_kernel void log2fKernel(const float *X, float *Out, |
| 141 | + size_t NumElements) noexcept { |
| 142 | + runKernelBody<log2f>(NumElements, Out, X); |
| 143 | +} |
| 144 | + |
| 145 | +__gpu_kernel void sinfKernel(const float *X, float *Out, |
| 146 | + size_t NumElements) noexcept { |
| 147 | + runKernelBody<sinf>(NumElements, Out, X); |
| 148 | +} |
| 149 | + |
| 150 | +__gpu_kernel void sincosfSinKernel(const float *X, float *Out, |
| 151 | + size_t NumElements) noexcept { |
| 152 | + runKernelBody<sincosfSin>(NumElements, Out, X); |
| 153 | +} |
| 154 | + |
| 155 | +__gpu_kernel void sincosfCosKernel(const float *X, float *Out, |
| 156 | + size_t NumElements) noexcept { |
| 157 | + runKernelBody<sincosfCos>(NumElements, Out, X); |
| 158 | +} |
| 159 | + |
| 160 | +__gpu_kernel void sinhfKernel(const float *X, float *Out, |
| 161 | + size_t NumElements) noexcept { |
| 162 | + runKernelBody<sinhf>(NumElements, Out, X); |
| 163 | +} |
| 164 | + |
| 165 | +__gpu_kernel void sinpifKernel(const float *X, float *Out, |
| 166 | + size_t NumElements) noexcept { |
| 167 | + runKernelBody<sinpif>(NumElements, Out, X); |
| 168 | +} |
| 169 | + |
| 170 | +__gpu_kernel void tanfKernel(const float *X, float *Out, |
| 171 | + size_t NumElements) noexcept { |
| 172 | + runKernelBody<tanf>(NumElements, Out, X); |
| 173 | +} |
| 174 | + |
| 175 | +__gpu_kernel void tanhfKernel(const float *X, float *Out, |
| 176 | + size_t NumElements) noexcept { |
| 177 | + runKernelBody<tanhf>(NumElements, Out, X); |
| 178 | +} |
36 | 179 |
|
37 |
| - if (Index < NumElements) |
38 |
| - Out[Index] = logf(X[Index]); |
| 180 | +__gpu_kernel void tanpifKernel(const float *X, float *Out, |
| 181 | + size_t NumElements) noexcept { |
| 182 | + runKernelBody<tanpif>(NumElements, Out, X); |
39 | 183 | }
|
40 | 184 | } // extern "C"
|
0 commit comments