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

Simplify and fix precompile #28

Merged
merged 1 commit into from
Aug 31, 2023
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Documenter = "0.27"
Infiltrator = "1.0"
Interpolations = "0.13, 0.14"
MAT = "0.10"
PALEOboxes = "0.20.4, 0.21"
PALEOboxes = "0.21.18"
PALEOmodel = "0.15.8"
PrecompileTools = "1.0"
Plots = "1.0"
Expand Down
31 changes: 11 additions & 20 deletions src/PALEOcopse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,29 @@ include("sedcrust/SedCrust.jl")
include("biogeochem/BioGeoChem.jl")


# TODO gains here with Julia 1.9.0-rc3, PrecompileTools v1.0.3 are marginal (95sec -> 82sec for include("COPSE_reloaded_reloaded.jl"))
# gains from precompilation with Julia 1.10.0-beta2, PrecompileTools v1.2.0 are 48sec -> 27sec for include("COPSE_reloaded_reloaded.jl"))
if VERSION >= v"1.8.0" # negligible benefit from precompile prior to Julia 1.8.0
@PrecompileTools.setup_workload begin
# create Reactions and register methods to precompile this code

# Putting some things in `setup` can reduce the size of the
# precompile file and potentially make loading faster.


rdict = PB.find_all_reactions()
reactionlist = ["ReactionSrSed", "ReactionLandWeatheringFluxes", "ReactionSrLand", "ReactionLandArea", "ReactionForce_LIPs",
"ReactionForce_CK_Solar", "ReactionLandWeatheringRates", "ReactionModelBergman2004",
"ReactionCIsotopes", "ReactionMarineBiotaCOPSE", "ReactionOceanBurialCOPSE", "ReactionAtmOcean_A", "ReactionSedCrustCOPSE", "ReactionGlobalTemperatureBerner",
"ReactionSrOceanfloor", "ReactionForce_CPlandrelbergman2004", "ReactionForce_UDWEbergman2004", "ReactionSeafloorWeathering",
"ReactionSrMantleCrust", "ReactionLandBergman2004", "ReactionAtmOcean_O", "ReactionForce_spreadsheet",
"ReactionGlobalTemperatureCK1992", "ReactionLandBiota", "ReactionForce_Bbergman2004",
configlist = [
(joinpath(@__DIR__, "../examples/COPSE/COPSE_bergman2004_bergman2004_cfg.yaml"), "Bergman2004"),
(joinpath(@__DIR__, "../examples/COPSE/COPSE_reloaded_bergman2004_cfg.yaml"), "model1"),
(joinpath(@__DIR__, "../examples/COPSE/COPSE_reloaded_reloaded_cfg.yaml"), "model1"),
]

@PrecompileTools.compile_workload begin
# all calls in this block will be precompiled, regardless of whether
# they belong to your package or not (on Julia 1.8 and higher)

Logging.with_logger(Logging.NullLogger()) do
for r in reactionlist
PB.precompile_reaction(rdict, r)
end

#
PB.run_model(joinpath(@__DIR__, "../examples/COPSE/COPSE_bergman2004_bergman2004_cfg.yaml"), "Bergman2004")
PB.run_model(joinpath(@__DIR__, "../examples/COPSE/COPSE_reloaded_bergman2004_cfg.yaml"), "model1")
PB.run_model(joinpath(@__DIR__, "../examples/COPSE/COPSE_reloaded_reloaded_cfg.yaml"), "model1")
logger=Logging.NullLogger()
# logger=Logging.ConsoleLogger()

for (config_file, config_model) in configlist
PB.run_model(config_file, config_model; call_do_deriv=true, logger)
end

end
end
end
Expand Down