HIP: Heterogenous-computing Interface for Portability
hip_runtime_api.h
Go to the documentation of this file.
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 //#pragma once
24 #ifndef HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H
25 #define HIP_INCLUDE_HIP_HCC_DETAIL_HIP_RUNTIME_API_H
26 
31 #include <stdint.h>
32 #include <stddef.h>
33 
34 #ifndef GENERIC_GRID_LAUNCH
35 #define GENERIC_GRID_LAUNCH 1
36 #endif
37 
38 #ifndef __HIP_VDI__
39 #define __HIP_VDI__ 0
40 #endif
41 
43 #include <hip/hip_runtime_api.h>
44 #include <hip/hcc_detail/driver_types.h>
47 
48 #if !__HIP_VDI__
49 #include <hsa/hsa.h>
50 #include <hip/hcc_detail/program_state.hpp>
51 #endif
52 
53 #if defined(_MSC_VER)
54 #define DEPRECATED(msg) __declspec(deprecated(msg))
55 #else // !defined(_MSC_VER)
56 #define DEPRECATED(msg) __attribute__ ((deprecated(msg)))
57 #endif // !defined(_MSC_VER)
58 
59 #define DEPRECATED_MSG "This API is marked as deprecated and may not be supported in future releases.For more details please refer https://github.com/ROCm-Developer-Tools/HIP/tree/master/docs/markdown/hip_deprecated_api_list"
60 
61 #if defined(__HCC__) && (__hcc_workweek__ < 16155)
62 #error("This version of HIP requires a newer version of HCC.");
63 #endif
64 
65 #define HIP_LAUNCH_PARAM_BUFFER_POINTER ((void*)0x01)
66 #define HIP_LAUNCH_PARAM_BUFFER_SIZE ((void*)0x02)
67 #define HIP_LAUNCH_PARAM_END ((void*)0x03)
68 
69 #ifdef __cplusplus
70  #include <mutex>
71  #include <string>
72  #include <unordered_map>
73  #include <vector>
74 
75  #define __dparm(x) \
76  = x
77 #else
78  #define __dparm(x)
79 #endif
80 
81 namespace hip_impl {
82 hipError_t hip_init();
83 } // namespace hip_impl
84 
85 // Structure definitions:
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89 
90 //---
91 // API-visible structures
92 typedef struct ihipCtx_t* hipCtx_t;
93 
94 // Note many APIs also use integer deviceIds as an alternative to the device pointer:
95 typedef int hipDevice_t;
96 
97 typedef struct ihipStream_t* hipStream_t;
98 
99 // TODO: IPC implementation
100 
101 #define hipIpcMemLazyEnablePeerAccess 0
102 
103 #define HIP_IPC_HANDLE_SIZE 64
104 
105 typedef struct hipIpcMemHandle_st {
106  char reserved[HIP_IPC_HANDLE_SIZE];
108 
109 // TODO: IPC event handle currently unsupported
110 struct ihipIpcEventHandle_t;
111 typedef struct ihipIpcEventHandle_t* hipIpcEventHandle_t;
112 
113 
114 // END TODO
115 
116 typedef struct ihipModule_t* hipModule_t;
117 
118 typedef struct ihipModuleSymbol_t* hipFunction_t;
119 
120 typedef struct hipFuncAttributes {
121  int binaryVersion;
122  int cacheModeCA;
123  size_t constSizeBytes;
124  size_t localSizeBytes;
125  int maxDynamicSharedSizeBytes;
126  int maxThreadsPerBlock;
127  int numRegs;
128  int preferredShmemCarveout;
129  int ptxVersion;
130  size_t sharedSizeBytes;
132 
133 typedef struct ihipEvent_t* hipEvent_t;
134 
135 enum hipLimit_t {
136  hipLimitMallocHeapSize = 0x02,
137 };
138 
143 #define hipStreamDefault \
145  0x00
146 #define hipStreamNonBlocking 0x01
147 
148 
150 #define hipEventDefault 0x0
151 #define hipEventBlockingSync \
152  0x1
153 #define hipEventDisableTiming \
154  0x2
155 #define hipEventInterprocess 0x4
156 #define hipEventReleaseToDevice \
157  0x40000000
158 #define hipEventReleaseToSystem \
161  0x80000000
162 
165 
167 #define hipHostMallocDefault 0x0
168 #define hipHostMallocPortable 0x1
169 #define hipHostMallocMapped \
170  0x2
171 #define hipHostMallocWriteCombined 0x4
173 #define hipHostMallocCoherent \
174  0x40000000
175 #define hipHostMallocNonCoherent \
177  0x80000000
178 
180 #define hipDeviceMallocDefault 0x0
181 #define hipDeviceMallocFinegrained 0x1
182 
183 #define hipHostRegisterDefault 0x0
185 #define hipHostRegisterPortable 0x1
186 #define hipHostRegisterMapped \
187  0x2
188 #define hipHostRegisterIoMemory 0x4
190 
191 
192 #define hipDeviceScheduleAuto 0x0
193 #define hipDeviceScheduleSpin \
194  0x1
195 #define hipDeviceScheduleYield \
197  0x2
198 #define hipDeviceScheduleBlockingSync 0x4
200 #define hipDeviceScheduleMask 0x7
201 
202 #define hipDeviceMapHost 0x8
203 #define hipDeviceLmemResizeToMax 0x16
204 
205 #define hipArrayDefault 0x00
206 #define hipArrayLayered 0x01
207 #define hipArraySurfaceLoadStore 0x02
208 #define hipArrayCubemap 0x04
209 #define hipArrayTextureGather 0x08
210 
211 /*
212  * @brief hipJitOption
213  * @enum
214  * @ingroup Enumerations
215  */
216 typedef enum hipJitOption {
217  hipJitOptionMaxRegisters = 0,
218  hipJitOptionThreadsPerBlock,
219  hipJitOptionWallTime,
220  hipJitOptionInfoLogBuffer,
221  hipJitOptionInfoLogBufferSizeBytes,
222  hipJitOptionErrorLogBuffer,
223  hipJitOptionErrorLogBufferSizeBytes,
224  hipJitOptionOptimizationLevel,
225  hipJitOptionTargetFromContext,
226  hipJitOptionTarget,
227  hipJitOptionFallbackStrategy,
228  hipJitOptionGenerateDebugInfo,
229  hipJitOptionLogVerbose,
230  hipJitOptionGenerateLineInfo,
231  hipJitOptionCacheMode,
232  hipJitOptionSm3xOpt,
233  hipJitOptionFastCompile,
234  hipJitOptionNumOptions
235 } hipJitOption;
236 
237 
241 typedef enum hipFuncCache_t {
247 
248 
252 typedef enum hipSharedMemConfig {
259 
260 
265 typedef struct dim3 {
266  uint32_t x;
267  uint32_t y;
268  uint32_t z;
269 #ifdef __cplusplus
270  dim3(uint32_t _x = 1, uint32_t _y = 1, uint32_t _z = 1) : x(_x), y(_y), z(_z){};
271 #endif
272 } dim3;
273 
274 
275 // Doxygen end group GlobalDefs
279 //-------------------------------------------------------------------------------------------------
280 
281 
282 // The handle allows the async commands to use the stream even if the parent hipStream_t goes
283 // out-of-scope.
284 // typedef class ihipStream_t * hipStream_t;
285 
286 
287 /*
288  * Opaque structure allows the true event (pointed at by the handle) to remain "live" even if the
289  * surrounding hipEvent_t goes out-of-scope. This is handy for cases where the hipEvent_t goes
290  * out-of-scope but the true event is being written by some async queue or device */
291 // typedef struct hipEvent_t {
292 // struct ihipEvent_t *_handle;
293 //} hipEvent_t;
294 
295 
321 hipError_t hipDeviceSynchronize(void);
322 
323 
335 hipError_t hipDeviceReset(void);
336 
337 
369 hipError_t hipSetDevice(int deviceId);
370 
371 
385 hipError_t hipGetDevice(int* deviceId);
386 
387 
400 hipError_t hipGetDeviceCount(int* count);
401 
411 hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int deviceId);
412 
426 hipError_t hipGetDeviceProperties(hipDeviceProp_t* prop, int deviceId);
427 
428 
439 hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig);
440 
441 
452 hipError_t hipDeviceGetCacheConfig(hipFuncCache_t* cacheConfig);
453 
464 hipError_t hipDeviceGetLimit(size_t* pValue, enum hipLimit_t limit);
465 
466 
477 hipError_t hipFuncSetCacheConfig(const void* func, hipFuncCache_t config);
478 
490 hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig* pConfig);
491 
492 
504 hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config);
505 
530 hipError_t hipSetDeviceFlags(unsigned flags);
531 
540 hipError_t hipChooseDevice(int* device, const hipDeviceProp_t* prop);
541 
542 // end doxygen Device
565 hipError_t hipGetLastError(void);
566 
567 
578 hipError_t hipPeekAtLastError(void);
579 
580 
589 const char* hipGetErrorName(hipError_t hip_error);
590 
591 
602 const char* hipGetErrorString(hipError_t hipError);
603 
604 // end doxygen Error
637 hipError_t hipStreamCreate(hipStream_t* stream);
638 
639 
657 hipError_t hipStreamCreateWithFlags(hipStream_t* stream, unsigned int flags);
658 
659 
678 hipError_t hipStreamCreateWithPriority(hipStream_t* stream, unsigned int flags, int priority);
679 
680 
695 hipError_t hipDeviceGetStreamPriorityRange(int* leastPriority, int* greatestPriority);
696 
697 
716 hipError_t hipStreamDestroy(hipStream_t stream);
717 
718 
734 hipError_t hipStreamQuery(hipStream_t stream);
735 
736 
756 hipError_t hipStreamSynchronize(hipStream_t stream);
757 
758 
778 hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags);
779 
780 
794 hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int* flags);
795 
796 
810 hipError_t hipStreamGetPriority(hipStream_t stream, int* priority);
811 
812 
816 typedef void (*hipStreamCallback_t)(hipStream_t stream, hipError_t status, void* userData);
817 
833 hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void* userData,
834  unsigned int flags);
835 
836 
837 // end doxygen Stream
874 hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags);
875 
876 
888 hipError_t hipEventCreate(hipEvent_t* event);
889 
890 
918 #ifdef __cplusplus
919 hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream = NULL);
920 #else
921 hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream);
922 #endif
923 
940 hipError_t hipEventDestroy(hipEvent_t event);
941 
942 
960 hipError_t hipEventSynchronize(hipEvent_t event);
961 
962 
991 hipError_t hipEventElapsedTime(float* ms, hipEvent_t start, hipEvent_t stop);
992 
993 
1009 hipError_t hipEventQuery(hipEvent_t event);
1010 
1011 
1012 // end doxygen Events
1043 hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr);
1044 
1058 hipError_t hipMalloc(void** ptr, size_t size);
1059 
1074 hipError_t hipExtMallocWithFlags(void** ptr, size_t sizeBytes, unsigned int flags);
1075 
1088 DEPRECATED("use hipHostMalloc instead")
1089 hipError_t hipMallocHost(void** ptr, size_t size);
1090 
1104 hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int flags);
1105 
1119 DEPRECATED("use hipHostMalloc instead")
1120 hipError_t hipHostAlloc(void** ptr, size_t size, unsigned int flags);
1121 
1133 hipError_t hipHostGetDevicePointer(void** devPtr, void* hstPtr, unsigned int flags);
1134 
1144 hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr);
1145 
1182 hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags);
1183 
1192 hipError_t hipHostUnregister(void* hostPtr);
1193 
1213 hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height);
1214 
1228 hipError_t hipFree(void* ptr);
1229 
1240 DEPRECATED("use hipHostFree instead")
1241 hipError_t hipFreeHost(void* ptr);
1242 
1256 hipError_t hipHostFree(void* ptr);
1257 
1285 hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind);
1286 
1304 hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes);
1305 
1323 hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes);
1324 
1342 hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes);
1343 
1361 hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream);
1362 
1380 hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream);
1381 
1399 hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes,
1400  hipStream_t stream);
1401 
1402 #if __HIP_VDI__
1403 hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes,
1404  hipModule_t hmod, const char* name);
1405 
1406 hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName);
1407 hipError_t hipGetSymbolSize(size_t* size, const void* symbolName);
1408 hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src,
1409  size_t sizeBytes, size_t offset __dparm(0),
1410  hipMemcpyKind kind __dparm(hipMemcpyHostToDevice));
1411 hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src,
1412  size_t sizeBytes, size_t offset,
1413  hipMemcpyKind kind, hipStream_t stream __dparm(0));
1414 hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName,
1415  size_t sizeBytes, size_t offset __dparm(0),
1416  hipMemcpyKind kind __dparm(hipMemcpyDeviceToHost));
1417 hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName,
1418  size_t sizeBytes, size_t offset,
1419  hipMemcpyKind kind,
1420  hipStream_t stream __dparm(0));
1421 #else
1422 hipError_t hipModuleGetGlobal(void**, size_t*, hipModule_t, const char*);
1423 
1424 namespace hip_impl {
1425 inline
1426 __attribute__((visibility("hidden")))
1427 hipError_t read_agent_global_from_process(hipDeviceptr_t* dptr, size_t* bytes,
1428  const char* name);
1429 } // Namespace hip_impl.
1430 
1441 inline
1442 __attribute__((visibility("hidden")))
1443 hipError_t hipGetSymbolAddress(void** devPtr, const void* symbolName) {
1444  //HIP_INIT_API(hipGetSymbolAddress, devPtr, symbolName);
1445  hip_impl::hip_init();
1446  size_t size = 0;
1447  return hip_impl::read_agent_global_from_process(devPtr, &size, (const char*)symbolName);
1448 }
1449 
1450 
1461 inline
1462 __attribute__((visibility("hidden")))
1463 hipError_t hipGetSymbolSize(size_t* size, const void* symbolName) {
1464  // HIP_INIT_API(hipGetSymbolSize, size, symbolName);
1465  hip_impl::hip_init();
1466  void* devPtr = nullptr;
1467  return hip_impl::read_agent_global_from_process(&devPtr, size, (const char*)symbolName);
1468 }
1469 
1470 #if defined(__cplusplus)
1471 } // extern "C"
1472 #endif
1473 
1474 namespace hip_impl {
1475 hipError_t hipMemcpyToSymbol(void*, const void*, size_t, size_t, hipMemcpyKind,
1476  const char*);
1477 } // Namespace hip_impl.
1478 
1479 #if defined(__cplusplus)
1480 extern "C" {
1481 #endif
1482 
1506 inline
1507 __attribute__((visibility("hidden")))
1508 hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src,
1509  size_t sizeBytes, size_t offset __dparm(0),
1510  hipMemcpyKind kind __dparm(hipMemcpyHostToDevice)) {
1511  if (!symbolName) return hipErrorInvalidSymbol;
1512 
1513  hipDeviceptr_t dst = NULL;
1514  hipGetSymbolAddress(&dst, (const char*)symbolName);
1515 
1516  return hip_impl::hipMemcpyToSymbol(dst, src, sizeBytes, offset, kind,
1517  (const char*)symbolName);
1518 }
1519 
1520 #if defined(__cplusplus)
1521 } // extern "C"
1522 #endif
1523 
1524 namespace hip_impl {
1525 hipError_t hipMemcpyToSymbolAsync(void*, const void*, size_t, size_t,
1526  hipMemcpyKind, hipStream_t, const char*);
1527 hipError_t hipMemcpyFromSymbol(void*, const void*, size_t, size_t,
1528  hipMemcpyKind, const char*);
1529 hipError_t hipMemcpyFromSymbolAsync(void*, const void*, size_t, size_t,
1530  hipMemcpyKind, hipStream_t, const char*);
1531 } // Namespace hip_impl.
1532 
1533 #if defined(__cplusplus)
1534 extern "C" {
1535 #endif
1536 
1562 inline
1563 __attribute__((visibility("hidden")))
1564 hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src,
1565  size_t sizeBytes, size_t offset,
1566  hipMemcpyKind kind, hipStream_t stream __dparm(0)) {
1567  if (!symbolName) return hipErrorInvalidSymbol;
1568 
1569  hipDeviceptr_t dst = NULL;
1570  hipGetSymbolAddress(&dst, symbolName);
1571 
1572  return hip_impl::hipMemcpyToSymbolAsync(dst, src, sizeBytes, offset, kind,
1573  stream,
1574  (const char*)symbolName);
1575 }
1576 
1577 inline
1578 __attribute__((visibility("hidden")))
1579 hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName,
1580  size_t sizeBytes, size_t offset __dparm(0),
1581  hipMemcpyKind kind __dparm(hipMemcpyDeviceToHost)) {
1582  if (!symbolName) return hipErrorInvalidSymbol;
1583 
1584  hipDeviceptr_t src = NULL;
1585  hipGetSymbolAddress(&src, symbolName);
1586 
1587  return hip_impl::hipMemcpyFromSymbol(dst, src, sizeBytes, offset, kind,
1588  (const char*)symbolName);
1589 }
1590 
1591 inline
1592 __attribute__((visibility("hidden")))
1593 hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName,
1594  size_t sizeBytes, size_t offset,
1595  hipMemcpyKind kind,
1596  hipStream_t stream __dparm(0)) {
1597  if (!symbolName) return hipErrorInvalidSymbol;
1598 
1599  hipDeviceptr_t src = NULL;
1600  hipGetSymbolAddress(&src, symbolName);
1601 
1602  return hip_impl::hipMemcpyFromSymbolAsync(dst, src, sizeBytes, offset, kind,
1603  stream,
1604  (const char*)symbolName);
1605 }
1606 
1607 #endif // __HIP_VDI__
1608 
1636 hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind,
1637  hipStream_t stream __dparm(0));
1638 
1648 hipError_t hipMemset(void* dst, int value, size_t sizeBytes);
1649 
1659 hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes);
1660 
1670 hipError_t hipMemsetD32(hipDeviceptr_t dest, int value, size_t count);
1671 
1687 hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream __dparm(0));
1688 
1704 hipError_t hipMemsetD32Async(hipDeviceptr_t dst, int value, size_t count,
1705  hipStream_t stream __dparm(0));
1706 
1718 hipError_t hipMemset2D(void* dst, size_t pitch, int value, size_t width, size_t height);
1719 
1732 hipError_t hipMemset2DAsync(void* dst, size_t pitch, int value, size_t width, size_t height,hipStream_t stream __dparm(0));
1733 
1742 hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent );
1743 
1753 hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent ,hipStream_t stream __dparm(0));
1754 
1764 hipError_t hipMemGetInfo(size_t* free, size_t* total);
1765 
1766 
1767 hipError_t hipMemPtrGetInfo(void* ptr, size_t* size);
1768 
1769 
1782 hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width,
1783  size_t height __dparm(0), unsigned int flags __dparm(hipArrayDefault));
1784 hipError_t hipArrayCreate(hipArray** pHandle, const HIP_ARRAY_DESCRIPTOR* pAllocateArray);
1785 
1786 hipError_t hipArray3DCreate(hipArray** array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray);
1787 
1788 hipError_t hipMalloc3D(hipPitchedPtr* pitchedDevPtr, hipExtent extent);
1789 
1798 hipError_t hipFreeArray(hipArray* array);
1799 
1812 hipError_t hipMalloc3DArray(hipArray** array, const struct hipChannelFormatDesc* desc,
1813  struct hipExtent extent, unsigned int flags);
1830 hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width,
1831  size_t height, hipMemcpyKind kind);
1832 hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy);
1833 
1851 hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width,
1852  size_t height, hipMemcpyKind kind, hipStream_t stream __dparm(0));
1853 
1870 hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src,
1871  size_t spitch, size_t width, size_t height, hipMemcpyKind kind);
1872 
1889 hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src,
1890  size_t count, hipMemcpyKind kind);
1891 
1907 hipError_t hipMemcpyFromArray(void* dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset,
1908  size_t count, hipMemcpyKind kind);
1909 
1923 hipError_t hipMemcpyAtoH(void* dst, hipArray* srcArray, size_t srcOffset, size_t count);
1924 
1938 hipError_t hipMemcpyHtoA(hipArray* dstArray, size_t dstOffset, const void* srcHost, size_t count);
1939 
1950 hipError_t hipMemcpy3D(const struct hipMemcpy3DParms* p);
1951 
1952 // doxygen end Memory
1984 hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId);
1985 
1986 
2003 hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags);
2004 
2005 
2017 hipError_t hipDeviceDisablePeerAccess(int peerDeviceId);
2018 
2031 hipError_t hipMemGetAddressRange(hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr);
2032 
2033 #ifndef USE_PEER_NON_UNIFIED
2034 #define USE_PEER_NON_UNIFIED 1
2035 #endif
2036 
2037 #if USE_PEER_NON_UNIFIED == 1
2038 
2049 hipError_t hipMemcpyPeer(void* dst, int dstDeviceId, const void* src, int srcDeviceId,
2050  size_t sizeBytes);
2051 
2064 hipError_t hipMemcpyPeerAsync(void* dst, int dstDeviceId, const void* src, int srcDevice,
2065  size_t sizeBytes, hipStream_t stream __dparm(0));
2066 #endif
2067 
2068 
2069 // doxygen end PeerToPeer
2088 // TODO-ctx - more description on error codes.
2089 hipError_t hipInit(unsigned int flags);
2090 
2091 
2111 DEPRECATED(DEPRECATED_MSG)
2112 hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device);
2113 
2124 DEPRECATED(DEPRECATED_MSG)
2125 hipError_t hipCtxDestroy(hipCtx_t ctx);
2126 
2137 DEPRECATED(DEPRECATED_MSG)
2138 hipError_t hipCtxPopCurrent(hipCtx_t* ctx);
2139 
2150 DEPRECATED(DEPRECATED_MSG)
2151 hipError_t hipCtxPushCurrent(hipCtx_t ctx);
2152 
2163 DEPRECATED(DEPRECATED_MSG)
2164 hipError_t hipCtxSetCurrent(hipCtx_t ctx);
2165 
2176 DEPRECATED(DEPRECATED_MSG)
2177 hipError_t hipCtxGetCurrent(hipCtx_t* ctx);
2178 
2190 DEPRECATED(DEPRECATED_MSG)
2191 hipError_t hipCtxGetDevice(hipDevice_t* device);
2192 
2210 DEPRECATED(DEPRECATED_MSG)
2211 hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion);
2212 
2226 DEPRECATED(DEPRECATED_MSG)
2227 hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig);
2228 
2242 DEPRECATED(DEPRECATED_MSG)
2243 hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig);
2244 
2258 DEPRECATED(DEPRECATED_MSG)
2259 hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config);
2260 
2274 DEPRECATED(DEPRECATED_MSG)
2275 hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig);
2276 
2288 DEPRECATED(DEPRECATED_MSG)
2289 hipError_t hipCtxSynchronize(void);
2290 
2301 DEPRECATED(DEPRECATED_MSG)
2302 hipError_t hipCtxGetFlags(unsigned int* flags);
2303 
2323 DEPRECATED(DEPRECATED_MSG)
2324 hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags);
2325 
2342 DEPRECATED(DEPRECATED_MSG)
2343 hipError_t hipCtxDisablePeerAccess(hipCtx_t peerCtx);
2344 
2357 hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active);
2358 
2371 hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev);
2372 
2384 hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev);
2385 
2396 hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev);
2397 
2409 hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags);
2410 
2411 // doxygen end Context Management
2423 hipError_t hipDeviceGet(hipDevice_t* device, int ordinal);
2424 
2433 hipError_t hipDeviceComputeCapability(int* major, int* minor, hipDevice_t device);
2434 
2443 hipError_t hipDeviceGetName(char* name, int len, hipDevice_t device);
2444 
2453 hipError_t hipDeviceGetPCIBusId(char* pciBusId, int len, int device);
2454 
2455 
2463 hipError_t hipDeviceGetByPCIBusId(int* device, const char* pciBusId);
2464 
2465 
2473 hipError_t hipDeviceTotalMem(size_t* bytes, hipDevice_t device);
2474 
2490 hipError_t hipDriverGetVersion(int* driverVersion);
2491 
2504 hipError_t hipRuntimeGetVersion(int* runtimeVersion);
2505 
2517 hipError_t hipModuleLoad(hipModule_t* module, const char* fname);
2518 
2529 hipError_t hipModuleUnload(hipModule_t module);
2530 
2541 hipError_t hipModuleGetFunction(hipFunction_t* function, hipModule_t module, const char* kname);
2542 
2552 hipError_t hipFuncGetAttributes(hipFuncAttributes* attr, const void* func);
2553 
2555 
2556  Agent_global() : name(nullptr), address(nullptr), byte_cnt(0) {}
2557  Agent_global(const char* name, hipDeviceptr_t address, uint32_t byte_cnt)
2558  : name(nullptr), address(address), byte_cnt(byte_cnt) {
2559  if (name)
2560  this->name = strdup(name);
2561  }
2562 
2563  Agent_global& operator=(Agent_global&& t) {
2564  if (this == &t) return *this;
2565 
2566  if (name) free(name);
2567  name = t.name;
2568  address = t.address;
2569  byte_cnt = t.byte_cnt;
2570 
2571  t.name = nullptr;
2572  t.address = nullptr;
2573  t.byte_cnt = 0;
2574 
2575  return *this;
2576  }
2577 
2578  Agent_global(Agent_global&& t)
2579  : name(nullptr), address(nullptr), byte_cnt(0) {
2580  *this = std::move(t);
2581  }
2582 
2583  // not needed, delete them to prevent bugs
2584  Agent_global(const Agent_global&) = delete;
2585  Agent_global& operator=(Agent_global& t) = delete;
2586 
2587  ~Agent_global() { if (name) free(name); }
2588 
2589  char* name;
2590  hipDeviceptr_t address;
2591  uint32_t byte_cnt;
2592 };
2593 
2594 #if !__HIP_VDI__
2595 #if defined(__cplusplus)
2596 } // extern "C"
2597 #endif
2598 
2599 namespace hip_impl {
2600 hsa_executable_t executable_for(hipModule_t);
2601 const char* hash_for(hipModule_t);
2602 
2603 template<typename ForwardIterator>
2604 std::pair<hipDeviceptr_t, std::size_t> read_global_description(
2605  ForwardIterator f, ForwardIterator l, const char* name) {
2606  const auto it = std::find_if(f, l, [=](const Agent_global& x) {
2607  return strcmp(x.name, name) == 0;
2608  });
2609 
2610  return it == l ?
2611  std::make_pair(nullptr, 0u) : std::make_pair(it->address, it->byte_cnt);
2612 }
2613 
2614 std::vector<Agent_global> read_agent_globals(hsa_agent_t agent,
2615  hsa_executable_t executable);
2616 hsa_agent_t this_agent();
2617 
2618 inline
2619 __attribute__((visibility("hidden")))
2620 hipError_t read_agent_global_from_module(hipDeviceptr_t* dptr, size_t* bytes,
2621  hipModule_t hmod, const char* name) {
2622  // the key of the map would the hash of code object associated with the
2623  // hipModule_t instance
2624  static std::unordered_map<
2625  std::string, std::vector<Agent_global>> agent_globals;
2626  std::string key(hash_for(hmod));
2627 
2628  if (agent_globals.count(key) == 0) {
2629  static std::mutex mtx;
2630  std::lock_guard<std::mutex> lck{mtx};
2631 
2632  if (agent_globals.count(key) == 0) {
2633  agent_globals.emplace(
2634  key, read_agent_globals(this_agent(), executable_for(hmod)));
2635  }
2636  }
2637 
2638  const auto it0 = agent_globals.find(key);
2639  if (it0 == agent_globals.cend()) {
2640  hip_throw(
2641  std::runtime_error{"agent_globals data structure corrupted."});
2642  }
2643 
2644  std::tie(*dptr, *bytes) = read_global_description(it0->second.cbegin(),
2645  it0->second.cend(), name);
2646 
2647  // HACK for SWDEV-173477
2648  //
2649  // For code objects with global symbols of length 0, ROCR runtime would
2650  // ignore them even though they exist in the symbol table. Therefore the
2651  // result from read_agent_globals() can't be trusted entirely.
2652  //
2653  // As a workaround to tame applications which depend on the existence of
2654  // global symbols with length 0, always return hipSuccess here.
2655  //
2656  // This behavior shall be reverted once ROCR runtime has been fixed to
2657  // address SWDEV-173477
2658 
2659  //return *dptr ? hipSuccess : hipErrorNotFound;
2660  return hipSuccess;
2661 }
2662 
2663 inline
2664 __attribute__((visibility("hidden")))
2665 hipError_t read_agent_global_from_process(hipDeviceptr_t* dptr, size_t* bytes,
2666  const char* name) {
2667  static std::unordered_map<hsa_agent_t, std::pair<std::once_flag,
2668  std::vector<Agent_global>>> globals;
2669  static std::once_flag f;
2670  auto agent = this_agent();
2671 
2672  // Create placeholder for each agent in the map.
2673  std::call_once(f, []() {
2674  for (auto&& x : hip_impl::all_hsa_agents()) {
2675  (void)globals[x];
2676  }
2677  });
2678 
2679  if (globals.find(agent) == globals.cend()) {
2680  hip_throw(std::runtime_error{"invalid agent"});
2681  }
2682 
2683  std::call_once(globals[agent].first, [](hsa_agent_t aa) {
2684  std::vector<Agent_global> tmp0;
2685  for (auto&& executable : executables(aa)) {
2686  auto tmp1 = read_agent_globals(aa, executable);
2687  tmp0.insert(tmp0.end(), make_move_iterator(tmp1.begin()),
2688  make_move_iterator(tmp1.end()));
2689  }
2690  globals[aa].second = move(tmp0);
2691  }, agent);
2692 
2693  const auto it = globals.find(agent);
2694 
2695  if (it == globals.cend()) return hipErrorNotInitialized;
2696 
2697  std::tie(*dptr, *bytes) = read_global_description(it->second.second.cbegin(),
2698  it->second.second.cend(), name);
2699 
2700  return *dptr ? hipSuccess : hipErrorNotFound;
2701 }
2702 } // Namespace hip_impl.
2703 
2704 #if defined(__cplusplus)
2705 extern "C" {
2706 #endif
2707 
2718 hipError_t hipModuleGetGlobal(hipDeviceptr_t* dptr, size_t* bytes,
2719  hipModule_t hmod, const char* name);
2720 #endif // __HIP_VDI__
2721 
2722 hipError_t hipModuleGetTexRef(textureReference** texRef, hipModule_t hmod, const char* name);
2732 hipError_t hipModuleLoadData(hipModule_t* module, const void* image);
2733 
2746 hipError_t hipModuleLoadDataEx(hipModule_t* module, const void* image, unsigned int numOptions,
2747  hipJitOption* options, void** optionValues);
2748 
2773 hipError_t hipModuleLaunchKernel(hipFunction_t f, unsigned int gridDimX, unsigned int gridDimY,
2774  unsigned int gridDimZ, unsigned int blockDimX,
2775  unsigned int blockDimY, unsigned int blockDimZ,
2776  unsigned int sharedMemBytes, hipStream_t stream,
2777  void** kernelParams, void** extra);
2778 
2779 // doxygen end Version Management
2797 // TODO - expand descriptions:
2803 hipError_t hipProfilerStart();
2804 
2805 
2811 hipError_t hipProfilerStop();
2812 
2813 
2818 // TODO: implement IPC apis
2819 
2845 hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr);
2846 
2883 hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags);
2884 
2903 hipError_t hipIpcCloseMemHandle(void* devPtr);
2904 
2905 
2906 // hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr);
2907 // hipError_t hipIpcCloseMemHandle(void *devPtr);
2908 // // hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle);
2909 // hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags);
2910 
2911 
2932 hipError_t hipConfigureCall(dim3 gridDim, dim3 blockDim, size_t sharedMem __dparm(0), hipStream_t stream __dparm(0));
2933 
2934 
2945 hipError_t hipSetupArgument(const void* arg, size_t size, size_t offset);
2946 
2947 
2956 hipError_t hipLaunchByPtr(const void* func);
2957 
2958 
2959 
2965 #ifdef __cplusplus
2966 } /* extern "c" */
2967 #endif
2968 
2969 #include <hip/hcc_detail/hip_prof_api.h>
2970 
2971 #ifdef __cplusplus
2972 extern "C" {
2973 #endif
2974 
2977 hipError_t hipRegisterApiCallback(uint32_t id, void* fun, void* arg);
2978 hipError_t hipRemoveApiCallback(uint32_t id);
2979 hipError_t hipRegisterActivityCallback(uint32_t id, void* fun, void* arg);
2980 hipError_t hipRemoveActivityCallback(uint32_t id);
2981 static inline const char* hipApiName(const uint32_t& id) { return hip_api_name(id); }
2982 const char* hipKernelNameRef(const hipFunction_t f);
2983 #ifdef __cplusplus
2984 } /* extern "C" */
2985 #endif
2986 
2987 #ifdef __cplusplus
2988 
2989 hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* devPtr,
2990  const hipChannelFormatDesc* desc, size_t size = UINT_MAX);
2991 
2992 hipError_t ihipBindTextureImpl(int dim, enum hipTextureReadMode readMode, size_t* offset,
2993  const void* devPtr, const struct hipChannelFormatDesc* desc,
2994  size_t size, textureReference* tex);
2995 
2996 /*
2997  * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture
2998  *reference tex.
2999  *
3000  * @p desc describes how the memory is interpreted when fetching values from the texture. The @p
3001  *offset parameter is an optional byte offset as with the low-level hipBindTexture() function. Any
3002  *memory previously bound to tex is unbound.
3003  *
3004  * @param[in] offset - Offset in bytes
3005  * @param[out] tex - texture to bind
3006  * @param[in] devPtr - Memory area on device
3007  * @param[in] desc - Channel format
3008  * @param[in] size - Size of the memory area pointed to by devPtr
3009  * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
3010  **/
3011 template <class T, int dim, enum hipTextureReadMode readMode>
3012 hipError_t hipBindTexture(size_t* offset, struct texture<T, dim, readMode>& tex, const void* devPtr,
3013  const struct hipChannelFormatDesc& desc, size_t size = UINT_MAX) {
3014  return ihipBindTextureImpl(dim, readMode, offset, devPtr, &desc, size, &tex);
3015 }
3016 
3017 /*
3018  * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture
3019  *reference tex.
3020  *
3021  * @p desc describes how the memory is interpreted when fetching values from the texture. The @p
3022  *offset parameter is an optional byte offset as with the low-level hipBindTexture() function. Any
3023  *memory previously bound to tex is unbound.
3024  *
3025  * @param[in] offset - Offset in bytes
3026  * @param[in] tex - texture to bind
3027  * @param[in] devPtr - Memory area on device
3028  * @param[in] size - Size of the memory area pointed to by devPtr
3029  * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
3030  **/
3031 template <class T, int dim, enum hipTextureReadMode readMode>
3032 hipError_t hipBindTexture(size_t* offset, struct texture<T, dim, readMode>& tex, const void* devPtr,
3033  size_t size = UINT_MAX) {
3034  return ihipBindTextureImpl(dim, readMode, offset, devPtr, &(tex.channelDesc), size, &tex);
3035 }
3036 
3037 // C API
3038 hipError_t hipBindTexture2D(size_t* offset, textureReference* tex, const void* devPtr,
3039  const hipChannelFormatDesc* desc, size_t width, size_t height,
3040  size_t pitch);
3041 
3042 hipError_t ihipBindTexture2DImpl(int dim, enum hipTextureReadMode readMode, size_t* offset,
3043  const void* devPtr, const struct hipChannelFormatDesc* desc,
3044  size_t width, size_t height, textureReference* tex);
3045 
3046 template <class T, int dim, enum hipTextureReadMode readMode>
3047 hipError_t hipBindTexture2D(size_t* offset, struct texture<T, dim, readMode>& tex,
3048  const void* devPtr, size_t width, size_t height, size_t pitch) {
3049  return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, &(tex.channelDesc), width, height,
3050  &tex);
3051 }
3052 
3053 template <class T, int dim, enum hipTextureReadMode readMode>
3054 hipError_t hipBindTexture2D(size_t* offset, struct texture<T, dim, readMode>& tex,
3055  const void* devPtr, const struct hipChannelFormatDesc& desc,
3056  size_t width, size_t height, size_t pitch) {
3057  return ihipBindTexture2DImpl(dim, readMode, offset, devPtr, &desc, width, height, &tex);
3058 }
3059 
3060 // C API
3061 hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array,
3062  const hipChannelFormatDesc* desc);
3063 
3064 hipError_t ihipBindTextureToArrayImpl(int dim, enum hipTextureReadMode readMode,
3065  hipArray_const_t array,
3066  const struct hipChannelFormatDesc& desc,
3067  textureReference* tex);
3068 
3069 template <class T, int dim, enum hipTextureReadMode readMode>
3070 hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex, hipArray_const_t array) {
3071  return ihipBindTextureToArrayImpl(dim, readMode, array, tex.channelDesc, &tex);
3072 }
3073 
3074 template <class T, int dim, enum hipTextureReadMode readMode>
3075 hipError_t hipBindTextureToArray(struct texture<T, dim, readMode>& tex, hipArray_const_t array,
3076  const struct hipChannelFormatDesc& desc) {
3077  return ihipBindTextureToArrayImpl(dim, readMode, array, desc, &tex);
3078 }
3079 
3080 template <class T, int dim, enum hipTextureReadMode readMode>
3081 inline static hipError_t hipBindTextureToArray(struct texture<T, dim, readMode> *tex,
3082  hipArray_const_t array,
3083  const struct hipChannelFormatDesc* desc) {
3084  return ihipBindTextureToArrayImpl(dim, readMode, array, *desc, tex);
3085 }
3086 
3087 // C API
3088 hipError_t hipBindTextureToMipmappedArray(const textureReference* tex,
3089  hipMipmappedArray_const_t mipmappedArray,
3090  const hipChannelFormatDesc* desc);
3091 
3092 template <class T, int dim, enum hipTextureReadMode readMode>
3093 hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
3094  hipMipmappedArray_const_t mipmappedArray) {
3095  return hipSuccess;
3096 }
3097 
3098 template <class T, int dim, enum hipTextureReadMode readMode>
3099 hipError_t hipBindTextureToMipmappedArray(const texture<T, dim, readMode>& tex,
3100  hipMipmappedArray_const_t mipmappedArray,
3101  const hipChannelFormatDesc& desc) {
3102  return hipSuccess;
3103 }
3104 
3105 /*
3106  * @brief Unbinds the textuer bound to @p tex
3107  *
3108  * @param[in] tex - texture to unbind
3109  *
3110  * @return #hipSuccess
3111  **/
3112 hipError_t hipUnbindTexture(const textureReference* tex);
3113 
3114 extern hipError_t ihipUnbindTextureImpl(const hipTextureObject_t& textureObject);
3115 
3116 template <class T, int dim, enum hipTextureReadMode readMode>
3117 hipError_t hipUnbindTexture(struct texture<T, dim, readMode>& tex) {
3118  return ihipUnbindTextureImpl(tex.textureObject);
3119 }
3120 
3121 hipError_t hipGetChannelDesc(hipChannelFormatDesc* desc, hipArray_const_t array);
3122 hipError_t hipGetTextureAlignmentOffset(size_t* offset, const textureReference* texref);
3123 hipError_t hipGetTextureReference(const textureReference** texref, const void* symbol);
3124 
3125 hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResourceDesc* pResDesc,
3126  const hipTextureDesc* pTexDesc,
3127  const hipResourceViewDesc* pResViewDesc);
3128 
3129 hipError_t hipDestroyTextureObject(hipTextureObject_t textureObject);
3130 
3131 hipError_t hipGetTextureObjectResourceDesc(hipResourceDesc* pResDesc,
3132  hipTextureObject_t textureObject);
3133 hipError_t hipGetTextureObjectResourceViewDesc(hipResourceViewDesc* pResViewDesc,
3134  hipTextureObject_t textureObject);
3135 hipError_t hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc,
3136  hipTextureObject_t textureObject);
3137 hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsigned int flags);
3138 
3139 hipError_t hipTexRefSetAddressMode(textureReference* tex, int dim, hipTextureAddressMode am);
3140 
3141 hipError_t hipTexRefSetFilterMode(textureReference* tex, hipTextureFilterMode fm);
3142 
3143 hipError_t hipTexRefSetFlags(textureReference* tex, unsigned int flags);
3144 
3145 hipError_t hipTexRefSetFormat(textureReference* tex, hipArray_Format fmt, int NumPackedComponents);
3146 
3147 hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDeviceptr_t devPtr,
3148  size_t size);
3149 
3150 hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPTOR* desc,
3151  hipDeviceptr_t devPtr, size_t pitch);
3152 
3153 hipError_t hipCreateSurfaceObject(hipSurfaceObject_t* pSurfObject, const hipResourceDesc* pResDesc);
3154 
3155 hipError_t hipDestroySurfaceObject(hipSurfaceObject_t surfaceObject);
3156 
3157 // doxygen end Texture
3163 #endif
3164 
3165 
3183 // end-group HCC_Specific
3189 // doxygen end HIP API
3194 #endif
hipError_t hipHostFree(void *ptr)
Free memory allocated by the hcc hip host memory allocation API This API performs an implicit hipDevi...
Definition: hip_memory.cpp:1951
prefer larger L1 cache and smaller shared memory
Definition: hip_runtime_api.h:244
hipError_t hipModuleGetFunction(hipFunction_t *function, hipModule_t module, const char *kname)
Function with kname will be extracted if present in module.
Definition: hip_module.cpp:469
hipError_t hipCtxDisablePeerAccess(hipCtx_t peerCtx)
Disable direct access from current context&#39;s virtual address space to memory allocations physically l...
Definition: hip_peer.cpp:218
hipError_t hipMemset3D(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent)
Fills synchronously the memory area pointed to by pitchedDevPtr with the constant value...
Definition: hip_memory.cpp:1805
hipError_t hipStreamGetPriority(hipStream_t stream, int *priority)
Query the priority of a stream.
Definition: hip_stream.cpp:234
hipError_t hipDeviceGetCacheConfig(hipFuncCache_t *cacheConfig)
Set Cache configuration for a specific function.
Definition: hip_device.cpp:84
hipError_t hipDriverGetVersion(int *driverVersion)
Returns the approximate HIP driver version.
Definition: hip_context.cpp:88
hipError_t hipPeekAtLastError(void)
Return last error returned by any HIP runtime API call.
Definition: hip_error.cpp:41
hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags)
Set flags for the primary context.
Definition: hip_context.cpp:324
hipError_t hipDevicePrimaryCtxRetain(hipCtx_t *pctx, hipDevice_t dev)
Retain the primary context on the GPU.
Definition: hip_context.cpp:299
struct dim3 dim3
hipError_t hipDeviceComputeCapability(int *major, int *minor, hipDevice_t device)
Returns the compute capability of the device.
Definition: hip_device.cpp:369
hipError_t hipDeviceGetByPCIBusId(int *device, const char *pciBusId)
Returns a handle to a compute device.
Definition: hip_device.cpp:427
hipError_t hipExtMallocWithFlags(void **ptr, size_t sizeBytes, unsigned int flags)
Allocate memory on the default accelerator.
Definition: hip_memory.cpp:267
hipError_t hipMemGetAddressRange(hipDeviceptr_t *pbase, size_t *psize, hipDeviceptr_t dptr)
Get information on memory allocations.
Definition: hip_memory.cpp:2014
TODO-doc.
hipError_t hipFreeHost(void *ptr)
Free memory allocated by the hcc hip host memory allocation API. [Deprecated].
Definition: hip_memory.cpp:1984
hipError_t hipMemcpyToArray(hipArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t count, hipMemcpyKind kind)
Copies data between host and device.
Definition: hip_memory.cpp:1285
unsigned long long hipSurfaceObject_t
Definition: hip_surface_types.h:36
hipError_t hipModuleLoadDataEx(hipModule_t *module, const void *image, unsigned int numOptions, hipJitOption *options, void **optionValues)
builds module from code object which resides in host memory. Image is pointer to that location...
Definition: hip_module.cpp:579
Definition: driver_types.h:232
hipError_t hipMallocPitch(void **ptr, size_t *pitch, size_t width, size_t height)
Definition: hip_memory.cpp:440
hipError_t hipMemcpy2DAsync(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind, hipStream_t stream __dparm(0))
Copies data between host and device.
hipError_t hipMemcpy2D(void *dst, size_t dpitch, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind)
Copies data between host and device.
Definition: hip_memory.cpp:1632
hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void *userData, unsigned int flags)
Adds a callback to be called on the host after all currently enqueued items in the stream have comple...
Definition: hip_stream.cpp:254
hipError_t hipMemcpyFromArray(void *dst, hipArray_const_t srcArray, size_t wOffset, size_t hOffset, size_t count, hipMemcpyKind kind)
Copies data between host and device.
Definition: hip_memory.cpp:1304
uint32_t x
x
Definition: hip_runtime_api.h:266
hipError_t hipMemcpyAtoH(void *dst, hipArray *srcArray, size_t srcOffset, size_t count)
Copies data between host and device.
Definition: hip_memory.cpp:1341
hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags)
Enable direct access from current device&#39;s virtual address space to memory allocations physically loc...
Definition: hip_peer.cpp:191
hipError_t hipCtxPopCurrent(hipCtx_t *ctx)
Pop the current/default context and return the popped context.
Definition: hip_context.cpp:136
const char * hipGetErrorString(hipError_t hipError)
Return handy text string message to explain the error which occurred.
Definition: hip_error.cpp:54
hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig *pConfig)
Returns bank width of shared memory for current device.
Definition: hip_device.cpp:125
Definition: hip_runtime_api.h:137
hipError_t hipDeviceGetStreamPriorityRange(int *leastPriority, int *greatestPriority)
Returns numerical values that correspond to the least and greatest stream priority.
Definition: hip_stream.cpp:118
prefer equal size L1 cache and shared memory
Definition: hip_runtime_api.h:245
hipError_t hipHostGetDevicePointer(void **devPtr, void *hstPtr, unsigned int flags)
Get Device pointer from Host Pointer allocated through hipHostMalloc.
hipError_t hipFreeArray(hipArray *array)
Frees an array on the device.
Definition: hip_memory.cpp:1986
hipError_t hipStreamCreateWithPriority(hipStream_t *stream, unsigned int flags, int priority)
Create an asynchronous stream with the specified priority.
Definition: hip_stream.cpp:109
hipError_t hipMemsetAsync(void *dst, int value, size_t sizeBytes, hipStream_t stream __dparm(0))
Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value val...
hipError_t hipEventSynchronize(hipEvent_t event)
Wait for an event to complete.
Definition: hip_event.cpp:167
Definition: driver_types.h:173
hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void *src, size_t sizeBytes)
Copy data from Host to Device.
Definition: hip_memory.cpp:1130
hipError_t hipModuleUnload(hipModule_t module)
Frees the module.
Definition: hip_module.cpp:114
Definition: hip_module.cpp:89
hipError_t hipSetDeviceFlags(unsigned flags)
The current device behavior is changed according the flags passed.
hipError_t hipEventQuery(hipEvent_t event)
Query event status.
Definition: hip_event.cpp:257
hipError_t hipDeviceDisablePeerAccess(int peerDeviceId)
Disable direct access from current device&#39;s virtual address space to memory allocations physically lo...
Definition: hip_peer.cpp:184
hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig *pConfig)
Get Shared memory bank configuration.
Definition: hip_context.cpp:244
hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device)
Create a context and set it as current/ default context.
Definition: hip_context.cpp:55
#define hipArrayDefault
Default HIP array allocation flag.
Definition: hip_runtime_api.h:205
hipError_t hipMallocArray(hipArray **array, const hipChannelFormatDesc *desc, size_t width, size_t height __dparm(0), unsigned int flags __dparm(hipArrayDefault))
Allocate an array on the device.
hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config)
Set Shared memory bank configuration.
Definition: hip_context.cpp:236
hipError_t hipCtxSetCurrent(hipCtx_t ctx)
Set the passed context as current/default.
Definition: hip_context.cpp:181
hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t *handle, void *devPtr)
Gets an interprocess memory handle for an existing device memory allocation.
Definition: hip_memory.cpp:2035
Definition: hip_runtime_api.h:120
hipError_t hipMemset2DAsync(void *dst, size_t pitch, int value, size_t width, size_t height, hipStream_t stream __dparm(0))
Fills asynchronously the memory area pointed to by dst with the constant value.
Definition: driver_types.h:107
hipError_t hipHostMalloc(void **ptr, size_t size, unsigned int flags)
Allocate device accessible page locked host memory.
Definition: hip_memory.cpp:304
Definition: hip_hcc_internal.h:882
Definition: texture_types.h:73
hipError_t hipDeviceGetLimit(size_t *pValue, enum hipLimit_t limit)
Get Resource limits of current device.
Definition: hip_device.cpp:96
hipError_t hipModuleLoadData(hipModule_t *module, const void *image)
builds module from code object which resides in host memory. Image is pointer to that location...
Definition: hip_module.cpp:560
Definition: driver_types.h:70
hipDeviceAttribute_t
Definition: hip_runtime_api.h:259
hipError_t hipEventDestroy(hipEvent_t event)
Destroy the specified event.
Definition: hip_event.cpp:155
hipError_t hipStreamCreateWithFlags(hipStream_t *stream, unsigned int flags)
Create an asynchronous stream.
Definition: hip_stream.cpp:95
hipError_t hipConfigureCall(dim3 gridDim, dim3 blockDim, size_t sharedMem __dparm(0), hipStream_t stream __dparm(0))
Configure a kernel launch.
hipError_t hipChooseDevice(int *device, const hipDeviceProp_t *prop)
Device which matches hipDeviceProp_t is returned.
Definition: hip_device.cpp:453
hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig)
Set L1/Shared cache partition.
Definition: hip_context.cpp:228
hipError_t hipModuleLaunchKernel(hipFunction_t f, unsigned int gridDimX, unsigned int gridDimY, unsigned int gridDimZ, unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ, unsigned int sharedMemBytes, hipStream_t stream, void **kernelParams, void **extra)
launches kernel f with launch parameters and shared memory on stream with arguments passed to kernelp...
Definition: hip_runtime_api.h:265
uint32_t y
y
Definition: hip_runtime_api.h:267
void(* hipStreamCallback_t)(hipStream_t stream, hipError_t status, void *userData)
Definition: hip_runtime_api.h:816
hipError_t hipModuleLoad(hipModule_t *module, const char *fname)
Loads code object from file into a hipModule_t.
Definition: hip_module.cpp:565
hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev)
Resets the primary context on the GPU.
Definition: hip_context.cpp:311
hipError_t hipEventCreateWithFlags(hipEvent_t *event, unsigned flags)
Create an event with the specified flags.
Definition: hip_event.cpp:97
hipError_t hipHostAlloc(void **ptr, size_t size, unsigned int flags)
Allocate device accessible page locked host memory [Deprecated].
Definition: hip_memory.cpp:379
hipError_t hipMallocHost(void **ptr, size_t size)
Allocate pinned host memory [Deprecated].
Definition: hip_memory.cpp:375
hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop)
Return the elapsed time between two events.
Definition: hip_event.cpp:200
hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig)
Set L1/Shared cache partition.
Definition: hip_device.cpp:76
hipError_t hipDeviceCanAccessPeer(int *canAccessPeer, int deviceId, int peerDeviceId)
Determine if a device can access a peer&#39;s memory.
Definition: hip_peer.cpp:177
hipError_t hipGetDeviceCount(int *count)
Return number of compute-capable devices.
Definition: hip_device.cpp:71
hipError_t hipMemset(void *dst, int value, size_t sizeBytes)
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value va...
Definition: hip_memory.cpp:1721
Definition: driver_types.h:245
hipError_t hipStreamDestroy(hipStream_t stream)
Destroys the specified stream.
Definition: hip_stream.cpp:191
hipError_t hipHostGetFlags(unsigned int *flagsPtr, void *hostPtr)
Return flags associated with host pointer.
Definition: hip_memory.cpp:888
hipError_t hipStreamSynchronize(hipStream_t stream)
Wait for all commands in stream to complete.
Definition: hip_stream.cpp:180
hipError_t hipIpcOpenMemHandle(void **devPtr, hipIpcMemHandle_t handle, unsigned int flags)
Opens an interprocess memory handle exported from another process and returns a device pointer usable...
Definition: hip_memory.cpp:2071
hipError_t hipCtxGetCacheConfig(hipFuncCache_t *cacheConfig)
Set Cache configuration for a specific function.
Definition: hip_context.cpp:220
hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes)
Copy data from Device to Device.
Definition: hip_memory.cpp:1168
hipError_t hipMemset3DAsync(hipPitchedPtr pitchedDevPtr, int value, hipExtent extent, hipStream_t stream __dparm(0))
Fills asynchronously the memory area pointed to by pitchedDevPtr with the constant value...
Definition: hip_runtime_api.h:254
no preference for shared memory or L1 (default)
Definition: hip_runtime_api.h:242
hipError_t hipCtxSynchronize(void)
Blocks until the default context has completed all preceding requested tasks.
Definition: hip_context.cpp:252
hipError_t hipMemsetD32Async(hipDeviceptr_t dst, int value, size_t count, hipStream_t stream __dparm(0))
Fills the memory area pointed to by dev with the constant integer value for specified number of times...
hipError_t hipCtxGetCurrent(hipCtx_t *ctx)
Get the handle of the current/ default context.
Definition: hip_context.cpp:170
hipError_t hipMalloc3DArray(hipArray **array, const struct hipChannelFormatDesc *desc, struct hipExtent extent, unsigned int flags)
Allocate an array on the device.
Definition: hip_memory.cpp:800
hipError_t hipMemcpyDtoHAsync(void *dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)
Copy data from Device to Host asynchronously.
Definition: hip_memory.cpp:1226
hipError_t hipDeviceSynchronize(void)
Waits on all active streams on current device.
Definition: hip_device.cpp:144
hipError_t hipCtxPushCurrent(hipCtx_t ctx)
Push the context to be set as current/ default context.
Definition: hip_context.cpp:157
hipError_t hipMemcpyDtoH(void *dst, hipDeviceptr_t src, size_t sizeBytes)
Copy data from Device to Host.
Definition: hip_memory.cpp:1149
Defines the different newt vector types for HIP runtime.
hipError_t hipMemcpyAsync(void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream __dparm(0))
Copy data from src to dst asynchronously.
hipError_t hipDeviceGetName(char *name, int len, hipDevice_t device)
Returns an identifer string for the device.
Definition: hip_device.cpp:381
hipError_t hipGetDeviceProperties(hipDeviceProp_t *prop, int deviceId)
Returns device properties.
Definition: hip_device.cpp:316
hipError_t hipHostRegister(void *hostPtr, size_t sizeBytes, unsigned int flags)
Register host memory so it can be accessed from the current device.
Definition: hip_memory.cpp:916
Definition: driver_types.h:61
hipError_t hipMalloc(void **ptr, size_t size)
Allocate memory on the default accelerator.
Definition: hip_memory.cpp:239
const char * hipGetErrorName(hipError_t hip_error)
Return name of the specified error code in text form.
Definition: hip_error.cpp:48
hipError_t hipMemset2D(void *dst, size_t pitch, int value, size_t width, size_t height)
Fills the memory area pointed to by dst with the constant value.
Definition: hip_memory.cpp:1737
Definition: driver_types.h:225
hipFuncCache_t
Definition: hip_runtime_api.h:241
hipError_t hipGetLastError(void)
Return last error returned by any HIP runtime API call and resets the stored error code to #hipSucces...
Definition: hip_error.cpp:32
hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags)
Make the specified compute stream wait for an event.
Definition: hip_stream.cpp:126
hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int *flags)
Return flags associated with this stream.
Definition: hip_stream.cpp:219
Defines surface types for HIP runtime.
hipError_t hipMemGetInfo(size_t *free, size_t *total)
Query memory info. Return snapshot of free memory, and total allocatable memory on the device...
Definition: hip_memory.cpp:1841
hipError_t hipCtxGetDevice(hipDevice_t *device)
Get the handle of the device associated with current/default context.
Definition: hip_context.cpp:194
hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev)
Release the primary context on the GPU.
Definition: hip_context.cpp:288
hipError_t hipFree(void *ptr)
Free memory allocated by the hcc hip memory allocation API. This API performs an implicit hipDeviceSy...
Definition: hip_memory.cpp:1900
uint32_t z
z
Definition: hip_runtime_api.h:268
hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int *apiVersion)
Returns the approximate HIP api version.
Definition: hip_context.cpp:210
hipError_t hipDeviceReset(void)
The state of current device is discarded and updated to a fresh state.
Definition: hip_device.cpp:149
hipError_t hipInit(unsigned int flags)
Explicitly initializes the HIP runtime.
Definition: hip_context.cpp:42
hipError_t hipMemcpy3D(const struct hipMemcpy3DParms *p)
Copies data between host and device.
Definition: hip_memory.cpp:1360
hipError_t hipRuntimeGetVersion(int *runtimeVersion)
Returns the approximate HIP Runtime version.
Definition: hip_context.cpp:100
hipError_t hipFuncGetAttributes(hipFuncAttributes *attr, const void *func)
Definition: hip_module.cpp:507
hipError_t hipMemcpyHtoA(hipArray *dstArray, size_t dstOffset, const void *srcHost, size_t count)
Copies data between host and device.
Definition: hip_memory.cpp:1323
hipError_t hipSetupArgument(const void *arg, size_t size, size_t offset)
Set a kernel argument.
Definition: hip_clang.cpp:185
hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)
Copy data from Device to Device asynchronously.
Definition: hip_memory.cpp:1218
Definition: hip_runtime_api.h:83
hipError_t hipSetDevice(int deviceId)
Set default device to be used for subsequent hip API calls from this thread.
Definition: hip_device.cpp:133
hipError_t hipDeviceGet(hipDevice_t *device, int ordinal)
Returns a handle to a compute device.
Definition: hip_context.cpp:73
hipError_t hipDeviceTotalMem(size_t *bytes, hipDevice_t device)
Returns the total amount of memory on the device.
Definition: hip_device.cpp:415
Definition: hip_runtime_api.h:2554
hipError_t hipFuncSetCacheConfig(const void *func, hipFuncCache_t config)
Set Cache configuration for a specific function.
Definition: hip_device.cpp:109
The compiler selects a device-specific value for the banking.
Definition: hip_runtime_api.h:253
Definition: hip_runtime_api.h:81
hipError_t hipMemcpyPeerAsync(void *dst, int dstDeviceId, const void *src, int srcDevice, size_t sizeBytes, hipStream_t stream __dparm(0))
Copies memory from one device to memory on another device.
hipError_t hipCtxGetFlags(unsigned int *flags)
Return flags used for creating default context.
Definition: hip_context.cpp:257
__attribute__((visibility("hidden"))) hipError_t hipGetSymbolAddress(void **devPtr
Copies the memory address of symbol symbolName to devPtr.
hipError_t hipCtxDestroy(hipCtx_t ctx)
Destroy a HIP context.
Definition: hip_context.cpp:112
hipError_t hipRegisterApiCallback(uint32_t id, void *fun, void *arg)
Definition: hip_intercept.cpp:33
hipSharedMemConfig
Definition: hip_runtime_api.h:252
Definition: driver_types.h:38
Definition: hip_hcc_internal.h:702
hipError_t hipDeviceGetAttribute(int *pi, hipDeviceAttribute_t attr, int deviceId)
Query for a specific device attribute.
Definition: hip_device.cpp:289
hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void *src, size_t sizeBytes, hipStream_t stream)
Copy data from Host to Device asynchronously.
Definition: hip_memory.cpp:1211
hipError_t hipHostUnregister(void *hostPtr)
Un-register host pointer.
Definition: hip_memory.cpp:981
Definition: hip_hcc_internal.h:521
hipError_t hipMemcpyPeer(void *dst, int dstDeviceId, const void *src, int srcDeviceId, size_t sizeBytes)
Copies memory from one device to memory on another device.
Definition: hip_peer.cpp:198
hipError_t hipStreamCreate(hipStream_t *stream)
Create an asynchronous stream.
Definition: hip_stream.cpp:102
hipError_t hipMemcpy(void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind)
Copy data from src to dst.
Definition: hip_memory.cpp:1103
hipError_t hipEventCreate(hipEvent_t *event)
Definition: hip_event.cpp:103
Definition: driver_types.h:82
Definition: hip_runtime_api.h:105
hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int *flags, int *active)
Get the state of the primary context.
Definition: hip_context.cpp:266
hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags)
Enables direct access to memory allocations in a peer context.
Definition: hip_peer.cpp:212
Definition: driver_types.h:201
hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config)
The bank width of shared memory on current device is set.
Definition: hip_device.cpp:117
hipError_t hipGetDevice(int *deviceId)
Return the default device id for the calling host thread.
Definition: hip_device.cpp:32
hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream)
Record an event in the specified stream.
Definition: hip_event.cpp:110
hipError_t hipModuleGetGlobal(void **, size_t *, hipModule_t, const char *)
returns device memory pointer and size of the kernel present in the module with symbol name ...
Definition: hip_module.cpp:285
Definition: hip_hcc_internal.h:369
hipError_t hipDeviceGetPCIBusId(char *pciBusId, int len, int device)
Returns a PCI Bus Id string for the device, overloaded to take int device ID.
Definition: hip_device.cpp:395
prefer larger shared memory and smaller L1 cache
Definition: hip_runtime_api.h:243
hipError_t hipMemcpy2DToArray(hipArray *dst, size_t wOffset, size_t hOffset, const void *src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind)
Copies data between host and device.
Definition: hip_memory.cpp:1233
hipError_t hipStreamQuery(hipStream_t stream)
Return #hipSuccess if all of the operations in the specified stream have completed, or #hipErrorNotReady if not.
Definition: hip_stream.cpp:157
Definition: hip_runtime_api.h:256
hipError_t hipIpcCloseMemHandle(void *devPtr)
Close memory mapped with hipIpcOpenMemHandle.
Definition: hip_memory.cpp:2101
hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes)
Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant byte value va...
Definition: hip_memory.cpp:1773
hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void *ptr)
Return attributes for the specified pointer.
Definition: hip_memory.cpp:161
hipError_t hipProfilerStop()
Stop recording of profiling information. When using this API, start the profiler with profiling disab...
Definition: hip_hcc.cpp:2456
hipError_t hipMemsetD32(hipDeviceptr_t dest, int value, size_t count)
Fills the memory area pointed to by dest with the constant integer value for specified number of time...
Definition: hip_memory.cpp:1789
hipError_t hipProfilerStart()
Start recording of profiling information When using this API, start the profiler with profiling disab...
Definition: hip_hcc.cpp:2446
hipError_t hipLaunchByPtr(const void *func)
Launch a kernel.
Definition: hip_clang.cpp:203
Definition: texture_types.h:93