Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/xla/Client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ 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 0 (first available device).
"""
const DEFAULT_DEVICE = Ref{Int}(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're not doing an env var we can leave this as 1-indexed. [reason for env var is cuz cuda_visible_devices and friends are 0-indexed]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if you want we can still do DEFAULT_DEVICE = Ref{Int}(something(tryparse, ...)


function default_device(client::AbstractClient)
return addressable_devices(client)[DEFAULT_DEVICE[] + 1]
end
Loading