Skip to content

Commit

Permalink
fix: logging for preset comms device
Browse files Browse the repository at this point in the history
  • Loading branch information
haakon-e committed Nov 26, 2024
1 parent 7e4f29d commit 7f6d2fa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
22 changes: 10 additions & 12 deletions src/solver/type_getters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,18 +589,7 @@ function get_comms_context(parsed_args)
end
comms_ctx = ClimaComms.context(device)
ClimaComms.init(comms_ctx)
if ClimaComms.iamroot(comms_ctx)
Logging.global_logger(Logging.ConsoleLogger(stderr, Logging.Info))
else
Logging.global_logger(Logging.NullLogger())
end
@info "Running on $(nameof(typeof(device)))."
if comms_ctx isa ClimaComms.SingletonCommsContext
@info "Setting up single-process ClimaAtmos run"
else
@info "Setting up distributed ClimaAtmos run" nprocs =
ClimaComms.nprocs(comms_ctx)
end

if NVTX.isactive()
# makes output on buildkite a bit nicer
if ClimaComms.iamroot(comms_ctx)
Expand All @@ -613,6 +602,15 @@ function get_comms_context(parsed_args)
return comms_ctx
end

function set_global_logger(comms_ctx)
# Set logging to only display for the root process
if ClimaComms.iamroot(comms_ctx)
Logging.global_logger(Logging.ConsoleLogger(stderr, Logging.Info))
else
Logging.global_logger(Logging.NullLogger())
end
end

function get_simulation(config::AtmosConfig)
params = create_parameter_set(config)
atmos = get_atmos(config, params)
Expand Down
16 changes: 12 additions & 4 deletions src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -647,17 +647,25 @@ function AtmosConfig(
override_file = CP.merge_toml_files(config["toml"]),
)
comms_ctx = isnothing(comms_ctx) ? get_comms_context(config) : comms_ctx
device = ClimaComms.device(comms_ctx)
set_global_logger(comms_ctx)
@info "Running on $(nameof(typeof(device)))"
if comms_ctx isa ClimaComms.SingletonCommsContext
@info "Setting up single-process ClimaAtmos run"
else
@info "Setting up distributed ClimaAtmos run" nprocs =
ClimaComms.nprocs(comms_ctx)
end

config = config_with_resolved_and_acquired_artifacts(config, comms_ctx)
device = ClimaComms.device(comms_ctx)
if device isa ClimaComms.CPUMultiThreaded
@info "Running ClimaCore in threaded mode, with $(Threads.nthreads()) threads."
@info "Running ClimaCore in threaded mode, with $(Threads.nthreads()) threads"
else
@info "Running ClimaCore in unthreaded mode."
@info "Running ClimaCore in unthreaded mode"
end

isempty(job_id) &&
@warn "`job_id` is empty and likely not passed to AtmosConfig."
@warn "`job_id` is empty and likely not passed to AtmosConfig"

@info "Making AtmosConfig with config files: $(sprint(config_summary, config_files))"

Expand Down

0 comments on commit 7f6d2fa

Please sign in to comment.