Skip to content

Commit

Permalink
DCMIP Advection, TestAMD
Browse files Browse the repository at this point in the history
  • Loading branch information
OsKnoth committed Dec 11, 2023
1 parent ab1660a commit 5b732a2
Show file tree
Hide file tree
Showing 62 changed files with 597 additions and 869 deletions.
57 changes: 57 additions & 0 deletions Examples/testAMD.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using MPI
using Base
using CUDA
using AMDGPU
using KernelAbstractions
using KernelAbstractions
using KernelAbstractions: @atomic, @atomicswap, @atomicreplace
using KernelAbstractions.Extras



@kernel function FluxUpdateKernel!(Flux,@Const(u),@Const(v),@Const(w),@Const(c))

i,j,k = @index(Global, NTuple)

M = @uniform @ndrange()[1]
N = @uniform @ndrange()[2]
L = @uniform @ndrange()[3]

if 1 < i && i < M && j > 1 && j < N && k > 1 && k < L
@inbounds FluxW = FT(0.5) * (u[i-1,j,k] - abs(u[i-1,j,k])) * c[i,j,k]
@inbounds FluxE = FT(0.5) * (u[i,j,k] + abs(u[i,j,k])) * c[i,j,k]
@inbounds FluxS = FT(0.5) * (v[i,j-1,k] - abs(v[i,j-1,k])) * c[i,j,k]
@inbounds FluxN = FT(0.5) * (v[i,j,k] + abs(v[i,j,k])) * c[i,j,k]
@inbounds FluxB = FT(0.5) * (w[i,j,k-1] - abs(w[i,j,k-1])) * c[i,j,k]
@inbounds FluxT = FT(0.5) * (w[i,j,k] + abs(w[i,j,k])) * c[i,j,k]
@inbounds @atomic Flux[i-1,j,k] += -FluxW
@inbounds @atomic Flux[i+1,j,k] += FluxE
@inbounds @atomic Flux[i,j-1,k] += -FluxS
@inbounds @atomic Flux[i,j+1,k] += FluxN
@inbounds @atomic Flux[i,j,k-1] += -FluxB
@inbounds @atomic Flux[i,j,k+1] += FluxT
@inbounds @atomic Flux[i,j,k] += (FluxW - FluxE + FluxS - FluxN + FluxB - FluxT)
end
end

backend = CPU()
FT = Float32
M = 100
N = 101
L = 102

group = (9, 9 ,9)
ndrange = (M, N , L)

u = KernelAbstractions.ones(backend,FT,M+1,N,L)
v = KernelAbstractions.ones(backend,FT,M,N+1,L)
w = KernelAbstractions.ones(backend,FT,M,N,L+1)
c = KernelAbstractions.ones(backend,FT,M,N,L)
Flux = KernelAbstractions.zeros(backend,FT,M,N,L)

KFluxUpdateKernel! = FluxUpdateKernel!(backend,group)

KFluxUpdateKernel!(Flux,u,v,w,c,ndrange=ndrange)
@time for iter = 1 : 100
KFluxUpdateKernel!(Flux,u,v,w,c,ndrange=ndrange)
end
4 changes: 2 additions & 2 deletions Examples/testAdvectionSphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ OrdPolyZ = 1
(CG,Metric,Exchange,Global) = DyCore.InitSphere(backend,FTB,OrdPoly,OrdPolyZ,nz,nPanel,H,GridType,
Topography,Decomp,Model,Phys,RadEarth)

if Problem == "DCMIPAdvection"
Profile = Examples.DCMIPAdvectionExample()(Param,Phys)
if Problem == "AdvectionDCMIP"
Profile = Examples.AdvectionSphereDCMIP()(Param,Phys)
elseif Problem == "AdvectionSphereSlottedCylinder"
Profile = Examples.DivergentSphereExample()(Param,Phys)
end
Expand Down
Loading

0 comments on commit 5b732a2

Please sign in to comment.