HIP: Heterogenous-computing Interface for Portability
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hip_fp16.h
1 /*
2 Copyright (c) 2015-2016 Advanced Micro Devices, Inc. All rights reserved.
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22 
23 #ifndef HIP_FP16_H
24 #define HIP_FP16_H
25 
26 #include "hip/hip_runtime.h"
27 
28 typedef struct{
29  unsigned x: 16;
30 } __half;
31 
32 
33 typedef struct __attribute__((aligned(4))){
34  __half p,q;
35 } __half2;
36 
37 typedef __half half;
38 typedef __half2 half2;
39 
40 /*
41 Arithmetic functions
42 */
43 
44 __device__ __half __hadd(const __half a, const __half b);
45 
46 __device__ __half __hadd_sat(const __half a, const __half b);
47 
48 __device__ __half __hfma(const __half a, const __half b, const __half c);
49 
50 __device__ __half __hfma_sat(const __half a, const __half b, const __half c);
51 
52 __device__ __half __hmul(const __half a, const __half b);
53 
54 __device__ __half __hmul_sat(const __half a, const __half b);
55 
56 __device__ __half __hneq(const __half a);
57 
58 __device__ __half __hsub(const __half a, const __half b);
59 
60 __device__ __half __hsub_sat(const __half a, const __half b);
61 
62 
63 
64 /*
65 Half2 Arithmetic Instructions
66 */
67 
68 __device__ __half2 __hadd2(const __half2 a, const __half2 b);
69 
70 __device__ __half2 __hadd2_sat(const __half2 a, const __half2 b);
71 
72 __device__ __half2 __hfma2(const __half2 a, const __half2 b, const __half2 c);
73 
74 __device__ __half2 __hfma2_sat(const __half2 a, const __half2 b, const __half2 c);
75 
76 __device__ __half2 __hmul2(const __half2 a, const __half2 b);
77 
78 __device__ __half2 __hmul2_sat(const __half2 a, const __half2 b);
79 
80 __device__ __half2 __hneq2(const __half2 a);
81 
82 __device__ __half2 __hsub2(const __half2 a, const __half2 b);
83 
84 __device__ __half2 __hsub2_sat(const __half2 a, const __half2 b);
85 
86 /*
87 Half Cmps
88 */
89 
90 __device__ bool __heq(const __half a, const __half b);
91 
92 __device__ bool __hge(const __half a, const __half b);
93 
94 __device__ bool __hgt(const __half a, const __half b);
95 
96 __device__ bool __hisinf(const __half a);
97 
98 __device__ bool __hisnan(const __half a);
99 
100 __device__ bool __hle(const __half a, const __half b);
101 
102 __device__ bool __hlt(const __half a, const __half b);
103 
104 __device__ bool __hne(const __half a, const __half b);
105 
106 /*
107 Half2 Cmps
108 */
109 
110 __device__ bool __hbeq2(const __half2 a, const __half2 b);
111 
112 __device__ bool __hbge2(const __half2 a, const __half2 b);
113 
114 __device__ bool __hbgt2(const __half2 a, const __half2 b);
115 
116 __device__ bool __hble2(const __half2 a, const __half2 b);
117 
118 __device__ bool __hblt2(const __half2 a, const __half2 b);
119 
120 __device__ bool __hbne2(const __half2 a, const __half2 b);
121 
122 __device__ __half2 __heq2(const __half2 a, const __half2 b);
123 
124 __device__ __half2 __hge2(const __half2 a, const __half2 b);
125 
126 __device__ __half2 __hgt2(const __half2 a, const __half2 b);
127 
128 __device__ __half2 __hisnan2(const __half2 a);
129 
130 __device__ __half2 __hle2(const __half2 a, const __half2 b);
131 
132 __device__ __half2 __hlt2(const __half2 a, const __half2 b);
133 
134 __device__ __half2 __hne2(const __half2 a, const __half2 b);
135 
136 
137 /*
138 Half Cnvs and Data Mvmnt
139 */
140 
141 __device__ __half2 __float22half2_rn(const float2 a);
142 
143 __device__ __half __float2half(const float a);
144 
145 __device__ __half2 __float2half2_rn(const float a);
146 
147 __device__ __half2 __floats2half2_rn(const float a, const float b);
148 
149 __device__ float2 __half22float2(const __half2 a);
150 
151 __device__ float __half2float(const __half a);
152 
153 __device__ __half2 __half2half2(const __half a);
154 
155 __device__ __half2 __halves2half2(const __half a, const __half b);
156 
157 __device__ float __high2float(const __half2 a);
158 
159 __device__ __half __high2half(const __half2 a);
160 
161 __device__ __half2 __high2half2(const __half2 a);
162 
163 __device__ __half2 __highs2half2(const __half2 a, const __half2 b);
164 
165 __device__ float __low2float(const __half2 a);
166 
167 __device__ __half __low2half(const __half2 a);
168 
169 __device__ __half2 __low2half2(const __half2 a);
170 
171 __device__ __half2 __lows2half2(const __half2 a, const __half2 b);
172 
173 __device__ __half2 __lowhigh2highlow(const __half2 a);
174 
175 __device__ __half2 __low2half2(const __half2 a, const __half2 b);
176 
177 #endif
Definition: hip_fp16.h:28