hipsetdevice Interface Reference#
Set default device to be used for subsequent hip API calls from this thread. More...
Public Member Functions | |
integer(kind(hipsuccess)) function | hipsetdevice_ (deviceId) |
Detailed Description
Set default device to be used for subsequent hip API calls from this thread.
- Parameters
-
[in] deviceId Valid 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.
- Returns
- hipSuccess, hipErrorInvalidDevice, hipErrorDeviceAlreadyInUse
- See also
- hipGetDevice, hipGetDeviceCount
Member Function/Subroutine Documentation
◆ hipsetdevice_()
integer(kind(hipsuccess)) function hipfort::hipsetdevice::hipsetdevice_ | ( | integer(c_int), value | deviceId | ) |
The documentation for this interface was generated from the following file: