Skip to content

Commit 924ad64

Browse files
author
Dmitry Razdoburdin
committed
one more fix
1 parent ed14d41 commit 924ad64

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plugin/sycl/device_manager.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,25 @@ ::sycl::queue DeviceManager::GetQueue(const DeviceOrd& device_spec) const {
7070
std::lock_guard<std::mutex> guard(queue_registering_mutex);
7171
if (not_use_default_selector) {
7272
DeviceRegister& device_register = GetDevicesRegister();
73-
const int device_idx =
74-
collective::IsDistributed() ? collective::GetRank() : device_spec.ordinal;
7573
if (device_spec.IsSyclDefault()) {
7674
auto& devices = device_register.devices;
75+
const int device_idx = collective::IsDistributed()
76+
? collective::GetRank() % devices.size()
77+
: device_spec.ordinal;
7778
CHECK_LT(device_idx, devices.size());
7879
queue_register[device_spec.Name()] = ::sycl::queue(devices[device_idx]);
7980
} else if (device_spec.IsSyclCPU()) {
8081
auto& cpu_devices = device_register.cpu_devices;
82+
const int device_idx = collective::IsDistributed()
83+
? collective::GetRank() % cpu_devices.size()
84+
: device_spec.ordinal;
8185
CHECK_LT(device_idx, cpu_devices.size());
8286
queue_register[device_spec.Name()] = ::sycl::queue(cpu_devices[device_idx]);
8387
} else if (device_spec.IsSyclGPU()) {
8488
auto& gpu_devices = device_register.gpu_devices;
89+
const int device_idx = collective::IsDistributed()
90+
? collective::GetRank() % gpu_devices.size()
91+
: device_spec.ordinal;
8592
CHECK_LT(device_idx, gpu_devices.size());
8693
queue_register[device_spec.Name()] = ::sycl::queue(gpu_devices[device_idx]);
8794
}

0 commit comments

Comments
 (0)