Skip to content

[SYCL] Add size to detail::string_view #18661

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

Conversation

Alexandr-Konovalov
Copy link
Contributor

This allows us to pass size of kernel name that is known in compile time, not compute the size in run time.

This allows us to pass size of kernel name that is known in compile
time, not compute the size in run time.
Signed-off-by: Alexandr Konovalov <[email protected]>
@frasercrmck
Copy link
Contributor

FYI I see the same sort of Arc A-Series failures, tracked in #18668.

Signed-off-by: Alexandr Konovalov <[email protected]>
Signed-off-by: Alexandr Konovalov <[email protected]>
@jbrodman
Copy link
Contributor

So the basic idea here is that we compute the string length once at the start then can reuse the length every time we create a new view of it?

@Alexandr-Konovalov
Copy link
Contributor Author

So the basic idea here is that we compute the string length once at the start then can reuse the length every time we create a new view of it?

Actually, KernelNameStr is constexpr and I see no string length computation at run time.

Signed-off-by: Alexandr Konovalov <[email protected]>
@Alexandr-Konovalov Alexandr-Konovalov marked this pull request as ready for review June 2, 2025 06:27
@Alexandr-Konovalov Alexandr-Konovalov requested review from a team as code owners June 2, 2025 06:27
@Alexandr-Konovalov Alexandr-Konovalov requested a review from Bensuo June 2, 2025 06:27
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.

Overall LGTM! One smallish suggestion.

@@ -17,10 +18,19 @@ namespace detail {
using KernelNameStrT = std::string_view;
using KernelNameStrRefT = std::string_view;
using ABINeutralKernelNameStrT = detail::string_view;

inline KernelNameStrT toKernelNameStrT(ABINeutralKernelNameStrT str) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the str argument constness need to differ between the definitions? I would prefer we keep them the same, even if it means removing const in the variant below. If it gets removed with breaking changes, I would argue it's better to have it the same and avoid the potential hidden faulty const use-cases we could have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, probably I do not understand. Are you for passing detail::string_view by const reference, like this?

inline KernelNameStrT toKernelNameStrT(const ABINeutralKernelNameStrT &str) {
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
  return std::string_view(str);
#else
  return str.data();
#endif
}

Copy link
Contributor

Choose a reason for hiding this comment

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

If that is an option, that would be good! My point is just to avoid differing constness of the reference argument in the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, let's unify.

@hvdijk
Copy link
Contributor

hvdijk commented Jun 2, 2025

As in #18565, this PR shows sycl/test/native_cpu/multiple_definitions.cpp being added but that doesn't belong in this PR, that came from #18726 and something went wrong in updating this PR.

@Alexandr-Konovalov
Copy link
Contributor Author

As in #18565, this PR shows sycl/test/native_cpu/multiple_definitions.cpp being added but that doesn't belong in this PR, that came from #18726 and something went wrong in updating this PR.

Thank you, removed form this PR as well.

@Alexandr-Konovalov
Copy link
Contributor Author

Colleagues @steffenlarsen , @Bensuo , could it be merged or not yet?

@steffenlarsen
Copy link
Contributor

Definitely!

@steffenlarsen steffenlarsen merged commit 73ff319 into intel:sycl Jun 3, 2025
23 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