HIP: Heterogenous-computing Interface for Portability
Classes | Macros | Typedefs | Enumerations | Functions
hip_runtime_api.h File Reference

Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h. More...

#include <stdint.h>
#include <stddef.h>
#include <iostream>
#include <hip/hcc_detail/host_defines.h>
#include <hip/hip_runtime_api.h>
#include <hip/hip_texture.h>

Go to the source code of this file.

Classes

struct  hipIpcMemHandle_st
 
struct  dim3
 
struct  hipArray
 

Macros

#define GENERIC_GRID_LAUNCH   1
 
#define HIP_LAUNCH_PARAM_BUFFER_POINTER   ((void*) 0x01)
 
#define HIP_LAUNCH_PARAM_BUFFER_SIZE   ((void*) 0x02)
 
#define HIP_LAUNCH_PARAM_END   ((void*) 0x03)
 
#define hipIpcMemLazyEnablePeerAccess   0
 
#define HIP_IPC_HANDLE_SIZE   64
 
#define hipStreamDefault   0x00
 Flags that can be used with hipStreamCreateWithFlags. More...
 
#define hipStreamNonBlocking   0x01
 Stream does not implicitly synchronize with null stream.
 
#define hipEventDefault   0x0
 Flags that can be used with hipEventCreateWithFlags: More...
 
#define hipEventBlockingSync   0x1
 Waiting will yield CPU. Power-friendly and usage-friendly but may increase latency.
 
#define hipEventDisableTiming   0x2
 Disable event's capability to record timing information. May improve performance.
 
#define hipEventInterprocess   0x4
 Event can support IPC. More...
 
#define hipEventReleaseToDevice   0x40000000
 
#define hipEventReleaseToSystem   0x80000000
 
#define hipHostMallocDefault   0x0
 Flags that can be used with hipHostMalloc.
 
#define hipHostMallocPortable   0x1
 Memory is considered allocated by all contexts.
 
#define hipHostMallocMapped   0x2
 Map the allocation into the address space for the current device. The device pointer can be obtained with hipHostGetDevicePointer.
 
#define hipHostMallocWriteCombined   0x4
 
#define hipHostMallocCoherent   0x40000000
 Allocate coherent memory. Overrides HIP_COHERENT_HOST_ALLOC for specific allocation.
 
#define hipHostMallocNonCoherent   0x80000000
 Allocate non-coherent memory. Overrides HIP_COHERENT_HOST_ALLOC for specific allocation.
 
#define hipHostRegisterDefault   0x0
 Flags that can be used with hipHostRegister. More...
 
#define hipHostRegisterPortable   0x1
 Memory is considered registered by all contexts.
 
#define hipHostRegisterMapped   0x2
 Map the allocation into the address space for the current device. The device pointer can be obtained with hipHostGetDevicePointer.
 
#define hipHostRegisterIoMemory   0x4
 Not supported.
 
#define hipDeviceScheduleAuto   0x0
 Automatically select between Spin and Yield.
 
#define hipDeviceScheduleSpin   0x1
 Dedicate a CPU core to spin-wait. Provides lowest latency, but burns a CPU core and may consume more power.
 
#define hipDeviceScheduleYield   0x2
 Yield the CPU to the operating system when waiting. May increase latency, but lowers power and is friendlier to other threads in the system.
 
#define hipDeviceScheduleBlockingSync   0x4
 
#define hipDeviceScheduleMask   0x7
 
#define hipDeviceMapHost   0x8
 
#define hipDeviceLmemResizeToMax   0x16
 
#define USE_PEER_NON_UNIFIED   1
 

Typedefs

typedef struct ihipCtx_thipCtx_t
 
typedef int hipDevice_t
 
typedef struct ihipStream_thipStream_t
 
typedef struct hipIpcMemHandle_st hipIpcMemHandle_t
 
typedef struct ihipIpcEventHandle_t * hipIpcEventHandle_t
 
typedef struct ihipModule_thipModule_t
 
typedef struct ihipModuleSymbol_thipFunction_t
 
typedef void * hipDeviceptr_t
 
typedef struct ihipEvent_thipEvent_t
 
typedef enum hipJitOption hipJitOption
 
