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