Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ext/OceananigansAMDGPUExt.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
module OceananigansAMDGPUExt

using AMDGPU
using AMDGPU.rocFFT
using Oceananigans
using Oceananigans.Utils: linear_expand, __linear_ndrange, MappedCompilerMetadata
using KernelAbstractions: __dynamic_checkbounds, __iterspace

import KernelAbstractions: __validindex

import Oceananigans.Architectures:
architecture,
convert_to_device,
on_architecture
import Oceananigans.Solvers:
plan_backward_transform,
plan_forward_transform

const ROCGPU = GPU{<:AMDGPU.ROCBackend}
ROCGPU() = GPU(AMDGPU.ROCBackend())
Expand All @@ -30,6 +35,19 @@ on_architecture(::ROCGPU, a::StepRangeLen) = a
@inline convert_to_device(::ROCGPU, args) = AMDGPU.rocconvert(args)
@inline convert_to_device(::ROCGPU, args::Tuple) = map(AMDGPU.rocconvert, args)

function plan_forward_transform(A::ROCArray, ::Union{Bounded, Periodic}, dims, planner_flag)
length(dims) == 0 && return nothing
return AMDGPU.rocFFT.plan_fft!(A, dims)
end

function plan_backward_transform(A::ROCArray, ::Union{Bounded, Periodic}, dims, planner_flag)
length(dims) == 0 && return nothing
return AMDGPU.rocFFT.plan_bfft!(A, dims)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the plan_bfft!, not the plan_ifft!
do we need to add a normalisation or something?

end

plan_backward_transform(A::ROCArray, ::Flat, args...) = nothing
plan_forward_transform(A::ROCArray, ::Flat, args...) = nothing

AMDGPU.Device.@device_override @inline function __validindex(ctx::MappedCompilerMetadata)
if __dynamic_checkbounds(ctx)
I = @inbounds linear_expand(__iterspace(ctx), AMDGPU.Device.blockIdx().x, AMDGPU.Device.threadIdx().x)
Expand Down
Loading