From eafb25c9f55e1614a68748023e4a6f95105d5191 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sat, 3 Oct 2026 18:53:58 +0200 Subject: [PATCH 1/2] Deprecate `GPU` as an alias of `Backend` instead of removing it `KernelAbstractions.GPU` was removed in #800, which breaks packages that still dispatch on `::GPU` or subtype it. A local test of the registered dependents against KA 0.10 found AbstractNeuralNetworks, ArraysOfArrays, BatchSolve, BeamTracking and Aether failing to precompile on it. Keep the name as a deprecated, exported binding for `Backend`, so that code written against 0.9 keeps working with a deprecation warning. Since `CPU` was a subtype of `GPU` already, `::GPU` matching every backend is the same behavior as before. Assisted-by: Claude Code (Opus 5.5) --- docs/src/index.md | 9 +++++---- src/KernelAbstractions.jl | 5 +++++ test/runtests.jl | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/src/index.md b/docs/src/index.md index 9342c32fc..01df3560b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -141,10 +141,11 @@ end the CPU backend became an OpenCL backend meant every backend. Use `KernelAbstractions.@device_code_llvm` and `KernelAbstractions.@device_code_typed` instead, which report on the code a backend actually generates; see [Reflection](@ref). -- `KernelAbstractions.GPU` has been removed: it didn't mean GPU hardware (the `CPU` backend - was a subtype), and backends now subtype `KernelAbstractions.Backend` directly. Code - dispatching on `::GPU` should dispatch on `::Backend`, on concrete backend types, or on a - capability such as `KernelAbstractions.supports_float64`. +- `KernelAbstractions.GPU` is deprecated: it didn't mean GPU hardware (the `CPU` backend + was a subtype), and backends now subtype `KernelAbstractions.Backend` directly. `GPU` is + now an alias of `Backend` and will be removed in a future release, so `::GPU` also matches + the `CPU` backend. Code dispatching on `::GPU` should dispatch on `::Backend`, on concrete + backend types, or on a capability such as `KernelAbstractions.supports_float64`. - An exception thrown in a kernel on the `CPU` backend is reported as a `KernelAbstractions.POCL.KernelException` when the kernel has completed, like on GPU backends, and no longer as the original exception (e.g., a `BoundsError`). Depending on diff --git a/src/KernelAbstractions.jl b/src/KernelAbstractions.jl index c7c9c5504..d70e84497 100644 --- a/src/KernelAbstractions.jl +++ b/src/KernelAbstractions.jl @@ -18,6 +18,11 @@ using KernelInterface: KernelInterface, Backend, get_backend, functional, synchr import KernelInterface as KI export KernelInterface +# `GPU` was removed in 0.10: it did not mean GPU hardware (the `CPU` backend subtyped it), +# and backends now subtype `Backend` directly. Keep the name working for code written +# against 0.9, both `x::GPU` and `struct MyBackend <: GPU`. +Base.@deprecate_binding GPU Backend + """ @kernel function f(args) end diff --git a/test/runtests.jl b/test/runtests.jl index 0b5d06e91..7e9c1b3ee 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -423,3 +423,9 @@ struct NewBackend <: KernelAbstractions.Backend end @test KernelAbstractions.functional(backend) === missing end + +@testset "Deprecated GPU alias" begin + @test KernelAbstractions.GPU === KernelAbstractions.Backend + @test CPU() isa KernelAbstractions.GPU + @test NewBackend <: KernelAbstractions.GPU +end From a3ce9f105f52c99ba85aa6e70a6874b5bafd4988 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Sat, 3 Oct 2026 21:02:48 +0200 Subject: [PATCH 2/2] Apply batched suggestions from code review Co-authored-by: Valentin Churavy --- docs/src/index.md | 5 +---- src/KernelAbstractions.jl | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/src/index.md b/docs/src/index.md index 01df3560b..9e28aaea3 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -141,10 +141,7 @@ end the CPU backend became an OpenCL backend meant every backend. Use `KernelAbstractions.@device_code_llvm` and `KernelAbstractions.@device_code_typed` instead, which report on the code a backend actually generates; see [Reflection](@ref). -- `KernelAbstractions.GPU` is deprecated: it didn't mean GPU hardware (the `CPU` backend - was a subtype), and backends now subtype `KernelAbstractions.Backend` directly. `GPU` is - now an alias of `Backend` and will be removed in a future release, so `::GPU` also matches - the `CPU` backend. Code dispatching on `::GPU` should dispatch on `::Backend`, on concrete +- `KernelAbstractions.GPU` is deprecated: and backends should now subtype `KernelAbstractions.Backend` directly. `GPU` is now an alias of `Backend` and will be removed in a future release. Code dispatching on `::GPU` should dispatch on `::Backend`, on concrete backend types, or on a capability such as `KernelAbstractions.supports_float64`. - An exception thrown in a kernel on the `CPU` backend is reported as a `KernelAbstractions.POCL.KernelException` when the kernel has completed, like on GPU diff --git a/src/KernelAbstractions.jl b/src/KernelAbstractions.jl index d70e84497..d93ccdbbf 100644 --- a/src/KernelAbstractions.jl +++ b/src/KernelAbstractions.jl @@ -18,8 +18,7 @@ using KernelInterface: KernelInterface, Backend, get_backend, functional, synchr import KernelInterface as KI export KernelInterface -# `GPU` was removed in 0.10: it did not mean GPU hardware (the `CPU` backend subtyped it), -# and backends now subtype `Backend` directly. Keep the name working for code written +# `GPU` is deprecated in 0.10: and backends ends now subtype `Backend` directly. Keep the name working for code written # against 0.9, both `x::GPU` and `struct MyBackend <: GPU`. Base.@deprecate_binding GPU Backend