Skip to content

Conversation

@elizabethandrews
Copy link
Contributor

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.

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.

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