Skip to content

Unexpected behavior for KA.device!(backend, num) #636

@simone-silvestri

Description

@simone-silvestri

Over at Oceananingans, we had memory issues related to the fact that it seems that

KA.device!(backend, num)

does not switch to the intended device
MWE:

julia> using CUDA, KernelAbstractions

julia> KernelAbstractions.device!(CUDABackend(), 2)

julia> CUDA.device() # should be device number 1
CuDevice(0): NVIDIA TITAN V

This is because device! is only defined for an Int32
https://github.com/JuliaGPU/CUDA.jl/blob/cd2ab1d22e36396b6a1141ee8782d182a5020087/src/CUDAKernels.jl#L67-L69

julia> KernelAbstractions.device!(CUDABackend(), Int32(2))
CuDevice(1): NVIDIA TITAN V

Why is this the case? Should we allow any integer? Or maybe a non-silent failure in case the device cannot be switched

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions