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 
30 #include <stdint.h>
31 #include <stddef.h>
32 #include <iostream>
33 
34 #ifndef GENERIC_GRID_LAUNCH
35 #define GENERIC_GRID_LAUNCH 1
36 #endif
37 
39 #include <hip/hip_runtime_api.h>
40 #include <hip/hip_texture.h>
41 
42 #if defined (__HCC__) && (__hcc_workweek__ < 16155)
43 #error("This version of HIP requires a newer version of HCC.");
44 #endif
45 
46 #define HIP_LAUNCH_PARAM_BUFFER_POINTER ((void*) 0x01)
47 #define HIP_LAUNCH_PARAM_BUFFER_SIZE ((void*) 0x02)
48 #define HIP_LAUNCH_PARAM_END ((void*) 0x03)
49 
50 // Structure definitions:
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 //---
56 //API-visible structures
57 typedef struct ihipCtx_t *hipCtx_t;
58 
59 // Note many APIs also use integer deviceIds as an alternative to the device pointer:
60 typedef int hipDevice_t;
61 
62 typedef struct ihipStream_t *hipStream_t;
63 
64 //TODO: IPC implementation
65 
66 #define hipIpcMemLazyEnablePeerAccess 0
67 
68 #define HIP_IPC_HANDLE_SIZE 64
69 
70 typedef struct hipIpcMemHandle_st
71 {
72  char reserved[HIP_IPC_HANDLE_SIZE];
74 
75 //TODO: IPC event handle currently unsupported
76 struct ihipIpcEventHandle_t;
77 typedef struct ihipIpcEventHandle_t *hipIpcEventHandle_t;
78 
79 
80 //END TODO
81 
82 typedef struct ihipModule_t *hipModule_t;
83 
84 typedef struct ihipModuleSymbol_t *hipFunction_t;
85 
86 typedef void* hipDeviceptr_t;
87 
88 typedef struct ihipEvent_t *hipEvent_t;
89 
90 enum hipLimit_t
91 {
92  hipLimitMallocHeapSize = 0x02,
93 };
94 
99 #define hipStreamDefault 0x00
101 #define hipStreamNonBlocking 0x01
102 
103 
105 #define hipEventDefault 0x0
106 #define hipEventBlockingSync 0x1
107 #define hipEventDisableTiming 0x2
108 #define hipEventInterprocess 0x4
109 #define hipEventReleaseToDevice 0x40000000
110 #define hipEventReleaseToSystem 0x80000000
111 
112 
114 #define hipHostMallocDefault 0x0
115 #define hipHostMallocPortable 0x1
116 #define hipHostMallocMapped 0x2
117 #define hipHostMallocWriteCombined 0x4
118 #define hipHostMallocCoherent 0x40000000
119 #define hipHostMallocNonCoherent 0x80000000
120 
121 
123 #define hipHostRegisterDefault 0x0
124 #define hipHostRegisterPortable 0x1
125 #define hipHostRegisterMapped 0x2
126 #define hipHostRegisterIoMemory 0x4
127 
128 
129 
130 #define hipDeviceScheduleAuto 0x0
131 #define hipDeviceScheduleSpin 0x1
132 #define hipDeviceScheduleYield 0x2
133 #define hipDeviceScheduleBlockingSync 0x4
134 #define hipDeviceScheduleMask 0x7
135 
136 #define hipDeviceMapHost 0x8
137 #define hipDeviceLmemResizeToMax 0x16
138 
139 
140 /*
141 * @brief hipJitOption
142 * @enum
143 * @ingroup Enumerations
144 */
145 typedef enum hipJitOption {
146  hipJitOptionMaxRegisters = 0,
147  hipJitOptionThreadsPerBlock,
148  hipJitOptionWallTime,
149  hipJitOptionInfoLogBuffer,
150  hipJitOptionInfoLogBufferSizeBytes,
151  hipJitOptionErrorLogBuffer,
152  hipJitOptionErrorLogBufferSizeBytes,
153  hipJitOptionOptimizationLevel,
154  hipJitOptionTargetFromContext,
155  hipJitOptionTarget,
156  hipJitOptionFallbackStrategy,
157  hipJitOptionGenerateDebugInfo,
158  hipJitOptionLogVerbose,
159  hipJitOptionGenerateLineInfo,
160  hipJitOptionCacheMode,
161  hipJitOptionSm3xOpt,
162  hipJitOptionFastCompile,
163  hipJitOptionNumOptions
164 } hipJitOption;
165 
166 
170 typedef enum hipFuncCache_t {
176 
177 
181 typedef enum hipSharedMemConfig {
186 
187 
188 
193 typedef struct dim3 {
194  uint32_t x;
195  uint32_t y;
196  uint32_t z;
197 #ifdef __cplusplus
198  dim3(uint32_t _x=1, uint32_t _y=1, uint32_t _z=1) : x(_x), y(_y), z(_z) {};
199 #endif
200 } dim3;
201 
202 
207 typedef enum hipMemcpyKind {
213 } hipMemcpyKind;
214 
215 typedef struct {
216  unsigned int width;
217  unsigned int height;
218  enum hipChannelFormatKind f;
219  void* data; //FIXME: generalize this
220 } hipArray;
221 
222 
223 
224 // Doxygen end group GlobalDefs
228 //-------------------------------------------------------------------------------------------------
229 
230 
231 // The handle allows the async commands to use the stream even if the parent hipStream_t goes out-of-scope.
232 //typedef class ihipStream_t * hipStream_t;
233 
234 
235 /*
236  * Opaque structure allows the true event (pointed at by the handle) to remain "live" even if the surrounding hipEvent_t goes out-of-scope.
237  * This is handy for cases where the hipEvent_t goes out-of-scope but the true event is being written by some async queue or device */
238 //typedef struct hipEvent_t {
239 // struct ihipEvent_t *_handle;
240 //} hipEvent_t;
241 
242 
243 
244 
245 
246 
247 
275 
276 
277 
289 
290 
317 hipError_t hipSetDevice(int deviceId);
318 
319 
333 hipError_t hipGetDevice(int *deviceId);
334 
335 
347 hipError_t hipGetDeviceCount(int *count);
348 
358 hipError_t hipDeviceGetAttribute(int* pi, hipDeviceAttribute_t attr, int deviceId);
359 
374 
375 
385 hipError_t hipDeviceSetCacheConfig ( hipFuncCache_t cacheConfig );
386 
387 
397 hipError_t hipDeviceGetCacheConfig ( hipFuncCache_t *cacheConfig );
398 
409 hipError_t hipDeviceGetLimit(size_t *pValue, enum hipLimit_t limit);
410 
411 
421 hipError_t hipFuncSetCacheConfig (const void* func, hipFuncCache_t config );
422 
433 hipError_t hipDeviceGetSharedMemConfig ( hipSharedMemConfig * pConfig );
434 
435 
446 hipError_t hipDeviceSetSharedMemConfig ( hipSharedMemConfig config );
447 
467 hipError_t hipSetDeviceFlags ( unsigned flags);
468 
477 hipError_t hipChooseDevice(int *device, const hipDeviceProp_t* prop);
478 
479 // end doxygen Device
502 
503 
515 
516 
517 
526 const char *hipGetErrorName(hipError_t hip_error);
527 
528 
539 const char *hipGetErrorString(hipError_t hipError);
540 
541 // end doxygen Error
575 hipError_t hipStreamCreate(hipStream_t *stream);
576 
577 
594 hipError_t hipStreamCreateWithFlags(hipStream_t *stream, unsigned int flags);
595 
596 
612 hipError_t hipStreamDestroy(hipStream_t stream);
613 
614 
627 hipError_t hipStreamQuery(hipStream_t stream);
628 
629 
647 hipError_t hipStreamSynchronize(hipStream_t stream);
648 
649 
668 hipError_t hipStreamWaitEvent(hipStream_t stream, hipEvent_t event, unsigned int flags);
669 
670 
671 
685 hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int *flags);
686 
690 typedef void(* hipStreamCallback_t)(hipStream_t stream, hipError_t status, void* userData);
691 
706 hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback, void *userData, unsigned int flags);
707 
708 
709 // end doxygen Stream
740 hipError_t hipEventCreateWithFlags(hipEvent_t* event, unsigned flags);
741 
742 
752 hipError_t hipEventCreate(hipEvent_t* event);
753 
754 
779 #ifdef __cplusplus
780 hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream = NULL);
781 #else
782 hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream);
783 #endif
784 
798 hipError_t hipEventDestroy(hipEvent_t event);
799 
800 
815 hipError_t hipEventSynchronize(hipEvent_t event);
816 
817 
844 hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop);
845 
846 
859 hipError_t hipEventQuery(hipEvent_t event) ;
860 
861 
862 // end doxygen Events
894 hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void* ptr);
895 
908 hipError_t hipMalloc(void** ptr, size_t size) ;
909 
922 hipError_t hipMallocHost(void** ptr, size_t size) __attribute__((deprecated("use hipHostMalloc instead"))) ;
923 
937 hipError_t hipHostMalloc(void** ptr, size_t size, unsigned int flags) ;
938 
952 hipError_t hipHostAlloc(void** ptr, size_t size, unsigned int flags) __attribute__((deprecated("use hipHostMalloc instead"))) ;
953 
965 hipError_t hipHostGetDevicePointer(void** devPtr, void* hstPtr, unsigned int flags) ;
966 
976 hipError_t hipHostGetFlags(unsigned int* flagsPtr, void* hostPtr) ;
977 
1010 hipError_t hipHostRegister(void* hostPtr, size_t sizeBytes, unsigned int flags) ;
1011 
1020 hipError_t hipHostUnregister(void* hostPtr) ;
1021 
1040 hipError_t hipMallocPitch(void** ptr, size_t* pitch, size_t width, size_t height);
1041 
1053 hipError_t hipFree(void* ptr);
1054 
1064 hipError_t hipFreeHost(void* ptr) __attribute__((deprecated("use hipHostFree instead")));
1065 
1077 hipError_t hipHostFree(void* ptr);
1078 
1100 hipError_t hipMemcpy(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind);
1101 
1113 hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void* src, size_t sizeBytes);
1114 
1126 hipError_t hipMemcpyDtoH(void* dst, hipDeviceptr_t src, size_t sizeBytes);
1127 
1139 hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes);
1140 
1152 hipError_t hipMemcpyHtoDAsync(hipDeviceptr_t dst, void* src, size_t sizeBytes, hipStream_t stream);
1153 
1165 hipError_t hipMemcpyDtoHAsync(void* dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream);
1166 
1178 hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream);
1179 
1180 
1197 hipError_t hipMemcpyToSymbol(const void* symbolName, const void *src, size_t sizeBytes, size_t offset = 0, hipMemcpyKind kind = hipMemcpyHostToDevice);
1198 
1199 
1217 hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream = 0);
1218 
1219 hipError_t hipMemcpyFromSymbol(void *dst, const void* symbolName, size_t sizeBytes, size_t offset = 0, hipMemcpyKind kind = hipMemcpyDeviceToHost);
1220 
1221 hipError_t hipMemcpyFromSymbolAsync(void *dst, const void* symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream = 0);
1222 
1245 #if __cplusplus
1246 hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream=0);
1247 #else
1248 hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream);
1249 #endif
1250 
1259 hipError_t hipMemset(void* dst, int value, size_t sizeBytes );
1260 
1269 hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeBytes );
1270 
1284 #if __cplusplus
1285 hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream = 0 );
1286 #else
1287 hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream);
1288 #endif
1289 
1298 hipError_t hipMemGetInfo (size_t * free, size_t * total) ;
1299 
1300 
1301 hipError_t hipMemPtrGetInfo(void *ptr, size_t *size);
1302 
1303 
1316 #if __cplusplus
1318  size_t width, size_t height = 0, unsigned int flags = 0);
1319 #else
1320 hipError_t hipMallocArray(hipArray** array, const struct hipChannelFormatDesc* desc,
1321  size_t width, size_t height, unsigned int flags);
1322 #endif
1323 
1332 
1347 hipError_t hipMemcpy2D(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, size_t height, hipMemcpyKind kind);
1348 
1364 #if __cplusplus
1365 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 = 0);
1366 #else
1367 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);
1368 #endif
1369 
1384 hipError_t hipMemcpy2DToArray(hipArray* dst, size_t wOffset, size_t hOffset, const void* src,
1385  size_t spitch, size_t width, size_t height, hipMemcpyKind kind);
1386 
1401 hipError_t hipMemcpyToArray(hipArray* dst, size_t wOffset, size_t hOffset,
1402  const void* src, size_t count, hipMemcpyKind kind);
1403 
1404 
1405 
1406 // doxygen end Memory
1439 hipError_t hipDeviceCanAccessPeer (int* canAccessPeer, int deviceId, int peerDeviceId);
1440 
1441 
1457 hipError_t hipDeviceEnablePeerAccess (int peerDeviceId, unsigned int flags);
1458 
1459 
1470 hipError_t hipDeviceDisablePeerAccess (int peerDeviceId);
1471 
1483 hipError_t hipMemGetAddressRange ( hipDeviceptr_t* pbase, size_t* psize, hipDeviceptr_t dptr );
1484 
1485 #ifndef USE_PEER_NON_UNIFIED
1486 #define USE_PEER_NON_UNIFIED 1
1487 #endif
1488 
1489 #if USE_PEER_NON_UNIFIED==1
1490 
1502 hipError_t hipMemcpyPeer (void* dst, int dstDeviceId, const void* src, int srcDeviceId, size_t sizeBytes);
1503 
1516 #if __cplusplus
1517 hipError_t hipMemcpyPeerAsync ( void* dst, int dstDeviceId, const void* src, int srcDevice, size_t sizeBytes, hipStream_t stream=0 );
1518 #else
1519 hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice, size_t sizeBytes, hipStream_t stream);
1520 #endif
1521 #endif
1522 
1523 
1524 // doxygen end PeerToPeer
1543 // TODO-ctx - more description on error codes.
1544 hipError_t hipInit(unsigned int flags) ;
1545 
1546 
1565 hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device);
1566 
1576 hipError_t hipCtxDestroy(hipCtx_t ctx);
1577 
1587 hipError_t hipCtxPopCurrent(hipCtx_t* ctx);
1588 
1598 hipError_t hipCtxPushCurrent(hipCtx_t ctx);
1599 
1609 hipError_t hipCtxSetCurrent(hipCtx_t ctx);
1610 
1620 hipError_t hipCtxGetCurrent(hipCtx_t* ctx);
1621 
1632 hipError_t hipCtxGetDevice(hipDevice_t *device);
1633 
1650 hipError_t hipCtxGetApiVersion (hipCtx_t ctx,int *apiVersion);
1651 
1663 hipError_t hipCtxGetCacheConfig ( hipFuncCache_t *cacheConfig );
1664 
1676 hipError_t hipCtxSetCacheConfig ( hipFuncCache_t cacheConfig );
1677 
1689 hipError_t hipCtxSetSharedMemConfig ( hipSharedMemConfig config );
1690 
1702 hipError_t hipCtxGetSharedMemConfig ( hipSharedMemConfig * pConfig );
1703 
1713 hipError_t hipCtxSynchronize ( void );
1714 
1724 hipError_t hipCtxGetFlags ( unsigned int* flags );
1725 
1742 hipError_t hipCtxEnablePeerAccess (hipCtx_t peerCtx, unsigned int flags);
1743 
1756 hipError_t hipCtxDisablePeerAccess (hipCtx_t peerCtx);
1757 
1769 hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active );
1770 
1781 hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev);
1782 
1793 hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev );
1794 
1804 hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev );
1805 
1816 hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags );
1817 
1818 // doxygen end Context Management
1830 hipError_t hipDeviceGet(hipDevice_t *device, int ordinal);
1831 
1840 hipError_t hipDeviceComputeCapability(int *major,int *minor,hipDevice_t device);
1841 
1850 hipError_t hipDeviceGetName(char *name,int len,hipDevice_t device);
1851 
1860 hipError_t hipDeviceGetPCIBusId (char *pciBusId,int len,int device);
1861 
1862 
1870 hipError_t hipDeviceGetByPCIBusId ( int* device,const int* pciBusId );
1871 
1872 
1880 hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device);
1881 
1897 hipError_t hipDriverGetVersion(int *driverVersion) ;
1898 
1911 hipError_t hipRuntimeGetVersion(int *runtimeVersion) ;
1912 
1923 hipError_t hipModuleLoad(hipModule_t *module, const char *fname);
1924 
1935 hipError_t hipModuleUnload(hipModule_t module);
1936 
1946 hipError_t hipModuleGetFunction(hipFunction_t *function, hipModule_t module, const char *kname);
1947 
1958 hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, hipModule_t hmod, const char *name);
1959 
1968 hipError_t hipModuleLoadData(hipModule_t *module, const void *image);
1969 
1981 hipError_t hipModuleLoadDataEx(hipModule_t *module, const void *image, unsigned int numOptions, hipJitOption *options, void **optionValues);
1982 
2002 hipError_t hipModuleLaunchKernel(hipFunction_t f,
2003  unsigned int gridDimX,
2004  unsigned int gridDimY,
2005  unsigned int gridDimZ,
2006  unsigned int blockDimX,
2007  unsigned int blockDimY,
2008  unsigned int blockDimZ,
2009  unsigned int sharedMemBytes,
2010  hipStream_t stream,
2011  void **kernelParams,
2012  void **extra) ;
2013 
2014 // doxygen end Version Management
2032 // TODO - expand descriptions:
2039 
2040 
2047 
2048 
2053 //TODO: implement IPC apis
2054 
2080 hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t *handle, void *devPtr);
2081 
2118 hipError_t hipIpcOpenMemHandle(void **devPtr,
2119  hipIpcMemHandle_t handle, unsigned int flags);
2120 
2139 hipError_t hipIpcCloseMemHandle(void *devPtr);
2140 
2141 
2142 // hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t* handle, void* devPtr);
2143 // hipError_t hipIpcCloseMemHandle(void *devPtr);
2144 // // hipError_t hipIpcOpenEventHandle(hipEvent_t* event, hipIpcEventHandle_t handle);
2145 // hipError_t hipIpcOpenMemHandle(void** devPtr, hipIpcMemHandle_t handle, unsigned int flags);
2146 
2147 
2148 #ifdef __cplusplus
2149 } /* extern "c" */
2150 #endif
2151 
2152 #ifdef __cplusplus
2153 /*
2154  * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex.
2155  *
2156  * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level
2157  * hipBindTexture() function. Any memory previously bound to tex is unbound.
2158  *
2159  * @param[in] offset - Offset in bytes
2160  * @param[out] tex - texture to bind
2161  * @param[in] devPtr - Memory area on device
2162  * @param[in] desc - Channel format
2163  * @param[in] size - Size of the memory area pointed to by devPtr
2164  * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
2165  **/
2166 template <class T, int dim, enum hipTextureReadMode readMode>
2167 hipError_t hipBindTexture(size_t *offset,
2168  struct texture<T, dim, readMode> &tex,
2169  const void *devPtr,
2170  const struct hipChannelFormatDesc *desc,
2171  size_t size=UINT_MAX)
2172 {
2173  tex._dataPtr = static_cast<const T*>(devPtr);
2174 
2175  return hipSuccess;
2176 }
2177 
2178 /*
2179  * @brief hipBindTexture Binds size bytes of the memory area pointed to by @p devPtr to the texture reference tex.
2180  *
2181  * @p desc describes how the memory is interpreted when fetching values from the texture. The @p offset parameter is an optional byte offset as with the low-level
2182  * hipBindTexture() function. Any memory previously bound to tex is unbound.
2183  *
2184  * @param[in] offset - Offset in bytes
2185  * @param[in] tex - texture to bind
2186  * @param[in] devPtr - Memory area on device
2187  * @param[in] size - Size of the memory area pointed to by devPtr
2188  * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree, #hipErrorUnknown
2189  **/
2190 template <class T, int dim, enum hipTextureReadMode readMode>
2191 hipError_t hipBindTexture(size_t *offset,
2192  struct texture<T, dim, readMode> &tex,
2193  const void *devPtr,
2194  size_t size=UINT_MAX)
2195 {
2196  return hipBindTexture(offset, tex, devPtr, &tex.channelDesc, size);
2197 }
2198 
2199 template <class T, int dim, enum hipTextureReadMode readMode>
2200 hipError_t hipBindTextureToArray(struct texture<T, dim, readMode> &tex, hipArray* array) {
2201  tex.width = array->width;
2202  tex.height = array->height;
2203  tex._dataPtr = static_cast<const T*>(array->data);
2204  return hipSuccess;
2205 }
2206 
2207 /*
2208  * @brief Unbinds the textuer bound to @p tex
2209  *
2210  * @param[in] tex - texture to unbind
2211  *
2212  * @return #hipSuccess
2213  **/
2214 template <class T, int dim, enum hipTextureReadMode readMode>
2215 hipError_t hipUnbindTexture(struct texture<T, dim, readMode> &tex)
2216 {
2217  tex._dataPtr = NULL;
2218 
2219  return hipSuccess;
2220 }
2221 
2222 
2223 
2224 // doxygen end Texture
2230 #endif
2231 
2232 
2250 // end-group HCC_Specific
2257 // doxygen end HIP API
2262 #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:1199
prefer larger L1 cache and smaller shared memory
Definition: hip_runtime_api.h:173
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:359
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:222
hipError_t hipDeviceGetByPCIBusId(int *device, const int *pciBusId)
Returns a handle to a compute device.
Definition: hip_device.cpp:403
hipError_t hipDeviceGetCacheConfig(hipFuncCache_t *cacheConfig)
Set Cache configuration for a specific function.
Definition: hip_device.cpp:88
hipError_t hipMemcpyAsync(void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream)
Copy data from src to dst asynchronously.
Definition: hip_memory.cpp:772
hipError_t hipDriverGetVersion(int *driverVersion)
Returns the approximate HIP driver version.
Definition: hip_context.cpp:90
hipError_t hipPeekAtLastError(void)
Return last error returned by any HIP runtime API call.
Definition: hip_error.cpp:42
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)
Copies data between host and device.
hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags)
Set flags for the primary context.
Definition: hip_context.cpp:349
hipError_t hipDevicePrimaryCtxRetain(hipCtx_t *pctx, hipDevice_t dev)
Retain the primary context on the GPU.
Definition: hip_context.cpp:322
struct dim3 dim3
hipError_t hipDeviceComputeCapability(int *major, int *minor, hipDevice_t device)
Returns the compute capability of the device.
Definition: hip_device.cpp:349
hipError_t hipMemGetAddressRange(hipDeviceptr_t *pbase, size_t *psize, hipDeviceptr_t dptr)
Get information on memory allocations.
Definition: hip_memory.cpp:1257
TODO-doc.
Successful completion.
Definition: hip_runtime_api.h:155
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:900
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:584
hipError_t hipMallocPitch(void **ptr, size_t *pitch, size_t width, size_t height)
Definition: hip_memory.cpp:330
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:803
hipError_t hipMemcpyToSymbol(const void *symbolName, const void *src, size_t sizeBytes, size_t offset=0, hipMemcpyKind kind=hipMemcpyHostToDevice)
Copies sizeBytes bytes from the memory area pointed to by src to the memory area pointed to by offset...
Definition: hip_memory.cpp:512
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:207
uint32_t x
x
Definition: hip_runtime_api.h:194
Host-to-Device Copy.
Definition: hip_runtime_api.h:209
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:194
hipError_t hipCtxPopCurrent(hipCtx_t *ctx)
Pop the current/default context and return the popped context.
Definition: hip_context.cpp:145
const char * hipGetErrorString(hipError_t hipError)
Return handy text string message to explain the error which occurred.
Definition: hip_error.cpp:57
hipError_t hipDeviceGetSharedMemConfig(hipSharedMemConfig *pConfig)
Returns bank width of shared memory for current device.
Definition: hip_device.cpp:133
Definition: hip_runtime_api.h:127
Device-to-Host Copy.
Definition: hip_runtime_api.h:210
prefer equal size L1 cache and shared memory
Definition: hip_runtime_api.h:174
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:1233
hipError_t hipEventSynchronize(hipEvent_t event)
Wait for an event to complete.
Definition: hip_event.cpp:176
hipError_t hipMemcpyHtoD(hipDeviceptr_t dst, void *src, size_t sizeBytes)
Copy data from Host to Device.
Definition: hip_memory.cpp:681
hipError_t hipModuleUnload(hipModule_t module)
Frees the module.
Definition: hip_module.cpp:274
Definition: hip_module.cpp:66
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:255
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:186
hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig *pConfig)
Get Shared memory bank configuration.
Definition: hip_context.cpp:262
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:56
hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config)
Set Shared memory bank configuration.
Definition: hip_context.cpp:253
hipError_t hipCtxSetCurrent(hipCtx_t ctx)
Set the passed context as current/default.
Definition: hip_context.cpp:192
hipError_t hipMallocHost(void **ptr, size_t size) __attribute__((deprecated("use hipHostMalloc instead")))
Allocate pinned host memory [Deprecated].
Definition: hip_memory.cpp:316
hipError_t hipIpcGetMemHandle(hipIpcMemHandle_t *handle, void *devPtr)
Gets an interprocess memory handle for an existing device memory allocation.
Definition: hip_memory.cpp:1276
hipError_t hipHostMalloc(void **ptr, size_t size, unsigned int flags)
Allocate device accessible page locked host memory.
Definition: hip_memory.cpp:247
Definition: hip_hcc_internal.h:775
hipError_t hipDeviceGetLimit(size_t *pValue, enum hipLimit_t limit)
Get Resource limits of current device.
Definition: hip_device.cpp:101
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:534
Definition: hip_runtime_api.h:215
hipDeviceAttribute_t
Definition: hip_runtime_api.h:225
hipError_t hipEventDestroy(hipEvent_t event)
Destroy the specified event.
Definition: hip_event.cpp:163
hipError_t hipStreamCreateWithFlags(hipStream_t *stream, unsigned int flags)
Create an asynchronous stream.
Definition: hip_stream.cpp:68
hipError_t hipChooseDevice(int *device, const hipDeviceProp_t *prop)
Device which matches hipDeviceProp_t is returned.
Definition: hip_device.cpp:422
hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig)
Set L1/Shared cache partition.
Definition: hip_context.cpp:244
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:193
uint32_t y
y
Definition: hip_runtime_api.h:195
hipError_t hipModuleLoad(hipModule_t *module, const char *fname)
Loads code object from file into a hipModule_t.
Definition: hip_module.cpp:161
hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev)
Resets the primary context on the GPU.
Definition: hip_context.cpp:335
hipError_t hipEventCreateWithFlags(hipEvent_t *event, unsigned flags)
Create an event with the specified flags.
Definition: hip_event.cpp:114
hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop)
Return the elapsed time between two events.
Definition: hip_event.cpp:203
hipError_t hipDeviceSetCacheConfig(hipFuncCache_t cacheConfig)
Set L1/Shared cache partition.
Definition: hip_device.cpp:79
hipError_t hipDeviceCanAccessPeer(int *canAccessPeer, int deviceId, int peerDeviceId)
Determine if a device can access a peer&#39;s memory.
Definition: hip_peer.cpp:179
hipError_t hipGetDeviceCount(int *count)
Return number of compute-capable devices.
Definition: hip_device.cpp:73
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:1009
hipError_t hipStreamDestroy(hipStream_t stream)
Destroys the specified stream.
Definition: hip_stream.cpp:164
hipError_t hipHostGetFlags(unsigned int *flagsPtr, void *hostPtr)
Return flags associated with host pointer.
Definition: hip_memory.cpp:421
hipError_t hipStreamSynchronize(hipStream_t stream)
Wait for all commands in stream to complete.
Definition: hip_stream.cpp:140
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:1308
hipError_t hipCtxGetCacheConfig(hipFuncCache_t *cacheConfig)
Set Cache configuration for a specific function.
Definition: hip_context.cpp:235
hipError_t hipMemcpyDtoD(hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes)
Copy data from Device to Device.
Definition: hip_memory.cpp:725
Shared mem is banked at 4-bytes intervals and performs best when adjacent threads access data 4 bytes...
Definition: hip_runtime_api.h:183
hipError_t
Definition: hip_runtime_api.h:154
no preference for shared memory or L1 (default)
Definition: hip_runtime_api.h:171
hipMemcpyKind
Definition: hip_runtime_api.h:207
hipError_t hipCtxSynchronize(void)
Blocks until the default context has completed all preceding requested tasks.
Definition: hip_context.cpp:271
hipError_t hipCtxGetCurrent(hipCtx_t *ctx)
Get the handle of the current/ default context.
Definition: hip_context.cpp:179
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:795
hipError_t hipDeviceSynchronize(void)
Waits on all active streams on current device.
Definition: hip_device.cpp:153
hipError_t hipCtxPushCurrent(hipCtx_t ctx)
Push the context to be set as current/ default context.
Definition: hip_context.cpp:165
hipError_t hipMemcpyDtoH(void *dst, hipDeviceptr_t src, size_t sizeBytes)
Copy data from Device to Host.
Definition: hip_memory.cpp:703
Definition: hip_hcc_internal.h:345
hipError_t hipDeviceGetName(char *name, int len, hipDevice_t device)
Returns an identifer string for the device.
Definition: hip_device.cpp:358
hipError_t hipGetDeviceProperties(hipDeviceProp_t *prop, int deviceId)
Returns device properties.
Definition: hip_device.cpp:298
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:447
hipError_t hipMalloc(void **ptr, size_t size)
Allocate memory on the default accelerator.
Definition: hip_memory.cpp:215
const char * hipGetErrorName(hipError_t hip_error)
Return name of the specified error code in text form.
Definition: hip_error.cpp:50
hipFuncCache_t
Definition: hip_runtime_api.h:170
hipError_t hipGetLastError(void)
Return last error returned by any HIP runtime API call and resets the stored error code to hipSuccess...
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:85
hipError_t hipStreamGetFlags(hipStream_t stream, unsigned int *flags)
Return flags associated with this stream.
Definition: hip_stream.cpp:191
hipError_t hipHostAlloc(void **ptr, size_t size, unsigned int flags) __attribute__((deprecated("use hipHostMalloc instead")))
Allocate device accessible page locked host memory [Deprecated].
Definition: hip_memory.cpp:323
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:1111
hipError_t hipCtxGetDevice(hipDevice_t *device)
Get the handle of the device associated with current/default context.
Definition: hip_context.cpp:206
hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev)
Release the primary context on the GPU.
Definition: hip_context.cpp:310
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:1171
uint32_t z
z
Definition: hip_runtime_api.h:196
hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int *apiVersion)
Returns the approximate HIP api version.
Definition: hip_context.cpp:224
hipError_t hipDeviceReset(void)
The state of current device is discarded and updated to a fresh state.
Definition: hip_device.cpp:159
hipError_t hipInit(unsigned int flags)
Explicitly initializes the HIP runtime.
Definition: hip_context.cpp:42
hipError_t hipRuntimeGetVersion(int *runtimeVersion)
Returns the approximate HIP Runtime version.
Definition: hip_context.cpp:104
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:788
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:142
hipError_t hipDeviceGet(hipDevice_t *device, int ordinal)
Returns a handle to a compute device.
Definition: hip_context.cpp:74
hipError_t hipDeviceTotalMem(size_t *bytes, hipDevice_t device)
Returns the total amount of memory on the device.
Definition: hip_device.cpp:394
hipError_t hipMemsetAsync(void *dst, int value, size_t sizeBytes, hipStream_t stream)
Fills the first sizeBytes bytes of the memory area pointed to by dev with the constant byte value val...
Definition: hip_memory.cpp:960
hipError_t hipFuncSetCacheConfig(const void *func, hipFuncCache_t config)
Set Cache configuration for a specific function.
Definition: hip_device.cpp:115
The compiler selects a device-specific value for the banking.
Definition: hip_runtime_api.h:182
hipError_t hipCtxGetFlags(unsigned int *flags)
Return flags used for creating default context.
Definition: hip_context.cpp:277
Device-to-Device Copy.
Definition: hip_runtime_api.h:211
hipError_t hipCtxDestroy(hipCtx_t ctx)
Destroy a HIP context.
Definition: hip_context.cpp:118
hipError_t hipMemcpyPeerAsync(void *dst, int dstDevice, const void *src, int srcDevice, size_t sizeBytes, hipStream_t stream)
Copies memory from one device to memory on another device.
Definition: hip_peer.cpp:209
Runtime will automatically determine copy-kind based on virtual addresses.
Definition: hip_runtime_api.h:212
hipSharedMemConfig
Definition: hip_runtime_api.h:181
Definition: driver_types.h:34
Definition: hip_hcc_internal.h:603
hipError_t hipMallocArray(hipArray **array, const struct hipChannelFormatDesc *desc, size_t width, size_t height, unsigned int flags)
Allocate an array on the device.
hipError_t hipDeviceGetAttribute(int *pi, hipDeviceAttribute_t attr, int deviceId)
Query for a specific device attribute.
Definition: hip_device.cpp:272
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:781
hipError_t hipHostUnregister(void *hostPtr)
Un-register host pointer.
Definition: hip_memory.cpp:494
Definition: hip_hcc_internal.h:491
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:202
hipError_t hipStreamCreate(hipStream_t *stream)
Create an asynchronous stream.
Definition: hip_stream.cpp:77
hipError_t hipMemcpy(void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind)
Copy data from src to dst.
Definition: hip_memory.cpp:659
hipError_t hipEventCreate(hipEvent_t *event)
Definition: hip_event.cpp:121
Definition: hip_runtime_api.h:70
hipError_t hipFreeHost(void *ptr) __attribute__((deprecated("use hipHostFree instead")))
Free memory allocated by the hcc hip host memory allocation API. [Deprecated].
Definition: hip_memory.cpp:1228
hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int *flags, int *active)
Get the state of the primary context.
Definition: hip_context.cpp:287
hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags)
Enables direct access to memory allocations in a peer context.
Definition: hip_peer.cpp:215
hipError_t hipDeviceSetSharedMemConfig(hipSharedMemConfig config)
The bank width of shared memory on current device is set.
Definition: hip_device.cpp:124
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:128
hipError_t hipModuleGetGlobal(hipDeviceptr_t *dptr, size_t *bytes, hipModule_t hmod, const char *name)
returns device memory pointer and size of the kernel present in the module with symbol name ...
Definition: hip_module.cpp:514
Host-to-Host Copy.
Definition: hip_runtime_api.h:208
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:369
prefer larger shared memory and smaller L1 cache
Definition: hip_runtime_api.h:172
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:847
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:115
Shared mem is banked at 8-byte intervals and performs best when adjacent threads access data 4 bytes ...
Definition: hip_runtime_api.h:184
hipError_t hipIpcCloseMemHandle(void *devPtr)
Close memory mapped with hipIpcOpenMemHandle.
Definition: hip_memory.cpp:1339
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:1061
hipError_t hipPointerGetAttributes(hipPointerAttribute_t *attributes, const void *ptr)
Return attributes for the specified pointer.
Definition: hip_memory.cpp:145
hipError_t hipMemcpyToSymbolAsync(const void *symbolName, const void *src, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream=0)
Copies sizeBytes bytes from the memory area pointed to by src to the memory area pointed to by offset...
Definition: hip_memory.cpp:582
hipError_t hipProfilerStop()
Stop recording of profiling information. When using this API, start the profiler with profiling disab...
Definition: hip_hcc.cpp:2068
void(* hipStreamCallback_t)(hipStream_t stream, hipError_t status, void *userData)
Definition: hip_runtime_api.h:690
hipError_t hipProfilerStart()
Start recording of profiling information When using this API, start the profiler with profiling disab...
Definition: hip_hcc.cpp:2057