Skip to content

Commit b840fb3

Browse files
committed
Use the REACTANT_DEFAULT_DEVICE environment variable
1 parent 26a1438 commit b840fb3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/xla/Client.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function platform_name end
1616
"""
1717
DEFAULT_DEVICE :: Ref{Int}
1818
19-
0-based index of default device to use, by default 0 (first available device).
19+
0-based index of default device to use.
20+
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).
2021
"""
2122
const DEFAULT_DEVICE = Ref{Int}(0)
2223

src/xla/XLA.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ function __init__()
158158
1
159159
end
160160

161+
if haskey(ENV, "REACTANT_DEFAULT_DEVICE")
162+
DEFAULT_DEVICE[] = max(0, something(tryparse(Int, ENV["REACTANT_DEFAULT_DEVICE"]), 0))
163+
@debug "REACTANT_DEFAULT_DEVICE: " DEFAULT_DEVICE[] maxlog = 1
164+
end
165+
161166
@debug "REACTANT_XLA_RUNTIME: " REACTANT_XLA_RUNTIME maxlog = 1
162167

163168
@ccall MLIR.API.mlir_c.RegisterEnzymeXLACPUHandler()::Cvoid

0 commit comments

Comments
 (0)