Skip to content

Commit fa62396

Browse files
Add a performance benchmark pipeline (#4375)
* add the runbenchmarks * let's ty it out * trigger tests * on everything * run the benchmarks * maybe this works * above project * adding benchmarktools * try pushing on docs build * try this once * correct queue * try out the pipeline * no need for an architecture * use the oceananigans queue * add a trace * change output per group * use GPU1 for the moment * instantiate inside the test * instantiate first * try uploading an artifact * add an artifact * should work all in one pipeline * some bugfixes * runb the complete benchmark test suite * load cheap advection * fix cheap advection * Update .buildkite/pipeline-benchmarks.yml Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com> * switch queue * add login to the benchmark pipeline * add login to the benchmark pipeline * same the main build name * add a condiitonal block * add a conditional save * not working? * conditional metadata save once again * add a comment --------- Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com>
1 parent a82c773 commit fa62396

File tree

2 files changed

+205
-0
lines changed

2 files changed

+205
-0
lines changed

.buildkite/pipeline-benchmarks.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
env:
2+
JULIA_VERSION: "1.10.9"
3+
JULIA_MINOR_VERSION: "1.10"
4+
TARTARUS_HOME: "/storage5/buildkite-agent"
5+
JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
6+
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
7+
JULIA_NUM_PRECOMPILE_TASKS: 24
8+
JULIA_NUM_THREADS: 8
9+
NSYS: "/storage6/nsight/bin/nsys"
10+
CUDA_VISIBLE_DEVICES: "1" # Tartarus device for GPU Benchmarking
11+
TMPDIR: "$TARTARUS_HOME/tmp"
12+
13+
steps:
14+
- label: "🏕️ initialize tartarus environment"
15+
key: "init"
16+
env:
17+
JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
18+
TEST_GROUP: "init"
19+
JULIA_BINDIR: "$TARTARUS_HOME/julia-$JULIA_VERSION/bin"
20+
command: |
21+
# Download julia binaries
22+
wget -N -P $TARTARUS_HOME https://julialang-s3.julialang.org/bin/linux/x64/$JULIA_MINOR_VERSION/julia-$JULIA_VERSION-linux-x86_64.tar.gz
23+
tar xf $TARTARUS_HOME/julia-$JULIA_VERSION-linux-x86_64.tar.gz -C $TARTARUS_HOME
24+
agents:
25+
queue: "Oceananigans-benchmarks"
26+
retry:
27+
automatic:
28+
- exit_status: 1
29+
limit: 1
30+
31+
- wait
32+
33+
# Saving the latest build ID of the main branch for
34+
# later comparison of the artifacts in PRs
35+
- label: "💾 conditional metadata save"
36+
key: "save-metadata"
37+
agents:
38+
queue: Oceananigans-benchmarks
39+
40+
command: |
41+
if [ "$BUILDKITE_BRANCH" = "main" ]; then
42+
echo "Saving build ID for main..."
43+
buildkite-agent meta-data set "latest-main-build" "$BUILDKITE_BUILD_ID"
44+
else
45+
echo "Not on main, skipping metadata save."
46+
fi
47+
48+
- label: "🚀 Oceananigans GPU benchmarks"
49+
key: "benchmarks"
50+
agents:
51+
queue: "Oceananigans-benchmarks"
52+
53+
command: |
54+
# Instantiate
55+
$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no -e 'using Pkg; Pkg.instantiate()'
56+
57+
# Run Periodic benchmarks
58+
export BENCHMARK_GROUP="periodic"
59+
$NSYS profile --output=periodic_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
60+
$NSYS stats periodic_output.nsys-rep > periodic_output.txt
61+
62+
# Remove generated output files
63+
rm periodic_output.nsys-rep
64+
rm periodic_output.sqlite
65+
66+
# Run Bounded benchmarks
67+
export BENCHMARK_GROUP="bounded"
68+
$NSYS profile --output=bounded_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
69+
$NSYS stats bounded_output.nsys-rep > bounded_output.txt
70+
71+
# Remove generated output files
72+
rm bounded_output.nsys-rep
73+
rm bounded_output.sqlite
74+
75+
# Run Periodic cheap advection benchmarks
76+
export BENCHMARK_GROUP="periodic_cheap_advection"
77+
$NSYS profile --output=periodic_cheap_advection_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
78+
$NSYS stats periodic_cheap_advection_output.nsys-rep > periodic_cheap_advection_output.txt
79+
80+
# Remove generated output files
81+
rm periodic_cheap_advection_output.nsys-rep
82+
rm periodic_cheap_advection_output.sqlite
83+
84+
# Run Bounded cheap advection benchmarks
85+
export BENCHMARK_GROUP="bounded_cheap_advection"
86+
$NSYS profile --output=bounded_cheap_advection_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
87+
$NSYS stats bounded_cheap_advection_output.nsys-rep > bounded_cheap_advection_output.txt
88+
89+
# Remove generated output files
90+
rm bounded_cheap_advection_output.nsys-rep
91+
rm bounded_cheap_advection_output.sqlite
92+
93+
# Run Immersed benchmarks
94+
export BENCHMARK_GROUP="immersed"
95+
$NSYS profile --output=immersed_output --trace=cuda $TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia --color=yes --project --check-bounds=no test/benchmark_tests.jl
96+
$NSYS stats immersed_output.nsys-rep > immersed_output.txt
97+
98+
# Remove generated output files
99+
rm immersed_output.nsys-rep
100+
rm immersed_output.sqlite
101+
102+
artifact_paths:
103+
- "periodic_output.txt"
104+
- "bounded_output.txt"
105+
- "periodic_cheap_advection_output.txt"
106+
- "bounded_cheap_advection_output.txt"
107+
- "immersed_output.txt"
108+
soft_fail:
109+
- exit_status: 3
110+

test/benchmark_tests.jl

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using Oceananigans
2+
using Oceananigans.Units
3+
using Oceananigans.Architectures: on_architecture
4+
using Oceananigans.TurbulenceClosures.TKEBasedVerticalDiffusivities: CATKEVerticalDiffusivity
5+
using SeawaterPolynomials.TEOS10
6+
using Random
7+
8+
function ocean_benchmark(arch, Nx, Ny, Nz, topology, immersed, tracer_advection=WENO(order=7))
9+
10+
z_faces = collect(range(-6000, 0, length=Nz+1))
11+
12+
grid = RectilinearGrid(arch; size=(Nx, Ny, Nz),
13+
halo=(7, 7, 7),
14+
z=z_faces,
15+
x=(-1000kilometers, 1000kilometers),
16+
y=(-1000kilometers, 1000kilometers),
17+
topology)
18+
19+
grid = if immersed
20+
Random.seed!(1234)
21+
bottom = Oceananigans.Architectures.on_architecture(arch, - 5000 .* rand(Nx, Ny) .- 1000)
22+
ImmersedBoundaryGrid(grid, GridFittedBottom(bottom); active_cells_map=true)
23+
else
24+
grid
25+
end
26+
27+
@info "Grid is built"
28+
momentum_advection = WENOVectorInvariant()
29+
buoyancy = SeawaterBuoyancy(equation_of_state=TEOS10EquationOfState())
30+
free_surface = SplitExplicitFreeSurface(grid; substeps=70)
31+
closure = CATKEVerticalDiffusivity()
32+
33+
model = HydrostaticFreeSurfaceModel(; grid,
34+
momentum_advection,
35+
tracer_advection,
36+
buoyancy,
37+
closure,
38+
free_surface,
39+
tracers = (:T, :S, :e))
40+
41+
@info "Model is built"
42+
43+
R = rand(size(model.grid))
44+
45+
# initialize variables with randomish values
46+
Tᵢ = 0.0001 .* R .+ 20
47+
Sᵢ = 0.0001 .* R .+ 35
48+
uᵢ = 0.0001 .* R
49+
vᵢ = 0.0001 .* R
50+
51+
set!(model, T=Tᵢ, S=Sᵢ, e=1e-6, u=uᵢ, v=vᵢ)
52+
53+
return model
54+
end
55+
56+
function run_benchmark(model)
57+
for _ in 1:15
58+
time_step!(model, 1.0)
59+
end
60+
end
61+
62+
group = get(ENV, "BENCHMARK_GROUP", "all") |> Symbol
63+
64+
const Nx = 500
65+
const Ny = 200
66+
const Nz = 60
67+
68+
arch = GPU()
69+
70+
cheap_advection = FluxFormAdvection(WENO(order=7), WENO(order=7), Centered())
71+
72+
if group == :periodic
73+
model = ocean_benchmark(arch, Nx, Ny, Nz, (Periodic, Periodic, Bounded), false)
74+
run_benchmark(model)
75+
end
76+
77+
if group == :bounded
78+
model = ocean_benchmark(arch, Nx, Ny, Nz, (Bounded, Bounded, Bounded), false)
79+
run_benchmark(model)
80+
end
81+
82+
if group == :periodic_cheap_advection
83+
model = ocean_benchmark(arch, Nx, Ny, Nz, (Periodic, Periodic, Bounded), false, cheap_advection)
84+
run_benchmark(model)
85+
end
86+
87+
if group == :bounded_cheap_advection
88+
model = ocean_benchmark(arch, Nx, Ny, Nz, (Bounded, Bounded, Bounded), false, cheap_advection)
89+
run_benchmark(model)
90+
end
91+
92+
if group == :immersed
93+
model = ocean_benchmark(arch, Nx, Ny, Nz, (Periodic, Periodic, Bounded), true)
94+
run_benchmark(model)
95+
end

0 commit comments

Comments
 (0)