Skip to content

Conversation

@elizabethandrews
Copy link
Contributor

@elizabethandrews elizabethandrews commented Nov 3, 2025

Add sentinel value to compiler generated array kernel_args_sizes in integration header to avoid warnings about empty arrays. This array is used to hold the number of elements in each kernel. This PR changes the type to int to add a sentinel value of std::numeric_limits<uint32_t>::max().

Add sentinel value to compiler generated array kernel_args_sizes
in integration header to avoid warnings about empty arrays. This
array is used to hold the number of elements in each kernel. This
PR changes the type to int to add a sentinel value of -1.
Copy link
Contributor

@Fznamznon Fznamznon left a comment

Choose a reason for hiding this comment

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

CI fails might be related.

O << "};\n\n";

O << "static constexpr unsigned kernel_args_sizes[] = {";
O << "static constexpr int kernel_args_sizes[] = {";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that array used at all? I can't grep it in sycl folder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure actually. @aelovikov-intel would you know if this is just a relic of the past or whether we actually need this generated?

Copy link
Contributor

Choose a reason for hiding this comment

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

CI says

  # | C:\Users\GH_RUN~1\AppData\Local\Temp\lit-tmp-qc0j5t24\L0_interop_test-header-a28efe.h:82:75: error: cannot initialize a parameter of type 'const unsigned int *' with an lvalue of type 'const int[2]'
  # |    82 |     sycl::detail::free_function_info_map::add(sycl::detail::kernel_names, sycl::detail::kernel_args_sizes, 1);
  # |       |                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

so, this seems to be used within the integration header?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea it looks like this is used for the implementation of free functions/device globals.

Copy link
Contributor

Choose a reason for hiding this comment

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

@elizabethandrews @aelovikov-intel yes, it is used in free functions:
https://github.com/intel/llvm/blob/sycl/clang/lib/Sema/SemaSYCL.cpp#L7055
https://github.com/intel/llvm/blob/sycl/clang/lib/Sema/SemaSYCL.cpp#L7317
https://github.com/intel/llvm/blob/sycl/clang/lib/Sema/SemaSYCL.cpp#L7323

namespace detail::free_function_info_map {

If it is needed to change the type of kernel_args_sizes, then it is needed to change the whole chain..

Also, it is supposed that both arrays kernel arg sizes and kernel names have the same size. If -1 is added into kernel arg sizes, please, check which size is used during add and remove calls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the type would be an ABI break. So I have change the PR to use a sentinel value of 0 so we can keep it unsigned. I don't see any harm with that but please let me know if you disagree.

Copy link
Contributor

@Fznamznon Fznamznon Nov 6, 2025

Choose a reason for hiding this comment

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

I'm slightly concerned that we can actually put 0 for some arguments there. A capturless lambda is an example.
I think alternatively we could put there something like std::numeric_limits<uint32_t>::max(); Hopefully there is no argument of that size :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I had talked to @premanandrao about this. You're right in that there is an overlap about what 0 means here. Kernels without captures and no kernels will both have 0 here now. We thought it shouldn't matter since hopefully the runtime will have some other way of detecting no kernels. Maybe @dklochkov-emb can weigh in here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think, using std::numeric_limits<uint32_t>::max(); is better, it looks reasonable and large enough to avoid collisions

@elizabethandrews
Copy link
Contributor Author

@intel/llvm-gatekeepers How do I re-run the failed test. I tried to do re-run jobs and get an error about "failing to download artifact"

@sarnex
Copy link
Contributor

sarnex commented Nov 20, 2025

That error means too much time has passed between when build was run and now so we don't have the build artifacts anymore. You can restart the build job to fix it, that will also rerun the tests. I'll restart it.

@elizabethandrews
Copy link
Contributor Author

@intel/llvm-gatekeepers PR is ready for merge

@steffenlarsen steffenlarsen merged commit 5da1a25 into intel:sycl Nov 21, 2025
60 of 62 checks passed
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