Skip to content

Commit

Permalink
update more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aelligp committed May 23, 2024
1 parent 84e1b69 commit a57e4fc
Show file tree
Hide file tree
Showing 15 changed files with 487 additions and 87 deletions.
37 changes: 33 additions & 4 deletions test/test_VanKeken.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
push!(LOAD_PATH, "..")
using Test, Suppressor

using ParallelStencil
@init_parallel_stencil(Threads, Float64, 2)
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil
@init_parallel_stencil(AMDGPU, Float64, 2)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil
@init_parallel_stencil(CUDA, Float64, 2)
else
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 2)
end

using Printf, LinearAlgebra, GeoParams, CellArrays
using JustRelax, JustRelax.JustRelax2D
import JustRelax.@cell
const backend_JR = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend

const backend_JR = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end

using JustPIC, JustPIC._2D
# Threads is the default backend,
# to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA") at the beginning of the script,
# and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") at the beginning of the script.
const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend
const backend = @static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU"
JustPIC.AMDGPUBackend
elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA"
JustPIC.CUDABackend
else
JustPIC.CPUBackend
end

# x-length of the domain
const λ = 0.9142
Expand Down
33 changes: 28 additions & 5 deletions test/test_diffusion3D.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
push!(LOAD_PATH, "..")

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor
using GeoParams
using JustRelax, JustRelax.JustRelax3D
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 3)

const backend = CPUBackend
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil
@init_parallel_stencil(AMDGPU, Float64, 3)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil
@init_parallel_stencil(CUDA, Float64, 3)
else
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 3)
end

const backend = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end

# HELPER FUNCTIONS ---------------------------------------------------------------
@parallel_indices (i, j, k) function init_T!(T, z)
Expand Down Expand Up @@ -110,8 +133,8 @@ function diffusion_3D(;
args,
dt,
di;
kwargs = (;
igg,
kwargs = (;
igg,
verbose=false
),
)
Expand Down
8 changes: 8 additions & 0 deletions test/test_grid2D.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor, JustRelax, JustRelax.JustRelax2D

@testset "Grid2D" begin
Expand Down
8 changes: 8 additions & 0 deletions test/test_grid3D.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor, JustRelax, JustRelax.JustRelax3D

@testset "Grid3D" begin
Expand Down
29 changes: 26 additions & 3 deletions test/test_shearband2D.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
push!(LOAD_PATH, "..")

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor
using GeoParams
using JustRelax, JustRelax.JustRelax2D
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 2)

const backend = CPUBackend
const backend = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil
@init_parallel_stencil(AMDGPU, Float64, 2)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil
@init_parallel_stencil(CUDA, Float64, 2)
else
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 2)
end

# HELPER FUNCTIONS ----------------------------------- ----------------------------
solution(ε, t, G, η) = 2 * ε * η * (1 - exp(-G * t / η))
Expand Down
29 changes: 26 additions & 3 deletions test/test_shearband2D_softening.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
push!(LOAD_PATH, "..")

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor
using GeoParams, CellArrays
using JustRelax, JustRelax.JustRelax2D
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 2)

const backend = CPUBackend
const backend = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil
@init_parallel_stencil(AMDGPU, Float64, 2)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil
@init_parallel_stencil(CUDA, Float64, 2)
else
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 2)
end


# HELPER FUNCTIONS ----------------------------------- ----------------------------
Expand Down
38 changes: 33 additions & 5 deletions test/test_shearheating2D.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor

# Benchmark of Duretz et al. 2014
# http://dx.doi.org/10.1002/2014GL060438
using JustRelax, JustRelax.JustRelax2D
const backend_JR = CPUBackend

using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(Threads, Float64, 2) #or (CUDA, Float64, 2) or (AMDGPU, Float64, 2)
const backend_JR = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(AMDGPU, Float64, 2)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(CUDA, Float64, 2)
else
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(Threads, Float64, 2)
end

using JustPIC, JustPIC._2D
# Threads is the default backend,
# to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA") at the beginning of the script,
# and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") at the beginning of the script.
const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend
# const backend = CUDABackend # Options: CPUBackend, CUDABackend, AMDGPUBackend
const backend = @static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU"
JustPIC.AMDGPUBackend
elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA"
JustPIC.CUDABackend
else
JustPIC.CPUBackend
end

# Load script dependencies
using GeoParams
Expand Down
45 changes: 38 additions & 7 deletions test/test_shearheating3D.jl
Original file line number Diff line number Diff line change
@@ -1,21 +1,52 @@
push!(LOAD_PATH, "..")
using Test, Suppressor

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

# Benchmark of Duretz et al. 2014
# http://dx.doi.org/10.1002/2014GL060438
using JustRelax, JustRelax.JustRelax3D
const backend_JR = CPUBackend
import JustRelax.@cell

using ParallelStencil, ParallelStencil.FiniteDifferences3D
@init_parallel_stencil(Threads, Float64, 3) #or (CUDA, Float64, 2) or (AMDGPU, Float64, 2)
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil
@init_parallel_stencil(AMDGPU, Float64, 3)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil
@init_parallel_stencil(CUDA, Float64, 3)
else
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 3)
end


using JustPIC, JustPIC._3D
const backend_JR = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end


using JustPIC
using JustPIC._3D
# Threads is the default backend,
# to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA") at the beginning of the script,
# and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") at the beginning of the script.
const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend
# const backend = CUDABackend # Options: CPUBackend, CUDABackend, AMDGPUBackend
const backend = @static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU"
JustPIC.AMDGPUBackend
elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA"
CUDABackend
else
JustPIC.CPUBackend
end
import JustRelax.@cell

# Load script dependencies
using Printf, GeoParams
Expand Down
38 changes: 34 additions & 4 deletions test/test_sinking_block.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,44 @@
push!(LOAD_PATH, "..")

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end


using Test, Suppressor
using JustRelax, JustRelax.JustRelax2D
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(Threads, Float64, 2)

const backend_JR = CPUBackend
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(AMDGPU, Float64, 2)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(CUDA, Float64, 2)
else
using ParallelStencil, ParallelStencil.FiniteDifferences2D
@init_parallel_stencil(Threads, Float64, 2)
end

const backend_JR = @static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
JustRelax.AMDGPUBackend
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
JustRelax.CUDABackend
else
JustRelax.CPUbackend
end

using JustPIC, JustPIC._2D
const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend
const backend = @static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU"
JustPIC.AMDGPUBackend
elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA"
CUDABackend
else
JustPIC.CPUBackend
end

using GeoParams

Expand Down
25 changes: 19 additions & 6 deletions test/test_stokes_burstedde.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
push!(LOAD_PATH, "..")

@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using AMDGPU
AMDGPU.allowscalar(true)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using CUDA
CUDA.allowscalar(true)
end

using Test, Suppressor
using JustRelax
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 3)
using JustRelax, JustRelax.JustRelax3D

# setup ParallelStencil.jl environment
model = PS_Setup(:cpu, Float64, 3)
environment!(model)
@static if ENV["JULIA_JUSTRELAX_BACKEND"] === "AMDGPU"
using ParallelStencil
@init_parallel_stencil(AMDGPU, Float64, 3)
elseif ENV["JULIA_JUSTRELAX_BACKEND"] === "CUDA"
using ParallelStencil
@init_parallel_stencil(CUDA, Float64, 3)
else
using ParallelStencil
@init_parallel_stencil(Threads, Float64, 3)
end

include("../miniapps/benchmarks/stokes3D/burstedde/Burstedde.jl")

Expand Down
Loading

0 comments on commit a57e4fc

Please sign in to comment.