Execution Control

Execution Control#

HIP Runtime API Reference: Execution Control
Execution Control
Collaboration diagram for Execution Control:

Functions

hipError_t hipExtModuleLaunchKernel (hipFunction_t f, uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, size_t sharedMemBytes, hipStream_t hStream, void **kernelParams, void **extra, hipEvent_t startEvent, hipEvent_t stopEvent, uint32_t flags)
 Launches kernel with parameters and shared memory on stream with arguments passed to kernel params or extra arguments.
 
hipError_t hipHccModuleLaunchKernel (hipFunction_t f, uint32_t globalWorkSizeX, uint32_t globalWorkSizeY, uint32_t globalWorkSizeZ, uint32_t localWorkSizeX, uint32_t localWorkSizeY, uint32_t localWorkSizeZ, size_t sharedMemBytes, hipStream_t hStream, void **kernelParams, void **extra, hipEvent_t startEvent, hipEvent_t stopEvent)
 This HIP API is deprecated, please use hipExtModuleLaunchKernel() instead.
 
hipError_t hipExtLaunchKernel (const void *function_address, dim3 numBlocks, dim3 dimBlocks, void **args, size_t sharedMemBytes, hipStream_t stream, hipEvent_t startEvent, hipEvent_t stopEvent, int flags)
 Launches kernel from the pointer address, with arguments and shared memory on stream.
 
template<typename... Args, typename F = void (*)(Args...)>
void hipExtLaunchKernelGGL (F kernel, const dim3 &numBlocks, const dim3 &dimBlocks, std::uint32_t sharedMemBytes, hipStream_t stream, hipEvent_t startEvent, hipEvent_t stopEvent, std::uint32_t flags, Args... args)
 Launches kernel with dimention parameters and shared memory on stream with templated kernel and arguments.
 
hipError_t hipFuncSetAttribute (const void *func, hipFuncAttribute attr, int value)
 Set attribute for a specific function.
 
hipError_t hipFuncSetCacheConfig (const void *func, hipFuncCache_t config)
 Set Cache configuration for a specific function.
 
hipError_t hipFuncSetSharedMemConfig (const void *func, hipSharedMemConfig config)
 Set shared memory configuation for a specific function.
 
hipError_t hipFuncGetAttributes (struct hipFuncAttributes *attr, const void *func)
 Find out attributes for a given function.
 
hipError_t hipFuncGetAttribute (int *value, hipFunction_attribute attrib, hipFunction_t hfunc)
 Find out a specific attribute for a given function.
 
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
 
hipError_t hipExtLaunchMultiKernelMultiDevice (hipLaunchParams *launchParamsList, int numDevices, unsigned int flags)
 Launches kernels on multiple devices and guarantees all specified kernels are dispatched on respective streams before enqueuing any other work on the specified streams from any other threads.
 
hipError_t hipLaunchKernelExC (const hipLaunchConfig_t *config, const void *fPtr, void **args)
 Launches a HIP kernel using a generic function pointer and the specified configuration.
 
hipError_t hipDrvLaunchKernelEx (const HIP_LAUNCH_CONFIG *config, hipFunction_t f, void **params, void **extra)
 Launches a HIP kernel using the driver API with the specified configuration.
 
template<class T >
hipError_t hipExtLaunchMultiKernelMultiDevice (hipLaunchParams *launchParamsList, unsigned int numDevices, unsigned int flags=0)
 Launches kernels on multiple devices and guarantees all specified kernels are dispatched on respective streams before enqueuing any other work on the specified streams from any other threads.
 

Detailed Description

This section describes the execution control functions of HIP runtime API.

Function Documentation

◆ hipDrvLaunchKernelEx()

hipError_t hipDrvLaunchKernelEx ( const HIP_LAUNCH_CONFIG config,
hipFunction_t  f,
void **  params,
void **  extra 
)

Launches a HIP kernel using the driver API with the specified configuration.

This function dispatches the device kernel represented by a HIP function object. It passes both the kernel parameters and any extra configuration arguments to the kernel launch.

Parameters
[in]configPointer to the kernel launch configuration structure.
[in]fHIP function object representing the device kernel to be launched.
[in]paramsArray of pointers to the kernel parameters.
[in]extraArray of pointers for additional launch parameters or extra configuration data.
Returns
hipSuccess if the kernel is launched successfully, otherwise an appropriate error code.

◆ hipExtLaunchKernel()

hipError_t hipExtLaunchKernel ( const void *  function_address,
dim3  numBlocks,
dim3  dimBlocks,
void **  args,
size_t  sharedMemBytes,
hipStream_t  stream,
hipEvent_t  startEvent,
hipEvent_t  stopEvent,
int  flags 
)

Launches kernel from the pointer address, with arguments and shared memory on stream.

