Devices
In AMDGPU, all GPU devices are auto-detected by the runtime, if they're supported.
AMDGPU maintains a global default device. The default device is relevant for all kernel and GPUArray operations. If one is not specified via @roc
or an equivalent interface, then the default device is used for those operations, which affects compilation and kernel launch.
The device bound to a current Julia task is accessible via AMDGPU.device
method. The list of available devices can be queried with AMDGPU.devices
method.
If you have a HIPDevice
object, you can also switch the device with AMDGPU.device!
. This will switch it only within the task it is called from.
xd1 = AMDGPU.ones(Float32, 16) # On `AMDGPU.device()` device.
AMDGPU.device!(AMDGPU.devices()[2]) # Switch to second device.
xd2 = AMDPGU.ones(Float32, 16) # On second device.
Additionally, devices have an associated numeric ID. This value is bounded between 1
and length(AMDGPU.devices())
, and device 1
is the default device when AMDGPU is first loaded. The ID of the device associated with the current task can be queried with AMDGPU.device_id
and changed with AMDGPU.device_id!
.
AMDGPU.HIP.devices
— Functiondevices()
Get list of all devices.
AMDGPU.device
— Functiondevice()::HIPDevice
Get currently active device. This device is used when launching kernels via @roc
.
device(A::ROCArray) -> HIPDevice
Return the device associated with the array A
.
AMDGPU.device!
— Functiondevice!(device::HIPDevice)
Switch current device being used. This switches only for a task inside which it is called.
AMDGPU.device_id
— Functiondevice_id() -> Int
device_id(device::HIPDevice) -> Int
Returns the numerical device ID for device
or for the current AMDGPU.device()
.
AMDGPU.device_id!
— Functiondevice_id!(idx::Integer)
Sets the current device to AMDGPU.devices()[idx]
. See device_id
for details on the numbering semantics.
Device Properties
AMDGPU.HIP.name
— Functionname(dev::HIPDevice)::String
Get name of the device.
AMDGPU.HIP.wavefrontsize
— Functionwavefrontsize(d::HIPDevice)::Cint
Get size of the wavefront. AMD GPUs support either 32 or 64.
AMDGPU.HIP.gcn_arch
— Functiongcn_arch(d::HIPDevice)::String
Get GCN architecture for the device.
AMDGPU.HIP.device_id
— Functiondevice_id(d::HIPDevice)
Zero-based device ID as expected by HIP functions. Differs from AMDGPU.device_id
method by 1
.
AMDGPU.HIP.properties
— Functionproperties(dev::HIPDevice)::hipDeviceProp_t
Get all properties for the device. See HIP documentation for hipDeviceProp_t
for the meaning of each field.