Skip to content

Header for dpctl sycl interface type casters #960

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

Merged
merged 10 commits into from
Nov 5, 2022

Conversation

oleksandr-pavlyk
Copy link
Contributor

This PR adds "libsyclinterface/include/dpctl_sycl_type_casters.hpp" which defines
dpctl::syclinterface::dpctl_device_selector class corresponding to DPCTLDeviceSelectorRef opaque pointer.

The class is derived from sycl::device_selector to support oneAPI DPC++ 2022.2 and older, but is a stand-alone
class if __SYCL_COMPILER_VERSION >= 20221020L.

Use of dpctl_device_selector in sycl::device and sycl::platform constructors is adjusted based on the compiler version too.

This PR also exposes dpctl::syclinterface::wrap<T> and dpctl::syclinterface::unwrap<T> templated functions where the template type must be the underlying sycl type to the pointer of which the opaque pointer should be reinterpret_cast-ed.

For example:

   DPCTLSyclDeviceRef DRef;
   auto Dev = ::dpctl::syclinterface::unwrap<sycl::device>(DRef);

libsyclinterface/source and libsyclinterface/tests are adjusted to use exported wrap/unwrap.

  • 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?
  • If this PR is a work in progress, are you filing the PR as a draft?

wrap/unwrap functions for conversions between opaque DPCTL types
and underlying SYCL object pointers is provided in this new header.

Use of the header is deployed to files in libsyclinterface/source/
and libsyclinterface/tests/ folders.

Removed libsyclinterface/include/Support/CBindingWrapping.h
…emplated

Moved dpctl_*_selector definitions into dpctl::syclinterface namespace.

wrap/unwrap functions are made templated, with template parameter being C++
type to pointer of which the opaque pointer is cast.

dpctl_device_selector for SYCL 2020 implements virtual call operator to enable
type inference of this type as std::function<int(const device&)>. The derived
classes override the call operator as appropriate.

Calls to constructors of sycl::device and sycl::platform which take device selector
callable are implemented differently depending on the compiler version.
@github-actions
Copy link

github-actions bot commented Nov 3, 2022

@github-actions
Copy link

github-actions bot commented Nov 3, 2022

Array API standard conformance tests for dpctl=0.14.0dev0=py310h8c27c75_236 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@github-actions
Copy link

github-actions bot commented Nov 3, 2022

Array API standard conformance tests for dpctl=0.14.0dev0=py310h8c27c75_238 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk oleksandr-pavlyk force-pushed the header-for-DPCTLSyclInterface-type-casters branch 3 times, most recently from 66a7148 to 31cc9db Compare November 3, 2022 21:22
@coveralls
Copy link
Collaborator

coveralls commented Nov 4, 2022

Coverage Status

Coverage decreased (-0.04%) to 81.996% when pulling e28769a on header-for-DPCTLSyclInterface-type-casters into eb8ddb2 on master.

@github-actions
Copy link

github-actions bot commented Nov 4, 2022

Array API standard conformance tests for dpctl=0.14.0dev1=py310h8c27c75_10 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@oleksandr-pavlyk
Copy link
Contributor Author

Should this PR also remove setting of SYCL_ENABLE_HOST_DEVICE=1 in workflows?

…o new file

Added config parameters for __SYCL_COMPILER_VERSION cutoffs used throughout.
Moved declarations of dpctl_device_selector and other derived classes to a
dedicated .hpp file.
Added ifdefs around changes needed to work with both newer
OS compiler and current oneAPI DPC++
@oleksandr-pavlyk oleksandr-pavlyk force-pushed the header-for-DPCTLSyclInterface-type-casters branch from cf8d625 to 6052ba0 Compare November 4, 2022 13:12
@github-actions
Copy link

github-actions bot commented Nov 4, 2022

Array API standard conformance tests for dpctl=0.14.0dev1=py310h8c27c75_8 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@github-actions
Copy link

github-actions bot commented Nov 4, 2022

Array API standard conformance tests for dpctl=0.14.0dev1=py310h8c27c75_10 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

diptorupd
diptorupd previously approved these changes Nov 4, 2022
Copy link
Contributor

@diptorupd diptorupd left a comment

Choose a reason for hiding this comment

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

I did not go very deep as the changes are fairly mechanical and we have already discussed them offline.

Please merge.

@oleksandr-pavlyk oleksandr-pavlyk merged commit 2c86ef6 into master Nov 5, 2022
@oleksandr-pavlyk oleksandr-pavlyk deleted the header-for-DPCTLSyclInterface-type-casters branch November 5, 2022 13:38
@github-actions
Copy link

github-actions bot commented Nov 5, 2022

Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞

@github-actions
Copy link

github-actions bot commented Nov 5, 2022

Array API standard conformance tests for dpctl=0.14.0dev1=py310h8c27c75_19 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

@github-actions
Copy link

github-actions bot commented Nov 5, 2022

Array API standard conformance tests for dpctl=0.14.0dev1=py310h8c27c75_19 ran successfully.
Passed: 33
Failed: 801
Skipped: 3138

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.

3 participants