Skip to content

Commit 8ab9e4d

Browse files
authored
Use JuliaGPU Buildkite CI for GPU tests (trixi-framework#723)
* Use JuliaGPU Buildkite CI for GPU tests * Remove Codecov token * Add GPU tests * Print ENV * Fix merge error in runtests.jl * Add CI for AMDGPU and oneAPI * Fix GPU tests * Fix formatting of pipeline.yml * Disable `count_allocations` for GPU tests * Add single and double precision test * Add proper GPU tests (and fix problems) * Reformat * Disable double precision tests for oneAPI * Reformat * Reformat * Improve readability of boundary extrapolation condition * Fix EDAC and dam break plate gate on GPUs * Reformat * Fix open boundary system * Fix DEMSystem * Fix EDAC test * Undo Float32 literals in smoothing kernels * Fix allocations * First step to make packing work on GPUs * Second step to make packing system GPU compatible * Revert "Second step to make packing system GPU compatible" This reverts commit e1b86e3. * Revert "First step to make packing work on GPUs" This reverts commit c350289. * Fix particle packing system * Reformat * Fix doctests * Use manual trigger for buildkite * Revert "Use manual trigger for buildkite" This reverts commit 3ac3fc1. * Add trigger buildkite action * Fix action * Try action without if condition * Try again * Remove action again * Try more * Fix GPU tests * Reformat * Fix tests * Disable oneAPI tests * Fix * Add GPU support to README
1 parent aa6475b commit 8ab9e4d

File tree

30 files changed

+626
-157
lines changed

30 files changed

+626
-157
lines changed

.buildkite/pipeline.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
steps:
2+
- label: "CUDA"
3+
plugins:
4+
- JuliaCI/julia#v1:
5+
version: "1"
6+
agents:
7+
queue: "juliagpu"
8+
cuda: "*"
9+
command: |
10+
julia --color=yes --project=test -e 'using Pkg; Pkg.add("CUDA"); Pkg.develop(path="."); Pkg.instantiate()'
11+
julia --color=yes --project=test -e 'include("test/runtests.jl")'
12+
env:
13+
TRIXIPARTICLES_TEST: cuda
14+
timeout_in_minutes: 60
15+
16+
- label: "AMDGPU"
17+
plugins:
18+
- JuliaCI/julia#v1:
19+
version: "1"
20+
agents:
21+
queue: "juliagpu"
22+
rocm: "*"
23+
command: |
24+
julia --color=yes --project=test -e 'using Pkg; Pkg.add("AMDGPU"); Pkg.develop(path="."); Pkg.instantiate()'
25+
julia --color=yes --project=test -e 'include("test/runtests.jl")'
26+
env:
27+
TRIXIPARTICLES_TEST: amdgpu
28+
timeout_in_minutes: 60
29+
30+
- label: "Metal"
31+
plugins:
32+
- JuliaCI/julia#v1:
33+
version: "1"
34+
agents:
35+
queue: "juliaecosystem"
36+
os: "macos"
37+
arch: "aarch64"
38+
command: |
39+
julia --color=yes --project=test -e 'using Pkg; Pkg.add("Metal"); Pkg.develop(path="."); Pkg.instantiate()'
40+
julia --color=yes --project=test -e 'include("test/runtests.jl")'
41+
env:
42+
TRIXIPARTICLES_TEST: metal
43+
timeout_in_minutes: 60
44+
45+
# Doesn't work. Fails with segfault. See https://github.com/trixi-framework/TrixiParticles.jl/issues/484.
46+
# - label: "oneAPI"
47+
# plugins:
48+
# - JuliaCI/julia#v1:
49+
# version: "1"
50+
# agents:
51+
# queue: "juliagpu"
52+
# intel: "*"
53+
# command: |
54+
# julia --color=yes --project=test -e 'using Pkg; Pkg.add("oneAPI"); Pkg.develop(path="."); Pkg.instantiate()'
55+
# julia --color=yes --project=test -e 'include("test/runtests.jl")'
56+
# env:
57+
# TRIXIPARTICLES_TEST: oneapi
58+
# timeout_in_minutes: 60

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ It offers intuitive configuration, robust pre- and post-processing, and vendor-a
3636
- Particle sampling of complex geometries from `.stl` and `.asc` files.
3737
- Output formats:
3838
- VTK
39+
- Support for GPUs by Nvidia, AMD and Apple (experimental)
3940

4041
## Examples
4142
We provide several example simulation setups in the `examples` folder (which can be accessed from Julia via `examples_dir()`).

examples/fluid/dam_break_2d_gpu.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using TrixiParticles
99
# Load setup from dam break example
1010
trixi_include(@__MODULE__,
1111
joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
12-
sol=nothing)
12+
sol=nothing, ode=nothing)
1313

