Skip to content
Open
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
12 changes: 11 additions & 1 deletion src/xla/Client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ function get_device end
function get_addressable_device end
function platform_name end

default_device(client::AbstractClient) = first(addressable_devices(client))
"""
DEFAULT_DEVICE :: Ref{Int}

0-based index of default device to use.
By default, the value of the environment variable `REACTANT_DEFAULT_DEVICE` is used when set to a non-negative integer, otherwise it is set to 0 (first available device).
"""
const DEFAULT_DEVICE = Ref{Int}(0)

function default_device(client::AbstractClient)
return addressable_devices(client)[DEFAULT_DEVICE[] + 1]
end
7 changes: 7 additions & 0 deletions src/xla/XLA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ function __init__()
1
end

if haskey(ENV, "REACTANT_DEFAULT_DEVICE")
DEFAULT_DEVICE[] = max(
0, something(tryparse(Int, ENV["REACTANT_DEFAULT_DEVICE"]), 0)
)
@debug "REACTANT_DEFAULT_DEVICE: " DEFAULT_DEVICE[] maxlog = 1
end

@debug "REACTANT_XLA_RUNTIME: " REACTANT_XLA_RUNTIME maxlog = 1

@ccall MLIR.API.mlir_c.RegisterEnzymeXLACPUHandler()::Cvoid
Expand Down
Loading