Skip to content

CUDA: fix Float64 add and float swap on device - #81

Merged
vchuravy merged 1 commit into
mainfrom
vc/cuda-ext-fixes
Sep 8, 2026
Merged

vchuravy merged 1 commit into
mainfrom
vc/cuda-ext-fixes

Conversation

@vchuravy

@vchuravy vchuravy commented Sep 8, 2026

Copy link
Copy Markdown
Member

Follow-up to #80. KernelAbstractions' CI (JuliaGPU/KernelAbstractions.jl#737) ran the new float atomics on CUDA and found two paths of the CUDA extension that do not compile in kernels:

  • Float64 add checked compute_capability() >= v"6.0", comparing a SimpleVersion against a VersionNumber. That is a dynamic isless on device (InvalidIRError: unsupported dynamic function invocation (call to isless); a MethodError on 1.13). It now compares the major component of the SimpleVersion.
  • Float swap looked up the integer type through CUDA.inttype, which left reinterpret with a dynamic type. The Float32/UInt32 and Float64/UInt64 methods are now spelled out.

The #80 tests only covered Float32 and integer swap, which is why this slipped through. Every backend's test file now also swaps a float, and the CUDA and OpenCL files gain a Float64 testset mirroring the Float32 one.

Verified locally on Julia 1.10: Atomix --CUDA (CUDA v6.3.1, cc 7.5) 9/9 testsets, --OpenCL (pocl) 9/9, and KernelAbstractions' atomics testsuite on OpenCLBackend 36/36.

This needs a 1.2.1 release; 1.2.0's CUDA extension fails on any Float64 @atomic += and any float @atomicswap.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DnYMbgSmZQr7KtRUwei63a

Two paths of the new CUDA extension did not compile in kernels:

- The Float64 add checked `compute_capability() >= v"6.0"`, comparing
  against a `VersionNumber`, which is not GPU compatible (dynamic
  `isless`). Compare the major component of the SimpleVersion instead.
- The float swap looked up the integer type through `CUDA.inttype`,
  leaving `reinterpret` with a dynamic type. Spell out the Float32/UInt32
  and Float64/UInt64 methods.

Tests now cover float swap on every backend and Float64 on CUDA and
OpenCL, which is what caught this in KernelAbstractions' CI.

Assisted-by: Claude Code (Fable 5.1)
@vchuravy
vchuravy merged commit c0df97e into main Sep 8, 2026
6 of 7 checks passed
@vchuravy
vchuravy deleted the vc/cuda-ext-fixes branch September 8, 2026 19:57
vchuravy added a commit to JuliaGPU/KernelAbstractions.jl that referenced this pull request Sep 9, 2026
Atomix 1.2.0's CUDA extension does not compile Float64 `@atomic +=` or
float `@atomicswap` inside kernels (JuliaConcurrent/Atomix.jl#81), so
require 1.2.1. The "Supported operations" table gains the atomic load,
store and swap forms that Atomix 1.2 made portable, and a note on how
memory orderings are treated on GPU backends.

Assisted-by: Claude Code (Fable 5.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant