HIP: Heterogenous-computing Interface for Portability
Loading...
Searching...
No Matches
driver_types.h
1/*
2Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23#ifndef HIP_INCLUDE_HIP_DRIVER_TYPES_H
24#define HIP_INCLUDE_HIP_DRIVER_TYPES_H
25
26#include <hip/hip_common.h>
27
28#if !(defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && (defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
29#include "driver_types.h"
30#elif (defined(__HIP_PLATFORM_HCC__) || defined(__HIP_PLATFORM_AMD__)) && !(defined(__HIP_PLATFORM_NVCC__) || defined(__HIP_PLATFORM_NVIDIA__))
31
32// The follow macro should be removed after upstream updation.
33// It's defined here for workarround of rocThrust building failure.
34#define HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H
35#if !defined(__HIPCC_RTC__)
36#ifndef __cplusplus
37#include <stdbool.h>
38#endif
39#endif // !defined(__HIPCC_RTC__)
40typedef void* hipDeviceptr_t;
41typedef enum hipChannelFormatKind {
42 hipChannelFormatKindSigned = 0,
43 hipChannelFormatKindUnsigned = 1,
44 hipChannelFormatKindFloat = 2,
45 hipChannelFormatKindNone = 3
46}hipChannelFormatKind;
47typedef struct hipChannelFormatDesc {
48 int x;
49 int y;
50 int z;
51 int w;
52 enum hipChannelFormatKind f;
54#define HIP_TRSA_OVERRIDE_FORMAT 0x01
55#define HIP_TRSF_READ_AS_INTEGER 0x01
56#define HIP_TRSF_NORMALIZED_COORDINATES 0x02
57#define HIP_TRSF_SRGB 0x10
58typedef enum hipArray_Format {
59 HIP_AD_FORMAT_UNSIGNED_INT8 = 0x01,
60 HIP_AD_FORMAT_UNSIGNED_INT16 = 0x02,
61 HIP_AD_FORMAT_UNSIGNED_INT32 = 0x03,
62 HIP_AD_FORMAT_SIGNED_INT8 = 0x08,
63 HIP_AD_FORMAT_SIGNED_INT16 = 0x09,
64 HIP_AD_FORMAT_SIGNED_INT32 = 0x0a,
65 HIP_AD_FORMAT_HALF = 0x10,
66 HIP_AD_FORMAT_FLOAT = 0x20
67}hipArray_Format;
68typedef struct HIP_ARRAY_DESCRIPTOR {
69 size_t Width;
70 size_t Height;
71 enum hipArray_Format Format;
72 unsigned int NumChannels;
74typedef struct HIP_ARRAY3D_DESCRIPTOR {
75 size_t Width;
76 size_t Height;
77 size_t Depth;
78 enum hipArray_Format Format;
79 unsigned int NumChannels;
80 unsigned int Flags;
82typedef 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;
94#if !defined(__HIPCC_RTC__)
95typedef 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;
113#endif // !defined(__HIPCC_RTC__)
114typedef struct hipArray* hipArray_t;
115typedef hipArray_t hiparray;
116typedef const struct hipArray* hipArray_const_t;
117typedef struct hipMipmappedArray {
118 void* data;
119 struct hipChannelFormatDesc desc;
120 unsigned int type;
121 unsigned int width;
122 unsigned int height;
123 unsigned int depth;
124 unsigned int min_mipmap_level;
125 unsigned int max_mipmap_level;
126 unsigned int flags;
127 enum hipArray_Format format;
130typedef const struct hipMipmappedArray* hipMipmappedArray_const_t;
134typedef enum hipResourceType {
135 hipResourceTypeArray = 0x00,
136 hipResourceTypeMipmappedArray = 0x01,
137 hipResourceTypeLinear = 0x02,
138 hipResourceTypePitch2D = 0x03
139}hipResourceType;
140typedef enum HIPresourcetype_enum {
141 HIP_RESOURCE_TYPE_ARRAY = 0x00,
142 HIP_RESOURCE_TYPE_MIPMAPPED_ARRAY = 0x01,
143 HIP_RESOURCE_TYPE_LINEAR = 0x02,
144 HIP_RESOURCE_TYPE_PITCH2D = 0x03
145} HIPresourcetype;
149typedef enum HIPaddress_mode_enum {
150 HIP_TR_ADDRESS_MODE_WRAP = 0,
151 HIP_TR_ADDRESS_MODE_CLAMP = 1,
152 HIP_TR_ADDRESS_MODE_MIRROR = 2,
153 HIP_TR_ADDRESS_MODE_BORDER = 3
154} HIPaddress_mode;
158typedef enum HIPfilter_mode_enum {
159 HIP_TR_FILTER_MODE_POINT = 0,
160 HIP_TR_FILTER_MODE_LINEAR = 1
161} HIPfilter_mode;
165typedef struct HIP_TEXTURE_DESC_st {
166 HIPaddress_mode addressMode[3];
167 HIPfilter_mode filterMode;
168 unsigned int flags;
169 unsigned int maxAnisotropy;
170 HIPfilter_mode mipmapFilterMode;
174 float borderColor[4];
175 int reserved[12];
180typedef enum hipResourceViewFormat {
181 hipResViewFormatNone = 0x00,
182 hipResViewFormatUnsignedChar1 = 0x01,
183 hipResViewFormatUnsignedChar2 = 0x02,
184 hipResViewFormatUnsignedChar4 = 0x03,
185 hipResViewFormatSignedChar1 = 0x04,
186 hipResViewFormatSignedChar2 = 0x05,
187 hipResViewFormatSignedChar4 = 0x06,
188 hipResViewFormatUnsignedShort1 = 0x07,
189 hipResViewFormatUnsignedShort2 = 0x08,
190 hipResViewFormatUnsignedShort4 = 0x09,
191 hipResViewFormatSignedShort1 = 0x0a,
192 hipResViewFormatSignedShort2 = 0x0b,
193 hipResViewFormatSignedShort4 = 0x0c,
194 hipResViewFormatUnsignedInt1 = 0x0d,
195 hipResViewFormatUnsignedInt2 = 0x0e,
196 hipResViewFormatUnsignedInt4 = 0x0f,
197 hipResViewFormatSignedInt1 = 0x10,
198 hipResViewFormatSignedInt2 = 0x11,
199 hipResViewFormatSignedInt4 = 0x12,
200 hipResViewFormatHalf1 = 0x13,
201 hipResViewFormatHalf2 = 0x14,
202 hipResViewFormatHalf4 = 0x15,
203 hipResViewFormatFloat1 = 0x16,
204 hipResViewFormatFloat2 = 0x17,
205 hipResViewFormatFloat4 = 0x18,
206 hipResViewFormatUnsignedBlockCompressed1 = 0x19,
207 hipResViewFormatUnsignedBlockCompressed2 = 0x1a,
208 hipResViewFormatUnsignedBlockCompressed3 = 0x1b,
209 hipResViewFormatUnsignedBlockCompressed4 = 0x1c,
210 hipResViewFormatSignedBlockCompressed4 = 0x1d,
211 hipResViewFormatUnsignedBlockCompressed5 = 0x1e,
212 hipResViewFormatSignedBlockCompressed5 = 0x1f,
213 hipResViewFormatUnsignedBlockCompressed6H = 0x20,
214 hipResViewFormatSignedBlockCompressed6H = 0x21,
215 hipResViewFormatUnsignedBlockCompressed7 = 0x22
216}hipResourceViewFormat;
217typedef enum HIPresourceViewFormat_enum
218{
219 HIP_RES_VIEW_FORMAT_NONE = 0x00,
220 HIP_RES_VIEW_FORMAT_UINT_1X8 = 0x01,
221 HIP_RES_VIEW_FORMAT_UINT_2X8 = 0x02,
222 HIP_RES_VIEW_FORMAT_UINT_4X8 = 0x03,
223 HIP_RES_VIEW_FORMAT_SINT_1X8 = 0x04,
224 HIP_RES_VIEW_FORMAT_SINT_2X8 = 0x05,
225 HIP_RES_VIEW_FORMAT_SINT_4X8 = 0x06,
226 HIP_RES_VIEW_FORMAT_UINT_1X16 = 0x07,
227 HIP_RES_VIEW_FORMAT_UINT_2X16 = 0x08,
228 HIP_RES_VIEW_FORMAT_UINT_4X16 = 0x09,
229 HIP_RES_VIEW_FORMAT_SINT_1X16 = 0x0a,
230 HIP_RES_VIEW_FORMAT_SINT_2X16 = 0x0b,
231 HIP_RES_VIEW_FORMAT_SINT_4X16 = 0x0c,
232 HIP_RES_VIEW_FORMAT_UINT_1X32 = 0x0d,
233 HIP_RES_VIEW_FORMAT_UINT_2X32 = 0x0e,
234 HIP_RES_VIEW_FORMAT_UINT_4X32 = 0x0f,
235 HIP_RES_VIEW_FORMAT_SINT_1X32 = 0x10,
236 HIP_RES_VIEW_FORMAT_SINT_2X32 = 0x11,
237 HIP_RES_VIEW_FORMAT_SINT_4X32 = 0x12,
238 HIP_RES_VIEW_FORMAT_FLOAT_1X16 = 0x13,
239 HIP_RES_VIEW_FORMAT_FLOAT_2X16 = 0x14,
240 HIP_RES_VIEW_FORMAT_FLOAT_4X16 = 0x15,
241 HIP_RES_VIEW_FORMAT_FLOAT_1X32 = 0x16,
242 HIP_RES_VIEW_FORMAT_FLOAT_2X32 = 0x17,
243 HIP_RES_VIEW_FORMAT_FLOAT_4X32 = 0x18,
244 HIP_RES_VIEW_FORMAT_UNSIGNED_BC1 = 0x19,
245 HIP_RES_VIEW_FORMAT_UNSIGNED_BC2 = 0x1a,
246 HIP_RES_VIEW_FORMAT_UNSIGNED_BC3 = 0x1b,
247 HIP_RES_VIEW_FORMAT_UNSIGNED_BC4 = 0x1c,
248 HIP_RES_VIEW_FORMAT_SIGNED_BC4 = 0x1d,
249 HIP_RES_VIEW_FORMAT_UNSIGNED_BC5 = 0x1e,
250 HIP_RES_VIEW_FORMAT_SIGNED_BC5 = 0x1f,
251 HIP_RES_VIEW_FORMAT_UNSIGNED_BC6H = 0x20,
252 HIP_RES_VIEW_FORMAT_SIGNED_BC6H = 0x21,
253 HIP_RES_VIEW_FORMAT_UNSIGNED_BC7 = 0x22
254} HIPresourceViewFormat;
258typedef struct hipResourceDesc {
259 enum hipResourceType resType;
260 union {
261 struct {
262 hipArray_t array;
263 } array;
264 struct {
265 hipMipmappedArray_t mipmap;
266 } mipmap;
267 struct {
268 void* devPtr;
269 struct hipChannelFormatDesc desc;
270 size_t sizeInBytes;
271 } linear;
272 struct {
273 void* devPtr;
274 struct hipChannelFormatDesc desc;
275 size_t width;
276 size_t height;
277 size_t pitchInBytes;
278 } pitch2D;
279 } res;
282{
283 HIPresourcetype resType;
284 union {
285 struct {
287 } array;
288 struct {
290 } mipmap;
291 struct {
292 hipDeviceptr_t devPtr;
293 hipArray_Format format;
294 unsigned int numChannels;
295 size_t sizeInBytes;
296 } linear;
297 struct {
298 hipDeviceptr_t devPtr;
299 hipArray_Format format;
300 unsigned int numChannels;
301 size_t width;
302 size_t height;
304 } pitch2D;
305 struct {
306 int reserved[32];
307 } reserved;
308 } res;
309 unsigned int flags;
315 enum hipResourceViewFormat format;
316 size_t width;
317 size_t height;
318 size_t depth;
319 unsigned int firstMipmapLevel;
320 unsigned int lastMipmapLevel;
321 unsigned int firstLayer;
322 unsigned int lastLayer;
323};
328{
329 HIPresourceViewFormat format;
330 size_t width;
331 size_t height;
332 size_t depth;
333 unsigned int firstMipmapLevel;
334 unsigned int lastMipmapLevel;
335 unsigned int firstLayer;
336 unsigned int lastLayer;
337 unsigned int reserved[16];
343#if !defined(__HIPCC_RTC__)
344typedef enum hipMemcpyKind {
345 hipMemcpyHostToHost = 0,
346 hipMemcpyHostToDevice = 1,
347 hipMemcpyDeviceToHost = 2,
348 hipMemcpyDeviceToDevice = 3,
349 hipMemcpyDefault =
350 4
351} hipMemcpyKind;
352typedef struct hipPitchedPtr {
353 void* ptr;
354 size_t pitch;
355 size_t xsize;
356 size_t ysize;
358typedef struct hipExtent {
359 size_t width; // Width in elements when referring to array memory, in bytes when referring to
360 // linear memory
361 size_t height;
362 size_t depth;
363}hipExtent;
364typedef struct hipPos {
365 size_t x;
366 size_t y;
367 size_t z;
368}hipPos;
369typedef struct hipMemcpy3DParms {
370 hipArray_t srcArray;
371 struct hipPos srcPos;
372 struct hipPitchedPtr srcPtr;
373 hipArray_t dstArray;
374 struct hipPos dstPos;
375 struct hipPitchedPtr dstPtr;
376 struct hipExtent extent;
377 enum hipMemcpyKind kind;
379typedef struct HIP_MEMCPY3D {
380 unsigned int srcXInBytes;
381 unsigned int srcY;
382 unsigned int srcZ;
383 unsigned int srcLOD;
384 hipMemoryType srcMemoryType;
385 const void* srcHost;
386 hipDeviceptr_t srcDevice;
387 hipArray_t srcArray;
388 unsigned int srcPitch;
389 unsigned int srcHeight;
390 unsigned int dstXInBytes;
391 unsigned int dstY;
392 unsigned int dstZ;
393 unsigned int dstLOD;
394 hipMemoryType dstMemoryType;
395 void* dstHost;
396 hipDeviceptr_t dstDevice;
397 hipArray_t dstArray;
398 unsigned int dstPitch;
399 unsigned int dstHeight;
400 unsigned int WidthInBytes;
401 unsigned int Height;
402 unsigned int Depth;
404static inline struct hipPitchedPtr make_hipPitchedPtr(void* d, size_t p, size_t xsz,
405 size_t ysz) {
406 struct hipPitchedPtr s;
407 s.ptr = d;
408 s.pitch = p;
409 s.xsize = xsz;
410 s.ysize = ysz;
411 return s;
412}
413static inline struct hipPos make_hipPos(size_t x, size_t y, size_t z) {
414 struct hipPos p;
415 p.x = x;
416 p.y = y;
417 p.z = z;
418 return p;
419}
420static inline struct hipExtent make_hipExtent(size_t w, size_t h, size_t d) {
421 struct hipExtent e;
422 e.width = w;
423 e.height = h;
424 e.depth = d;
425 return e;
426}
427typedef enum hipFunction_attribute {
428 HIP_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
429 HIP_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES,
430 HIP_FUNC_ATTRIBUTE_CONST_SIZE_BYTES,
431 HIP_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES,
432 HIP_FUNC_ATTRIBUTE_NUM_REGS,
433 HIP_FUNC_ATTRIBUTE_PTX_VERSION,
434 HIP_FUNC_ATTRIBUTE_BINARY_VERSION,
435 HIP_FUNC_ATTRIBUTE_CACHE_MODE_CA,
436 HIP_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES,
437 HIP_FUNC_ATTRIBUTE_PREFERRED_SHARED_MEMORY_CARVEOUT,
438 HIP_FUNC_ATTRIBUTE_MAX
439} hipFunction_attribute;
440
441typedef enum hipPointer_attribute {
442 HIP_POINTER_ATTRIBUTE_CONTEXT = 1,
444 HIP_POINTER_ATTRIBUTE_MEMORY_TYPE,
445 HIP_POINTER_ATTRIBUTE_DEVICE_POINTER,
446 HIP_POINTER_ATTRIBUTE_HOST_POINTER,
447 HIP_POINTER_ATTRIBUTE_P2P_TOKENS,
449 HIP_POINTER_ATTRIBUTE_SYNC_MEMOPS,
451 HIP_POINTER_ATTRIBUTE_BUFFER_ID,
452 HIP_POINTER_ATTRIBUTE_IS_MANAGED,
453 HIP_POINTER_ATTRIBUTE_DEVICE_ORDINAL,
455 HIP_POINTER_ATTRIBUTE_IS_LEGACY_HIP_IPC_CAPABLE,
458 HIP_POINTER_ATTRIBUTE_RANGE_START_ADDR,
459 HIP_POINTER_ATTRIBUTE_RANGE_SIZE,
460 HIP_POINTER_ATTRIBUTE_MAPPED,
462 HIP_POINTER_ATTRIBUTE_ALLOWED_HANDLE_TYPES,
464 HIP_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE,
467 HIP_POINTER_ATTRIBUTE_ACCESS_FLAGS,
469 HIP_POINTER_ATTRIBUTE_MEMPOOL_HANDLE
472} hipPointer_attribute;
473
474#endif // !defined(__HIPCC_RTC__)
475#else
476#error("Must define exactly one of __HIP_PLATFORM_AMD__ or __HIP_PLATFORM_NVIDIA__");
477#endif
478#endif
hipMemoryType
Definition hip_runtime_api.h:159
Definition driver_types.h:74
Definition driver_types.h:68
Definition driver_types.h:379
Definition driver_types.h:282
hipArray_t hArray
Definition driver_types.h:286
HIPresourcetype resType
Definition driver_types.h:283
unsigned int numChannels
Definition driver_types.h:294
hipMipmappedArray_t hMipmappedArray
Definition driver_types.h:289
hipArray_Format format
Definition driver_types.h:293
unsigned int flags
Definition driver_types.h:309
size_t pitchInBytes
Definition driver_types.h:303
size_t width
Definition driver_types.h:301
size_t height
Definition driver_types.h:302
size_t sizeInBytes
Definition driver_types.h:295
hipDeviceptr_t devPtr
Definition driver_types.h:292
Definition driver_types.h:328
size_t width
Definition driver_types.h:330
unsigned int firstLayer
Definition driver_types.h:335
unsigned int lastMipmapLevel
Definition driver_types.h:334
size_t depth
Definition driver_types.h:332
unsigned int lastLayer
Definition driver_types.h:336
unsigned int firstMipmapLevel
Definition driver_types.h:333
size_t height
Definition driver_types.h:331
HIPresourceViewFormat format
Definition driver_types.h:329
Definition driver_types.h:165
float maxMipmapLevelClamp
Definition driver_types.h:173
unsigned int maxAnisotropy
Definition driver_types.h:169
float mipmapLevelBias
Definition driver_types.h:171
unsigned int flags
Definition driver_types.h:168
float borderColor[4]
Definition driver_types.h:174
HIPaddress_mode addressMode[3]
Definition driver_types.h:166
HIPfilter_mode mipmapFilterMode
Definition driver_types.h:170
float minMipmapLevelClamp
Definition driver_types.h:172
HIPfilter_mode filterMode
Definition driver_types.h:167
Definition driver_types.h:82
Definition driver_types.h:47
Definition driver_types.h:358
Definition driver_types.h:369
Definition driver_types.h:117
Definition driver_types.h:352
Definition driver_types.h:364
Definition driver_types.h:258
Definition driver_types.h:314
Definition driver_types.h:95