Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose hipDeviceCanAccessPeer #472

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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