-
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.
- Loading branch information
Showing
7 changed files
with
92 additions
and
76 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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
export import_required_backends | ||
|
||
function mpi_required() | ||
return context_type() == :MPICommsContext | ||
end | ||
|
||
function cuda_required() | ||
return device() isa CUDADevice | ||
end | ||
|
||
""" | ||
ClimaComms.@import_required_backends | ||
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. | ||
""" | ||
macro import_required_backends() | ||
return quote | ||
@static if $mpi_required() | ||
try | ||
import MPI | ||
catch | ||
error( | ||
"Cannot load MPI.jl. Make sure it is included in your environment stack.", | ||
) | ||
end | ||
end | ||
@static if $cuda_required() | ||
try | ||
import CUDA | ||
catch | ||
error( | ||
"Cannot load CUDA.jl. Make sure it is included in your environment stack.", | ||
) | ||
end | ||
end | ||
end | ||
end |
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