1414
# Define a GPU-compatible neighborhood search
1515
min_corner = minimum(tank.boundary.coordinates, dims=2)
@@ -23,4 +23,7 @@ trixi_include(@__MODULE__,
2323
neighborhood_search=neighborhood_search,
2424
fluid_particle_spacing=fluid_particle_spacing,
2525
tspan=tspan,
26+
density_diffusion=density_diffusion,
27+
boundary_layers=boundary_layers, spacing_ratio=spacing_ratio,
28+
boundary_model=boundary_model,
2629
data_type=nothing)

examples/fluid/dam_break_3d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ boundary_system = BoundarySPHSystem(tank.boundary, boundary_model)
5757
# ==========================================================================================
5858
# ==== Simulation
5959
semi = Semidiscretization(fluid_system, boundary_system)
60-
ode = semidiscretize(semi, tspan)
60+
ode = semidiscretize(semi, tspan, data_type=nothing)
6161

6262
info_callback = InfoCallback(interval=10)
6363
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")

examples/fluid/hydrostatic_water_column_2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ boundary_system = BoundarySPHSystem(tank.boundary, boundary_model, movement=noth
6262
# ==========================================================================================
6363
# ==== Simulation
6464
semi = Semidiscretization(fluid_system, boundary_system)
65-
ode = semidiscretize(semi, tspan)
65+
ode = semidiscretize(semi, tspan, data_type=nothing)
6666

6767
info_callback = InfoCallback(interval=50)
6868
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")

examples/fluid/periodic_channel_2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ periodic_box = PeriodicBox(min_corner=[0.0, -0.25], max_corner=[1.0, 0.75])
6060
neighborhood_search = GridNeighborhoodSearch{2}(; periodic_box)
6161

6262
semi = Semidiscretization(fluid_system, boundary_system; neighborhood_search)
63-
ode = semidiscretize(semi, tspan)
63+
ode = semidiscretize(semi, tspan, data_type=nothing)
6464

6565
info_callback = InfoCallback(interval=100)
6666
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")

examples/fluid/pipe_flow_2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ boundary_system = BoundarySPHSystem(pipe.boundary, boundary_model)
125125
semi = Semidiscretization(fluid_system, open_boundary_in, open_boundary_out,
126126
boundary_system)
127127

128-
ode = semidiscretize(semi, tspan)
128+
ode = semidiscretize(semi, tspan, data_type=nothing)
129129

130130
info_callback = InfoCallback(interval=100)
131131
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")

examples/fsi/dam_break_gate_2d.jl

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# "Study of a complex fluid-structure dam-breaking benchmark problem using a multi-phase SPH method with APR".
55
# In: Engineering Analysis with Boundary Elements 104 (2019), pages 240-258.
66
# https://doi.org/10.1016/j.enganabound.2019.03.033
7+
#
8+
# Use a higher resolution and see the comments below regarding plate thickness
9+
# to reproduce the results from the paper.
710

811
using TrixiParticles
912
using OrdinaryDiffEq
@@ -14,7 +17,7 @@ using OrdinaryDiffEq
1417
# since "larger" particles don't fit through the slightly opened gate. Lower fluid
1518
# resolutions thereforce cause a later and more violent fluid impact against the gate.
1619
fluid_particle_spacing = 0.02
17-
n_particles_x = 5
20+
n_particles_x = 4
1821

1922
# Change spacing ratio to 3 and boundary layers to 1 when using Monaghan-Kajtar boundary model
2023
boundary_layers = 3
@@ -54,13 +57,15 @@ is_moving(t) = t < 0.1
5457

5558
gate_movement = BoundaryMovement(movement_function, is_moving)
5659

57-
# Elastic plate/beam
60+
# Elastic plate/beam.
61+
# The paper is using a thickness of 0.004, which only works properly when a similar fluid
62+
# resolution is used. Increase resolution and change to 0.004 to reproduce the results.
5863
length_beam = 0.09
59-
thickness = 0.004
64+
thickness = 0.004 * 10
6065
solid_density = 1161.54
6166

6267
# Young's modulus and Poisson ratio
63-
E = 3.5e6
68+
E = 3.5e6 / 10
6469
nu = 0.45
6570

6671
# The structure starts at the position of the first particle and ends
@@ -123,24 +128,11 @@ solid_smoothing_kernel = WendlandC2Kernel{2}()
123128
hydrodynamic_densites = fluid_density * ones(size(solid.density))
124129
hydrodynamic_masses = hydrodynamic_densites * solid_particle_spacing^2
125130

126-
k_solid = gravity * initial_fluid_size[2]
127-
beta_solid = fluid_particle_spacing / solid_particle_spacing
128-
boundary_model_solid = BoundaryModelMonaghanKajtar(k_solid, beta_solid,
129-
solid_particle_spacing,
130-
hydrodynamic_masses)
131-
132-
# `BoundaryModelDummyParticles` usually produces better results, since Monaghan-Kajtar BCs
133-
# tend to introduce a non-physical gap between fluid and boundary.
134-
# However, `BoundaryModelDummyParticles` can only be used when the plate thickness is
135-
# at least two fluid particle spacings, so that the compact support is fully sampled,
136-
# or fluid particles can penetrate the solid.
137-
# For higher fluid resolutions, uncomment the code below for better results.
138-
#
139-
# boundary_model_solid = BoundaryModelDummyParticles(hydrodynamic_densites,
140-
# hydrodynamic_masses,
141-
# state_equation=state_equation,
142-
# AdamiPressureExtrapolation(),
143-
# smoothing_kernel, smoothing_length)
131+
boundary_model_solid = BoundaryModelDummyParticles(hydrodynamic_densites,
132+
hydrodynamic_masses,
133+
state_equation=state_equation,
134+
AdamiPressureExtrapolation(),
135+
smoothing_kernel, smoothing_length)
144136

145137
solid_system = TotalLagrangianSPHSystem(solid,
146138
solid_smoothing_kernel, solid_smoothing_length,
@@ -152,7 +144,7 @@ solid_system = TotalLagrangianSPHSystem(solid,
152144
# ==== Simulation
153145
semi = Semidiscretization(fluid_system, boundary_system_tank,
154146
boundary_system_gate, solid_system)
155-
ode = semidiscretize(semi, tspan)
147+
ode = semidiscretize(semi, tspan, data_type=nothing)
156148

157149
info_callback = InfoCallback(interval=100)
158150
saving_callback = SolutionSavingCallback(dt=0.02, prefix="")

examples/solid/oscillating_beam_2d.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ solid_system = TotalLagrangianSPHSystem(solid, smoothing_kernel, smoothing_lengt
5656
# ==== Simulation
5757
semi = Semidiscretization(solid_system,
5858
neighborhood_search=PrecomputedNeighborhoodSearch{2}())
59-
ode = semidiscretize(semi, tspan)
59+
ode = semidiscretize(semi, tspan, data_type=nothing)
6060

6161
info_callback = InfoCallback(interval=100)
6262

src/general/gpu.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
Adapt.@adapt_structure Semidiscretization
1111
Adapt.@adapt_structure WeaklyCompressibleSPHSystem
1212
Adapt.@adapt_structure DensityDiffusionAntuono
13+
Adapt.@adapt_structure EntropicallyDampedSPHSystem
1314
Adapt.@adapt_structure BoundarySPHSystem
1415
Adapt.@adapt_structure BoundaryModelDummyParticles
1516
Adapt.@adapt_structure BoundaryModelMonaghanKajtar
17+
Adapt.@adapt_structure BoundaryMovement
1618
Adapt.@adapt_structure TotalLagrangianSPHSystem
1719

1820
# The initial conditions are only used for initialization, which happens before `adapt`ing

0 commit comments

Comments
 (0)