Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_devices method to dpctl.SyclPlatform class #1992

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ndgrigorian
Copy link
Collaborator

This PR proposes implementing the get_devices method to dpctl.SyclPlatform class as per SYCL 2020 spec, which specifies including a device_type filter.

Closes #509

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

@ndgrigorian
Copy link
Collaborator Author

ndgrigorian commented Feb 11, 2025

@oleksandr-pavlyk
For some context, this PR is setting the stage to support composite devices

It occurred to me that get_devices itself is not supported by dpctl.SyclPlatform, leading to me noticing this long-standing issue.

Copy link

Copy link

Array API standard conformance tests for dpctl= ran successfully.
Passed: 895
Failed: 1
Skipped: 118

@ndgrigorian ndgrigorian force-pushed the get-devices-from-sycl-platform branch from d0d61c3 to 0629e08 Compare February 11, 2025 06:39
Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310h93fe807_521 ran successfully.
Passed: 894
Failed: 2
Skipped: 118

1 similar comment
Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310h93fe807_521 ran successfully.
Passed: 894
Failed: 2
Skipped: 118

@ndgrigorian ndgrigorian marked this pull request as ready for review February 11, 2025 07:58
Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310h93fe807_523 ran successfully.
Passed: 894
Failed: 2
Skipped: 118

@ndgrigorian
Copy link
Collaborator Author

ndgrigorian commented Feb 11, 2025

@oleksandr-pavlyk
I've made the requested change, and made a change to instead give unknown when the function is provided automatic or custom as device types.

Using these device types would yield the same result as all from pure SYCL code, i.e.,

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

int main()
{
   sycl::platform p{};

   auto DTy = sycl::info::device_type::custom;
   size_t n_devs_all = p.get_devices(sycl::info::device_type::all).size();
   size_t n_devs_custom = p.get_devices(sycl::info::device_type::custom).size();

   std::cout << (n_devs_all == n_devs_custom) << std::endl;

   return 0;
}

will always show 1. Same if device_type::automatic is used. It seems that in the compiler, it defaults to all unless cpu, gpu, or accelerator are provided.

To spare user confusion, I think it makes more sense to return empty lists for custom and automatic.

@coveralls
Copy link
Collaborator

coveralls commented Feb 19, 2025

Coverage Status

coverage: 88.177% (-0.06%) from 88.233%
when pulling 1c8ee57 on get-devices-from-sycl-platform
into 7e2b69e on master.

Also removes some remaining, sporadic references to the deprecated sycl::info::device_type::host
These device types act unexpectedly in DPC++ 2025.0.4, returning the same result as `sycl::info::device_type::all`, so use unknown device and return an empty list instead
@ndgrigorian ndgrigorian force-pushed the get-devices-from-sycl-platform branch from f60d32a to 1c8ee57 Compare February 21, 2025 20:55
Copy link

Array API standard conformance tests for dpctl=0.19.0dev0=py310h93fe807_541 ran successfully.
Passed: 895
Failed: 1
Skipped: 118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dpctl.SyclPlatform should provide get_devices method
3 participants