typedef enum hipFuncCache_t hipFuncCache_t
 
typedef enum hipSharedMemConfig hipSharedMemConfig
 
typedef struct dim3 dim3
 
typedef enum hipMemcpyKind hipMemcpyKind
 
typedef void(* hipStreamCallback_t) (hipStream_t stream, hipError_t status, void *userData)
 

Enumerations

enum  hipLimit_t { hipLimitMallocHeapSize = 0x02 }
 
enum  hipJitOption {
  hipJitOptionMaxRegisters = 0, hipJitOptionThreadsPerBlock, hipJitOptionWallTime, hipJitOptionInfoLogBuffer,
  hipJitOptionInfoLogBufferSizeBytes, hipJitOptionErrorLogBuffer, hipJitOptionErrorLogBufferSizeBytes, hipJitOptionOptimizationLevel,
  hipJitOptionTargetFromContext, hipJitOptionTarget, hipJitOptionFallbackStrategy, hipJitOptionGenerateDebugInfo,
  hipJitOptionLogVerbose, hipJitOptionGenerateLineInfo, hipJitOptionCacheMode, hipJitOptionSm3xOpt,
  hipJitOptionFastCompile, hipJitOptionNumOptions
}
 
enum  hipFuncCache_t { hipFuncCachePreferNone, hipFuncCachePreferShared, hipFuncCachePreferL1, hipFuncCachePreferEqual }
 
enum  hipSharedMemConfig { hipSharedMemBankSizeDefault, hipSharedMemBankSizeFourByte, hipSharedMemBankSizeEightByte }
 
enum  hipMemcpyKind {
  hipMemcpyHostToHost = 0, hipMemcpyHostToDevice = 1, hipMemcpyDeviceToHost = 2, hipMemcpyDeviceToDevice =3,
  hipMemcpyDefault = 4
}
 

Functions

hipError_t hipDeviceSynchronize (void)
 Waits on all active streams on current device. More...
 
hipError_t hipDeviceReset (void)
 The state of current device is discarded and updated to a fresh state. More...
 
hipError_t hipSetDevice (int deviceId)
 Set default device to be used for subsequent hip API calls from this thread. More...
 
hipError_t hipGetDevice (int *deviceId)
 Return the default device id for the calling host thread. More...
 
hipError_t hipGetDeviceCount (int *count)
 Return number of compute-capable devices. More...
 
hipError_t hipDeviceGetAttribute (int *pi, hipDeviceAttribute_t attr, int deviceId)
 Query for a specific device attribute. More...
 
hipError_t hipGetDeviceProperties (hipDeviceProp_t *prop, int deviceId)
 Returns device properties. More...
 
hipError_t hipDeviceSetCacheConfig (hipFuncCache_t cacheConfig)
 Set L1/Shared cache partition. More...
 
hipError_t hipDeviceGetCacheConfig (hipFuncCache_t *cacheConfig)
 Set Cache configuration for a specific function. More...
 
hipError_t hipDeviceGetLimit (size_t *pValue, enum hipLimit_t limit)
 Get Resource limits of current device. More...
 
hipError_t hipFuncSetCacheConfig (const void *func, hipFuncCache_t config)
 Set Cache configuration for a specific function. More...
 
hipError_t hipDeviceGetSharedMemConfig (hipSharedMemConfig *pConfig)
 Returns bank width of shared memory for current device. More...
 
hipError_t hipDeviceSetSharedMemConfig (hipSharedMemConfig config)
 The bank width of shared memory on current device is set. More...
 
hipError_t hipSetDeviceFlags (unsigned flags)
 The current device behavior is changed according the flags passed. More...
 
hipError_t hipChooseDevice (int *device, const hipDeviceProp_t *prop)
 Device which matches hipDeviceProp_t is returned. More...
 
hipError_t hipGetLastError (void)
 Return last error returned by any HIP runtime API call and resets the stored error code to hipSuccess. More...
 
hipError_t hipPeekAtLastError (void)
 Return last error returned by any HIP runtime API call. More...
 
const char * hipGetErrorName (hipError_t hip_error)
 Return name of the specified error code in text form. More...
 
const char * hipGetErrorString (hipError_t hipError)
 Return handy text string message to explain the error which occurred. More...
 
hipError_t hipStreamCreate (hipStream_t *stream)
 Create an asynchronous stream. More...
 
hipError_t hipStreamCreateWithFlags (hipStream_t *stream, unsigned int flags)
 Create an asynchronous stream. More...
 
hipError_t hipStreamDestroy (hipStream_t stream)
 Destroys the specified stream. More...
 
hipError_t hipStreamQuery (hipStream_t stream)
 Return hipSuccess if all of the operations in the specified stream have completed, or hipErrorNotReady if not. More...
 
hipError_t hipStreamSynchronize (hipStream_t stream)
 Wait for all commands in stream to complete. More...
 
hipError_t hipStreamWaitEvent (hipStream_t stream, hipEvent_t event, unsigned int flags)
 Make the specified compute stream wait for an event. More...
 
hipError_t hipStreamGetFlags (hipStream_t stream, unsigned int *flags)
 Return flags associated with this stream. More...
 
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 completed. For each cudaStreamAddCallback call, a callback will be executed exactly once. The callback will block later work in the stream until it is finished. More...
 
hipError_t hipEventCreateWithFlags (hipEvent_t *event, unsigned flags)
 Create an event with the specified flags. More...
 
hipError_t hipEventCreate (hipEvent_t *event)
 
hipError_t hipEventRecord (hipEvent_t event, hipStream_t stream)
 Record an event in the specified stream. More...
 
hipError_t hipEventDestroy (hipEvent_t event)
 Destroy the specified event. More...
 
hipError_t hipEventSynchronize (hipEvent_t event)
 Wait for an event to complete. More...
 
hipError_t hipEventElapsedTime (float *ms, hipEvent_t start, hipEvent_t stop)
 Return the elapsed time between two events. More...
 
hipError_t hipEventQuery (hipEvent_t event)
 Query event status. More...
 
hipError_t hipPointerGetAttributes (hipPointerAttribute_t *attributes, const void *ptr)
 Return attributes for the specified pointer. More...
 
hipError_t hipMalloc (void **ptr, size_t size)
 Allocate memory on the default accelerator. More...
 
hipError_t hipMallocHost (void **ptr, size_t size) __attribute__((deprecated("use hipHostMalloc instead")))
 Allocate pinned host memory [Deprecated]. More...
 
hipError_t hipHostMalloc (void **ptr, size_t size, unsigned int flags)
 Allocate device accessible page locked host memory. More...
 
hipError_t hipHostAlloc (void **ptr, size_t size, unsigned int flags) __attribute__((deprecated("use hipHostMalloc instead")))
 Allocate device accessible page locked host memory [Deprecated]. More...
 
hipError_t hipHostGetDevicePointer (void **devPtr, void *hstPtr, unsigned int flags)
 Get Device pointer from Host Pointer allocated through hipHostMalloc. More...
 
hipError_t hipHostGetFlags (unsigned int *flagsPtr, void *hostPtr)
 Return flags associated with host pointer. More...
 
hipError_t hipHostRegister (void *hostPtr, size_t sizeBytes, unsigned int flags)
 Register host memory so it can be accessed from the current device. More...
 
hipError_t hipHostUnregister (void *hostPtr)
 Un-register host pointer. More...
 
hipError_t hipMallocPitch (void **ptr, size_t *pitch, size_t width, size_t height)
 
hipError_t hipFree (void *ptr)
 Free memory allocated by the hcc hip memory allocation API. This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned. More...
 
hipError_t hipFreeHost (void *ptr) __attribute__((deprecated("use hipHostFree instead")))
 Free memory allocated by the hcc hip host memory allocation API. [Deprecated]. More...
 
hipError_t hipHostFree (void *ptr)
 Free memory allocated by the hcc hip host memory allocation API This API performs an implicit hipDeviceSynchronize() call. If pointer is NULL, the hip runtime is initialized and hipSuccess is returned. More...
 
hipError_t hipMemcpy (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind)
 Copy data from src to dst. More...
 
hipError_t hipMemcpyHtoD (hipDeviceptr_t dst, void *src, size_t sizeBytes)
 Copy data from Host to Device. More...
 
hipError_t hipMemcpyDtoH (void *dst, hipDeviceptr_t src, size_t sizeBytes)
 Copy data from Device to Host. More...
 
hipError_t hipMemcpyDtoD (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes)
 Copy data from Device to Device. More...
 
hipError_t hipMemcpyHtoDAsync (hipDeviceptr_t dst, void *src, size_t sizeBytes, hipStream_t stream)
 Copy data from Host to Device asynchronously. More...
 
hipError_t hipMemcpyDtoHAsync (void *dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)
 Copy data from Device to Host asynchronously. More...
 
hipError_t hipMemcpyDtoDAsync (hipDeviceptr_t dst, hipDeviceptr_t src, size_t sizeBytes, hipStream_t stream)
 Copy data from Device to Device asynchronously. More...
 
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 bytes from the start of symbol symbol. More...
 
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 bytes from the start of symbol symbol. More...
 
hipError_t hipMemcpyFromSymbol (void *dst, const void *symbolName, size_t sizeBytes, size_t offset=0, hipMemcpyKind kind=hipMemcpyDeviceToHost)
 
hipError_t hipMemcpyFromSymbolAsync (void *dst, const void *symbolName, size_t sizeBytes, size_t offset, hipMemcpyKind kind, hipStream_t stream=0)
 
hipError_t hipMemcpyAsync (void *dst, const void *src, size_t sizeBytes, hipMemcpyKind kind, hipStream_t stream)
 Copy data from src to dst asynchronously. More...
 
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 value. More...
 
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 value. More...
 
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 value. More...
 
hipError_t hipMemGetInfo (size_t *free, size_t *total)
 Query memory info. Return snapshot of free memory, and total allocatable memory on the device. More...
 
hipError_t hipMemPtrGetInfo (void *ptr, size_t *size)
 
hipError_t hipMallocArray (hipArray **array, const struct hipChannelFormatDesc *desc, size_t width, size_t height, unsigned int flags)
 Allocate an array on the device. More...
 
hipError_t hipFreeArray (hipArray *array)
 Frees an array on the device. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
hipError_t hipDeviceCanAccessPeer (int *canAccessPeer, int deviceId, int peerDeviceId)
 Determine if a device can access a peer's memory. More...
 
hipError_t hipDeviceEnablePeerAccess (int peerDeviceId, unsigned int flags)
 Enable direct access from current device's virtual address space to memory allocations physically located on a peer device. More...
 
hipError_t hipDeviceDisablePeerAccess (int peerDeviceId)
 Disable direct access from current device's virtual address space to memory allocations physically located on a peer device. More...
 
hipError_t hipMemGetAddressRange (hipDeviceptr_t *pbase, size_t *psize, hipDeviceptr_t dptr)
 Get information on memory allocations. More...
 
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. More...
 
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. More...
 
hipError_t hipInit (unsigned int flags)
 Explicitly initializes the HIP runtime. More...
 
hipError_t hipCtxCreate (hipCtx_t *ctx, unsigned int flags, hipDevice_t device)
 Create a context and set it as current/ default context. More...
 
hipError_t hipCtxDestroy (hipCtx_t ctx)
 Destroy a HIP context. More...
 
hipError_t hipCtxPopCurrent (hipCtx_t *ctx)
 Pop the current/default context and return the popped context. More...
 
hipError_t hipCtxPushCurrent (hipCtx_t ctx)
 Push the context to be set as current/ default context. More...
 
hipError_t hipCtxSetCurrent (hipCtx_t ctx)
 Set the passed context as current/default. More...
 
hipError_t hipCtxGetCurrent (hipCtx_t *ctx)
 Get the handle of the current/ default context. More...
 
hipError_t hipCtxGetDevice (hipDevice_t *device)
 Get the handle of the device associated with current/default context. More...
 
hipError_t hipCtxGetApiVersion (hipCtx_t ctx, int *apiVersion)
 Returns the approximate HIP api version. More...
 
hipError_t hipCtxGetCacheConfig (hipFuncCache_t *cacheConfig)
 Set Cache configuration for a specific function. More...
 
