Skip to content

Commit

Permalink
Merge pull request #28 from omlins/lr-miniapps
Browse files Browse the repository at this point in the history
GPU method override for `CUDA.pow()`
  • Loading branch information
luraess authored Jun 18, 2021
2 parents 1381f6b + 8ab11d5 commit 8469645
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name = "ParallelStencil"
uuid = "94395366-693c-11ea-3b26-d9b7aac5d958"
authors = ["Samuel Omlin", "Ludovic Räss"]
version = "0.5.3"
version = "0.5.4"

[compat]
julia = "1"
CUDA = "1, 2, 3"
CUDA = "3"
MacroTools = "0.5"

[deps]
Expand Down
9 changes: 2 additions & 7 deletions miniapps/HydroMech2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ using ParallelStencil
using ParallelStencil.FiniteDifferences2D
@static if USE_GPU
@init_parallel_stencil(CUDA, Float64, 2)
macro pow(args...) esc(:(CUDA.pow($(args...)))) end
macro tanh(args...) esc(:(CUDA.tanh($(args...)))) end
else
@init_parallel_stencil(Threads, Float64, 2)
pow(x,y) = x^y
macro pow(args...) esc(:(pow($(args...)))) end
macro tanh(args...) esc(:(Base.tanh($(args...)))) end
end
using Plots, Printf, Statistics, LinearAlgebra

Expand All @@ -20,8 +15,8 @@ using Plots, Printf, Statistics, LinearAlgebra
end

@parallel function compute_params_∇!(EtaC::Data.Array, K_muf::Data.Array, Rog::Data.Array, ∇V::Data.Array, ∇qD::Data.Array, Phi::Data.Array, Pf::Data.Array, Pt::Data.Array, Vx::Data.Array, Vy::Data.Array, qDx::Data.Array, qDy::Data.Array, μs::Data.Number, η2μs::Data.Number, R::Data.Number, λPe::Data.Number, k_μf0::Data.Number, ϕ0::Data.Number, nperm::Data.Number, θ_e::Data.Number, θ_k::Data.Number, ρfg::Data.Number, ρsg::Data.Number, ρgBG::Data.Number, dx::Data.Number, dy::Data.Number)
@all(EtaC) = (1.0-θ_e)*@all(EtaC) + θ_e*( μs/@all(Phi)*η2μs*(1.0+0.5*(1.0/R-1.0)*(1.0+@tanh((@all(Pf)-@all(Pt))/λPe))) )
@all(K_muf) = (1.0-θ_k)*@all(K_muf) + θ_k*( k_μf0*@pow((@all(Phi)/ϕ0), nperm) )
@all(EtaC) = (1.0-θ_e)*@all(EtaC) + θ_e*( μs/@all(Phi)*η2μs*(1.0+0.5*(1.0/R-1.0)*(1.0+tanh((@all(Pf)-@all(Pt))/λPe))) )
@all(K_muf) = (1.0-θ_k)*@all(K_muf) + θ_k*( k_μf0 * (@all(Phi)/ϕ0)^nperm )
@all(Rog) = ρfg*@all(Phi) + ρsg*(1.0-@all(Phi)) - ρgBG
@all(∇V) = @d_xa(Vx)/dx + @d_ya(Vy)/dy
@all(∇qD) = @d_xa(qDx)/dx + @d_ya(qDy)/dy
Expand Down
5 changes: 1 addition & 4 deletions miniapps/scalar_porowaves2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ using ParallelStencil
using ParallelStencil.FiniteDifferences2D
@static if USE_GPU
@init_parallel_stencil(CUDA, Float64, 2)
macro pow(args...) esc(:(CUDA.pow($(args...)))) end
else
@init_parallel_stencil(Threads, Float64, 2)
pow(x,y) = x^y
macro pow(args...) esc(:(pow($(args...)))) end
end
using Plots, Printf, Statistics

@parallel function compute_nonlin!(K_mu::Data.Array, EtaR::Data.Array, Phi::Data.Array, Eta::Data.Array, k_μ0::Data.Number, n::Data.Number)
@all(K_mu) = k_μ0*@pow(@all(Phi), n)
@all(K_mu) = k_μ0 * @all(Phi)^n
@all(EtaR) = @all(Eta)
return
end
Expand Down

2 comments on commit 8469645

@luraess
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@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/39123

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.5.4 -m "<description of version>" 846964586227e5f08c98c3f4880ab00fcb296b50
git push origin v0.5.4

Please sign in to comment.