Skip to content
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

Define cuda_sync in ext, restrict cpu implementations #85

Merged
merged 1 commit into from
Jun 21, 2024
Merged
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
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
ClimaComms.jl Release Notes
========================

v0.6.3
-------

- Bugfix: `cuda_sync` was missing in the extension and, as a result, `ClimaComms.@cuda_sync` was not actually synchronizing. We've also removed the abstract fallback, so that we instead method-error if we pass a cuda device when the cuda extension does not exist.

v0.6.2
-------

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
"Jake Bolewski <[email protected]>",
"Gabriele Bozzola <[email protected]>",
]
version = "0.6.2"
version = "0.6.3"

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down
2 changes: 2 additions & 0 deletions ext/ClimaCommsCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ClimaComms.allowscalar(f, ::CUDADevice, args...; kwargs...) =
# Extending ClimaComms methods that operate on expressions (cannot use dispatch here)
ClimaComms.sync(f::F, ::CUDADevice, args...; kwargs...) where {F} =
CUDA.@sync f(args...; kwargs...)
ClimaComms.cuda_sync(f::F, ::CUDADevice, args...; kwargs...) where {F} =
CUDA.@sync f(args...; kwargs...)
ClimaComms.time(f::F, ::CUDADevice, args...; kwargs...) where {F} =
CUDA.@time f(args...; kwargs...)
ClimaComms.elapsed(f::F, ::CUDADevice, args...; kwargs...) where {F} =
Expand Down
10 changes: 5 additions & 5 deletions src/devices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ CUDA.@time f(args...; kwargs...)
```
for CUDA devices.
"""
function time(f::F, device::AbstractDevice, args...; kwargs...) where {F}
function time(f::F, device::AbstractCPUDevice, args...; kwargs...) where {F}
Base.@time begin
f(args...; kwargs...)
end
Expand All @@ -165,7 +165,7 @@ CUDA.@elapsed f(args...; kwargs...)
```
for CUDA devices.
"""
function elapsed(f::F, device::AbstractDevice, args...; kwargs...) where {F}
function elapsed(f::F, device::AbstractCPUDevice, args...; kwargs...) where {F}
Base.@elapsed begin
f(args...; kwargs...)
end
Expand Down Expand Up @@ -205,7 +205,7 @@ If the CPU version of the above example does not leverage
spawned tasks (which require using `Base.sync` or `Threads.wait`
to synchronize), then you may want to simply use [`cuda_sync`](@ref).
"""
function sync(f::F, ::AbstractDevice, args...; kwargs...) where {F}
function sync(f::F, ::AbstractCPUDevice, args...; kwargs...) where {F}
Base.@sync begin
f(args...; kwargs...)
end
Expand All @@ -226,7 +226,7 @@ CUDA.@sync f(args...; kwargs...)
```
for CUDA devices.
"""
function cuda_sync(f::F, ::AbstractDevice, args...; kwargs...) where {F}
function cuda_sync(f::F, ::AbstractCPUDevice, args...; kwargs...) where {F}
f(args...; kwargs...)
end

Expand All @@ -252,7 +252,7 @@ allowscalar(device) do
end
```
"""
allowscalar(f, ::AbstractDevice, args...; kwargs...) = f(args...; kwargs...)
allowscalar(f, ::AbstractCPUDevice, args...; kwargs...) = f(args...; kwargs...)

"""
@time device expr
Expand Down
Loading