Skip to content

SYCL ext one api launch queries implementation #16709

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

Conversation

dklochkov-emb
Copy link
Contributor

@dklochkov-emb dklochkov-emb commented Jan 21, 2025

  1. Added 4 sycl ext oneapi launch queries:
    max_work_item_sizes,
    max_work_group_size,
    max_sub_group_size,
    num_sub_groups
    see docs
  2. Unit tests added to check all new queries, mock class is updated for this purpose
  3. e2e tests added

@dklochkov-emb dklochkov-emb self-assigned this Jan 21, 2025
@dklochkov-emb dklochkov-emb requested a review from a team as a code owner January 21, 2025 11:21
@dklochkov-emb dklochkov-emb marked this pull request as draft January 21, 2025 11:21
[SYCL] fix formatting
getSyclObjImpl(Queue.get_device())->getHandleRef();

size_t KernelWGSize = 0;
if (auto Result = Adapter->call_nocheck<UrApiKind::urKernelGetGroupInfo>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Documentation for urKernelGetGroupInfo does not list UR_RESULT_ERROR_UNSUPPORTED_FEATURE as a possible error code, meaning that this API should be supported by every adapter.

Therefore, we should be able to simplify this code and other queries which use the same API call

ext::oneapi::experimental::info::kernel_queue_specific::num_sub_groups>(
queue Queue, const range<2> &) const;

template __SYCL_EXPORT typename ext::oneapi::experimental::info::
Copy link
Contributor

Choose a reason for hiding this comment

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

Lots of repeated code here, I would suggest that we hide it under a macro like it is done for max_num_work_groups below

@@ -0,0 +1,86 @@
// REQUIRES aspect-subgroup
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no dedicated aspect for sub-groups (SYCL 2020 spec) and the same goes for the launch queries extension spec - it does not say that any of those queries require any aspects to be supported by a device, i.e. they should work on every device.

This test would have been always skipped if not for missing : which is required for a LIT directive to work.

The concept is required to be supported by every device, but device can say that it only provides a single sub-group per work-group, or say that maximum sub-group size is equal to 1 to indicate lack of support for the feature.

#include <sycl/detail/info_desc_helpers.hpp>
#include <sycl/kernel.hpp>
#include <sycl/kernel_bundle.hpp>
#include <sycl/sycl.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

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

You must not include sycl.hpp in E2E tests, it is way to heavy. Instead, you should you specific headers you need directly

Copy link
Contributor

Choose a reason for hiding this comment

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

I would also move this file into a separate sub-directory under test-e2e. SYCL extensions are not basic functionality. Personally, I don't like us having tests for non-standard things in Basic folder

auto bundle = sycl::get_kernel_bundle<sycl::bundle_state::executable>(ctx);
auto kernel = bundle.template get_kernel<kernels::TestKernel>();

// get value to compare with
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you submit a distinct kernel, which is different from the one described by TestKernel functor. There is no guarantee that maximum sub-group size you get here is the same the one you will get for TestKernel.

[SYCL] fix windows dump test
[SYCL] fix max work group size e2e test
@dklochkov-emb
Copy link
Contributor Author

@AlexeySachkov @intel/llvm-reviewers-runtime @cperkinsintel Please, review it. Some of the tests fail due to other problems, which are not related to these changes - it was checked 2-3 last precommit checks.
Most of the comments are fixed.

@dklochkov-emb dklochkov-emb changed the title Sycl ext one api launch queries implementation SYCL ext one api launch queries implementation Feb 21, 2025
UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS)
ADD_TEMPLATE_METHOD_SPEC(num_sub_groups, 2, urKernelGetSubGroupInfo,
UR_KERNEL_SUB_GROUP_INFO_MAX_NUM_SUB_GROUPS)
ADD_TEMPLATE_METHOD_SPEC(num_sub_groups, 1, urKernelGetSubGroupInfo,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit; Looks like they all use urKernelGetSubGroupInfo as their Kind argument. I think it would be easier to read if you just inline it instead.

Co-authored-by: Steffen Larsen <[email protected]>
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

https://github.com/intel/llvm/pull/16709/files#r1965532820 is still applicable, but it's not critical, so you have my approval. Additionally, great work on the tests! 🚀

/// \param Queue is a valid SYCL queue.
/// \param WG is a work group size
/// \return depends on information being queried.
template <typename Param>
Copy link
Contributor

@lbushi25 lbushi25 Feb 25, 2025

Choose a reason for hiding this comment

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

Should we perhaps use some kind of SFINAE here to explicitly check that Param has the value defined in the spec?

It seems like at the moment we are doing SFINAE only on the return type by saying Param::return_type but there could be other descriptors that will have this type defined and we will end up instantiating declarations for them if the user supplies an invalid Param by mistake. This could lead to some weird linker errors or some runtime bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't user-visible API. Don't we have proper constraints there?

Copy link
Contributor

@lbushi25 lbushi25 Feb 25, 2025

Choose a reason for hiding this comment

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

The user-visible API in kernel.hpp which calls this one also does something similar with typename detail::is_kernel_queue_specific_info_desc<Param>::return_type which again, could potentially allow other Param types to slip through the cracks. Ideally, we'd like to follow the spec to the letter and mandate Param to be as required by the spec through SFINAE, in this case for example, to be max_num_work_groups.

@AlexeySachkov AlexeySachkov merged commit 4849b71 into intel:sycl Feb 26, 2025
19 checks passed
@sarnex
Copy link
Contributor

sarnex commented Feb 26, 2025

@dklochkov-emb Failing in postcommit on FPGA:

env ONEAPI_DEVICE_SELECTOR=opencl:fpga  /__w/llvm/llvm/build-e2e/Experimental/launch_queries/Output/max_sub_groups.cpp.tmp.out
# executed command: env ONEAPI_DEVICE_SELECTOR=opencl:fpga /__w/llvm/llvm/build-e2e/Experimental/launch_queries/Output/max_sub_groups.cpp.tmp.out
# .---command stderr------------
# | max_sub_groups.cpp.tmp.out: /__w/llvm/llvm/llvm/sycl/test-e2e/Experimental/launch_queries/max_sub_groups.cpp:67: int main(): Assertion `subSGSize <= maxDeviceValue' failed.
# | Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
# | 0  libsycl.so.8               0x00007f84036bc892
# | 1  libsycl.so.8               0x00007f84036b9d56
# | 2  libc.so.6                  0x00007f84031a7330
# | 3  libc.so.6                  0x00007f8403200b2c pthread_kill + 284
# | 4  libc.so.6                  0x00007f84031a727e gsignal + 30
# | 5  libc.so.6                  0x00007f840318a8ff abort + 223
# | 6  libc.so.6                  0x00007f840318a81b
# | 7  libc.so.6                  0x00007f840319d517
# | 8  max_sub_groups.cpp.tmp.out 0x00000000004038db
# | 9  libc.so.6                  0x00007f840318c1ca
# | 10 libc.so.6                  0x00007f840318c28b __libc_start_main + 139
# | 11 max_sub_groups.cpp.tmp.out 0x0000000000403585
# `-----------------------------
# error: command failed with exit status: -6

Please fix it ASAP and if not possible disable the test/revert the change. Thx

@AlexeySachkov
Copy link
Contributor

@dklochkov-emb Failing in postcommit on FPGA:
Please fix it ASAP and if not possible disable the test/revert the change. Thx

Considering that we are dropping FPGA support, I would say let's just XFAIL the test on this platform for now

@steffenlarsen
Copy link
Contributor

I have opened #17209 and #17210.

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.

6 participants