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

Convert diagnostics output for MultiLayerQG from Arrays to Tuples? #273

Closed
navidcy opened this issue Nov 21, 2021 · 1 comment · Fixed by #293
Closed

Convert diagnostics output for MultiLayerQG from Arrays to Tuples? #273

navidcy opened this issue Nov 21, 2021 · 1 comment · Fixed by #293

Comments

@navidcy
Copy link
Member

navidcy commented Nov 21, 2021

For example, the energies() diagnostic returns KE as nlayer x 1 array, and PE as (nlayer-1) x 1 arrays.

for j = 1:nlayers
CUDA.@allowscalar KE[j] = 1 / (2 * grid.Lx * grid.Ly) * parsevalsum(abs²∇𝐮h[:, :, j], grid) * params.H[j] / sum(params.H)
end
for j = 1:nlayers-1
CUDA.@allowscalar PE[j] = 1 / (2 * grid.Lx * grid.Ly) * params.f₀^2 / params.g′[j] * parsevalsum(abs2.(vars.ψh[:, :, j+1] .- vars.ψh[:, :, j]), grid)
end

Should we convert these to Tuples? Would that avoid scalar operations, e.g., in

CUDA.@allowscalar KE[j] = 1 / (2 * grid.Lx * grid.Ly) * parsevalsum(abs²∇𝐮h[:, :, j], grid) * params.H[j] / sum(params.H)

?

@glwagner
Copy link
Member

That might work. Using views might be another option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants