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