From e01270789c395887779258bb3ccbf97f722cbfae Mon Sep 17 00:00:00 2001 From: Albert de Montserrat Date: Fri, 3 May 2024 22:50:59 +0200 Subject: [PATCH 1/5] unexport backends --- ext/JustPICAMDGPUExt.jl | 2 ++ ext/JustPICCUDAExt.jl | 2 ++ src/JustPIC.jl | 2 -- src/JustPIC_CPU.jl | 4 ++++ test/test_2D.jl | 4 ++-- test/test_3D.jl | 4 ++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ext/JustPICAMDGPUExt.jl b/ext/JustPICAMDGPUExt.jl index 93f3862e..c1ae2133 100644 --- a/ext/JustPICAMDGPUExt.jl +++ b/ext/JustPICAMDGPUExt.jl @@ -19,6 +19,7 @@ module _2D import JustPIC: Euler, RungeKutta2, AbstractAdvectionIntegrator import JustPIC._2D.CA import JustPIC: Particles, PassiveMarkers + import JustPIC: AbstractBackend, AMDGPUBackend macro myatomic(expr) return esc( @@ -206,6 +207,7 @@ module _3D @init_parallel_stencil(AMDGPU, Float64, 3) import JustPIC: Euler, RungeKutta2, AbstractAdvectionIntegrator, Particles, PassiveMarkers + import JustPIC: AbstractBackend, AMDGPUBackend macro myatomic(expr) return esc( diff --git a/ext/JustPICCUDAExt.jl b/ext/JustPICCUDAExt.jl index b049b0cc..e94695d5 100644 --- a/ext/JustPICCUDAExt.jl +++ b/ext/JustPICCUDAExt.jl @@ -19,6 +19,7 @@ module _2D import JustPIC: Euler, RungeKutta2, AbstractAdvectionIntegrator import JustPIC._2D.CA import JustPIC: Particles, PassiveMarkers + import JustPIC: AbstractBackend export CA @@ -211,6 +212,7 @@ module _3D end import JustPIC: Euler, RungeKutta2, AbstractAdvectionIntegrator, Particles, PassiveMarkers + import JustPIC: AbstractBackend function JustPIC._3D.CA(::Type{CUDABackend}, dims; eltype=Float64) return CuCellArray{eltype}(undef, dims) diff --git a/src/JustPIC.jl b/src/JustPIC.jl index a62e5f62..03aa6c7a 100644 --- a/src/JustPIC.jl +++ b/src/JustPIC.jl @@ -1,7 +1,5 @@ module JustPIC -export CPUBackend, CUDABackend, AMDGPUBackend - abstract type AbstractBackend end struct CPUBackend <: AbstractBackend end struct AMDGPUBackend <: AbstractBackend end diff --git a/src/JustPIC_CPU.jl b/src/JustPIC_CPU.jl index cd4e78e1..e56b40e4 100644 --- a/src/JustPIC_CPU.jl +++ b/src/JustPIC_CPU.jl @@ -7,6 +7,8 @@ using CellArrays using Atomix using ..JustPIC +import ..JustPIC: AbstractBackend, CPUBackend, CUDABackend, AMDGPUBackend + @init_parallel_stencil(Threads, Float64, 2) export CA @@ -33,6 +35,8 @@ using CellArrays using Atomix using ..JustPIC +import ..JustPIC: AbstractBackend, CPUBackend, CUDABackend, AMDGPUBackend + @init_parallel_stencil(Threads, Float64, 3) export CA diff --git a/test/test_2D.jl b/test/test_2D.jl index a8ba21f2..c5131303 100644 --- a/test/test_2D.jl +++ b/test/test_2D.jl @@ -9,11 +9,11 @@ end using JustPIC, JustPIC._2D, CellArrays, Test, LinearAlgebra const backend = @static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU" - AMDGPUBackend + JustPIC.AMDGPUBackend elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA" CUDABackend else - CPUBackend + JustPIC.CPUBackend end function expand_range(x::AbstractRange) diff --git a/test/test_3D.jl b/test/test_3D.jl index 1360ca17..65eb9cb5 100644 --- a/test/test_3D.jl +++ b/test/test_3D.jl @@ -9,11 +9,11 @@ end using JustPIC, JustPIC._3D, CellArrays, ParallelStencil, Test, LinearAlgebra const backend = @static if ENV["JULIA_JUSTPIC_BACKEND"] === "AMDGPU" - AMDGPUBackend + JustPIC.AMDGPUBackend elseif ENV["JULIA_JUSTPIC_BACKEND"] === "CUDA" CUDABackend else - CPUBackend + JustPIC.CPUBackend end function expand_range(x::AbstractRange) From e9c0b9f085ed4125440d3e36c46951741d9a6ee9 Mon Sep 17 00:00:00 2001 From: Albert de Montserrat Date: Fri, 3 May 2024 23:02:40 +0200 Subject: [PATCH 2/5] update scripts --- scripts/rotating_circle.jl | 2 +- scripts/rotating_marker_chain.jl | 2 +- scripts/rotating_passive_markers.jl | 2 +- scripts/single_particle_advection.jl | 2 +- scripts/single_particle_advection_MPI.jl | 2 +- scripts/temperature_advection.jl | 2 +- scripts/temperature_advection3d.jl | 2 +- scripts/temperature_advection_AMDGPU.jl | 2 +- scripts/temperature_advection_MPI.jl | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/rotating_circle.jl b/scripts/rotating_circle.jl index 1de60a9e..94c693a6 100644 --- a/scripts/rotating_circle.jl +++ b/scripts/rotating_circle.jl @@ -3,7 +3,7 @@ using JustPIC._2D # Threads is the default backend, # to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA"), # and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") -const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend +const backend = JustPIC.CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend using GLMakie diff --git a/scripts/rotating_marker_chain.jl b/scripts/rotating_marker_chain.jl index 149b4a91..aa8b337d 100644 --- a/scripts/rotating_marker_chain.jl +++ b/scripts/rotating_marker_chain.jl @@ -4,7 +4,7 @@ using ParallelStencil @init_parallel_stencil(Threads, Float64, 2) using GLMakie -const backend = CPUBackend +const backend = JustPIC.CPUBackend function expand_range(x::AbstractRange) dx = x[2] - x[1] diff --git a/scripts/rotating_passive_markers.jl b/scripts/rotating_passive_markers.jl index f3ceebd7..f724c91a 100644 --- a/scripts/rotating_passive_markers.jl +++ b/scripts/rotating_passive_markers.jl @@ -2,7 +2,7 @@ using JustPIC using JustPIC._2D using GLMakie -const backend = CPUBackend +const backend = JustPIC.CPUBackend function expand_range(x::AbstractRange) dx = x[2] - x[1] diff --git a/scripts/single_particle_advection.jl b/scripts/single_particle_advection.jl index e8a348d2..1b7f8b02 100644 --- a/scripts/single_particle_advection.jl +++ b/scripts/single_particle_advection.jl @@ -4,7 +4,7 @@ using JustPIC._2D # Threads is the default backend, # to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA"), # and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") -const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend +const backend = JustPIC.CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend using GLMakie diff --git a/scripts/single_particle_advection_MPI.jl b/scripts/single_particle_advection_MPI.jl index 9da728d9..b4ea1533 100644 --- a/scripts/single_particle_advection_MPI.jl +++ b/scripts/single_particle_advection_MPI.jl @@ -4,7 +4,7 @@ using JustPIC._2D # Threads is the default backend, # to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA"), # and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") -const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend +const backend = JustPIC.CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend using GLMakie diff --git a/scripts/temperature_advection.jl b/scripts/temperature_advection.jl index 7e0b3874..1f8aae21 100644 --- a/scripts/temperature_advection.jl +++ b/scripts/temperature_advection.jl @@ -4,7 +4,7 @@ using JustPIC._2D # Threads is the default backend, # to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA"), # and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") -const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend +const backend = JustPIC.CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend using GLMakie diff --git a/scripts/temperature_advection3d.jl b/scripts/temperature_advection3d.jl index 331e2339..b5ddb42f 100644 --- a/scripts/temperature_advection3d.jl +++ b/scripts/temperature_advection3d.jl @@ -4,7 +4,7 @@ using JustPIC._3D # Threads is the default backend, # to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA"), # and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") -const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend +const backend = JustPIC.CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend using GLMakie diff --git a/scripts/temperature_advection_AMDGPU.jl b/scripts/temperature_advection_AMDGPU.jl index c0c8fcf5..e084dabe 100644 --- a/scripts/temperature_advection_AMDGPU.jl +++ b/scripts/temperature_advection_AMDGPU.jl @@ -2,7 +2,7 @@ using AMDGPU using JustPIC using JustPIC._2D -const backend = AMDGPUBackend +const backend = JustPIC.AMDGPUBackend using CairoMakie function init_particles(nxcell, max_xcell, min_xcell, x, y, dx, dy, nx, ny) diff --git a/scripts/temperature_advection_MPI.jl b/scripts/temperature_advection_MPI.jl index 4e843308..eb322a23 100644 --- a/scripts/temperature_advection_MPI.jl +++ b/scripts/temperature_advection_MPI.jl @@ -4,7 +4,7 @@ using JustPIC._2D # Threads is the default backend, # to run on a CUDA GPU load CUDA.jl (i.e. "using CUDA"), # and to run on an AMD GPU load AMDGPU.jl (i.e. "using AMDGPU") -const backend = CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend +const backend = JustPIC.CPUBackend # Options: CPUBackend, CUDABackend, AMDGPUBackend using GLMakie using ImplicitGlobalGrid From 4f71503a1cd0c5b16dad9d842444700f4814a587 Mon Sep 17 00:00:00 2001 From: Albert de Montserrat Date: Fri, 3 May 2024 23:04:29 +0200 Subject: [PATCH 3/5] docs --- docs/make.jl | 2 +- docs/src/field_advection2D.md | 2 +- docs/src/field_advection3D.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index b87b0454..07d19f98 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -10,8 +10,8 @@ makedocs(; warnonly = Documenter.except(:footnote), pages=[ "Home" => "index.md", + "CellArrays" =>"CellArrays.md", "Examples" => [ - "CellArrays.md", "field_advection2D.md", "field_advection3D.md", ], diff --git a/docs/src/field_advection2D.md b/docs/src/field_advection2D.md index cdfa2251..2f1571c1 100644 --- a/docs/src/field_advection2D.md +++ b/docs/src/field_advection2D.md @@ -15,7 +15,7 @@ using JustPIC._2D We need to specify what backend are we running our simulation on. For convenience we define the backend as a constant. In this case we use the CPU backend, but we could also use the CUDA (CUDABackend) or AMDGPU (AMDGPUBackend) backends. ```julia -const backend = CPUBackend +const backend = JustPIC.CPUBackend ``` we define an analytical flow solution to advected our particles diff --git a/docs/src/field_advection3D.md b/docs/src/field_advection3D.md index a8420754..ca601b86 100644 --- a/docs/src/field_advection3D.md +++ b/docs/src/field_advection3D.md @@ -15,7 +15,7 @@ using JustPIC._3D We need to specify what backend are we running our simulation on. For convenience we define the backend as a constant. In this case we use the CPU backend, but we could also use the CUDA (CUDABackend) or AMDGPU (AMDGPUBackend) backends. ```julia -const backend = CPUBackend +const backend = JustPIC.CPUBackend ``` we define an analytical flow solution to advected our particles From a38e78ac09f7dd8561bf9ffb490e01605393f39c Mon Sep 17 00:00:00 2001 From: Albert de Montserrat Date: Fri, 3 May 2024 23:13:51 +0200 Subject: [PATCH 4/5] bug --- ext/JustPICAMDGPUExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/JustPICAMDGPUExt.jl b/ext/JustPICAMDGPUExt.jl index c1ae2133..4b0fbe8c 100644 --- a/ext/JustPICAMDGPUExt.jl +++ b/ext/JustPICAMDGPUExt.jl @@ -2,7 +2,7 @@ module JustPICAMDGPUExt using JustPIC using AMDGPU -JustPIC.TA(::Type{AMDGPUBackend}) = ROCArray +JustPIC.TA(::Type{JustPIC.AMDGPUBackend}) = ROCArray module _2D using ImplicitGlobalGrid From 26e9de9502f7721c4cf76bc9fadc75b9c1f615c3 Mon Sep 17 00:00:00 2001 From: Albert de Montserrat Date: Fri, 3 May 2024 23:36:16 +0200 Subject: [PATCH 5/5] bump minor version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 32525be1..8bb417b9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "JustPIC" uuid = "10dc771f-8528-4cd9-9d3b-b21b2e693339" authors = ["Albert De Montserrat , Ivan Utkin "] -version = "0.3.2" +version = "0.3.3" [deps] Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"