Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/benchmark/AMDGPU/run.jl
5586 views
1
using Trixi
2
using AMDGPU
3
using TimerOutputs
4
using JSON
5
6
function main(elixir_path)
7
8
# setup
9
maxiters = 50
10
initial_refinement_level = 3
11
storage_type = ROCArray
12
real_type = Float64
13
14
println("Warming up...")
15
16
# start simulation with tiny final time to trigger compilation
17
duration_compile = @elapsed begin
18
trixi_include(elixir_path,
19
tspan = (0.0, 1e-14),
20
storage_type = storage_type,
21
real_type = real_type)
22
end
23
24
println("Finished warm-up in $duration_compile seconds\n")
25
println("Starting simulation...")
26
27
# start the real simulation
28
duration_elixir = @elapsed trixi_include(elixir_path,
29
maxiters = maxiters,
30
initial_refinement_level = initial_refinement_level,
31
storage_type = storage_type,
32
real_type = real_type)
33
34
# store metrics (on every rank!)
35
metrics = Dict{String, Float64}("elapsed time" => duration_elixir)
36
37
# read TimerOutputs timings
38
timer = Trixi.timer()
39
metrics["total time"] = 1.0e-9 * TimerOutputs.tottime(timer)
40
metrics["rhs! time"] = 1.0e-9 * TimerOutputs.time(timer["rhs!"])
41
42
# compute performance index
43
latest_semi = @invokelatest (@__MODULE__).semi
44
nrhscalls = Trixi.ncalls(latest_semi.performance_counter)
45
walltime = 1.0e-9 * take!(latest_semi.performance_counter)
46
metrics["PID"] = walltime * Trixi.mpi_nranks() /
47
(Trixi.ndofsglobal(latest_semi) * nrhscalls)
48
49
# write json file
50
open("metrics.out", "w") do f
51
indent = 2
52
JSON.print(f, metrics, indent)
53
end
54
end
55
56
# hardcoded elixir
57
elixir_path = joinpath(@__DIR__(), "elixir_euler_taylor_green_vortex.jl")
58
59
main(elixir_path)
60
61