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

Updated the DPCTLKernelArgType enum values to be aligned with C++11 types #1581

Merged
merged 6 commits into from
Mar 6, 2024

Conversation

diptorupd
Copy link
Contributor

@diptorupd diptorupd commented Mar 5, 2024

  • Have you provided a meaningful PR description?

Previously, the DPCTLKernelArgType had a mix of C99 types (long, long long, etc.) and C++ types (size_t, int8_t). After these changes the enum values have been updated to only include the C++11 integer types: [u]int[8|16|32|64]_t, float and double.

A Python enum corresponding to the libsyclinterface C++ enum was also added to make it simpler to get the types from Python. It will help numba-dpex not have to hard code magic values in its code base.

The DPCTLQueue_SubmitRange and DPCTLQueue_SubmitNdRange functions were updated to silence compiler warnings.

Unit tests were added for verifying the submission of one-dimensional range kernels each with a different kernel argument type.

NOTE: DPCTLQueue_SubmitNdRange will not be tested as part of this PR. I will be be adding those tests as part of the local accessor support as a kernel argument PR.

  • Have you added a test, reproducer or referred to an issue with a reproducer?

New libsyclinterfrace unit tests to test for all possible kernel argument types, including a negative test.

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

@diptorupd diptorupd force-pushed the update/dpctl_kernelargtypes branch from 481448d to 1d9c7a9 Compare March 5, 2024 06:12
@diptorupd diptorupd marked this pull request as draft March 5, 2024 06:12
Copy link

github-actions bot commented Mar 5, 2024

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

Copy link

github-actions bot commented Mar 5, 2024

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_60 ran successfully.
Passed: 906
Failed: 0
Skipped: 94

@diptorupd diptorupd force-pushed the update/dpctl_kernelargtypes branch from 6702b3b to 3041dad Compare March 5, 2024 21:02
Copy link

github-actions bot commented Mar 5, 2024

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_62 ran successfully.
Passed: 906
Failed: 0
Skipped: 94

@diptorupd diptorupd force-pushed the update/dpctl_kernelargtypes branch from 3041dad to 27be69f Compare March 5, 2024 23:31
@coveralls
Copy link
Collaborator

coveralls commented Mar 6, 2024

Coverage Status

coverage: 87.717% (+0.3%) from 87.449%
when pulling 554541f on update/dpctl_kernelargtypes
into 786f7fc on master.

Copy link

github-actions bot commented Mar 6, 2024

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_62 ran successfully.
Passed: 906
Failed: 0
Skipped: 94

@diptorupd diptorupd force-pushed the update/dpctl_kernelargtypes branch from 27be69f to 56374ee Compare March 6, 2024 01:32
@diptorupd diptorupd marked this pull request as ready for review March 6, 2024 01:32
Copy link

github-actions bot commented Mar 6, 2024

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_62 ran successfully.
Passed: 906
Failed: 0
Skipped: 94

rm -rf ${INSTALL_PREFIX}

cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=icx \
-DCMAKE_CXX_COMPILER=dpcpp \
-DCMAKE_CXX_COMPILER=icpx \
-DCMAKE_CXX_FLAGS=-fsycl \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably the right way of integrating SYCL and cmake would be to use find_package(IntelSycl), but this could be done in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes are in the helper script, let us fix in separate PR. I just needed to get the helper script working once more to develop on libsyclinterface.

Copy link
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

Thank you @diptorupd

It would also be useful to document in the comment how multiple SPVs are compiled into a single one.

Also, if one is on a machine without support for double type, IGC route of generation of the kernel for double won't work, how does one generate the kernel then?

@oleksandr-pavlyk
Copy link
Collaborator

Thank you @diptorupd

It would also be useful to document in the comment how multiple SPVs are compiled into a single one.

Also, if one is on a machine without support for double type, IGC route of generation of the kernel for double won't work, how does one generate the kernel then?

Clarifying my own misunderstanding. When C++ is compiled with default -fsycl-split-device-code value, kernel bundles are formed as per aspect required, so a kernel function would contain kernels specialized for all types but float16 and float64 and two more kernel bundles may be formed, one for float16 and one for float64.

This way, JIT-ting the generic bundle would work for all devices, regardless of the aspect supported. Hence no manual bundling of multiple SPV files is required.

The recipe to extract SPV from executable produced by DPC++ assumes IGC is available. An alternative approach is to use SYCL_DUMP_IMAGES environment variable supported by oneAPI DPC++, which would dump all offload sections of fat binary to the current working directory.

With these clarified, the PR is good to go in, although I'd still prefer if these notes were copied into the source of the test file.

@oleksandr-pavlyk oleksandr-pavlyk self-requested a review March 6, 2024 18:54
@diptorupd
Copy link
Contributor Author

Thank you @diptorupd
It would also be useful to document in the comment how multiple SPVs are compiled into a single one.
Also, if one is on a machine without support for double type, IGC route of generation of the kernel for double won't work, how does one generate the kernel then?

Clarifying my own misunderstanding. When C++ is compiled with default -fsycl-split-device-code value, kernel bundles are formed as per aspect required, so a kernel function would contain kernels specialized for all types but float16 and float64 and two more kernel bundles may be formed, one for float16 and one for float64.

This way, JIT-ting the generic bundle would work for all devices, regardless of the aspect supported. Hence no manual bundling of multiple SPV files is required.

The recipe to extract SPV from executable produced by DPC++ assumes IGC is available. An alternative approach is to use SYCL_DUMP_IMAGES environment variable supported by oneAPI DPC++, which would dump all offload sections of fat binary to the current working directory.

With these clarified, the PR is good to go in, although I'd still prefer if these notes were copied into the source of the test file.

I have updated the comment in the test file.

Copy link
Collaborator

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

Thank you @diptorupd , LTGM!

@diptorupd diptorupd enabled auto-merge March 6, 2024 19:16
@diptorupd diptorupd merged commit 545dff2 into master Mar 6, 2024
23 of 31 checks passed
Copy link

github-actions bot commented Mar 6, 2024

Array API standard conformance tests for dpctl=0.17.0dev0=py310h15de555_67 ran successfully.
Passed: 906
Failed: 0
Skipped: 94

@diptorupd diptorupd deleted the update/dpctl_kernelargtypes branch March 7, 2024 03:53
kargty[idx] = _arg_data_type._UNSIGNED_INT
elif isinstance(arg, ctypes.c_uint8):
kargty[idx] = _arg_data_type._INT16_T
elif isinstance(arg, ctypes.c_ushort):
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for being late, but why if instance(arg, ....) still uses old style types?

@ZzEeKkAa ZzEeKkAa mentioned this pull request Mar 7, 2024
6 tasks
oleksandr-pavlyk added a commit that referenced this pull request Mar 27, 2024
@oleksandr-pavlyk oleksandr-pavlyk mentioned this pull request Mar 27, 2024
6 tasks
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.

4 participants