HIP: Heterogenous-computing Interface for Portability
driver_types.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_DRIVER_TYPES_H
24 #define HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H
25 
26 #ifndef __cplusplus
27 #include <stdbool.h>
28 #endif
29 
30 typedef void* hipDeviceptr_t;
31 typedef enum hipChannelFormatKind {
32  hipChannelFormatKindSigned = 0,
33  hipChannelFormatKindUnsigned = 1,
34  hipChannelFormatKindFloat = 2,
35  hipChannelFormatKindNone = 3
36 }hipChannelFormatKind;
37 
38 typedef struct hipChannelFormatDesc {
39  int x;
40  int y;
41  int z;
42  int w;
43  enum hipChannelFormatKind f;
45 
46 #define HIP_TRSA_OVERRIDE_FORMAT 0x01
47 #define HIP_TRSF_READ_AS_INTEGER 0x01
48 #define HIP_TRSF_NORMALIZED_COORDINATES 0x02
49 #define HIP_TRSF_SRGB 0x10
50 
51 typedef enum hipArray_Format {
52  HIP_AD_FORMAT_UNSIGNED_INT8 = 0x01,
53  HIP_AD_FORMAT_UNSIGNED_INT16 = 0x02,
54  HIP_AD_FORMAT_UNSIGNED_INT32 = 0x03,
55  HIP_AD_FORMAT_SIGNED_INT8 = 0x08,
56  HIP_AD_FORMAT_SIGNED_INT16 = 0x09,
57  HIP_AD_FORMAT_SIGNED_INT32 = 0x0a,
58  HIP_AD_FORMAT_HALF = 0x10,
59  HIP_AD_FORMAT_FLOAT = 0x20
60 }hipArray_Format;
61 
62 typedef struct HIP_ARRAY_DESCRIPTOR {
63  size_t Width;
64  size_t Height;
65  enum hipArray_Format Format;
66  unsigned int NumChannels;
68 
69 typedef struct HIP_ARRAY3D_DESCRIPTOR {
70  size_t Width;
71  size_t Height;
72  size_t Depth;
73  enum hipArray_Format Format;
74  unsigned int NumChannels;
75  unsigned int Flags;
77 
78 typedef struct hipArray {
79  void* data; // FIXME: generalize this
80  struct hipChannelFormatDesc desc;
81  unsigned int type;
82  unsigned int width;
83  unsigned int height;
84  unsigned int depth;
85  enum hipArray_Format Format;
86  unsigned int NumChannels;
87  bool isDrv;
88  unsigned int textureType;
89 }hipArray;
90 
91 typedef struct hip_Memcpy2D {
92  size_t srcXInBytes;
93  size_t srcY;
94  hipMemoryType srcMemoryType;
95  const void* srcHost;
96  hipDeviceptr_t srcDevice;
97  hipArray* srcArray;
98  size_t srcPitch;
99  size_t dstXInBytes;
100  size_t dstY;
101  hipMemoryType dstMemoryType;
102  void* dstHost;
103  hipDeviceptr_t dstDevice;
104  hipArray* dstArray;
105  size_t dstPitch;
106  size_t WidthInBytes;
107  size_t Height;
108 } hip_Memcpy2D;
109 
110 
111 typedef struct hipArray* hipArray_t;
112 typedef hipArray_t hiparray;
113 typedef const struct hipArray* hipArray_const_t;
114 
115 // TODO: It needs to be modified since it was just copied from hipArray.
117  void* data; // FIXME: generalize this
118  struct hipChannelFormatDesc desc;
119  unsigned int width;
120  unsigned int height;
121  unsigned int depth;
122 };
123 
124 typedef struct hipMipmappedArray* hipMipmappedArray_t;
125 
126 typedef const struct hipMipmappedArray* hipMipmappedArray_const_t;
127 
131 typedef enum hipResourceType {
132  hipResourceTypeArray = 0x00,
133  hipResourceTypeMipmappedArray = 0x01,
134  hipResourceTypeLinear = 0x02,
135  hipResourceTypePitch2D = 0x03
136 }hipResourceType;
137 
138 typedef enum HIPresourcetype_enum {
139  HIP_RESOURCE_TYPE_ARRAY = 0x00,
140  HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
141  HIP_RESOURCE_TYPE_LINEAR = 0x02,
142  HIP_RESOURCE_TYPE_PITCH2D = 0x03
143 } HIPresourcetype;
144 
148 typedef enum HIPaddress_mode_enum {
149  HIP_TR_ADDRESS_MODE_WRAP = 0,
150  HIP_TR_ADDRESS_MODE_CLAMP = 1,
151  HIP_TR_ADDRESS_MODE_MIRROR = 2,
152  HIP_TR_ADDRESS_MODE_BORDER = 3
153 } HIPaddress_mode;
154 
158 typedef enum HIPfilter_mode_enum {
159  HIP_TR_FILTER_MODE_POINT = 0,
160  HIP_TR_FILTER_MODE_LINEAR = 1
161 } HIPfilter_mode;
162 
166 typedef struct HIP_TEXTURE_DESC_st {
167  HIPaddress_mode addressMode[3];
168  HIPfilter_mode filterMode;
169  unsigned int flags;
170  unsigned int maxAnisotropy;
171  HIPfilter_mode mipmapFilterMode;
175  float borderColor[4];
176  int reserved[12];
178 
182 typedef enum hipResourceViewFormat {
183  hipResViewFormatNone = 0x00,
184  hipResViewFormatUnsignedChar1 = 0x01,
185  hipResViewFormatUnsignedChar2 = 0x02,
186  hipResViewFormatUnsignedChar4 = 0x03,
187  hipResViewFormatSignedChar1 = 0x04,
188  hipResViewFormatSignedChar2 = 0x05,
189  hipResViewFormatSignedChar4 = 0x06,
190  hipResViewFormatUnsignedShort1 = 0x07,
191  hipResViewFormatUnsignedShort2 = 0x08,
192  hipResViewFormatUnsignedShort4 = 0x09,
193  hipResViewFormatSignedShort1 = 0x0a,
194  hipResViewFormatSignedShort2 = 0x0b,
195  hipResViewFormatSignedShort4 = 0x0c,
196  hipResViewFormatUnsignedInt1 = 0x0d,
197  hipResViewFormatUnsignedInt2 = 0x0e,
198  hipResViewFormatUnsignedInt4 = 0x0f,
199  hipResViewFormatSignedInt1 = 0x10,
200  hipResViewFormatSignedInt2 = 0x11,
201  hipResViewFormatSignedInt4 = 0x12,
202  hipResViewFormatHalf1 = 0x13,
203  hipResViewFormatHalf2 = 0x14,
204  hipResViewFormatHalf4 = 0x15,
205  hipResViewFormatFloat1 = 0x16,
206  hipResViewFormatFloat2 = 0x17,
207  hipResViewFormatFloat4 = 0x18,
208  hipResViewFormatUnsignedBlockCompressed1 = 0x19,
209  hipResViewFormatUnsignedBlockCompressed2 = 0x1a,
210  hipResViewFormatUnsignedBlockCompressed3 = 0x1b,
211  hipResViewFormatUnsignedBlockCompressed4 = 0x1c,
212  hipResViewFormatSignedBlockCompressed4 = 0x1d,
213  hipResViewFormatUnsignedBlockCompressed5 = 0x1e,
214  hipResViewFormatSignedBlockCompressed5 = 0x1f,
215  hipResViewFormatUnsignedBlockCompressed6H = 0x20,
216  hipResViewFormatSignedBlockCompressed6H = 0x21,
217  hipResViewFormatUnsignedBlockCompressed7 = 0x22
218 }hipResourceViewFormat;
219 
220 typedef enum HIPresourceViewFormat_enum
221 {
222  HIP_RES_VIEW_FORMAT_NONE = 0x00,
223  HIP_RES_VIEW_FORMAT_UINT_1X8 = 0x01,
224  HIP_RES_VIEW_FORMAT_UINT_2X8 = 0x02,
225  HIP_RES_VIEW_FORMAT_UINT_4X8 = 0x03,
226  HIP_RES_VIEW_FORMAT_SINT_1X8 = 0x04,
227  HIP_RES_VIEW_FORMAT_SINT_2X8 = 0x05,
228  HIP_RES_VIEW_FORMAT_SINT_4X8 = 0x06,
229  HIP_RES_VIEW_FORMAT_UINT_1X16 = 0x07,
230  HIP_RES_VIEW_FORMAT_UINT_2X16 = 0x08,
231  HIP_RES_VIEW_FORMAT_UINT_4X16 = 0x09,
232  HIP_RES_VIEW_FORMAT_SINT_1X16 = 0x0a,
233  HIP_RES_VIEW_FORMAT_SINT_2X16 = 0x0b,
234  HIP_RES_VIEW_FORMAT_SINT_4X16 = 0x0c,
235  HIP_RES_VIEW_FORMAT_UINT_1X32 = 0x0d,
236  HIP_RES_VIEW_FORMAT_UINT_2X32 = 0x0e,
237  HIP_RES_VIEW_FORMAT_UINT_4X32 = 0x0f,
238  HIP_RES_VIEW_FORMAT_SINT_1X32 = 0x10,
239  HIP_RES_VIEW_FORMAT_SINT_2X32 = 0x11,
240  HIP_RES_VIEW_FORMAT_SINT_4X32 = 0x12,
241  HIP_RES_VIEW_FORMAT_FLOAT_1X16 = 0x13,
242  HIP_RES_VIEW_FORMAT_FLOAT_2X16 = 0x14,
243  HIP_RES_VIEW_FORMAT_FLOAT_4X16 = 0x15,
244  HIP_RES_VIEW_FORMAT_FLOAT_1X32 = 0x16,
245  HIP_RES_VIEW_FORMAT_FLOAT_2X32 = 0x17,
246  HIP_RES_VIEW_FORMAT_FLOAT_4X32 = 0x18,
247  HIP_RES_VIEW_FORMAT_UNSIGNED_BC1 = 0x19,
248  HIP_RES_VIEW_FORMAT_UNSIGNED_BC2 = 0x1a,
249  HIP_RES_VIEW_FORMAT_UNSIGNED_BC3 = 0x1b,
250  HIP_RES_VIEW_FORMAT_UNSIGNED_BC4 = 0x1c,
251  HIP_RES_VIEW_FORMAT_SIGNED_BC4 = 0x1d,
252  HIP_RES_VIEW_FORMAT_UNSIGNED_BC5 = 0x1e,
253  HIP_RES_VIEW_FORMAT_SIGNED_BC5 = 0x1f,
254  HIP_RES_VIEW_FORMAT_UNSIGNED_BC6H = 0x20,
255  HIP_RES_VIEW_FORMAT_SIGNED_BC6H = 0x21,
256  HIP_RES_VIEW_FORMAT_UNSIGNED_BC7 = 0x22
257 } HIPresourceViewFormat;
258 
262 typedef struct hipResourceDesc {
263  enum hipResourceType resType;
264 
265  union {
266  struct {
267  hipArray_t array;
268  } array;
269  struct {
270  hipMipmappedArray_t mipmap;
271  } mipmap;
272  struct {
273  void* devPtr;
274  struct hipChannelFormatDesc desc;
275  size_t sizeInBytes;
276  } linear;
277  struct {
278  void* devPtr;
279  struct hipChannelFormatDesc desc;
280  size_t width;
281  size_t height;
282  size_t pitchInBytes;
283  } pitch2D;
284  } res;
286 
287 typedef struct HIP_RESOURCE_DESC_st
288 {
289  HIPresourcetype resType;
291  union {
292  struct {
294  } array;
295  struct {
297  } mipmap;
298  struct {
299  hipDeviceptr_t devPtr;
300  hipArray_Format format;
301  unsigned int numChannels;
302  size_t sizeInBytes;
303  } linear;
304  struct {
305  hipDeviceptr_t devPtr;
306  hipArray_Format format;
307  unsigned int numChannels;
308  size_t width;
309  size_t height;
310  size_t pitchInBytes;
311  } pitch2D;
312  struct {
313  int reserved[32];
314  } reserved;
315  } res;
316 
317  unsigned int flags;
319 
324  enum hipResourceViewFormat format;
325  size_t width;
326  size_t height;
327  size_t depth;
328  unsigned int firstMipmapLevel;
329  unsigned int lastMipmapLevel;
330  unsigned int firstLayer;
331  unsigned int lastLayer;
332 };
333 
338 {
339  HIPresourceViewFormat format;
340  size_t width;
341  size_t height;
342  size_t depth;
343  unsigned int firstMipmapLevel;
344  unsigned int lastMipmapLevel;
345  unsigned int firstLayer;
346  unsigned int lastLayer;
347  unsigned int reserved[16];
349 
354 typedef enum hipMemcpyKind {
355  hipMemcpyHostToHost = 0,
356  hipMemcpyHostToDevice = 1,
357  hipMemcpyDeviceToHost = 2,
358  hipMemcpyDeviceToDevice = 3,
359  hipMemcpyDefault =
360  4
361 } hipMemcpyKind;
362 
363 typedef struct hipPitchedPtr {
364  void* ptr;
365  size_t pitch;
366  size_t xsize;
367  size_t ysize;
369 
370 typedef struct hipExtent {
371  size_t width; // Width in elements when referring to array memory, in bytes when referring to
372  // linear memory
373  size_t height;
374  size_t depth;
375 }hipExtent;
376 
377 typedef struct hipPos {
378  size_t x;
379  size_t y;
380  size_t z;
381 }hipPos;
382 
383 typedef struct hipMemcpy3DParms {
384  hipArray_t srcArray;
385  struct hipPos srcPos;
386  struct hipPitchedPtr srcPtr;
387  hipArray_t dstArray;
388  struct hipPos dstPos;
389  struct hipPitchedPtr dstPtr;
390  struct hipExtent extent;
391  enum hipMemcpyKind kind;
393 
394 typedef struct HIP_MEMCPY3D {
395  unsigned int srcXInBytes;
396  unsigned int srcY;
397  unsigned int srcZ;
398  unsigned int srcLOD;
399  hipMemoryType srcMemoryType;
400  const void* srcHost;
401  hipDeviceptr_t srcDevice;
402  hipArray_t srcArray;
403  unsigned int srcPitch;
404  unsigned int srcHeight;
405  unsigned int dstXInBytes;
406  unsigned int dstY;
407  unsigned int dstZ;
408  unsigned int dstLOD;
409  hipMemoryType dstMemoryType;
410  void* dstHost;
411  hipDeviceptr_t dstDevice;
412  hipArray_t dstArray;
413  unsigned int dstPitch;
414  unsigned int dstHeight;
415  unsigned int WidthInBytes;
416  unsigned int Height;
417  unsigned int Depth;
418 } HIP_MEMCPY3D;
419 
420 static inline struct hipPitchedPtr make_hipPitchedPtr(void* d, size_t p, size_t xsz,
421  size_t ysz) {
422  struct hipPitchedPtr s;
423 
424  s.ptr = d;
425  s.pitch = p;
426  s.xsize = xsz;
427  s.ysize = ysz;
428 
429  return s;
430 }
431 
432 static inline struct hipPos make_hipPos(size_t x, size_t y, size_t z) {
433  struct hipPos p;
434 
435  p.x = x;
436  p.y = y;
437  p.z = z;
438 
439  return p;
440 }
441 
442 static inline struct hipExtent make_hipExtent(size_t w, size_t h, size_t d) {
443  struct hipExtent e;
444 
445  e.width = w;
446  e.height = h;
447  e.depth = d;
448 
449  return e;
450 }
451 
452 typedef enum hipFunction_attribute {
453  HIP_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
454  HIP_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES,
455  HIP_FUNC_ATTRIBUTE_CONST_SIZE_BYTES,
456  HIP_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES,
457  HIP_FUNC_ATTRIBUTE_NUM_REGS,
458  HIP_FUNC_ATTRIBUTE_PTX_VERSION,
459  HIP_FUNC_ATTRIBUTE_BINARY_VERSION,
460  HIP_FUNC_ATTRIBUTE_CACHE_MODE_CA,
461  HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES,
462  HIP_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT,
463  HIP_FUNC_ATTRIBUTE_MAX
464 }hipFunction_attribute;
465 
466 #endif
HIP_RESOURCE_DESC_st::numChannels
unsigned int numChannels
Definition: driver_types.h:301
HIP_TEXTURE_DESC_st::maxAnisotropy
unsigned int maxAnisotropy
Definition: driver_types.h:170
HIP_TEXTURE_DESC_st::addressMode
HIPaddress_mode addressMode[3]
Definition: driver_types.h:167
HIP_TEXTURE_DESC_st::mipmapFilterMode
HIPfilter_mode mipmapFilterMode
Definition: driver_types.h:171
HIP_RESOURCE_DESC_st::hArray
hipArray_t hArray
Definition: driver_types.h:293
HIP_RESOURCE_DESC_st::flags
unsigned int flags
Definition: driver_types.h:317
HIP_TEXTURE_DESC_st::minMipmapLevelClamp
float minMipmapLevelClamp
Definition: driver_types.h:173
HIP_TEXTURE_DESC_st::flags
unsigned int flags
Definition: driver_types.h:169
HIP_MEMCPY3D
Definition: driver_types.h:394
HIP_RESOURCE_VIEW_DESC_st::lastMipmapLevel
unsigned int lastMipmapLevel
Definition: driver_types.h:344
HIP_RESOURCE_VIEW_DESC_st::depth
size_t depth
Definition: driver_types.h:342
HIP_RESOURCE_DESC_st::pitchInBytes
size_t pitchInBytes
Definition: driver_types.h:310
hip_Memcpy2D
Definition: driver_types.h:91
HIP_RESOURCE_VIEW_DESC_st::firstLayer
unsigned int firstLayer
Definition: driver_types.h:345
HIP_RESOURCE_VIEW_DESC_st::firstMipmapLevel
unsigned int firstMipmapLevel
Definition: driver_types.h:343
HIP_TEXTURE_DESC_st::borderColor
float borderColor[4]
Definition: driver_types.h:175
hipMemcpy3DParms
Definition: driver_types.h:383
HIP_RESOURCE_VIEW_DESC_st::width
size_t width
Definition: driver_types.h:340
hipMipmappedArray
Definition: driver_types.h:116
HIP_TEXTURE_DESC_st::filterMode
HIPfilter_mode filterMode
Definition: driver_types.h:168
HIP_TEXTURE_DESC_st
Definition: driver_types.h:166
hipArray
Definition: driver_types.h:78
HIP_TEXTURE_DESC_st::mipmapLevelBias
float mipmapLevelBias
Definition: driver_types.h:172
HIP_RESOURCE_DESC_st::sizeInBytes
size_t sizeInBytes
Definition: driver_types.h:302
HIP_ARRAY3D_DESCRIPTOR
Definition: driver_types.h:69
HIP_TEXTURE_DESC_st::maxMipmapLevelClamp
float maxMipmapLevelClamp
Definition: driver_types.h:174
HIP_RESOURCE_DESC_st::width
size_t width
Definition: driver_types.h:308
HIP_RESOURCE_VIEW_DESC_st::height
size_t height
Definition: driver_types.h:341
hipExtent
Definition: driver_types.h:370
hipPitchedPtr
Definition: driver_types.h:363
HIP_RESOURCE_DESC_st::format
hipArray_Format format
Definition: driver_types.h:300
HIP_RESOURCE_DESC_st::height
size_t height
Definition: driver_types.h:309
HIP_RESOURCE_DESC_st::devPtr
hipDeviceptr_t devPtr
Definition: driver_types.h:299
HIP_RESOURCE_DESC_st::resType
HIPresourcetype resType
Definition: driver_types.h:289
HIP_RESOURCE_DESC_st
Definition: driver_types.h:288
hipResourceViewDesc
Definition: driver_types.h:323
HIP_RESOURCE_DESC_st::hMipmappedArray
hipMipmappedArray_t hMipmappedArray
Definition: driver_types.h:296
HIP_ARRAY_DESCRIPTOR
Definition: driver_types.h:62
HIP_RESOURCE_VIEW_DESC_st::lastLayer
unsigned int lastLayer
Definition: driver_types.h:346
hipResourceDesc
Definition: driver_types.h:262
hipPos
Definition: driver_types.h:377
HIP_RESOURCE_VIEW_DESC_st
Definition: driver_types.h:338
hipMemoryType
hipMemoryType
Definition: hip_runtime_api.h:156
HIP_RESOURCE_VIEW_DESC_st::format
HIPresourceViewFormat format
Definition: driver_types.h:339
hipChannelFormatDesc
Definition: driver_types.h:38