-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API for device selection #395
Comments
The closest to I have no insights for oneAPI or Metal. |
Something like the following pseudocode? abstract type BackendDevice end
DeviceType(::Type{<:Backend})::Type{<:BackendDevice} # trait
devices(::TBackend)::AbstractVector{TBackendDevice} where {TBackend <: Backend, TBackendDevice = DeviceType(TBackend)}
device(::TBackend)::TBackendDevice where {TBackend <: Backend, TBackendDevice = DeviceType(TBackend)}
device!(dev::{<:BackendDevice})::Nothing # Selects dev device
function device(f::Function, dev::TBackendDevice)
current_device = device()
device!(dev)
try
f()
finally
device!(current_device)
end
end with e.g. CUDAKernels defining: struct CUDAKernelDevice <: BackendDevice
cu_device::CuDevice
end
KernelAbstractions.DeviceType(::Type{CUDABackend}) = CUDAKernelDevice
KernelAbstractions.devices(::CUDABackend) = CUDAKernelDevice.(devices())
KernelAbstractions.device(::CUDABackend) = CUDAKernelDevice(device())
KernelAbstractions.device!(dev::CUDAKernelDevice) = device!(dev.cu_device) ... and equivalent for ROCKernels, oneAPIKernels, and MetalKernels - seems like it can be implemented for all four backends. |
From a short conversation with @vchuravy I learned that there is currently no way of selecting between different GPUs by the same vendor on a single host using KernelAbstractions. It seems that KA.jl always defaults to the GPU with the lowest index.
CUDA.jl offers this feature already, see https://cuda.juliagpu.org/stable/usage/multigpu/, I'm not sure about AMDGPU.jl and oneAPI.jl. KA.jl should maybe offer some backend agnostic API for this.
The text was updated successfully, but these errors were encountered: