forked from eth-cscs/ImplicitGlobalGrid.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eth-cscs#84 from eth-cscs/gpu-exts
Use extensions for GPU dependencies
- Loading branch information
Showing
29 changed files
with
816 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ImplicitGlobalGrid_AMDGPUExt | ||
include(joinpath(@__DIR__, "..", "src", "AMDGPUExt", "shared.jl")) | ||
include(joinpath(@__DIR__, "..", "src", "AMDGPUExt", "select_device.jl")) | ||
include(joinpath(@__DIR__, "..", "src", "AMDGPUExt", "update_halo.jl")) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module ImplicitGlobalGrid_CUDAExt | ||
include(joinpath(@__DIR__, "..", "src", "CUDAExt", "shared.jl")) | ||
include(joinpath(@__DIR__, "..", "src", "CUDAExt", "select_device.jl")) | ||
include(joinpath(@__DIR__, "..", "src", "CUDAExt", "update_halo.jl")) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# shared.jl | ||
|
||
is_rocarray(A::GGArray) = false | ||
|
||
|
||
# select_device.jl | ||
|
||
function nb_rocdevices end | ||
function rocdevice! end | ||
|
||
|
||
# update_halo.jl | ||
|
||
function free_update_halo_rocbuffers end | ||
function init_rocbufs_arrays end | ||
function init_rocbufs end | ||
function reinterpret_rocbufs end | ||
function reallocate_undersized_rocbufs end | ||
function reregister_rocbufs end | ||
function get_rocsendbufs_raw end | ||
function get_rocrecvbufs_raw end | ||
function allocate_rocstreams end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ImplicitGlobalGrid.nb_rocdevices() = length(AMDGPU.devices()) | ||
ImplicitGlobalGrid.rocdevice!(device_id) = AMDGPU.device_id!(device_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ImplicitGlobalGrid | ||
import ImplicitGlobalGrid: GGArray, GGField, GGNumber, halosize, ol, amdgpuaware_MPI, sendranges, recvranges, sendbuf_flat, recvbuf_flat, write_d2x!, read_x2d!, write_d2h_async!, read_h2d_async!, register, is_rocarray | ||
import ImplicitGlobalGrid: NNEIGHBORS_PER_DIM, GG_ALLOC_GRANULARITY | ||
using AMDGPU | ||
|
||
|
||
##------ | ||
## TYPES | ||
|
||
const ROCField{T,N} = GGField{T,N,ROCArray{T,N}} | ||
|
||
|
||
##------------------------------------ | ||
## HANDLING OF CUDA AND AMDGPU SUPPORT | ||
|
||
ImplicitGlobalGrid.is_loaded(::Val{:ImplicitGlobalGrid_AMDGPUExt}) = true | ||
ImplicitGlobalGrid.is_functional(::Val{:AMDGPU}) = AMDGPU.functional() | ||
|
||
|
||
##------------- | ||
## SYNTAX SUGAR | ||
|
||
ImplicitGlobalGrid.is_rocarray(A::ROCArray) = true #NOTE: this function is only to be used when multiple dispatch on the type of the array seems an overkill (in particular when only something needs to be done for the GPU case, but nothing for the CPU case) and as long as performance does not suffer. | ||
|
||
|
||
##-------------------------------------------------------------------------------- | ||
## FUNCTIONS FOR WRAPPING ARRAYS AND FIELDS AND DEFINE ARRAY PROPERTY BASE METHODS | ||
|
||
ImplicitGlobalGrid.wrap_field(A::ROCArray, hw::Tuple) = ROCField{eltype(A), ndims(A)}((A, hw)) | ||
|
||
Base.size(A::ROCField) = Base.size(A.A) | ||
Base.size(A::ROCField, args...) = Base.size(A.A, args...) | ||
Base.length(A::ROCField) = Base.length(A.A) | ||
Base.ndims(A::ROCField) = Base.ndims(A.A) | ||
Base.eltype(A::ROCField) = Base.eltype(A.A) | ||
|
||
##--------------- | ||
## AMDGPU functions | ||
|
||
function ImplicitGlobalGrid.register(::Type{<:ROCArray},buf::Array{T}) where T <: GGNumber | ||
return unsafe_wrap(ROCArray, pointer(buf), size(buf)) | ||
end |
Oops, something went wrong.