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

Compilation message with MPI extension #5

Merged
merged 12 commits into from
Jan 31, 2024
12 changes: 12 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@ name = "TrixiBase"
uuid = "9a0f1c46-06d5-4909-a5a3-ce25d3fa3284"
authors = ["Michael Schlottke-Lakemper <[email protected]>"]
version = "0.1.0"

[weakdeps]
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"

[extensions]
TrixiBaseMPIExt = "MPI"

[compat]
julia = "1.8"

[extras]
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
21 changes: 21 additions & 0 deletions ext/TrixiBaseMPIExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Package extension for adding MPI-based features to TrixiBase.jl
module TrixiBaseMPIExt
sloede marked this conversation as resolved.
Show resolved Hide resolved
__precompile__(false)

# Load package extension code on Julia v1.9 and newer
if isdefined(Base, :get_extension)
using MPI: MPI
end
import TrixiBase

# This is a really working version - assuming the same
# communication pattern etc. used in Trixi.jl.
function TrixiBase.mpi_isparallel()
ranocha marked this conversation as resolved.
Show resolved Hide resolved
if MPI.Initialized()
return MPI.Comm_size(MPI.COMM_WORLD) > 1
else
return false
end
end

end
9 changes: 9 additions & 0 deletions src/trixi_include.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ function trixi_include(mod::Module, elixir::AbstractString; kwargs...)
find_assignment(expr, key)
end

# Print information on potential wait time only in non-parallel case
if !mpi_isparallel()
ranocha marked this conversation as resolved.
Show resolved Hide resolved
@info "You just called `trixi_include`. Julia may now compile the code, please be patient."
end
Base.include(ex -> replace_assignments(insert_maxiters(ex); kwargs...), mod, elixir)
end

Expand Down Expand Up @@ -143,3 +147,8 @@ function find_assignment(expr, destination)

result
end

# This is just a dummy function. We only implement a real
# version if MPI.jl is loaded to avoid letting TrixiBase.jl
# depend explicitly on MPI.jl.
mpi_isparallel() = false
ranocha marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions test/dummy.jl
ranocha marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
println("Hello")
Loading