Parameters
[in]function_addresspointer to the Kernel to launch.
[in]numBlocksnumber of blocks.
[in]dimBlocksdimension of a block.
[in]argspointer to kernel arguments.
[in]sharedMemBytesAmount of dynamic shared memory to allocate for this kernel. HIP-Clang compiler provides support for extern shared declarations.
[in]streamStream where the kernel should be dispatched. May be 0, in which case the default stream is used with associated synchronization rules.
[in]startEventIf non-null, specified event will be updated to track the start time of the kernel launch. The event must be created before calling this API.
[in]stopEventIf non-null, specified event will be updated to track the stop time of the kernel launch. The event must be created before calling this API.
[in]flagsThe value of hipExtAnyOrderLaunch, signifies if kernel can be launched in any order.
Returns
hipSuccess, hipInvalidDeviceId, hipErrorNotInitialized, hipErrorInvalidValue.

◆ hipExtLaunchKernelGGL()

template<typename... Args, typename F = void (*)(Args...)>
void hipExtLaunchKernelGGL ( kernel,
const dim3 numBlocks,
const dim3 dimBlocks,
std::uint32_t  sharedMemBytes,
hipStream_t  stream,
hipEvent_t  startEvent,
hipEvent_t  stopEvent,
std::uint32_t  flags,
Args...  args 
)
inline

Launches kernel with dimention parameters and shared memory on stream with templated kernel and arguments.

Parameters
[in]kernelKernel to launch.
[in]numBlocksconst number of blocks.
[in]dimBlocksconst dimension of a block.
[in]sharedMemBytesAmount of dynamic shared memory to allocate for this kernel. HIP-Clang compiler provides support for extern shared declarations.
[in]streamStream where the kernel should be dispatched. May be 0, in which case the default stream is used with associated synchronization rules.
[in]startEventIf non-null, specified event will be updated to track the start time of the kernel launch. The event must be created before calling this API.
[in]stopEventIf non-null, specified event will be updated to track the stop time of the kernel launch. The event must be created before calling this API.
[in]flagsThe value of hipExtAnyOrderLaunch, signifies if kernel can be launched in any order.
[in]argstemplated kernel arguments.

◆ hipExtLaunchMultiKernelMultiDevice() [1/2]

hipError_t hipExtLaunchMultiKernelMultiDevice ( hipLaunchParams launchParamsList,
int  numDevices,
unsigned int  flags 
)

Launches kernels on multiple devices and guarantees all specified kernels are dispatched on respective streams before enqueuing any other work on the specified streams from any other threads.

Parameters
[in]launchParamsListList of launch parameters, one per device.
[in]numDevicesSize of the launchParamsList array.
[in]flagsFlags to control launch behavior.
Returns
hipSuccess, hipErrorNotInitialized, hipErrorInvalidValue

◆ hipExtLaunchMultiKernelMultiDevice() [2/2]

template<class T >
hipError_t hipExtLaunchMultiKernelMultiDevice ( hipLaunchParams launchParamsList,
unsigned int  numDevices,
unsigned int  flags = 0 
)
inline

Launches kernels on multiple devices and guarantees all specified kernels are dispatched on respective streams before enqueuing any other work on the specified streams from any other threads.

Parameters
[in]launchParamsListList of launch parameters, one per device.
[in]numDevicesSize of the launchParamsList array.
[in]flagsFlags to control launch behavior.
Returns
hipSuccess, hipErrorInvalidValue

◆ hipExtModuleLaunchKernel()

hipError_t hipExtModuleLaunchKernel ( hipFunction_t  f,
uint32_t  globalWorkSizeX,
uint32_t  globalWorkSizeY,
uint32_t  globalWorkSizeZ,
uint32_t  localWorkSizeX,
uint32_t  localWorkSizeY,
uint32_t  localWorkSizeZ,
size_t  sharedMemBytes,
hipStream_t  hStream,
void **  kernelParams,
void **  extra,
hipEvent_t  startEvent,
hipEvent_t  stopEvent,
uint32_t  flags 
)

Launches kernel with parameters and shared memory on stream with arguments passed to kernel params or extra arguments.

Parameters
[in]fKernel to launch.
[in]globalWorkSizeXX grid dimension specified in work-items.
[in]globalWorkSizeYY grid dimension specified in work-items.
[in]globalWorkSizeZZ grid dimension specified in work-items.
[in]localWorkSizeXX block dimension specified in work-items.
[in]localWorkSizeYY block dimension specified in work-items.
[in]localWorkSizeZZ block dimension specified in work-items.
[in]sharedMemBytesAmount of dynamic shared memory to allocate for this kernel. HIP-Clang compiler provides support for extern shared declarations.
[in]hStreamStream where the kernel should be dispatched. May be 0, in which case the default stream is used with associated synchronization rules.
[in]kernelParamspointer to kernel parameters.
[in]extraPointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. All passed arguments must be naturally aligned according to their type. The memory address of each argument should be a multiple of its size in bytes. Please refer to hip_porting_driver_api.md for sample usage.
[in]startEventIf non-null, specified event will be updated to track the start time of the kernel launch. The event must be created before calling this API.
[in]stopEventIf non-null, specified event will be updated to track the stop time of the kernel launch. The event must be created before calling this API.
[in]flagsThe value of hipExtAnyOrderLaunch, signifies if kernel can be launched in any order.
Returns
hipSuccess, hipInvalidDeviceId, hipErrorNotInitialized, hipErrorInvalidValue.

