HIP: Heterogenous-computing Interface for Portability
channel_descriptor.h
1 /*
2 Copyright (c) 2015 - present 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_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H
24 #define HIP_INCLUDE_HIP_HCC_DETAIL_CHANNEL_DESCRIPTOR_H
25 
26 #include<hip/hcc_detail/driver_types.h>
28 
29 #ifdef __cplusplus
30 
31 hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f);
32 
33 static inline hipChannelFormatDesc hipCreateChannelDescHalf() {
34  int e = (int)sizeof(unsigned short) * 8;
35  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat);
36 }
37 
38 static inline hipChannelFormatDesc hipCreateChannelDescHalf1() {
39  int e = (int)sizeof(unsigned short) * 8;
40  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat);
41 }
42 
43 static inline hipChannelFormatDesc hipCreateChannelDescHalf2()
44 {
45  int e = (int)sizeof(unsigned short) * 8;
46  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat);
47 }
48 
49 template<typename T>
50 static inline hipChannelFormatDesc hipCreateChannelDesc() {
51  return hipCreateChannelDesc(0, 0, 0, 0, hipChannelFormatKindNone);
52 }
53 
54 template<>
55 inline hipChannelFormatDesc hipCreateChannelDesc<char>()
56 {
57  int e = (int)sizeof(char) * 8;
58  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
59 }
60 
61 template<>
62 inline hipChannelFormatDesc hipCreateChannelDesc<signed char>()
63 {
64  int e = (int)sizeof(signed char) * 8;
65  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
66 }
67 
68 template<>
69 inline hipChannelFormatDesc hipCreateChannelDesc<unsigned char>()
70 {
71  int e = (int)sizeof(unsigned char) * 8;
72  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
73 }
74 
75 template<>
76 inline hipChannelFormatDesc hipCreateChannelDesc<uchar1>()
77 {
78  int e = (int)sizeof(unsigned char) * 8;
79  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
80 }
81 
82 template<>
83 inline hipChannelFormatDesc hipCreateChannelDesc<char1>()
84 {
85  int e = (int)sizeof(signed char) * 8;
86  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
87 }
88 
89 template<>
90 inline hipChannelFormatDesc hipCreateChannelDesc<uchar2>()
91 {
92  int e = (int)sizeof(unsigned char) * 8;
93  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned);
94 }
95 
96 template<>
97 inline hipChannelFormatDesc hipCreateChannelDesc<char2>()
98 {
99  int e = (int)sizeof(signed char) * 8;
100  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned);
101 }
102 
103 template<>
104 inline hipChannelFormatDesc hipCreateChannelDesc<uchar3>()
105 {
106  int e = (int)sizeof(unsigned char) * 8;
107  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned);
108 }
109 
110 template<>
111 inline hipChannelFormatDesc hipCreateChannelDesc<char3>()
112 {
113  int e = (int)sizeof(signed char) * 8;
114  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned);
115 }
116 
117 template<>
118 inline hipChannelFormatDesc hipCreateChannelDesc<uchar4>()
119 {
120  int e = (int)sizeof(unsigned char) * 8;
121  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned);
122 }
123 
124 template<>
125 inline hipChannelFormatDesc hipCreateChannelDesc<char4>()
126 {
127  int e = (int)sizeof(signed char) * 8;
128  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned);
129 }
130 
131 template<>
132 inline hipChannelFormatDesc hipCreateChannelDesc<unsigned short>()
133 {
134  int e = (int)sizeof(unsigned short) * 8;
135  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
136 }
137 
138 template<>
139 inline hipChannelFormatDesc hipCreateChannelDesc<signed short>()
140 {
141  int e = (int)sizeof(signed short) * 8;
142  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
143 }
144 
145 template<>
146 inline hipChannelFormatDesc hipCreateChannelDesc<ushort1>()
147 {
148  int e = (int)sizeof(unsigned short) * 8;
149  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
150 }
151 
152 template<>
153 inline hipChannelFormatDesc hipCreateChannelDesc<short1>()
154 {
155  int e = (int)sizeof(signed short) * 8;
156  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
157 }
158 
159 template<>
160 inline hipChannelFormatDesc hipCreateChannelDesc<ushort2>()
161 {
162  int e = (int)sizeof(unsigned short) * 8;
163  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned);
164 }
165 
166 template<>
167 inline hipChannelFormatDesc hipCreateChannelDesc<short2>()
168 {
169  int e = (int)sizeof(signed short) * 8;
170  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned);
171 }
172 
173 template<>
174 inline hipChannelFormatDesc hipCreateChannelDesc<ushort3>()
175 {
176  int e = (int)sizeof(unsigned short) * 8;
177  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned);
178 }
179 
180 template<>
181 inline hipChannelFormatDesc hipCreateChannelDesc<short3>()
182 {
183  int e = (int)sizeof(signed short) * 8;
184  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned);
185 }
186 
187 template<>
188 inline hipChannelFormatDesc hipCreateChannelDesc<ushort4>()
189 {
190  int e = (int)sizeof(unsigned short) * 8;
191  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned);
192 }
193 
194 template<>
195 inline hipChannelFormatDesc hipCreateChannelDesc<short4>()
196 {
197  int e = (int)sizeof(signed short) * 8;
198  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned);
199 }
200 
201 template<>
202 inline hipChannelFormatDesc hipCreateChannelDesc<unsigned int>()
203 {
204  int e = (int)sizeof(unsigned int) * 8;
205  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
206 }
207 
208 template<>
209 inline hipChannelFormatDesc hipCreateChannelDesc<signed int>()
210 {
211  int e = (int)sizeof(signed int) * 8;
212  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
213 }
214 
215 template<>
216 inline hipChannelFormatDesc hipCreateChannelDesc<uint1>()
217 {
218  int e = (int)sizeof(unsigned int) * 8;
219  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
220 }
221 
222 template<>
223 inline hipChannelFormatDesc hipCreateChannelDesc<int1>()
224 {
225  int e = (int)sizeof(signed int) * 8;
226  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
227 }
228 
229 template<>
230 inline hipChannelFormatDesc hipCreateChannelDesc<uint2>()
231 {
232  int e = (int)sizeof(unsigned int) * 8;
233  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned);
234 }
235 
236 template<>
237 inline hipChannelFormatDesc hipCreateChannelDesc<int2>()
238 {
239  int e = (int)sizeof(signed int) * 8;
240  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned);
241 }
242 
243 template<>
244 inline hipChannelFormatDesc hipCreateChannelDesc<uint3>()
245 {
246  int e = (int)sizeof(unsigned int) * 8;
247  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned);
248 }
249 
250 template<>
251 inline hipChannelFormatDesc hipCreateChannelDesc<int3>()
252 {
253  int e = (int)sizeof(signed int) * 8;
254  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned);
255 }
256 
257 template<>
258 inline hipChannelFormatDesc hipCreateChannelDesc<uint4>()
259 {
260  int e = (int)sizeof(unsigned int) * 8;
261  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned);
262 }
263 
264 template<>
265 inline hipChannelFormatDesc hipCreateChannelDesc<int4>()
266 {
267  int e = (int)sizeof(signed int) * 8;
268  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned);
269 }
270 
271 template<>
272 inline hipChannelFormatDesc hipCreateChannelDesc<float>()
273 {
274  int e = (int)sizeof(float) * 8;
275  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat);
276 }
277 
278 template<>
279 inline hipChannelFormatDesc hipCreateChannelDesc<float1>()
280 {
281  int e = (int)sizeof(float) * 8;
282  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindFloat);
283 }
284 
285 template<>
286 inline hipChannelFormatDesc hipCreateChannelDesc<float2>()
287 {
288  int e = (int)sizeof(float) * 8;
289  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindFloat);
290 }
291 
292 template<>
293 inline hipChannelFormatDesc hipCreateChannelDesc<float3>()
294 {
295  int e = (int)sizeof(float) * 8;
296  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindFloat);
297 }
298 
299 template<>
300 inline hipChannelFormatDesc hipCreateChannelDesc<float4>()
301 {
302  int e = (int)sizeof(float) * 8;
303  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindFloat);
304 }
305 
306 template<>
307 inline hipChannelFormatDesc hipCreateChannelDesc<unsigned long>()
308 {
309  int e = (int)sizeof(unsigned long) * 8;
310  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
311 }
312 
313 template<>
314 inline hipChannelFormatDesc hipCreateChannelDesc<signed long>()
315 {
316  int e = (int)sizeof(signed long) * 8;
317  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
318 }
319 
320 template<>
321 inline hipChannelFormatDesc hipCreateChannelDesc<ulong1>()
322 {
323  int e = (int)sizeof(unsigned long) * 8;
324  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindUnsigned);
325 }
326 
327 template<>
328 inline hipChannelFormatDesc hipCreateChannelDesc<long1>()
329 {
330  int e = (int)sizeof(signed long) * 8;
331  return hipCreateChannelDesc(e, 0, 0, 0, hipChannelFormatKindSigned);
332 }
333 
334 template<>
335 inline hipChannelFormatDesc hipCreateChannelDesc<ulong2>()
336 {
337  int e = (int)sizeof(unsigned long) * 8;
338  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindUnsigned);
339 }
340 
341 template<>
342 inline hipChannelFormatDesc hipCreateChannelDesc<long2>()
343 {
344  int e = (int)sizeof(signed long) * 8;
345  return hipCreateChannelDesc(e, e, 0, 0, hipChannelFormatKindSigned);
346 }
347 
348 template<>
349 inline hipChannelFormatDesc hipCreateChannelDesc<ulong3>()
350 {
351  int e = (int)sizeof(unsigned long) * 8;
352  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindUnsigned);
353 }
354 
355 template<>
356 inline hipChannelFormatDesc hipCreateChannelDesc<long3>()
357 {
358  int e = (int)sizeof(signed long) * 8;
359  return hipCreateChannelDesc(e, e, e, 0, hipChannelFormatKindSigned);
360 }
361 
362 template<>
363 inline hipChannelFormatDesc hipCreateChannelDesc<ulong4>()
364 {
365  int e = (int)sizeof(unsigned long) * 8;
366  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindUnsigned);
367 }
368 
369 template<>
370 inline hipChannelFormatDesc hipCreateChannelDesc<long4>()
371 {
372  int e = (int)sizeof(signed long) * 8;
373  return hipCreateChannelDesc(e, e, e, e, hipChannelFormatKindSigned);
374 }
375 
376 #else
377 
378 struct hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, enum hipChannelFormatKind f);
379 
380 #endif
381 
382 #endif
Defines the different newt vector types for HIP runtime.
Definition: driver_types.h:34