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

RFC: Support Adapt.AbstractGPUDevice #185

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion lib/level-zero/device.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export ZeDevice, properties, compute_properties, module_properties, memory_properties, memory_access_properties, cache_properties, image_properties, p2p_properties

struct ZeDevice
struct ZeDevice <: Adapt.AbstractGPUDevice
handle::ze_device_handle_t

driver::ZeDriver
Expand Down
3 changes: 3 additions & 0 deletions lib/level-zero/oneL0.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ using Printf
using NEO_jll
using oneAPI_Level_Zero_Loader_jll

import Adapt


include("utils.jl")
include("pointer.jl")

Expand Down
2 changes: 2 additions & 0 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ function device(A::oneArray)
return oneL0.device(A.storage.buffer)
end

Adapt.get_compute_unit_impl(@nospecialize(TypeHistory::Type), A::oneArray) = device(A)


## derived types

Expand Down
15 changes: 15 additions & 0 deletions src/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,18 @@ end
function oneL0.synchronize()
oneL0.synchronize(global_queue(context(), device()))
end


function Adapt.adapt_storage(dev::ZeDevice, x)
prev_dev = device()
try
device!(dev)
Adapt.adapt_storage(oneArray, x)
finally
device!(prev_dev)
end
end


# ToDo: implement Sys.total_memory(dev::ZeDevice)
# ToDo: implement Sys.free_memory(dev::ZeDevice)