Skip to content

Commit

Permalink
Merge pull request #472 from carstenbauer/cb/peer
Browse files Browse the repository at this point in the history
Expose `hipDeviceCanAccessPeer`
  • Loading branch information
jpsamaroo authored Aug 17, 2023
2 parents 8ee7a46 + 399ee18 commit 6d15048
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hip/device.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,9 @@ function device!(f::Base.Callable, device::HIPDevice)
device!(old_device_id_ref[] + 1)
end
end

function can_access_peer(dev::HIPDevice, peer::HIPDevice)
result = Ref{Cint}(0)
hipDeviceCanAccessPeer(result, device_id(dev), device_id(peer)) |> check
return result[] == 1
end
5 changes: 5 additions & 0 deletions src/hip/libhip.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,8 @@ function hipModuleOccupancyMaxPotentialBlockSize(
(Ptr{Cint}, Ptr{Cint}, hipFunction_t, Csize_t, Cint),
gridSize, blockSize, f, dynSharedMemPerBlk, blockSizeLimit)
end

function hipDeviceCanAccessPeer(can_access_peer_ref, deviceid, peer_deviceid)
ccall((:hipDeviceCanAccessPeer, libhip), hipError_t, (Ptr{Cint}, Cint, Cint),
can_access_peer_ref, deviceid, peer_deviceid)
end
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ if "hip" in TARGET_TESTS
@test t isa AbstractFloat
@test t >= 0
end)
if length(AMDGPU.devices()) > 1
push!(tests, "HIP Peer Access" => () -> begin
dev1, dev2, _ = AMDGPU.devices()
@test AMDGPU.HIP.can_access_peer(dev1, dev2) isa Bool
end)
end
end

"ext" in TARGET_TESTS && push!(tests,
Expand Down

0 comments on commit 6d15048

Please sign in to comment.