Skip to content

Commit

Permalink
Merge pull request #85 from CliMA/ck/bugfix
Browse files Browse the repository at this point in the history
Define cuda_sync in ext, restrict cpu implementations
  • Loading branch information
charleskawczynski authored Jun 21, 2024
2 parents e62f126 + 3c44543 commit 5cbb27f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
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

2 comments on commit 5cbb27f

@charleskawczynski
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/109507

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.3 -m "<description of version>" 5cbb27f4f6992365630db834cbe5bdaec130dad2
git push origin v0.6.3

Please sign in to comment.