Skip to content

dpctl.get_devices does not return devices in the same order as sycl::device::get_devices #447

Closed

Description

@oleksandr-pavlyk
In [25]: d0 = dpctl.SyclDevice("gpu:0")

In [26]: d0.filter_string
Out[26]: 'opencl:gpu:0'

In [27]: [i for i, di in enumerate(dpctl.get_devices(dpctl.backend_type.all, dpctl.device_type.gpu)) if di == d0]
Out[27]: [1]

In [28]: d0 == dpctl.SyclDevice(d0.filter_string)
Out[28]: True


In [29]: d1 = dpctl.SyclDevice("gpu:1")

In [30]: d1.filter_string
Out[30]: 'level_zero:gpu:0'

In [31]: [i for i, di in enumerate(dpctl.get_devices(dpctl.backend_type.all, dpctl.device_type.gpu)) if di == d1]
Out[31]: [0]

In [32]: d1 == dpctl.SyclDevice(d1.filter_string)
Out[32]: True

At the same type, the C++ code does:

#include <CL/sycl.hpp>
#include <iostream>

int main(void) {
    sycl::ONEAPI::filter_selector fs0{"gpu:0"};
    sycl::device d0(fs0);
    std::cout << "Device0's driver version " << d0.get_info<sycl::info::device::driver_version>() <<std::endl;

    sycl::ONEAPI::filter_selector fs1{"gpu:1"};
    sycl::device d1(fs1);
    std::cout << "Device1's driver version " << d1.get_info<sycl::info::device::driver_version>() <<std::endl;

    std::vector<sycl::device> v = sycl::device::get_devices(sycl::info::device_type::gpu);

    for(size_t i=0; i < v.size(); ++i) {
        if (v[i] == d0) {
            std::cout << "Index for device0 is " << i <<std::endl;
        }
        if (v[i] == d1) {
            std::cout << "Index for device1 is " << i <<std::endl;
        }
    }

    return 0;
}
(idp) [08:32:27 nuc wd]$ dpcpp example.cpp && ./a.out
Device0's driver version 21.11.19310
Device1's driver version 1.0.19310
Index for device0 is 0
Index for device1 is 1

Activity

  1. added
    bug
    on May 19, 2021
  2. added 4 commits that reference this issue on May 19, 2021
    e6f0374
    699e35e
    7cee465
    00cb985
  3. added 2 commits that reference this issue on May 24, 2021
    c9a0b22
    f44f8a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions