Comments (4)
@ali-ramadhan could the NVidia cufftw interface help ( https://docs.nvidia.com/cuda/cufft/index.html#fftw-supported-interface ) as a step. My reading is that this does things on GPU, so could avoid copy, but may not be as super optimal as native cuFFT. Maybe you already tried that - the advertising on the box seems to imply you just switch a few headers, link and existing FFTW works, but maybe there is small print?
from oceananigans.jl.
@christophernhill Yes I believe I am using the FFTW interface to do the FFT/IFFTs on the GPUs.
Where I got stuck is that the existing solver uses FFTW.r2r!(f.data, FFTW.REDFT10, 3)
for the DCT and FFTW.r2r!(ϕ.data, FFTW.REDFT01, 3)
for the IDCT, but under the "FFTW Interface to cuFFT" table, Read-to-Real Transforms and Read-to-Real Transform Kinds are "Not supported".
So I implemented a DCT using the N FFT (following this post)
https://github.com/ali-ramadhan/Oceananigans.jl/blob/93aa0038b3126470f263475d648bceb9562bbe91/src/spectral_solvers.jl#L359-L370
and an IDCT using the IFFT (following these course notes)
https://github.com/ali-ramadhan/Oceananigans.jl/blob/93aa0038b3126470f263475d648bceb9562bbe91/src/spectral_solvers.jl#L372-L387
They work in isolation (they produce the same output as FFTW.r2r!
but do not work when I substitute them into the Poisson solver. I'm playing around with it right now, hoping it's just a bug on my part.
from oceananigans.jl.
Hmmm, now I look through the notes again, maybe the IDCT I implemented only works for real inputs. That's exactly what we need though. I'll keep playing around.
from oceananigans.jl.
Upon closer inspection of the REDFT01 (DCT-III) transform in FFTW, I should have been dividing the first element X₀ by 2 in our DCT-III implementation using the IFFT. The correct IDCT is thus
function idct_dim3_gpu!(f)
Nx, Ny, Nz = size(f)
bfactors = exp.(collect(1im*π*(0:Nz-1) / (2*Nz)))
bfactors[1] *= 0.5
f .*= cu(repeat(reshape(bfactors, 1, 1, Nz), Nx, Ny, 1))
ifft!(f, 3)
f .= cu(reshape(permutedims(cat(f[:, :, 1:Int(Nz/2)], f[:, :, end:-1:Int(Nz/2)+1]; dims=4), (1, 2, 4, 3)), Nx, Ny, Nz))
# @. f = real(f) # Don't do it here. We'll do it when assigning real(ϕ) to pNHS to save some measly FLOPS.
nothing
end
This can all be optimized, but at least a working Poisson solver is a good step.
from oceananigans.jl.
Related Issues (20)
- Three-dimensional `StokesDrift` docstring example may be misleading HOT 2
- Improve example for 3D Stokes drift HOT 1
- `maximum(abs, v)` doesn't work on GPU in Julia 1.10.0 with grid size larger than (10, 10, 10) HOT 7
- Stokes Drift Docs/Physics page does not include 3D Stoke implementation
- Non-standard function throws an error when used in a `KernelFunctionOperation` on the GPU HOT 10
- Ambiguous method error when calculating a conditional `Average()` with an `ImmersedBoundaryGrid` HOT 7
- 2D turbulence example missing `fontsize` keyword in `Label` call HOT 10
- Question for 3D Stokes example HOT 7
- `WENOVectorInvariant` method cleanup? HOT 5
- `KernelFunctionOperation` produces incorrect result when given a `NamedTuple` with an `AbstractOperation` HOT 9
- Callback with `callsite=TendencyCallsite()` doesn't work HOT 1
- Can we rewrite the pressure equation and calculate each term in it? HOT 3
- Can we calculate a `Field` at every `N` grid points? HOT 5
- `restore_from_checkpoint` is deprecated? HOT 1
- Checkpointer required properties includes `:architecture` despite it can be inferred from `grid` HOT 1
- `LatitudeLongitudeGrid` may have incorrect metrics for `y`-Periodic domains HOT 4
- @fluidnumerics-joe the CI doesn't work... something's wrong with the Manifest you pushed. HOT 1
- `FieldTimeSeries` does not adapt correctly on GPU HOT 4
- Kernel size calculation for sliced field halo filling seems to be wrong HOT 1
- Move CUDA into an extension HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oceananigans.jl.