Skip to content
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

scalar getindex is disallowed with topology = (Periodic, Bounded, Bounded) using Oceananigans v0.34.1 #864

Closed
ali-ramadhan opened this issue Aug 21, 2020 · 2 comments · Fixed by #878
Labels
bug 🐞 Even a perfect program still has bugs GPU 👾 Where Oceananigans gets its powers from

Comments

@ali-ramadhan
Copy link
Member

Reported by @sandreza

Must have missed this (or tests didn't cover this case) in PR #851

Screen Shot 2020-08-21 at 5 45 54 PM

@ali-ramadhan ali-ramadhan added bug 🐞 Even a perfect program still has bugs GPU 👾 Where Oceananigans gets its powers from labels Aug 21, 2020
@glwagner
Copy link
Member

glwagner commented Aug 23, 2020

Code is here:

function solve_poisson_equation!(solver::PressureSolver{Channel, GPU}, grid)
Nx, Ny, Nz, _ = unpack_grid(grid)
kx², ky², kz² = solver.wavenumbers.kx², solver.wavenumbers.ky², solver.wavenumbers.kz²
ω_4Ny⁺, ω_4Ny⁻ = solver.constants.ω_4Ny⁺, solver.constants.ω_4Ny⁻
ω_4Nz⁺, ω_4Nz⁻ = solver.constants.ω_4Nz⁺, solver.constants.ω_4Nz⁻
r_y_inds, r_z_inds = solver.constants.r_y_inds, solver.constants.r_z_inds
M_ky, M_kz = solver.constants.M_ky, solver.constants.M_kz
# We can use the same storage for the RHS and the solution ϕ.
RHS = ϕ = solver.storage.storage1
B = solver.storage.storage2 # Complex buffer storage.
# Calculate DCTʸᶻ(f) in place using the FFT.
solver.transforms.FFTyz! * RHS
RHS⁻ = view(RHS, 1:Nx, r_y_inds, 1:Nz)
@. B = 2 * real(ω_4Nz⁺ * (ω_4Ny⁺ * RHS + ω_4Ny⁻ * RHS⁻))
solver.transforms.FFTx! * B # Calculate FFTˣ(f) in place.
@. B = -B / (kx² + ky² + kz²)
CUDA.@allowscalar B[1, 1, 1] = 0 # Setting DC component of the solution (the mean) to be zero.
solver.transforms.IFFTx! * B # Calculate IFFTˣ(ϕ̂) in place.
# Calculate IDCTʸᶻ(ϕ̂) in place using the FFT.
B⁻⁺ = view(B, 1:Nx, r_y_inds, 1:Nz)
B⁺⁻ = view(B, 1:Nx, 1:Ny, r_z_inds)
B⁻⁻ = view(B, 1:Nx, r_y_inds, r_z_inds)
@. ϕ = 1/4 * ω_4Ny⁻ * ω_4Nz⁻ * ((B - M_ky * M_kz * B⁻⁻) - im*(M_kz * B⁺⁻ + M_ky * B⁻⁺))
solver.transforms.IFFTyz! * ϕ
return nothing
end

The issue is a call to view on line 138.

@ali-ramadhan
Copy link
Member Author

Not sure why tests did not catch this in #851, but running tests on Tartarus is catching it now 🤷

Fixing and will open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Even a perfect program still has bugs GPU 👾 Where Oceananigans gets its powers from
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants