From 3c1e3ee73e9cbb3e80a4529dfe293f0d5656f0a0 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Mon, 5 May 2025 12:02:56 -0300 Subject: [PATCH] Extend `supports_atomics` to include type --- src/KernelAbstractions.jl | 6 +++--- test/runtests.jl | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/KernelAbstractions.jl b/src/KernelAbstractions.jl index ae258a569..e3e1df25b 100644 --- a/src/KernelAbstractions.jl +++ b/src/KernelAbstractions.jl @@ -553,15 +553,15 @@ function ones(backend::Backend, ::Type{T}, dims::Tuple) where {T} end """ - supports_atomics(::Backend)::Bool + supports_atomics(::Backend, [T::Type{<:Number}])::Bool -Returns whether `@atomic` operations are supported by the backend. +Returns whether `@atomic` operations of type `T` are supported by the backend. !!! note Backend implementations **must** implement this function, only if they **do not** support atomic operations with Atomix. """ -supports_atomics(::Backend) = true +supports_atomics(::Backend, T::Type{<:Number}=Number) = true """ supports_float64(::Backend)::Bool diff --git a/test/runtests.jl b/test/runtests.jl index 9dba56e78..e2ff33e7c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -24,6 +24,9 @@ struct NewBackend <: KernelAbstractions.GPU end @test_throws MethodError KernelAbstractions.ones(backend, Float32, 1) @test KernelAbstractions.supports_atomics(backend) == true + @test KernelAbstractions.supports_atomics(backend, Float64) == true + @test KernelAbstractions.supports_atomics(backend, Int32) == true + @test KernelAbstractions.supports_float64(backend) == true @test KernelAbstractions.priority!(backend, :high) === nothing