Skip to content

Commit

Permalink
Merge pull request #294 from CliMA/ck/customize_hcrop
Browse files Browse the repository at this point in the history
Add horizontal cropping to perf table
  • Loading branch information
charleskawczynski authored Jun 3, 2024
2 parents e141aff + a837eeb commit cffea1c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ClimaTimeSteppers"
uuid = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
authors = ["Climate Modeling Alliance"]
version = "0.7.30"
version = "0.7.31"

[deps]
ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d"
Expand Down
5 changes: 4 additions & 1 deletion ext/ClimaTimeSteppersBenchmarkToolsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const allowed_names =
with_cu_prof::Symbol = :bfrofile, # [:bprofile, :profile]
trace::Bool = false,
crop::Bool = false,
hcrop::Union{Nothing, Int} = nothing,
only::Union{Nothing, Vector{String}} = nothing,
)
Expand All @@ -62,6 +63,7 @@ Benchmark a DistributedODEIntegrator given:
- `with_cu_prof`, `:profile` or `:bprofile`, to call `CUDA.@profile` or `CUDA.@bprofile` respectively.
- `trace`, Bool passed to `CUDA.@profile` (see CUDA docs)
- `crop`, Bool indicating whether or not to crop the `CUDA.@profile` printed table.
- `hcrop`, Number of horizontal characters to include in the table before cropping.
- `only, list of functions to benchmarks (benchmark all by default)
`only` may contain:
Expand All @@ -81,6 +83,7 @@ function CTS.benchmark_step(
with_cu_prof::Symbol = :bprofile,
trace::Bool = false,
crop::Bool = false,
hcrop::Union{Nothing, Int} = nothing,
only::Union{Nothing, Vector{String}} = nothing,
)
(; u, p, t, dt, sol, alg) = integrator
Expand All @@ -96,7 +99,7 @@ function CTS.benchmark_step(
@. X = u
@. Xlim = u
trials₀ = OrderedCollections.OrderedDict()
kwargs = (; device, with_cu_prof, trace, crop)
kwargs = (; device, with_cu_prof, trace, crop, hcrop)
#! format: off
maybe_push!(trials₀, "Wfact", wfact_fun(integrator), (W, u, p, dt, t), kwargs, only)
maybe_push!(trials₀, "ldiv!", LA.ldiv!, (X, W, u), kwargs, only)
Expand Down
14 changes: 10 additions & 4 deletions ext/benchmark_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ function tabulate_summary(summary; n_calls_per_step)
)
end

get_trial(f::Nothing, args, name; device, with_cu_prof = :bprofile, trace = false, crop = false) = nothing
function get_trial(f, args, name; device, with_cu_prof = :bprofile, trace = false, crop = false)
get_trial(f::Nothing, args, name; device, with_cu_prof = :bprofile, trace = false, crop = false, hcrop = nothing) =
nothing
function get_trial(f, args, name; device, with_cu_prof = :bprofile, trace = false, crop = false, hcrop = nothing)
f(args...) # compile first
b = if device isa ClimaComms.CUDADevice
BenchmarkTools.@benchmarkable CUDA.@sync $f($(args)...)
Expand All @@ -68,8 +69,13 @@ function get_trial(f, args, name; device, with_cu_prof = :bprofile, trace = fals
if crop
println(p) # crops by default
else
io = IOContext(stdout, :crop => :horizontal)
show(io, p)
# use "COLUMNS" to set how many horizontal characters to crop:
# See https://github.com/ronisbr/PrettyTables.jl/issues/11#issuecomment-2145550354
envs = isnothing(hcrop) ? () : ("COLUMNS" => hcrop,)
withenv(envs...) do
io = IOContext(stdout, :crop => :horizontal, :limit => true, :displaysize => displaysize())
show(io, p)
end
println()
end
end
Expand Down

2 comments on commit cffea1c

@charleskawczynski
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/108184

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.31 -m "<description of version>" cffea1c543b6096cb84324d8fee293f10292a38b
git push origin v0.7.31

Please sign in to comment.