HIP/ROCm actually updates the start event when the associated kernel completes. Currently, timing between startEvent and stopEvent does not include the time it takes to perform a system scope release/cache flush - only the time it takes to issues writes to cache.

Note
For this HIP API, the flag 'hipExtAnyOrderLaunch' is not supported on AMD GFX9xx boards.

◆ hipFuncGetAttribute()

hipError_t hipFuncGetAttribute ( int *  value,
hipFunction_attribute  attrib,
hipFunction_t  hfunc 
)

Find out a specific attribute for a given function.

Parameters
[out]valuePointer to the value
[in]attribAttributes of the given funtion
[in]hfuncFunction to get attributes from
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidDeviceFunction

◆ hipFuncGetAttributes()

hipError_t hipFuncGetAttributes ( struct hipFuncAttributes attr,
const void *  func 
)

Find out attributes for a given function.

Parameters
[out]attrAttributes of funtion
[in]funcPointer to the function handle
Returns
hipSuccess, hipErrorInvalidValue, hipErrorInvalidDeviceFunction

◆ hipFuncSetAttribute()

hipError_t hipFuncSetAttribute ( const void *  func,
hipFuncAttribute  attr,
int  value 
)

Set attribute for a specific function.

Parameters
[in]funcPointer of the function
[in]attrAttribute to set
[in]valueValue to set
Returns
hipSuccess, hipErrorInvalidDeviceFunction, hipErrorInvalidValue

Note: AMD devices and some Nvidia GPUS do not support shared cache banking, and the hint is ignored on those architectures.

◆ hipFuncSetCacheConfig()

hipError_t hipFuncSetCacheConfig ( const void *  func,
hipFuncCache_t  config 
)

Set Cache configuration for a specific function.

Parameters
[in]funcPointer of the function.
[in]configConfiguration to set.
Returns
hipSuccess, hipErrorNotInitialized Note: AMD devices and some Nvidia GPUS do not support reconfigurable cache. This hint is ignored on those architectures.

◆ hipFuncSetSharedMemConfig()

hipError_t hipFuncSetSharedMemConfig ( const void *  func,
hipSharedMemConfig  config 
)

Set shared memory configuation for a specific function.

Parameters
[in]funcPointer of the function
[in]configConfiguration
Returns
hipSuccess, hipErrorInvalidDeviceFunction, hipErrorInvalidValue

Note: AMD devices and some Nvidia GPUS do not support shared cache banking, and the hint is ignored on those architectures.

◆ hipHccModuleLaunchKernel()

hipError_t hipHccModuleLaunchKernel ( hipFunction_t  f,
uint32_t  globalWorkSizeX,
uint32_t  globalWorkSizeY,
uint32_t  globalWorkSizeZ,
uint32_t  localWorkSizeX,
uint32_t  localWorkSizeY,
uint32_t  localWorkSizeZ,
size_t  sharedMemBytes,
hipStream_t  hStream,
void **  kernelParams,
void **  extra,
hipEvent_t  startEvent,
hipEvent_t  stopEvent 
)

This HIP API is deprecated, please use hipExtModuleLaunchKernel() instead.

◆ hipLaunchKernelExC()

hipError_t hipLaunchKernelExC ( const hipLaunchConfig_t config,
const void *  fPtr,
void **  args 
)

Launches a HIP kernel using a generic function pointer and the specified configuration.

This function is equivalent to hipLaunchKernelEx but accepts the kernel as a generic function pointer.

Parameters
[in]configPointer to the kernel launch configuration structure.
[in]fPtrPointer to the device kernel function.
[in]argsArray of pointers to the kernel arguments.
Returns
hipSuccess if the kernel is launched successfully, otherwise an appropriate error code.

◆ hipModuleLaunchKernel()

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

Parameters
[in]fKernel to launch.
[in]gridDimXX grid dimension specified as multiple of blockDimX.
[in]gridDimYY grid dimension specified as multiple of blockDimY.
[in]gridDimZZ grid dimension specified as multiple of blockDimZ.
[in]blockDimXX block dimensions specified in work-items
[in]blockDimYY grid dimension specified in work-items
[in]blockDimZZ grid dimension specified in work-items
[in]sharedMemBytesAmount of dynamic shared memory to allocate for this kernel. The HIP-Clang compiler provides support for extern shared declarations.
[in]streamStream where the kernel should be dispatched. May be 0, in which case th default stream is used with associated synchronization rules.
[in]kernelParamsKernel parameters to launch
[in]extraPointer to kernel arguments. These are passed directly to the kernel and must be in the memory layout and alignment expected by the kernel. All passed arguments must be naturally aligned according to their type. The memory address of each argument should be a multiple of its size in bytes. Please refer to hip_porting_driver_api.md for sample usage.

Please note, HIP does not support kernel launch with total work items defined in dimension with size gridDim x blockDim >= 2^32. So gridDim.x * blockDim.x, gridDim.y * blockDim.y and gridDim.z * blockDim.z are always less than 2^32.

Returns
hipSuccess, hipErrorNotInitialized, hipErrorInvalidValue