Skip to content

Commit

Permalink
Merge pull request #99 from JuliaGeodynamics/adm/unexport
Browse files Browse the repository at this point in the history
Unexport backends
  • Loading branch information
albert-de-montserrat authored May 3, 2024
2 parents f13f52f + 26e9de9 commit 2c2c66c
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JustPIC"
uuid = "10dc771f-8528-4cd9-9d3b-b21b2e693339"
authors = ["Albert De Montserrat <albertdemontserratnavarro@erdw.ethz.ch>, Ivan Utkin <iutkin@ethz.ch>"]
version = "0.3.2"
version = "0.3.3"

[deps]
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
2 changes: 1 addition & 1 deletion docs/src/field_advection2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/src/field_advection3D.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion ext/JustPICAMDGPUExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions ext/JustPICCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module _2D
import JustPIC: Euler, RungeKutta2, AbstractAdvectionIntegrator
import JustPIC._2D.CA
import JustPIC: Particles, PassiveMarkers
import JustPIC: AbstractBackend

export CA

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/rotating_circle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/rotating_marker_chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion scripts/rotating_passive_markers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion scripts/single_particle_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/single_particle_advection_MPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/temperature_advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/temperature_advection3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/temperature_advection_AMDGPU.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/temperature_advection_MPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/JustPIC.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module JustPIC

export CPUBackend, CUDABackend, AMDGPUBackend

abstract type AbstractBackend end
struct CPUBackend <: AbstractBackend end
struct AMDGPUBackend <: AbstractBackend end
Expand Down
4 changes: 4 additions & 0 deletions src/JustPIC_CPU.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ using CellArrays
using Atomix
using ..JustPIC

import ..JustPIC: AbstractBackend, CPUBackend, CUDABackend, AMDGPUBackend

@init_parallel_stencil(Threads, Float64, 2)

export CA
Expand All @@ -33,6 +35,8 @@ using CellArrays
using Atomix
using ..JustPIC

import ..JustPIC: AbstractBackend, CPUBackend, CUDABackend, AMDGPUBackend

@init_parallel_stencil(Threads, Float64, 3)

export CA
Expand Down
4 changes: 2 additions & 2 deletions test/test_2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/test_3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

2 comments on commit 2c2c66c

@albert-de-montserrat
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/106156

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.3 -m "<description of version>" 2c2c66c90eb2ab2d15a361410c2c9d931db08423
git push origin v0.3.3

Please sign in to comment.