Skip to content

Commit af67d52

Browse files
committed
Use global const Reactant.XLA.DEFAULT_DEVICE instead of env var
1 parent 3f9be82 commit af67d52

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/xla/Client.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ function get_device end
1313
function get_addressable_device end
1414
function platform_name end
1515

16+
"""
17+
DEFAULT_DEVICE :: Ref{Int}
18+
19+
0-based index of default device to use, by default 0 (first available device).
20+
"""
21+
const DEFAULT_DEVICE = Ref{Int}(0)
22+
1623
function default_device(client::AbstractClient)
17-
return addressable_devices(client)[something(
18-
# `REACTANT_DEFAULT_DEVICE` is interpreted as 0-based.
19-
tryparse(Int, get(ENV, "REACTANT_DEFAULT_DEVICE", "0")) + 1,
20-
1,
21-
)]
24+
return addressable_devices(client)[DEFAULT_DEVICE[] + 1]
2225
end

0 commit comments

Comments
 (0)