blob: 8be848ba2aa36fa296a7dd3c605ec32307288aa8 [file] [log] [blame]
Sasha Smundak0fc590b2020-10-07 08:11:59 -07001/*===---- __clang_hip_libdevice_declares.h - HIP device library decls -------===
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
10#ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
11#define __CLANG_HIP_LIBDEVICE_DECLARES_H__
12
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080013#ifdef __cplusplus
Sasha Smundak0fc590b2020-10-07 08:11:59 -070014extern "C" {
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080015#endif
Sasha Smundak0fc590b2020-10-07 08:11:59 -070016
17// BEGIN FLOAT
18__device__ __attribute__((const)) float __ocml_acos_f32(float);
19__device__ __attribute__((pure)) float __ocml_acosh_f32(float);
20__device__ __attribute__((const)) float __ocml_asin_f32(float);
21__device__ __attribute__((pure)) float __ocml_asinh_f32(float);
22__device__ __attribute__((const)) float __ocml_atan2_f32(float, float);
23__device__ __attribute__((const)) float __ocml_atan_f32(float);
24__device__ __attribute__((pure)) float __ocml_atanh_f32(float);
25__device__ __attribute__((pure)) float __ocml_cbrt_f32(float);
26__device__ __attribute__((const)) float __ocml_ceil_f32(float);
27__device__ __attribute__((const)) __device__ float __ocml_copysign_f32(float,
28 float);
29__device__ float __ocml_cos_f32(float);
30__device__ float __ocml_native_cos_f32(float);
31__device__ __attribute__((pure)) __device__ float __ocml_cosh_f32(float);
32__device__ float __ocml_cospi_f32(float);
33__device__ float __ocml_i0_f32(float);
34__device__ float __ocml_i1_f32(float);
35__device__ __attribute__((pure)) float __ocml_erfc_f32(float);
36__device__ __attribute__((pure)) float __ocml_erfcinv_f32(float);
37__device__ __attribute__((pure)) float __ocml_erfcx_f32(float);
38__device__ __attribute__((pure)) float __ocml_erf_f32(float);
39__device__ __attribute__((pure)) float __ocml_erfinv_f32(float);
40__device__ __attribute__((pure)) float __ocml_exp10_f32(float);
41__device__ __attribute__((pure)) float __ocml_native_exp10_f32(float);
42__device__ __attribute__((pure)) float __ocml_exp2_f32(float);
43__device__ __attribute__((pure)) float __ocml_exp_f32(float);
44__device__ __attribute__((pure)) float __ocml_native_exp_f32(float);
45__device__ __attribute__((pure)) float __ocml_expm1_f32(float);
46__device__ __attribute__((const)) float __ocml_fabs_f32(float);
47__device__ __attribute__((const)) float __ocml_fdim_f32(float, float);
48__device__ __attribute__((const)) float __ocml_floor_f32(float);
49__device__ __attribute__((const)) float __ocml_fma_f32(float, float, float);
50__device__ __attribute__((const)) float __ocml_fmax_f32(float, float);
51__device__ __attribute__((const)) float __ocml_fmin_f32(float, float);
52__device__ __attribute__((const)) __device__ float __ocml_fmod_f32(float,
53 float);
54__device__ float __ocml_frexp_f32(float,
55 __attribute__((address_space(5))) int *);
56__device__ __attribute__((const)) float __ocml_hypot_f32(float, float);
57__device__ __attribute__((const)) int __ocml_ilogb_f32(float);
58__device__ __attribute__((const)) int __ocml_isfinite_f32(float);
59__device__ __attribute__((const)) int __ocml_isinf_f32(float);
60__device__ __attribute__((const)) int __ocml_isnan_f32(float);
61__device__ float __ocml_j0_f32(float);
62__device__ float __ocml_j1_f32(float);
63__device__ __attribute__((const)) float __ocml_ldexp_f32(float, int);
64__device__ float __ocml_lgamma_f32(float);
65__device__ __attribute__((pure)) float __ocml_log10_f32(float);
66__device__ __attribute__((pure)) float __ocml_native_log10_f32(float);
67__device__ __attribute__((pure)) float __ocml_log1p_f32(float);
68__device__ __attribute__((pure)) float __ocml_log2_f32(float);
69__device__ __attribute__((pure)) float __ocml_native_log2_f32(float);
70__device__ __attribute__((const)) float __ocml_logb_f32(float);
71__device__ __attribute__((pure)) float __ocml_log_f32(float);
72__device__ __attribute__((pure)) float __ocml_native_log_f32(float);
73__device__ float __ocml_modf_f32(float,
74 __attribute__((address_space(5))) float *);
75__device__ __attribute__((const)) float __ocml_nearbyint_f32(float);
76__device__ __attribute__((const)) float __ocml_nextafter_f32(float, float);
77__device__ __attribute__((const)) float __ocml_len3_f32(float, float, float);
78__device__ __attribute__((const)) float __ocml_len4_f32(float, float, float,
79 float);
80__device__ __attribute__((pure)) float __ocml_ncdf_f32(float);
81__device__ __attribute__((pure)) float __ocml_ncdfinv_f32(float);
82__device__ __attribute__((pure)) float __ocml_pow_f32(float, float);
Sasha Smundak4b1f33a2021-01-11 15:05:07 -080083__device__ __attribute__((pure)) float __ocml_pown_f32(float, int);
Sasha Smundak0fc590b2020-10-07 08:11:59 -070084__device__ __attribute__((pure)) float __ocml_rcbrt_f32(float);
85__device__ __attribute__((const)) float __ocml_remainder_f32(float, float);
86__device__ float __ocml_remquo_f32(float, float,
87 __attribute__((address_space(5))) int *);
88__device__ __attribute__((const)) float __ocml_rhypot_f32(float, float);
89__device__ __attribute__((const)) float __ocml_rint_f32(float);
90__device__ __attribute__((const)) float __ocml_rlen3_f32(float, float, float);
91__device__ __attribute__((const)) float __ocml_rlen4_f32(float, float, float,
92 float);
93__device__ __attribute__((const)) float __ocml_round_f32(float);
94__device__ __attribute__((pure)) float __ocml_rsqrt_f32(float);
95__device__ __attribute__((const)) float __ocml_scalb_f32(float, float);
96__device__ __attribute__((const)) float __ocml_scalbn_f32(float, int);
97__device__ __attribute__((const)) int __ocml_signbit_f32(float);
98__device__ float __ocml_sincos_f32(float,
99 __attribute__((address_space(5))) float *);
100__device__ float __ocml_sincospi_f32(float,
101 __attribute__((address_space(5))) float *);
102__device__ float __ocml_sin_f32(float);
103__device__ float __ocml_native_sin_f32(float);
104__device__ __attribute__((pure)) float __ocml_sinh_f32(float);
105__device__ float __ocml_sinpi_f32(float);
106__device__ __attribute__((const)) float __ocml_sqrt_f32(float);
107__device__ __attribute__((const)) float __ocml_native_sqrt_f32(float);
108__device__ float __ocml_tan_f32(float);
109__device__ __attribute__((pure)) float __ocml_tanh_f32(float);
110__device__ float __ocml_tgamma_f32(float);
111__device__ __attribute__((const)) float __ocml_trunc_f32(float);
112__device__ float __ocml_y0_f32(float);
113__device__ float __ocml_y1_f32(float);
114
115// BEGIN INTRINSICS
116__device__ __attribute__((const)) float __ocml_add_rte_f32(float, float);
117__device__ __attribute__((const)) float __ocml_add_rtn_f32(float, float);
118__device__ __attribute__((const)) float __ocml_add_rtp_f32(float, float);
119__device__ __attribute__((const)) float __ocml_add_rtz_f32(float, float);
120__device__ __attribute__((const)) float __ocml_sub_rte_f32(float, float);
121__device__ __attribute__((const)) float __ocml_sub_rtn_f32(float, float);
122__device__ __attribute__((const)) float __ocml_sub_rtp_f32(float, float);
123__device__ __attribute__((const)) float __ocml_sub_rtz_f32(float, float);
124__device__ __attribute__((const)) float __ocml_mul_rte_f32(float, float);
125__device__ __attribute__((const)) float __ocml_mul_rtn_f32(float, float);
126__device__ __attribute__((const)) float __ocml_mul_rtp_f32(float, float);
127__device__ __attribute__((const)) float __ocml_mul_rtz_f32(float, float);
128__device__ __attribute__((const)) float __ocml_div_rte_f32(float, float);
129__device__ __attribute__((const)) float __ocml_div_rtn_f32(float, float);
130__device__ __attribute__((const)) float __ocml_div_rtp_f32(float, float);
131__device__ __attribute__((const)) float __ocml_div_rtz_f32(float, float);
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800132__device__ __attribute__((const)) float __ocml_sqrt_rte_f32(float);
133__device__ __attribute__((const)) float __ocml_sqrt_rtn_f32(float);
134__device__ __attribute__((const)) float __ocml_sqrt_rtp_f32(float);
135__device__ __attribute__((const)) float __ocml_sqrt_rtz_f32(float);
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700136__device__ __attribute__((const)) float __ocml_fma_rte_f32(float, float, float);
137__device__ __attribute__((const)) float __ocml_fma_rtn_f32(float, float, float);
138__device__ __attribute__((const)) float __ocml_fma_rtp_f32(float, float, float);
139__device__ __attribute__((const)) float __ocml_fma_rtz_f32(float, float, float);
140
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700141__device__ inline __attribute__((const)) float
142__llvm_amdgcn_cos_f32(float __x) {
143 return __builtin_amdgcn_cosf(__x);
144}
145__device__ inline __attribute__((const)) float
146__llvm_amdgcn_rcp_f32(float __x) {
147 return __builtin_amdgcn_rcpf(__x);
148}
149__device__ inline __attribute__((const)) float
150__llvm_amdgcn_rsq_f32(float __x) {
151 return __builtin_amdgcn_rsqf(__x);
152}
153__device__ inline __attribute__((const)) float
154__llvm_amdgcn_sin_f32(float __x) {
155 return __builtin_amdgcn_sinf(__x);
156}
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700157// END INTRINSICS
158// END FLOAT
159
160// BEGIN DOUBLE
161__device__ __attribute__((const)) double __ocml_acos_f64(double);
162__device__ __attribute__((pure)) double __ocml_acosh_f64(double);
163__device__ __attribute__((const)) double __ocml_asin_f64(double);
164__device__ __attribute__((pure)) double __ocml_asinh_f64(double);
165__device__ __attribute__((const)) double __ocml_atan2_f64(double, double);
166__device__ __attribute__((const)) double __ocml_atan_f64(double);
167__device__ __attribute__((pure)) double __ocml_atanh_f64(double);
168__device__ __attribute__((pure)) double __ocml_cbrt_f64(double);
169__device__ __attribute__((const)) double __ocml_ceil_f64(double);
170__device__ __attribute__((const)) double __ocml_copysign_f64(double, double);
171__device__ double __ocml_cos_f64(double);
172__device__ __attribute__((pure)) double __ocml_cosh_f64(double);
173__device__ double __ocml_cospi_f64(double);
174__device__ double __ocml_i0_f64(double);
175__device__ double __ocml_i1_f64(double);
176__device__ __attribute__((pure)) double __ocml_erfc_f64(double);
177__device__ __attribute__((pure)) double __ocml_erfcinv_f64(double);
178__device__ __attribute__((pure)) double __ocml_erfcx_f64(double);
179__device__ __attribute__((pure)) double __ocml_erf_f64(double);
180__device__ __attribute__((pure)) double __ocml_erfinv_f64(double);
181__device__ __attribute__((pure)) double __ocml_exp10_f64(double);
182__device__ __attribute__((pure)) double __ocml_exp2_f64(double);
183__device__ __attribute__((pure)) double __ocml_exp_f64(double);
184__device__ __attribute__((pure)) double __ocml_expm1_f64(double);
185__device__ __attribute__((const)) double __ocml_fabs_f64(double);
186__device__ __attribute__((const)) double __ocml_fdim_f64(double, double);
187__device__ __attribute__((const)) double __ocml_floor_f64(double);
188__device__ __attribute__((const)) double __ocml_fma_f64(double, double, double);
189__device__ __attribute__((const)) double __ocml_fmax_f64(double, double);
190__device__ __attribute__((const)) double __ocml_fmin_f64(double, double);
191__device__ __attribute__((const)) double __ocml_fmod_f64(double, double);
192__device__ double __ocml_frexp_f64(double,
193 __attribute__((address_space(5))) int *);
194__device__ __attribute__((const)) double __ocml_hypot_f64(double, double);
195__device__ __attribute__((const)) int __ocml_ilogb_f64(double);
196__device__ __attribute__((const)) int __ocml_isfinite_f64(double);
197__device__ __attribute__((const)) int __ocml_isinf_f64(double);
198__device__ __attribute__((const)) int __ocml_isnan_f64(double);
199__device__ double __ocml_j0_f64(double);
200__device__ double __ocml_j1_f64(double);
201__device__ __attribute__((const)) double __ocml_ldexp_f64(double, int);
202__device__ double __ocml_lgamma_f64(double);
203__device__ __attribute__((pure)) double __ocml_log10_f64(double);
204__device__ __attribute__((pure)) double __ocml_log1p_f64(double);
205__device__ __attribute__((pure)) double __ocml_log2_f64(double);
206__device__ __attribute__((const)) double __ocml_logb_f64(double);
207__device__ __attribute__((pure)) double __ocml_log_f64(double);
208__device__ double __ocml_modf_f64(double,
209 __attribute__((address_space(5))) double *);
210__device__ __attribute__((const)) double __ocml_nearbyint_f64(double);
211__device__ __attribute__((const)) double __ocml_nextafter_f64(double, double);
212__device__ __attribute__((const)) double __ocml_len3_f64(double, double,
213 double);
214__device__ __attribute__((const)) double __ocml_len4_f64(double, double, double,
215 double);
216__device__ __attribute__((pure)) double __ocml_ncdf_f64(double);
217__device__ __attribute__((pure)) double __ocml_ncdfinv_f64(double);
218__device__ __attribute__((pure)) double __ocml_pow_f64(double, double);
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800219__device__ __attribute__((pure)) double __ocml_pown_f64(double, int);
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700220__device__ __attribute__((pure)) double __ocml_rcbrt_f64(double);
221__device__ __attribute__((const)) double __ocml_remainder_f64(double, double);
222__device__ double __ocml_remquo_f64(double, double,
223 __attribute__((address_space(5))) int *);
224__device__ __attribute__((const)) double __ocml_rhypot_f64(double, double);
225__device__ __attribute__((const)) double __ocml_rint_f64(double);
226__device__ __attribute__((const)) double __ocml_rlen3_f64(double, double,
227 double);
228__device__ __attribute__((const)) double __ocml_rlen4_f64(double, double,
229 double, double);
230__device__ __attribute__((const)) double __ocml_round_f64(double);
231__device__ __attribute__((pure)) double __ocml_rsqrt_f64(double);
232__device__ __attribute__((const)) double __ocml_scalb_f64(double, double);
233__device__ __attribute__((const)) double __ocml_scalbn_f64(double, int);
234__device__ __attribute__((const)) int __ocml_signbit_f64(double);
235__device__ double __ocml_sincos_f64(double,
236 __attribute__((address_space(5))) double *);
237__device__ double
238__ocml_sincospi_f64(double, __attribute__((address_space(5))) double *);
239__device__ double __ocml_sin_f64(double);
240__device__ __attribute__((pure)) double __ocml_sinh_f64(double);
241__device__ double __ocml_sinpi_f64(double);
242__device__ __attribute__((const)) double __ocml_sqrt_f64(double);
243__device__ double __ocml_tan_f64(double);
244__device__ __attribute__((pure)) double __ocml_tanh_f64(double);
245__device__ double __ocml_tgamma_f64(double);
246__device__ __attribute__((const)) double __ocml_trunc_f64(double);
247__device__ double __ocml_y0_f64(double);
248__device__ double __ocml_y1_f64(double);
249
250// BEGIN INTRINSICS
251__device__ __attribute__((const)) double __ocml_add_rte_f64(double, double);
252__device__ __attribute__((const)) double __ocml_add_rtn_f64(double, double);
253__device__ __attribute__((const)) double __ocml_add_rtp_f64(double, double);
254__device__ __attribute__((const)) double __ocml_add_rtz_f64(double, double);
255__device__ __attribute__((const)) double __ocml_sub_rte_f64(double, double);
256__device__ __attribute__((const)) double __ocml_sub_rtn_f64(double, double);
257__device__ __attribute__((const)) double __ocml_sub_rtp_f64(double, double);
258__device__ __attribute__((const)) double __ocml_sub_rtz_f64(double, double);
259__device__ __attribute__((const)) double __ocml_mul_rte_f64(double, double);
260__device__ __attribute__((const)) double __ocml_mul_rtn_f64(double, double);
261__device__ __attribute__((const)) double __ocml_mul_rtp_f64(double, double);
262__device__ __attribute__((const)) double __ocml_mul_rtz_f64(double, double);
263__device__ __attribute__((const)) double __ocml_div_rte_f64(double, double);
264__device__ __attribute__((const)) double __ocml_div_rtn_f64(double, double);
265__device__ __attribute__((const)) double __ocml_div_rtp_f64(double, double);
266__device__ __attribute__((const)) double __ocml_div_rtz_f64(double, double);
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800267__device__ __attribute__((const)) double __ocml_sqrt_rte_f64(double);
268__device__ __attribute__((const)) double __ocml_sqrt_rtn_f64(double);
269__device__ __attribute__((const)) double __ocml_sqrt_rtp_f64(double);
270__device__ __attribute__((const)) double __ocml_sqrt_rtz_f64(double);
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700271__device__ __attribute__((const)) double __ocml_fma_rte_f64(double, double,
272 double);
273__device__ __attribute__((const)) double __ocml_fma_rtn_f64(double, double,
274 double);
275__device__ __attribute__((const)) double __ocml_fma_rtp_f64(double, double,
276 double);
277__device__ __attribute__((const)) double __ocml_fma_rtz_f64(double, double,
278 double);
279
Pirama Arumuga Nainar7e1f8392021-08-16 17:30:48 -0700280__device__ inline __attribute__((const)) double
281__llvm_amdgcn_rcp_f64(double __x) {
282 return __builtin_amdgcn_rcp(__x);
283}
284__device__ inline __attribute__((const)) double
285__llvm_amdgcn_rsq_f64(double __x) {
286 return __builtin_amdgcn_rsq(__x);
287}
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700288
289__device__ __attribute__((const)) _Float16 __ocml_ceil_f16(_Float16);
290__device__ _Float16 __ocml_cos_f16(_Float16);
291__device__ __attribute__((pure)) _Float16 __ocml_exp_f16(_Float16);
292__device__ __attribute__((pure)) _Float16 __ocml_exp10_f16(_Float16);
293__device__ __attribute__((pure)) _Float16 __ocml_exp2_f16(_Float16);
294__device__ __attribute__((const)) _Float16 __ocml_floor_f16(_Float16);
295__device__ __attribute__((const)) _Float16 __ocml_fma_f16(_Float16, _Float16,
296 _Float16);
297__device__ __attribute__((const)) _Float16 __ocml_fabs_f16(_Float16);
298__device__ __attribute__((const)) int __ocml_isinf_f16(_Float16);
299__device__ __attribute__((const)) int __ocml_isnan_f16(_Float16);
300__device__ __attribute__((pure)) _Float16 __ocml_log_f16(_Float16);
301__device__ __attribute__((pure)) _Float16 __ocml_log10_f16(_Float16);
302__device__ __attribute__((pure)) _Float16 __ocml_log2_f16(_Float16);
303__device__ __attribute__((const)) _Float16 __llvm_amdgcn_rcp_f16(_Float16);
304__device__ __attribute__((const)) _Float16 __ocml_rint_f16(_Float16);
305__device__ __attribute__((const)) _Float16 __ocml_rsqrt_f16(_Float16);
306__device__ _Float16 __ocml_sin_f16(_Float16);
307__device__ __attribute__((const)) _Float16 __ocml_sqrt_f16(_Float16);
308__device__ __attribute__((const)) _Float16 __ocml_trunc_f16(_Float16);
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800309__device__ __attribute__((pure)) _Float16 __ocml_pown_f16(_Float16, int);
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700310
311typedef _Float16 __2f16 __attribute__((ext_vector_type(2)));
312typedef short __2i16 __attribute__((ext_vector_type(2)));
313
314__device__ __attribute__((const)) float __ockl_fdot2(__2f16 a, __2f16 b,
315 float c, bool s);
316__device__ __attribute__((const)) __2f16 __ocml_ceil_2f16(__2f16);
317__device__ __attribute__((const)) __2f16 __ocml_fabs_2f16(__2f16);
318__device__ __2f16 __ocml_cos_2f16(__2f16);
319__device__ __attribute__((pure)) __2f16 __ocml_exp_2f16(__2f16);
320__device__ __attribute__((pure)) __2f16 __ocml_exp10_2f16(__2f16);
321__device__ __attribute__((pure)) __2f16 __ocml_exp2_2f16(__2f16);
322__device__ __attribute__((const)) __2f16 __ocml_floor_2f16(__2f16);
323__device__ __attribute__((const))
324__2f16 __ocml_fma_2f16(__2f16, __2f16, __2f16);
325__device__ __attribute__((const)) __2i16 __ocml_isinf_2f16(__2f16);
326__device__ __attribute__((const)) __2i16 __ocml_isnan_2f16(__2f16);
327__device__ __attribute__((pure)) __2f16 __ocml_log_2f16(__2f16);
328__device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16);
329__device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16);
330__device__ inline __2f16
331__llvm_amdgcn_rcp_2f16(__2f16 __x) // Not currently exposed by ROCDL.
332{
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800333 return (__2f16)(__llvm_amdgcn_rcp_f16(__x.x), __llvm_amdgcn_rcp_f16(__x.y));
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700334}
335__device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
336__device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
337__device__ __2f16 __ocml_sin_2f16(__2f16);
338__device__ __attribute__((const)) __2f16 __ocml_sqrt_2f16(__2f16);
339__device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800340__device__ __attribute__((const)) __2f16 __ocml_pown_2f16(__2f16, __2i16);
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700341
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800342#ifdef __cplusplus
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700343} // extern "C"
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800344#endif
Sasha Smundak0fc590b2020-10-07 08:11:59 -0700345
346#endif // __CLANG_HIP_LIBDEVICE_DECLARES_H__