HIP: Heterogenous-computing Interface for Portability
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Device Management

Functions

hipError_t hipDeviceSynchronize (void)
 Blocks until the default device has completed all preceding requested tasks. More...
 
hipError_t hipDeviceReset (void)
 Destroy all resources and reset all state on the default device in the current process. More...
 
hipError_t hipSetDevice (int device)
 Set default device to be used for subsequent hip API calls from this thread. More...
 
hipError_t hipGetDevice (int *device)
 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 hipDeviceGetProperties (hipDeviceProp_t *prop, int device)
 Returns device properties. More...
 
hipError_t hipDeviceSetCacheConfig (hipFuncCache cacheConfig)
 Set L1/Shared cache partition. More...
 
hipError_t hipDeviceGetCacheConfig (hipFuncCache *cacheConfig)
 Set Cache configuration for a specific function. More...
 
hipError_t hipFuncSetCacheConfig (hipFuncCache config)
 Set Cache configuration for a specific function. More...
 
hipError_t hipDeviceGetSharedMemConfig (hipSharedMemConfig *pConfig)
 Get Shared memory bank configuration. More...
 
hipError_t hipDeviceSetSharedMemConfig (hipSharedMemConfig config)
 Set Shared memory bank configuration. More...
 

Detailed Description

----------------------------------------------------------------------------------------------—

Function Documentation

hipError_t hipDeviceGetCacheConfig ( hipFuncCache cacheConfig)

Set Cache configuration for a specific function.

Note: AMD devices and recent NVIDIA GPUS do not support reconfigurable cache. This hint is ignored on those architectures.

Returns
hipSuccess
hipError_t hipDeviceGetProperties ( hipDeviceProp_t props,
int  device 
)

Returns device properties.

Parameters
[out]propwritten with device properties
[in]devicewhich device to query for information

Populates hipDeviceGetProperties with information for the specified device.

Returns
hipSuccess, hipErrorInvalidDevice
Bug:

HCC always returns 0 for maxThreadsPerMultiProcessor

HCC always returns 0 for regsPerBlock

HCC always returns 0 for l2CacheSize

hipError_t hipDeviceGetSharedMemConfig ( hipSharedMemConfig pConfig)

Get Shared memory bank configuration.

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

Returns
hipSuccess
hipError_t hipDeviceReset ( void  )

Destroy all resources and reset all state on the default device in the current process.

Explicity destroy all memory allocations, events, and queues associated with the default device in the current process.

This function will reset the device immmediately, and then return after all resources have been freed. The caller must ensure that the device is not being accessed by any other host threads from the active process when this function is called.

See Also
hipDeviceSynchronize
Returns
hipSuccess
Bug:
On HCC, hipDeviceReset is a nop and does not reset the device state.
hipError_t hipDeviceSetCacheConfig ( hipFuncCache  cacheConfig)

Set L1/Shared cache partition.

Note: AMD devices and recent NVIDIA GPUS do not support reconfigurable cache. This hint is ignored on those architectures.

Returns
hipSuccess
hipError_t hipDeviceSetSharedMemConfig ( hipSharedMemConfig  config)

Set Shared memory bank configuration.

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

Returns
hipSuccess
hipError_t hipDeviceSynchronize ( void  )

Blocks until the default device has completed all preceding requested tasks.

This function waits for all streams on the default device to complete execution, and then returns.

See Also
hipSetDevice, hipDeviceReset
Returns
hipSuccess
hipError_t hipFuncSetCacheConfig ( hipFuncCache  cacheConfig)

Set Cache configuration for a specific function.

Note: AMD devices and recent NVIDIA GPUS do not support reconfigurable cache. This hint is ignored on those architectures.

Returns
hipSuccess
hipError_t hipGetDevice ( int *  device)

Return the default device id for the calling host thread.

Parameters
[out]device*device is written with the default device

HIP maintains an default device for each thread using thread-local-storage. This device is used implicitly for HIP runtime APIs called by this thread. hipGetDevice returns in * device the default device for the calling host thread.

See Also
hipSetDevice, hipGetDevicesizeBytes
Returns
hipSuccess
hipError_t hipGetDeviceCount ( int *  count)

Return number of compute-capable devices.

Parameters
[output]count Returns number of compute-capable devices.

Returns in *count the number of devices that have ability to run compute commands. If there are no such devices, then hipGetDeviceCount will return hipErrorNoDevice. If 1 or more devices can be found, then hipGetDeviceCount returns hipSuccess.

Returns
hipSuccess, hipErrorNoDevice
hipError_t hipSetDevice ( int  device)

Set default device to be used for subsequent hip API calls from this thread.

Parameters
[in]deviceValid device in range 0...hipGetDeviceCount().

Sets device as the default device for the calling host thread. Valid device id's are 0... (hipGetDeviceCount()-1).

Many HIP APIs implicitly use the "default device" :

  • Any device memory subsequently allocated from this host thread (using hipMalloc) will be allocated on device.
  • Any streams or events created from this host thread will be associated with device.
  • Any kernels launched from this host thread (using hipLaunchKernel) will be executed on device (unless a specific stream is specified, in which case the device associated with that stream will be used).

This function may be called from any host thread. Multiple host threads may use the same device. This function does no synchronization with the previous or new device, and has very little runtime overhead. Applications can use hipSetDevice to quickly switch the default device before making a HIP runtime call which uses the default device.

The default device is stored in thread-local-storage for each thread. Thread-pool implementations may inherit the default device of the previous thread. A good practice is to always call hipSetDevice at the start of HIP coding sequency to establish a known standard device.

See Also
hipGetDevice, hipGetDeviceCount
Returns
hipSuccess, hipErrorInvalidDevice