hipError_t hipCtxSetCacheConfig (hipFuncCache_t cacheConfig)
 Set L1/Shared cache partition. More...
 
hipError_t hipCtxSetSharedMemConfig (hipSharedMemConfig config)
 Set Shared memory bank configuration. More...
 
hipError_t hipCtxGetSharedMemConfig (hipSharedMemConfig *pConfig)
 Get Shared memory bank configuration. More...
 
hipError_t hipCtxSynchronize (void)
 Blocks until the default context has completed all preceding requested tasks. More...
 
hipError_t hipCtxGetFlags (unsigned int *flags)
 Return flags used for creating default context. More...
 
hipError_t hipCtxEnablePeerAccess (hipCtx_t peerCtx, unsigned int flags)
 Enables direct access to memory allocations in a peer context. More...
 
hipError_t hipCtxDisablePeerAccess (hipCtx_t peerCtx)
 Disable direct access from current context's virtual address space to memory allocations physically located on a peer context.Disables direct access to memory allocations in a peer context and unregisters any registered allocations. More...
 
hipError_t hipDevicePrimaryCtxGetState (hipDevice_t dev, unsigned int *flags, int *active)
 Get the state of the primary context. More...
 
hipError_t hipDevicePrimaryCtxRelease (hipDevice_t dev)
 Release the primary context on the GPU. More...
 
hipError_t hipDevicePrimaryCtxRetain (hipCtx_t *pctx, hipDevice_t dev)
 Retain the primary context on the GPU. More...
 
hipError_t hipDevicePrimaryCtxReset (hipDevice_t dev)
 Resets the primary context on the GPU. More...
 
hipError_t hipDevicePrimaryCtxSetFlags (hipDevice_t dev, unsigned int flags)
 Set flags for the primary context. More...
 
hipError_t hipDeviceGet (hipDevice_t *device, int ordinal)
 Returns a handle to a compute device. More...
 
hipError_t hipDeviceComputeCapability (int *major, int *minor, hipDevice_t device)
 Returns the compute capability of the device. More...
 
hipError_t hipDeviceGetName (char *name, int len, hipDevice_t device)
 Returns an identifer string for the device. More...
 
hipError_t hipDeviceGetPCIBusId (char *pciBusId, int len, int device)
 Returns a PCI Bus Id string for the device, overloaded to take int device ID. More...
 
hipError_t hipDeviceGetByPCIBusId (int *device, const int *pciBusId)
 Returns a handle to a compute device. More...
 
hipError_t hipDeviceTotalMem (size_t *bytes, hipDevice_t device)
 Returns the total amount of memory on the device. More...
 
hipError_t hipDriverGetVersion (int *driverVersion)
 Returns the approximate HIP driver version. More...
 
hipError_t hipRuntimeGetVersion (int *runtimeVersion)
 Returns the approximate HIP Runtime version. More...
 
hipError_t hipModuleLoad (hipModule_t *module, const char *fname)
 Loads code object from file into a hipModule_t. More...
 
hipError_t hipModuleUnload (hipModule_t module)
 Frees the module. More...
 
hipError_t hipModuleGetFunction (hipFunction_t *function, hipModule_t module, const char *kname)
 Function with kname will be extracted if present in module. More...
 
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 More...
 
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. More...
 
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. Options are not used. hipModuleLoadData is called. More...
 
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 kernelparams or extra More...
 
hipError_t hipProfilerStart ()
 Start recording of profiling information When using this API, start the profiler with profiling disabled. (–startdisabled) More...
 
hipError_t hipProfilerStop ()
 Stop recording of profiling information. When using this API, start the profiler with profiling disabled. (–startdisabled) More...
 
hipError_t hipIpcGetMemHandle (hipIpcMemHandle_t *handle, void *devPtr)
 Gets an interprocess memory handle for an existing device memory allocation. More...
 
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 in the local process. More...
 
hipError_t hipIpcCloseMemHandle (void *devPtr)
 Close memory mapped with hipIpcOpenMemHandle. More...
 

Detailed Description

Contains C function APIs for HIP runtime. This file does not use any HCC builtin or special language extensions (-hc mode) ; those functions in hip_runtime.h.