Skip to content

[SYCL] Use mp11 to sort compile-time properties #8168

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
merged 10 commits into from
Feb 10, 2023

Conversation

uditagarwal97
Copy link
Contributor

Currently, compile-time properties are sorted using a hand-written implementation of merge-sort. However, this PR propose to sort compile-time properties using Boost's MP11 metaprogramming library instead. Mp11's sorting functionality is more optimized and it also improves the overall code readability (83 LOC vs just 11 LOC).

PS:- This PR does not introduce any new dependency as Mp11 is already integrated into the code base (See #5791).

Currently, property lists are sorted using a hand-written implementation of merge-sort. Using mp11, makes it more efficient and improves code readability.
@uditagarwal97 uditagarwal97 requested a review from a team as a code owner January 31, 2023 22:55
Comment on lines 17 to 18
// Using mp11 to sort property lists.
namespace __MP11_NS = sycl::detail::boost::mp11;
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 it's better not to introduce that in the global namespace.

// Sort types accoring to their PropertyID.
struct SortByPropertyId {
template<typename T, typename U> using fn =
__MP11_NS::mp_bool<PropertyID<T>::value < PropertyID<U>::value>;
Copy link
Contributor

Choose a reason for hiding this comment

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

... i.e, use fully qualified name here,

using type = std::tuple<LTs...>;
// Sort types accoring to their PropertyID.
struct SortByPropertyId {
template<typename T, typename U> using fn =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the same T1/T2 as on the left? I'm still not sure what our policies regarding those identifiers are.

@uditagarwal97 uditagarwal97 temporarily deployed to aws January 31, 2023 23:21 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws January 31, 2023 23:46 — with GitHub Actions Inactive
@steffenlarsen steffenlarsen self-requested a review February 1, 2023 10:25
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 3, 2023 13:50 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 marked this pull request as draft February 3, 2023 22:18
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 6, 2023 17:32 — with GitHub Actions Inactive
After integrating Boost::mp11, sycl::detail::something is ambigous so compiler prints the fully-qualified name, for e.g.: sycl::_V1::detail::something.
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 7, 2023 01:14 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 7, 2023 01:46 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 marked this pull request as ready for review February 7, 2023 01:49
Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

LGTM, the tests changes are due to the change in dumps that are non-functional, similar to what can be seen at https://godbolt.org/z/ndan4djdb

@steffenlarsen , do you agree with this? An alternative would be to update our boost machinery to use sycl::_V1::detail::boost instead of current sycl::detail::boost.

@steffenlarsen
Copy link
Contributor

@steffenlarsen , do you agree with this? An alternative would be to update our boost machinery to use sycl::_V1::detail::boost instead of current sycl::detail::boost.

I am okay with either, though I prefer the one that's most unlikely to cause the need to change the test in the future. Would the latter localize it to the actual changes?

Note also that RHEL build is failing, seemingly due some new ambiguities in unchanged code. First issue I see is use of sycl::detail::conditional_t, which should now be fixable by just changing it to use std::conditional_t.

…cl::detail namespace

This change is required to avoid compiler ambiguity between sycl::detail::<something> and sycl::_V1::detail::<something> when mp11 header is included in kernel_properties.cpp.
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 8, 2023 20:27 — with GitHub Actions Inactive
@uditagarwal97
Copy link
Contributor Author

Thanks for the feedback @steffenlarsen and @aelovikov-intel . Instead of my previous changes in the test cases, I have now made changes to import boost into sycl::_V1::detail namespace instead of the sycl::detail namespace. This prevents the need for updating test cases and also fixes the errors in pre-commit testing (jenkins / SYCL_CI/intel/Build_PR_RHEL / Build_PR_RHEL / #18327).

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.

Sad to see it go, but thank you for taking care of this! LGTM with minor nit. 🚀

@uditagarwal97 uditagarwal97 temporarily deployed to aws February 9, 2023 11:25 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 9, 2023 16:38 — with GitHub Actions Inactive
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 9, 2023 19:04 — with GitHub Actions Inactive
@bader bader requested a review from aelovikov-intel February 9, 2023 19:44
@uditagarwal97
Copy link
Contributor Author

@llvm-gatekeepers The PR is ready!

@steffenlarsen steffenlarsen merged commit eb31c2d into intel:sycl Feb 10, 2023
steffenlarsen added a commit that referenced this pull request Feb 13, 2023
bader pushed a commit that referenced this pull request Feb 14, 2023
Commit causes `sycl::detail` ambiguity errors with MSVC versions.

Reverts #8168
@uditagarwal97 uditagarwal97 temporarily deployed to aws February 16, 2023 18:07 — with GitHub Actions Inactive
steffenlarsen pushed a commit that referenced this pull request Feb 28, 2023
This PR reintroduces #8168 that was reverted by #8325 due to some build
errors with MSVC compilers. Upon inspection, it was found that the build
errors occur only in the case of incremental builds. With clean builds -
i.e. completely removing the build directory and
re-configuring/re-building again - there won't be any errors.

--------------
Currently, compile-time properties are sorted using a hand-written
implementation of merge-sort. However, this PR propose to sort
compile-time properties using Boost's MP11 metaprogramming library
instead. Mp11's sorting functionality is more optimized and it also
improves the overall code readability (83 LOC vs just 11 LOC).

PS:- This PR does not introduce any new dependency as Mp11 is already
integrated into the code base (See
#5791).
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.

3 participants