-
Notifications
You must be signed in to change notification settings - Fork 268
Open
Description
The FFT Poisson solvers should have eigenvalues with the same float type as the grid:
using Oceananigans
using Oceananigans.Solvers: FFTBasedPoissonSolver, FourierTridiagonalPoissonSolver
# The float type of the Poisson operator eigenvalues should be the same as that of the grid
grid = RectilinearGrid(CPU(), Float32, size = (2,2), extent=(1,1), topology = (Periodic, Flat, Bounded))
@show eltype(grid)
solver = FFTBasedPoissonSolver(grid)
@show eltype(solver.eigenvalues.λx)
solver = FourierTridiagonalPoissonSolver(grid)
@show eltype(solver.poisson_eigenvalues[1])
Output:
eltype(grid) = Float32
eltype(solver.eigenvalues.λx) = Float64
eltype(solver.poisson_eigenvalues[1]) = Float64This will become a problem once Metal supports FFTs, since it doesn't support Float64:
using Metal
metal = Metal.MetalBackend()
arch = GPU(metal)
grid_on_GPU = RectilinearGrid(arch, Float32, size = (2,2), extent=(1,1), topology = (Periodic, Flat, Bounded))
solver = FFTBasedPoissonSolver(grid_on_GPU)Output:
ERROR: LoadError: Metal does not support Float64 values, try using Float32 instead
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] check_eltype(T::Type)
@ Metal ~/.julia/packages/Metal/EFzAO/src/array.jl:32
[3] MtlArray{Float64, 3, Metal.PrivateStorage}(::UndefInitializer, dims::Tuple{Int64, Int64, Int64})
@ Metal ~/.julia/packages/Metal/EFzAO/src/array.jl:54
[4] (MtlArray{Float64, 3})(::UndefInitializer, dims::Tuple{Int64, Int64, Int64})
@ Metal ~/.julia/packages/Metal/EFzAO/src/array.jl:204
[5] MtlArray
@ ~/.julia/packages/Metal/EFzAO/src/array.jl:291 [inlined]
[6] MtlArray(A::Array{Float64, 3})
@ Metal ~/.julia/packages/Metal/EFzAO/src/array.jl:307
[7] on_architecture(::GPU{MetalBackend}, a::Array{Float64, 3})
@ OceananigansMetalExt ~/Documents/Edinburgh/Projects/Oceananigans.jl/ext/OceananigansMetalExt.jl:31
[8] FFTBasedPoissonSolver(grid::RectilinearGrid{…}, planner_flag::UInt32)
@ Oceananigans.Solvers ~/Documents/Edinburgh/Projects/Oceananigans.jl/src/Solvers/fft_based_poisson_solver.jl:60
[9] FFTBasedPoissonSolver(grid::RectilinearGrid{…})
@ Oceananigans.Solvers ~/Documents/Edinburgh/Projects/Oceananigans.jl/src/Solvers/fft_based_poisson_solver.jl:52
[10] top-level scope
@ ~/Documents/Edinburgh/Projects/Oceananigans.jl/examples/MWE_FT_bug.jl:21
[11] include(fname::String)
@ Base.MainInclude ./client.jl:494
[12] top-level scope
@ REPL[2]:1
in expression starting at /Users/lbaker/Documents/Edinburgh/Projects/Oceananigans.jl/examples/MWE_FT_bug.jl:21
Some type information was truncated. Use `show(err)` to see complete types.I'll add a PR to fix this by passing float type to poisson_eigenvalues() @simone-silvestri
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels