Skip to content

Extend supports_atomics to include type #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/KernelAbstractions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,15 @@
end

"""
supports_atomics(::Backend)::Bool
supports_atomics(::Backend, [T::Type{<:Number}])::Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The long-term goal with moving atomics support to GPUCompiler and legalizing there is that we should also be able to support non-numbers, like Tuple{Int32, Int32}, which makes this query tricky in general.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree this isn't the best approach. Operation support doesn't just depend on eltype it also depends on the operation itself. Maybe we stick to status quo until someone has the time to come up with a good interface for this api?


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

Check warning on line 564 in src/KernelAbstractions.jl

View check run for this annotation

Codecov / codecov/patch

src/KernelAbstractions.jl#L564

Added line #L564 was not covered by tests

"""
supports_float64(::Backend)::Bool
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading