HIP: Heterogenous-computing Interface for Portability
Loading...
Searching...
No Matches
hip_fp16_math_fwd.h
1/*
2Copyright (c) 2015 - 2023 Advanced Micro Devices, Inc. All rights reserved.
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23#pragma once
24
25// /*
26// Half Math Functions
27// */
28#if !defined(__HIPCC_RTC__)
29#include "host_defines.h"
30#endif
31#ifndef __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__
32extern "C"
33{
34 __device__ __attribute__((const)) _Float16 __ocml_ceil_f16(_Float16);
35 __device__ _Float16 __ocml_cos_f16(_Float16);
36 __device__ __attribute__((pure)) _Float16 __ocml_exp_f16(_Float16);
37 __device__ __attribute__((pure)) _Float16 __ocml_exp10_f16(_Float16);
38 __device__ __attribute__((pure)) _Float16 __ocml_exp2_f16(_Float16);
39 __device__ __attribute__((const)) _Float16 __ocml_floor_f16(_Float16);
40 __device__ __attribute__((const))
41 _Float16 __ocml_fma_f16(_Float16, _Float16, _Float16);
42 __device__ __attribute__((const)) _Float16 __ocml_fabs_f16(_Float16);
43 __device__ __attribute__((const)) int __ocml_isinf_f16(_Float16);
44 __device__ __attribute__((const)) int __ocml_isnan_f16(_Float16);
45 __device__ __attribute__((pure)) _Float16 __ocml_log_f16(_Float16);
46 __device__ __attribute__((pure)) _Float16 __ocml_log10_f16(_Float16);
47 __device__ __attribute__((pure)) _Float16 __ocml_log2_f16(_Float16);
48 __device__ __attribute__((pure)) _Float16 __ocml_pown_f16(_Float16, int);
49 __device__ __attribute__((const)) _Float16 __ocml_rint_f16(_Float16);
50 __device__ __attribute__((const)) _Float16 __ocml_rsqrt_f16(_Float16);
51 __device__ _Float16 __ocml_sin_f16(_Float16);
52 __device__ __attribute__((const)) _Float16 __ocml_sqrt_f16(_Float16);
53 __device__ __attribute__((const)) _Float16 __ocml_trunc_f16(_Float16);
54 __device__ __attribute__((const)) _Float16 __ocml_fmax_f16(_Float16, _Float16);
55 __device__ __attribute__((const)) _Float16 __ocml_fmin_f16(_Float16, _Float16);
56
57 typedef _Float16 __2f16 __attribute__((ext_vector_type(2)));
58 typedef short __2i16 __attribute__((ext_vector_type(2)));
59
60 #if defined(__clang__) && defined(__HIP__)
61 __device__ __attribute__((const)) float __ockl_fdot2(__2f16 a, __2f16 b, float c, bool s);
62 #endif
63
64 __device__ __attribute__((const)) __2f16 __ocml_ceil_2f16(__2f16);
65 __device__ __attribute__((const)) __2f16 __ocml_fabs_2f16(__2f16);
66 __device__ __2f16 __ocml_cos_2f16(__2f16);
67 __device__ __attribute__((pure)) __2f16 __ocml_exp_2f16(__2f16);
68 __device__ __attribute__((pure)) __2f16 __ocml_exp10_2f16(__2f16);
69 __device__ __attribute__((pure)) __2f16 __ocml_exp2_2f16(__2f16);
70 __device__ __attribute__((const)) __2f16 __ocml_floor_2f16(__2f16);
71 __device__ __attribute__((const)) __2f16 __ocml_fma_2f16(__2f16, __2f16, __2f16);
72 __device__ __attribute__((const)) __2i16 __ocml_isinf_2f16(__2f16);
73 __device__ __attribute__((const)) __2i16 __ocml_isnan_2f16(__2f16);
74 __device__ __attribute__((pure)) __2f16 __ocml_log_2f16(__2f16);
75 __device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16);
76 __device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16);
77 __device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
78 __device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
79 __device__ __2f16 __ocml_sin_2f16(__2f16);
80 __device__ __attribute__((const)) __2f16 __ocml_sqrt_2f16(__2f16);
81 __device__ __attribute__((const)) __2f16 __ocml_trunc_2f16(__2f16);
82
83 __device__ __attribute__((const)) _Float16 __ocml_cvtrtn_f16_f32(float);
84 __device__ __attribute__((const)) _Float16 __ocml_cvtrtp_f16_f32(float);
85 __device__ __attribute__((const)) _Float16 __ocml_cvtrtz_f16_f32(float);
86
87}
88#endif // !__CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__
89//TODO: remove these after they get into clang header __clang_hip_libdevice_declares.h'
90extern "C" {
91 __device__ __attribute__((const)) _Float16 __ocml_fmax_f16(_Float16, _Float16);
92 __device__ __attribute__((const)) _Float16 __ocml_fmin_f16(_Float16, _Float16);
93 __device__ __attribute__((const)) _Float16 __ocml_cvtrtn_f16_f32(float);
94 __device__ __attribute__((const)) _Float16 __ocml_cvtrtp_f16_f32(float);
95 __device__ __attribute__((const)) _Float16 __ocml_cvtrtz_f16_f32(float);
96}
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Definition hip_fp16_math_fwd.h:57