JuliaGPU / JuliaGPU/KernelAbstractions.jl

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

Open
#636 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
523
Forks
88
Avg merge
1d 11h
Merged PRs (30d)
25

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Julia MWE with KernelAbstractions.device!(CUDABackend(), 2), then inspect CUDAKernels.jl at the linked device! definition. Compare Int and Int32 behavior and add coverage for the chosen integer-handling or failure behavior; done means device selection is no longer silently incorrect.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
hpc
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.