Skip to content

[SYCL] Align range to SYCL 2020 specs - #22889

Open
Robertkq wants to merge 3 commits into
intel:syclfrom
Robertkq:Robertkq/22736
Open

[SYCL] Align range to SYCL 2020 specs#22889
Robertkq wants to merge 3 commits into
intel:syclfrom
Robertkq:Robertkq/22736

Conversation

@Robertkq

@Robertkq Robertkq commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

fixes #22736

This PR introduces an explicit line for range destructor (Rule of 5 or 0 is mandatory) and a missing overload for operator op, alongside multiple missing noexcept keywords for functions

@Robertkq Robertkq changed the title Add missing functions & noexcept keyword [SYCL] Add missing functions & noexcept keyword Aug 6, 2026
@Robertkq Robertkq changed the title [SYCL] Add missing functions & noexcept keyword [SYCL] Align range to SYCL 2020 specs Aug 6, 2026
@Robertkq

Robertkq commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

This PR introduces an explicit line for range destructor (Rule of 5 or 0 is mandatory) and a missing overload for operator op, alongside multiple missing noexcept keywords for functions

#define __SYCL_GEN_OPT(op) \
__SYCL_GEN_OPT_BASE(op) \
friend range<Dimensions> operator op(const range<Dimensions> &lhs, \
const size_t &rhs) { \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This overload is not in SYCL 2020 latest documentation, not adding noexcept

return result; \
} \
friend range<Dimensions> operator op(const size_t &lhs, \
const range<Dimensions> &rhs) { \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This overload is not in SYCL 2020 latest documentation, not adding noexcept

return lhs; \
} \
friend range<Dimensions> &operator op(range<Dimensions> &lhs, \
const size_t &rhs) { \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This overload is not in SYCL 2020 latest documentation, not adding noexcept. Also it is not guarded by __SYCL_DISABLE_ID_TO_INT_CONV__ like the previous ones

@KornevNikita KornevNikita Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess that's why you've also skipped some operators on lines 112 & 120 (upd. oh sorry you've already mentioned this above)? I'm not sure why we need these, I need to check the spec.

@KornevNikita KornevNikita Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this should also have noexcept. It's an #else branch of #ifndef __SYCL_DISABLE_ID_TO_INT_CONV__, although I don't know yet why we need this.
Anyways, std::is_integral_v<size_t> equals to true.
UPD looks like previously in SYCL 2020 were only operators with size_t args, but DPC++ supported all integer types. Seems like then it became part of the standard, see #4538 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@KseniyaTikhomirova do you know what is the purpose of __SYCL_DISABLE_ID_TO_INT_CONV__? At least here it looks like it does nothing as the code in both branches of this macro is same.

range(size_t, size_t, size_t)->range<3>;
range(size_t) -> range<1>;
range(size_t, size_t) -> range<2>;
range(size_t, size_t, size_t) -> range<3>;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

automatic change from my clang-format, I think it adheres to coding style rules of the repository

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's ok, let's update this. In general try to use git clang-format HEAD~ after you've created a commit. It'll only format your changes then.

@Robertkq
Robertkq marked this pull request as ready for review August 6, 2026 13:08
@Robertkq
Robertkq requested a review from a team as a code owner August 6, 2026 13:08
@Robertkq

Robertkq commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@KornevNikita @KseniyaTikhomirova can you take a look over the PR? Thanks!

@Robertkq

Robertkq commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Also, I wasn't able to find an existing test file to add a case for the new overload. If it exists and it can be provided to me, I'll happily add tests, otherwise I think the PR can continue?

@KornevNikita

Copy link
Copy Markdown
Contributor

This PR introduces an explicit line for range destructor (Rule of 5 or 0 is mandatory) and a missing overload for operator op, alongside multiple missing noexcept keywords for functions

could you please add this to the description


range(const range<Dimensions> &rhs) = default;
range(range<Dimensions> &&rhs) = default;
range(range<Dimensions> &&rhs) noexcept = default;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC SYCL 2020 doesn't require these functions (for by-value semantics) to be noexcept.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's right.. I thought that I should apply good practice here to add noexcept for move functions so they could benefit from moves. standard library usually moves types only if they have noexcept move constructor / operator, but now I properly understand that this type is designed to be passed by value and as such this noexcept should bring little to no improvement, so I will most likely remove it from here

return lhs; \
} \
friend range<Dimensions> &operator op(range<Dimensions> &lhs, \
const size_t &rhs) { \

@KornevNikita KornevNikita Aug 6, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess that's why you've also skipped some operators on lines 112 & 120 (upd. oh sorry you've already mentioned this above)? I'm not sure why we need these, I need to check the spec.

range(size_t, size_t, size_t)->range<3>;
range(size_t) -> range<1>;
range(size_t, size_t) -> range<2>;
range(size_t, size_t, size_t) -> range<3>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's ok, let's update this. In general try to use git clang-format HEAD~ after you've created a commit. It'll only format your changes then.

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.

Align range with SYCL 2020

2 participants