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