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_TRSF_NORMALIZED_COORDINATES 0x01
47 #define HIP_TRSF_READ_AS_INTEGER 0x00
48 #define HIP_TRSA_OVERRIDE_FORMAT 0x01
49 
50 typedef enum hipArray_Format {
51  HIP_AD_FORMAT_UNSIGNED_INT8 = 0x01,
52  HIP_AD_FORMAT_UNSIGNED_INT16 = 0x02,
53  HIP_AD_FORMAT_UNSIGNED_INT32 = 0x03,
54  HIP_AD_FORMAT_SIGNED_INT8 = 0x08,
55  HIP_AD_FORMAT_SIGNED_INT16 = 0x09,
56  HIP_AD_FORMAT_SIGNED_INT32 = 0x0a,
57  HIP_AD_FORMAT_HALF = 0x10,
58  HIP_AD_FORMAT_FLOAT = 0x20
59 }hipArray_Format;
60 
61 typedef struct HIP_ARRAY_DESCRIPTOR {
62  size_t Width;
63  size_t Height;
64  enum hipArray_Format Format;
65  unsigned int NumChannels;
67 
68 typedef struct HIP_ARRAY3D_DESCRIPTOR {
69  size_t Width;
70  size_t Height;
71  size_t Depth;
72  enum hipArray_Format Format;
73  unsigned int NumChannels;
74  unsigned int Flags;
76 
77 typedef struct hipArray {
78  void* data; // FIXME: generalize this
79  struct hipChannelFormatDesc desc;
80  unsigned int type;
81  unsigned int width;
82  unsigned int height;
83  unsigned int depth;
84  enum hipArray_Format Format;
85  unsigned int NumChannels;
86  bool isDrv;
87  unsigned int textureType;
88 }hipArray;
89 
90 typedef struct hip_Memcpy2D {
91  size_t srcXInBytes;
92  size_t srcY;
93  hipMemoryType srcMemoryType;
94  const void* srcHost;
95  hipDeviceptr_t srcDevice;
96  hipArray* srcArray;
97  size_t srcPitch;
98  size_t dstXInBytes;
99  size_t dstY;
100  hipMemoryType dstMemoryType;
101  void* dstHost;
102  hipDeviceptr_t dstDevice;
103  hipArray* dstArray;
104  size_t dstPitch;
105  size_t WidthInBytes;
106  size_t Height;
107 } hip_Memcpy2D;
108 
109 
110 typedef struct hipArray* hipArray_t;
111 
112 typedef const struct hipArray* hipArray_const_t;
113 
114 // TODO: It needs to be modified since it was just copied from hipArray.
116  void* data; // FIXME: generalize this
117  struct hipChannelFormatDesc desc;
118  unsigned int width;
119  unsigned int height;
120  unsigned int depth;
121 };
122 
123 typedef struct hipMipmappedArray* hipMipmappedArray_t;
124 
125 typedef const struct hipMipmappedArray* hipMipmappedArray_const_t;
126 
130 typedef enum hipResourceType {
131  hipResourceTypeArray = 0x00,
132  hipResourceTypeMipmappedArray = 0x01,
133  hipResourceTypeLinear = 0x02,
134  hipResourceTypePitch2D = 0x03
135 }hipResourceType;
136 
140 typedef enum hipResourceViewFormat {
141  hipResViewFormatNone = 0x00,
142  hipResViewFormatUnsignedChar1 = 0x01,
143  hipResViewFormatUnsignedChar2 = 0x02,
144  hipResViewFormatUnsignedChar4 = 0x03,
145  hipResViewFormatSignedChar1 = 0x04,
146  hipResViewFormatSignedChar2 = 0x05,
147  hipResViewFormatSignedChar4 = 0x06,
148  hipResViewFormatUnsignedShort1 = 0x07,
149  hipResViewFormatUnsignedShort2 = 0x08,
150  hipResViewFormatUnsignedShort4 = 0x09,
151  hipResViewFormatSignedShort1 = 0x0a,
152  hipResViewFormatSignedShort2 = 0x0b,
153  hipResViewFormatSignedShort4 = 0x0c,
154  hipResViewFormatUnsignedInt1 = 0x0d,
155  hipResViewFormatUnsignedInt2 = 0x0e,
156  hipResViewFormatUnsignedInt4 = 0x0f,
157  hipResViewFormatSignedInt1 = 0x10,
158  hipResViewFormatSignedInt2 = 0x11,
159  hipResViewFormatSignedInt4 = 0x12,
160  hipResViewFormatHalf1 = 0x13,
161  hipResViewFormatHalf2 = 0x14,
162  hipResViewFormatHalf4 = 0x15,
163  hipResViewFormatFloat1 = 0x16,
164  hipResViewFormatFloat2 = 0x17,
165  hipResViewFormatFloat4 = 0x18,
166  hipResViewFormatUnsignedBlockCompressed1 = 0x19,
167  hipResViewFormatUnsignedBlockCompressed2 = 0x1a,
168  hipResViewFormatUnsignedBlockCompressed3 = 0x1b,
169  hipResViewFormatUnsignedBlockCompressed4 = 0x1c,
170  hipResViewFormatSignedBlockCompressed4 = 0x1d,
171  hipResViewFormatUnsignedBlockCompressed5 = 0x1e,
172  hipResViewFormatSignedBlockCompressed5 = 0x1f,
173  hipResViewFormatUnsignedBlockCompressed6H = 0x20,
174  hipResViewFormatSignedBlockCompressed6H = 0x21,
175  hipResViewFormatUnsignedBlockCompressed7 = 0x22
176 }hipResourceViewFormat;
177 
181 typedef struct hipResourceDesc {
182  enum hipResourceType resType;
183 
184  union {
185  struct {
186  hipArray_t array;
187  } array;
188  struct {
189  hipMipmappedArray_t mipmap;
190  } mipmap;
191  struct {
192  void* devPtr;
193  struct hipChannelFormatDesc desc;
194  size_t sizeInBytes;
195  } linear;
196  struct {
197  void* devPtr;
198  struct hipChannelFormatDesc desc;
199  size_t width;
200  size_t height;
201  size_t pitchInBytes;
202  } pitch2D;
203  } res;
205 
210  enum hipResourceViewFormat format;
211  size_t width;
212  size_t height;
213  size_t depth;
214  unsigned int firstMipmapLevel;
215  unsigned int lastMipmapLevel;
216  unsigned int firstLayer;
217  unsigned int lastLayer;
218 };
219 
224 typedef enum hipMemcpyKind {
225  hipMemcpyHostToHost = 0,
226  hipMemcpyHostToDevice = 1,
227  hipMemcpyDeviceToHost = 2,
228  hipMemcpyDeviceToDevice = 3,
229  hipMemcpyDefault =
230  4
231 } hipMemcpyKind;
232 
233 typedef struct hipPitchedPtr {
234  void* ptr;
235  size_t pitch;
236  size_t xsize;
237  size_t ysize;
239 
240 typedef struct hipExtent {
241  size_t width; // Width in elements when referring to array memory, in bytes when referring to
242  // linear memory
243  size_t height;
244  size_t depth;
245 }hipExtent;
246 
247 typedef struct hipPos {
248  size_t x;
249  size_t y;
250  size_t z;
251 }hipPos;
252 
253 typedef struct hipMemcpy3DParms {
254  hipArray_t srcArray;
255  struct hipPos srcPos;
256  struct hipPitchedPtr srcPtr;
257 
258  hipArray_t dstArray;
259  struct hipPos dstPos;
260  struct hipPitchedPtr dstPtr;
261 
262  struct hipExtent extent;
263  enum hipMemcpyKind kind;
264 
265  size_t Depth;
266  size_t Height;
267  size_t WidthInBytes;
268  hipDeviceptr_t dstDevice;
269  size_t dstHeight;
270  void* dstHost;
271  size_t dstLOD;
272  hipMemoryType dstMemoryType;
273  size_t dstPitch;
274  size_t dstXInBytes;
275  size_t dstY;
276  size_t dstZ;
277  void* reserved0;
278  void* reserved1;
279  hipDeviceptr_t srcDevice;
280  size_t srcHeight;
281  const void* srcHost;
282  size_t srcLOD;
283  hipMemoryType srcMemoryType;
284  size_t srcPitch;
285  size_t srcXInBytes;
286  size_t srcY;
287  size_t srcZ;
289 
290 static inline struct hipPitchedPtr make_hipPitchedPtr(void* d, size_t p, size_t xsz,
291  size_t ysz) {
292  struct hipPitchedPtr s;
293 
294  s.ptr = d;
295  s.pitch = p;
296  s.xsize = xsz;
297  s.ysize = ysz;
298 
299  return s;
300 }
301 
302 static inline struct hipPos make_hipPos(size_t x, size_t y, size_t z) {
303  struct hipPos p;
304 
305  p.x = x;
306  p.y = y;
307  p.z = z;
308 
309  return p;
310 }
311 
312 static inline struct hipExtent make_hipExtent(size_t w, size_t h, size_t d) {
313  struct hipExtent e;
314 
315  e.width = w;
316  e.height = h;
317  e.depth = d;
318 
319  return e;
320 }
321 
322 typedef enum hipFunction_attribute {
323  HIP_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
324  HIP_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES,
325  HIP_FUNC_ATTRIBUTE_CONST_SIZE_BYTES,
326  HIP_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES,
327  HIP_FUNC_ATTRIBUTE_NUM_REGS,
328  HIP_FUNC_ATTRIBUTE_PTX_VERSION,
329  HIP_FUNC_ATTRIBUTE_BINARY_VERSION,
330  HIP_FUNC_ATTRIBUTE_CACHE_MODE_CA,
331  HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES,
332  HIP_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT,
333  HIP_FUNC_ATTRIBUTE_MAX
334 }hipFunction_attribute;
335 
336 #endif
Definition: driver_types.h:247
Definition: driver_types.h:240
Definition: driver_types.h:181
Definition: driver_types.h:115
Definition: driver_types.h:77
Definition: driver_types.h:68
Definition: driver_types.h:253
Definition: driver_types.h:61
Definition: driver_types.h:233
Definition: driver_types.h:38
Definition: driver_types.h:90
Definition: driver_types.h:209