-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify code loading, bump minor version
- Loading branch information
1 parent
a22e4ac
commit 756f5d5
Showing
8 changed files
with
81 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ authors = [ | |
"Jake Bolewski <[email protected]>", | ||
"Gabriele Bozzola <[email protected]>", | ||
] | ||
version = "0.6.0" | ||
version = "0.7.0" | ||
|
||
[weakdeps] | ||
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
import ..ClimaComms | ||
|
||
export import_required_backends | ||
|
||
function mpi_is_required() | ||
return context_type() == :MPICommsContext | ||
end | ||
|
||
function mpi_ext_is_not_loaded() | ||
return isnothing(Base.get_extension(ClimaComms, :ClimaCommsMPIExt)) | ||
end | ||
""" | ||
mpi_is_required() | ||
function cuda_is_required() | ||
return device_type() == :CUDADevice | ||
end | ||
Returns a Bool indicating if MPI should be loaded, based on the | ||
`ENV["CLIMACOMMS_CONTEXT"]`. See [`ClimaComms.context`](@ref) for | ||
more information. | ||
function cuda_ext_is_not_loaded() | ||
return isnothing(Base.get_extension(ClimaComms, :ClimaCommsCUDAExt)) | ||
end | ||
```julia | ||
mpi_is_required() && using MPI | ||
``` | ||
""" | ||
mpi_is_required() = context_type() == :MPICommsContext | ||
|
||
""" | ||
ClimaComms.@import_required_backends | ||
cuda_is_required() | ||
Returns a Bool indicating if CUDA should be loaded, based on the | ||
`ENV["CLIMACOMMS_DEVICE"]`. See [`ClimaComms.device`](@ref) for | ||
more information. | ||
If the desired context is MPI (as determined by `ClimaComms.context()`), try loading MPI.jl. | ||
If the desired device is CUDA (as determined by `ClimaComms.device()`), try loading CUDA.jl. | ||
```julia | ||
cuda_is_required() && using CUDA | ||
``` | ||
""" | ||
macro import_required_backends() | ||
return quote | ||
@static if $mpi_is_required() && $mpi_ext_is_not_loaded() | ||
import MPI | ||
@info "Loaded MPI.jl" | ||
end | ||
@static if $cuda_is_required() && $cuda_ext_is_not_loaded() | ||
import CUDA | ||
@info "Loaded CUDA.jl" | ||
end | ||
end | ||
end | ||
cuda_is_required() = device_type() == :CUDADevice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters