Skip to content

Commit 3d70138

Browse files
ucabc46Angeladadd
authored andcommitted
replace println with logging macros
1 parent cdbad91 commit 3d70138

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

extra/weak_scaling/run_particleda.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ using TimerOutputs
33
using MPI
44
using LinearAlgebra
55
using YAML
6+
using Logging
67

78
# Verify BLAS implementation is OpenBLAS
89
@assert occursin("openblas", string(BLAS.get_config()))
@@ -27,7 +28,7 @@ summary_stat_type = NaiveMeanSummaryStat
2728

2829
my_rank = MPI.Comm_rank(MPI.COMM_WORLD)
2930

30-
println("Rank $(my_rank): # Julia threads = $(Threads.nthreads()), # BLAS threads = $(BLAS.get_num_threads())")
31+
@info "Rank $(my_rank): # Julia threads = $(Threads.nthreads()), # BLAS threads = $(BLAS.get_num_threads())"
3132

3233
if my_rank == 0 && !isfile(observation_file)
3334
observation_sequence = simulate_observations_from_model(
@@ -48,7 +49,7 @@ open(parameters_file, "w") do io
4849
YAML.write(io, parameters)
4950
end
5051

51-
println("Optimized resampling enabled: ", parameters["filter"]["optimize_resampling"])
52+
@info "Optimized resampling enabled: ", parameters["filter"]["optimize_resampling"]
5253

5354
final_states, final_statistics = run_particle_filter(
5455
LLW2d.init, parameters_file, observation_file, filter_type, summary_stat_type

test/integration_test_7.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
filter:
22
nprt: 10
3-
optimize_resampling: true
3+
optimize_resampling: false
44

55
model:
66
llw2d:

test/mpi_optimized_copy_states.jl

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Test, ParticleDA, MPI, Random, TimerOutputs, HDF5, Serialization
1+
using Test, ParticleDA, MPI, Random, TimerOutputs, HDF5, Serialization, Logging
22
TimerOutputs.enable_debug_timings(ParticleDA)
33

44
const rng = Random.TaskLocalRNG()
@@ -37,7 +37,7 @@ MPI.Init()
3737
my_rank = MPI.Comm_rank(MPI.COMM_WORLD)
3838
my_size = MPI.Comm_size(MPI.COMM_WORLD)
3939

40-
println("Number of threads available: ", Threads.nthreads())
40+
@info "Number of threads available: ", Threads.nthreads()
4141

4242
n_particle_per_rank = 1000
4343
n_particle = n_particle_per_rank * my_size
@@ -48,13 +48,13 @@ if output_timer
4848
error("Please provide the output filename for timers.")
4949
end
5050
output_filename = ARGS[2]
51-
println("Outputting timers to HDF5 file '$output_filename'")
51+
@info "Outputting timers to HDF5 file '$output_filename'"
5252
end
5353
# default: dedup enabled for testing
5454
no_dedup = "-nd" in ARGS || "--no-dedup" in ARGS
55-
println("Deduplication enabled: ", !no_dedup)
55+
@info "Deduplication enabled: ", !no_dedup
5656
optimize_resample = "-o" in ARGS || "--optimize-resample" in ARGS
57-
println("Optimized resampling enabled: ", optimize_resample)
57+
@info "Optimized resampling enabled: ", optimize_resample
5858

5959
n_float_per_particle = 100000
6060
# total number of floats per rank
@@ -68,7 +68,7 @@ local_states = similar(init_local_states)
6868
if verbose
6969
for i = 1:my_size
7070
if i == my_rank + 1
71-
println("rank ", my_rank, ": local states: ", local_states)
71+
@info "rank $(my_rank): local states: ", local_states
7272
end
7373
MPI.Barrier(MPI.COMM_WORLD)
7474
end
@@ -88,14 +88,12 @@ local_timer_dicts = Dict{String, Dict{String,Any}}()
8888

8989
for (trial_name, indices_func) in trial_sets
9090
if verbose && my_rank == 0
91-
println()
92-
println("Resampling particles to indices ", indices)
93-
println()
91+
@info "Resampling particles to indices ", indices
9492
end
9593
indices = collect(1:n_particle) # Placeholder for actual indices
9694
# repeat experiment 10 times to get average time
9795
# warm up run
98-
println("Warm up run...")
96+
@info "Warm up run..."
9997
ParticleDA.optimized_resample!(indices, my_size)
10098
ParticleDA.copy_states!(
10199
local_states,
@@ -104,7 +102,7 @@ for (trial_name, indices_func) in trial_sets
104102
my_rank,
105103
n_particle_per_rank
106104
)
107-
println("Starting timed runs for trial '$trial_name'...")
105+
@info "Starting timed runs for trial '$trial_name'..."
108106

109107
timer = TimerOutputs.TimerOutput("copy_states")
110108
for _ in 1:10
@@ -141,11 +139,11 @@ for (trial_name, indices_func) in trial_sets
141139
# compare
142140
match = local_states == expected
143141

144-
println("rank ", my_rank, ": local_states =")
145-
show(stdout, "text/plain", local_states); println()
146-
println("rank ", my_rank, ": expected =")
147-
show(stdout, "text/plain", expected); println()
148-
println("rank ", my_rank, ": match = ", match)
142+
@info "rank $(my_rank): local_states ="
143+
show(stdout, "text/plain", local_states);
144+
@info "rank $(my_rank): expected ="
145+
show(stdout, "text/plain", expected);
146+
@info "rank $(my_rank): match = ", match
149147
end
150148
MPI.Barrier(MPI.COMM_WORLD)
151149
end

0 commit comments

Comments
 (0)