-
Notifications
You must be signed in to change notification settings - Fork 260
Extend FFTBasedPoissonSolver to work on AMDGPU #4593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
navidcy
wants to merge
14
commits into
main
Choose a base branch
from
ncc/amdgpu-fft
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
009bff7
extend plan transforms for Flat
navidcy 8e2621b
add methods for plan_fwd/bwd_transform
661887f
add tests for NonhydrostaticModel
navidcy 0c97835
compactify tests
navidcy 30eec3a
reorder
navidcy 495be48
test few grids
navidcy f06ae9b
merge main
navidcy 2f54d0e
merge main
navidcy f835c0d
Add tests for AMDGPU with HydrostaticFreeSurfaceModel
glwagner 039bcce
Merge branch 'main' into ncc/amdgpu-fft
glwagner f9a2daa
Merge branch 'main' into ncc/amdgpu-fft
giordano b07b3c0
[AMDGPUExt] Use FFT functions from `AbstractFFTs` instead non-existin…
giordano de4e9e9
Update test/test_amdgpu.jl
glwagner fa511bf
Add compat bound for `AbstractFFTs`
giordano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,116 @@ | ||
| include("dependencies_for_runtests.jl") | ||
|
|
||
| using AMDGPU | ||
| using SeawaterPolynomials.TEOS10: TEOS10EquationOfState | ||
|
|
||
| @testset "AMDGPU extension" begin | ||
| function build_and_timestep_simulation(model) | ||
| FT = eltype(model) | ||
|
|
||
| for field in merge(model.velocities, model.tracers) | ||
| @test parent(field) isa ROCArray | ||
| end | ||
|
|
||
| simulation = Simulation(model, Δt=1minute, stop_iteration=3, verbose=false) | ||
| run!(simulation) | ||
|
|
||
| @test iteration(simulation) == 3 | ||
| @test time(simulation) ≈ FT(3minutes) | ||
|
|
||
| return nothing | ||
| end | ||
|
|
||
| @testset "AMDGPU on RectilinearGrids" begin | ||
| roc = AMDGPU.ROCBackend() | ||
| arch = GPU(roc) | ||
|
|
||
| for FT in float_types | ||
| @info "Testing grids on $arch with $FT..." | ||
|
|
||
| regular_grid = RectilinearGrid(arch, FT, size=(4, 8, 16), x=(0, 4), y=(0, 1), z=(0, 16)) | ||
| horizontally_stretched_grid = RectilinearGrid(arch, FT, size=(4, 8, 16), x=[0, 1, 2, 3, 4], y=(0, 1), z=(0, 16)) | ||
| vertically_stretched_grid = RectilinearGrid(arch, FT, size=(16, 8, 4), x=(0, 16), y=(0, 1), z=[0, 1, 2, 3, 4]) | ||
|
|
||
| @test parent(horizontally_stretched_grid.xᶠᵃᵃ) isa ROCArray | ||
| @test parent(horizontally_stretched_grid.xᶜᵃᵃ) isa ROCArray | ||
|
|
||
| @test parent(vertically_stretched_grid.z.cᵃᵃᶠ) isa ROCArray | ||
| @test parent(vertically_stretched_grid.z.cᵃᵃᶜ) isa ROCArray | ||
| @test parent(vertically_stretched_grid.z.Δᵃᵃᶠ) isa ROCArray | ||
| @test parent(vertically_stretched_grid.z.Δᵃᵃᶜ) isa ROCArray | ||
|
|
||
| for grid in (regular_grid, horizontally_stretched_grid, vertically_stretched_grid) | ||
| @test eltype(grid) == FT | ||
| @test architecture(grid) isa GPU | ||
| end | ||
|
|
||
| @info "Testing HydrostaticFreeSurfaceModel on $arch with $FT..." | ||
|
|
||
| coriolis = FPlane(latitude=45) | ||
| buoyancy = BuoyancyTracer() | ||
| tracers = :b | ||
| advection = WENO(order=5) | ||
|
|
||
| for grid in (regular_grid, horizontally_stretched_grid, vertically_stretched_grid) | ||
| momentum_advection = tracer_advection = advection | ||
|
|
||
| free_surface = SplitExplicitFreeSurface(grid; substeps=60) | ||
|
|
||
| model = HydrostaticFreeSurfaceModel(grid; free_surface, | ||
| coriolis, buoyancy, tracers, | ||
| momentum_advection, tracer_advection) | ||
|
|
||
| build_and_timestep_simulation(model) | ||
| end | ||
|
|
||
| @info "Testing NonhydrostaticModel on $arch with $FT..." | ||
|
|
||
| for grid in (regular_grid, vertically_stretched_grid) | ||
| cg_kw = (maxiter=10, reltol=1e-7, abstol=1e-7, preconditioner=nothing) | ||
| pressure_solvers = (Oceananigans.Solvers.ConjugateGradientPoissonSolver(grid; cg_kw...), | ||
| Oceananigans.Solvers.FFTBasedPoissonSolver(grid)) | ||
|
|
||
| for pressure_solver in pressure_solvers | ||
| model = NonhydrostaticModel(grid; pressure_solver, | ||
| coriolis, buoyancy, | ||
| tracers, advection) | ||
|
|
||
| build_and_timestep_simulation(model) | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| @testset "AMDGPU on LatitudeLongitudeGrid with HydrostaticFreeSurfaceModel" begin | ||
| roc = AMDGPU.ROCBackend() | ||
| arch = GPU(roc) | ||
|
|
||
| for FT in float_types | ||
| @info " Testing on $arch with $FT" | ||
|
|
||
| grid = RectilinearGrid(arch, FT, size=(4, 8, 16), x=[0, 1, 2, 3, 4], y=(0, 1), z=(0, 16)) | ||
| grid = LatitudeLongitudeGrid(arch, FT, size=(4, 8, 16), longitude=(-60, 60), latitude=(0, 60), z=(0, 1)) | ||
|
|
||
| @test parent(grid.xᶠᵃᵃ) isa ROCArray | ||
| @test parent(grid.xᶜᵃᵃ) isa ROCArray | ||
| @test parent(grid.Δxᶜᶜᵃ) isa ROCArray | ||
| @test parent(grid.Δxᶠᶜᵃ) isa ROCArray | ||
| @test parent(grid.Δxᶜᶠᵃ) isa ROCArray | ||
| @test parent(grid.Δxᶠᶠᵃ) isa ROCArray | ||
| @test parent(grid.Azᶜᶜᵃ) isa ROCArray | ||
| @test parent(grid.Azᶠᶜᵃ) isa ROCArray | ||
| @test parent(grid.Azᶜᶠᵃ) isa ROCArray | ||
| @test parent(grid.Azᶠᶠᵃ) isa ROCArray | ||
| @test eltype(grid) == FT | ||
| @test architecture(grid) isa GPU | ||
|
|
||
| model = HydrostaticFreeSurfaceModel(grid; | ||
| equation_of_state = TEOS10EquationOfState() | ||
| buoyancy = SeawaterBuoyancy(; equation_of_state) | ||
|
|
||
| model = HydrostaticFreeSurfaceModel(grid; buoyancy, | ||
| coriolis = FPlane(latitude=45), | ||
| buoyancy = BuoyancyTracer(), | ||
| tracers = :b, | ||
| tracers = (:T, :S), | ||
| momentum_advection = WENO(order=5), | ||
| tracer_advection = WENO(order=5), | ||
| free_surface = SplitExplicitFreeSurface(grid; substeps=60)) | ||
|
|
||
| for field in merge(model.velocities, model.tracers) | ||
| @test parent(field) isa ROCArray | ||
| end | ||
|
|
||
| simulation = Simulation(model, Δt=1minute, stop_iteration=3) | ||
| run!(simulation) | ||
|
|
||
| @test iteration(simulation) == 3 | ||
| @test time(simulation) == 3minutes | ||
| build_and_time_step_simulation(model) | ||
| end | ||
| end | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glwagner you added this line in f835c0d, but this function doesn't exist anywhere as far as I can tell.