Skip to content

[SYCL] Adds compile-time properties #4976

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 24 commits into from
Feb 28, 2022

Conversation

steffenlarsen
Copy link
Contributor

@steffenlarsen steffenlarsen commented Nov 17, 2021

Implements the compile-time property list extension adding the sycl::ext::oneapi::properties and sycl::ext::oneapi::property_value classes. These allow for compile-time inspection of properties passed to SYCL objects. These changes do not add support for the new property lists to any existing SYCL classes however.

Implements the compile-time property list extension
(https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/PropertyList/SYCL_EXT_ONEAPI_property_list.asciidoc)
adding the sycl::ext::oneapi::property_list and
sycl::ext::oneapi::property_value classes. These allow for compile-time
inspection of properties passed to SYCL objects. These changes do not
add support for the new property lists to any existing SYCL classes
however.

Signed-off-by: Steffen Larsen <[email protected]>
@steffenlarsen
Copy link
Contributor Author

@gmlueck | @rolandschulz | @Pennycook - It seems that MSVC is complaining because get_property has both static and non-static overloads. It appears to be a problem we have had with accessor_property_list before as well: https://www.intel.com/content/www/us/en/developer/articles/troubleshooting/c2686-when-using-msvc-as-host-compiler.html

@dm-vodopyanov
Copy link
Contributor

dm-vodopyanov commented Nov 17, 2021

@steffenlarsen, can you try exactly the same syntax of std::enable_if_t from https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp?
It turned out this combination of std::enable_t syntax works for MSVC in accessor_property_list.
This patch made it work: #4240.
I hope it helps for property_list.

@steffenlarsen steffenlarsen changed the title [SYCL] Adds compile-time property list WIP: [SYCL] Adds compile-time property list Nov 17, 2021
@steffenlarsen steffenlarsen marked this pull request as draft November 17, 2021 21:15
@steffenlarsen
Copy link
Contributor Author

@steffenlarsen, can you try exactly the same syntax of std::enable_if_t from https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp? It turned out this combination of std::enable_t syntax works for MSVC in accessor_property_list. This patch made it work: #4240. I hope it helps for property_list.

Thank you! That seems to have done the trick.

Runtime properties for the new property lists need to be seperately
defined from the ones defined in SYCL 2020. These changes remove the
support for SYCL 2020 properties in the compile-time property_list and
adds the notion of runtime properties as a separate system.

Signed-off-by: Steffen Larsen <[email protected]>
Signed-off-by: Steffen Larsen <[email protected]>
@AaronBallman AaronBallman self-requested a review December 2, 2021 19:55
Signed-off-by: Steffen Larsen <[email protected]>
@steffenlarsen
Copy link
Contributor Author

Recent changes:

@steffenlarsen steffenlarsen marked this pull request as ready for review January 21, 2022 12:23
@steffenlarsen steffenlarsen changed the title WIP: [SYCL] Adds compile-time property list [SYCL] Adds compile-time properties Jan 21, 2022
Signed-off-by: Steffen Larsen <[email protected]>
Signed-off-by: Steffen Larsen <[email protected]>
ghost
ghost previously approved these changes Feb 3, 2022
@ghost
Copy link

ghost commented Feb 3, 2022

I'm not going to dive in details but from high-level perspective the patch looks good for me.

@gmlueck
Copy link
Contributor

gmlueck commented Feb 3, 2022

Could you please tell if the patch looks OK to you and if you are planning/not planning to review it?

Of the LEWG members, @rolandschulz was most involved in the implementation details of compile-time properties. I was not planning to review in detail, but @rolandschulz might want to.

@bader
Copy link
Contributor

bader commented Feb 8, 2022

@rolandschulz, could you take a look, please?

@bader
Copy link
Contributor

bader commented Feb 11, 2022

@rolandschulz, ping.

@steffenlarsen
Copy link
Contributor Author

@rolandschulz - Could you please clarify if you plan on reviewing this? If not, @Pennycook would you mind having a look?

@Pennycook
Copy link
Contributor

@rolandschulz - Could you please clarify if you plan on reviewing this? If not, @Pennycook would you mind having a look?

Like Greg, I wasn't planning to do an in-depth review here.

I did take a look when the PR was opened, but the template wizardry being employed is sufficiently advanced that I wouldn't feel comfortable reviewing for things like impact on compile-time, etc.

FWIW, what I understood looks good, and I appreciated the "How to add a new property" comments -- I think those will be very useful. 👍

cperkinsintel
cperkinsintel previously approved these changes Feb 23, 2022
Copy link
Contributor

@cperkinsintel cperkinsintel left a comment

Choose a reason for hiding this comment

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

Lime Gin Tastes Metallic!

// `sycl::ext::oneapi::experimental::detail::PropKind` representing the new
// property. Increment
// `sycl::ext::oneapi::experimental::detail::PropKind::PropKindSize`
// 2. Define property key class with `value_t` that must be `property_value`
Copy link
Contributor

Choose a reason for hiding this comment

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

can these new property keys be in other namespaces?

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. There is no requirement on the namespace of the properties. It would probably be preferable to have them in a namespace under sycl::ext::oneapi::experimental while it is still experimental, but since it is user-facing it should not be a requirement from the implementation.

namespace detail {
template <> struct PropertyToKind<bar_key> {
static constexpr PropKind Kind =
static_cast<enum PropKind>(PropKind::PropKindSize + 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing the awkward PropKindSize + X constructs here is because we aren't actually making modifications to property.hpp, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. These properties are not "real" so we make their PropKind outside the usual range to avoid confusing them with actual properties.

// (4.)
template <> struct is_property<bar_key> : std::true_type {};
// Replace SYCL_OBJ with the SYCL object to support the property.
template <> struct is_property_of<bar_key, SYCL_OBJ> : std::true_type {};
Copy link
Contributor

Choose a reason for hiding this comment

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

what if the SYCL_OBJ class itself requires template specialization? Use a template template? Proxy? Will we have order-of-evaluation issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is_property_of is already a thing in SYCL 2020. For example, if we specialize for buffer we have something long the lines of

template <typename T, int Dimensions, typename AllocatorT>
struct is_property_key_of<bar_key, buffer<T, Dimensions, AllocatorT, void>> : std::true_type {};

I don't believe there should be any issues with that.

@steffenlarsen steffenlarsen dismissed stale reviews from ghost and romanovvlad via 4608676 February 24, 2022 11:46
Signed-off-by: Steffen Larsen <[email protected]>
Signed-off-by: Steffen Larsen <[email protected]>
@steffenlarsen
Copy link
Contributor Author

Failures were unrelated. They have been reported and testing has been restarted.

@steffenlarsen
Copy link
Contributor Author

@romanovvlad & @psamolysov-intel & @cperkinsintel - There has been some minor corrections to the how-to. Would you mind having another look?

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

I didn't review deeply, but what I see in the latest 3 commits looks good for me. Thanks, @steffenlarsen!

@steffenlarsen
Copy link
Contributor Author

@intel/llvm-gatekeepers - Remaining questions have been answered. This should be ready for merge.

@bader bader merged commit 87f60f6 into intel:sycl Feb 28, 2022
@bader
Copy link
Contributor

bader commented Feb 28, 2022

@steffenlarsen, post-commit failed with

/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:54:51: error: unused parameter 'LHS' [-Werror,-Wunused-parameter]
operator==(const property_value<PropertyT, A...> &LHS,
                                                  ^
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:55:51: error: unused parameter 'RHS' [-Werror,-Wunused-parameter]
           const property_value<PropertyT, B...> &RHS) {
                                                  ^
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:62:51: error: unused parameter 'LHS' [-Werror,-Wunused-parameter]
operator!=(const property_value<PropertyT, A...> &LHS,
                                                  ^
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:63:51: error: unused parameter 'RHS' [-Werror,-Wunused-parameter]
           const property_value<PropertyT, B...> &RHS) {
                                                  ^
In file included from /home/runner/work/llvm/llvm/src/sycl/source/backend/level_zero.cpp:9:
In file included from /home/runner/work/llvm/llvm/src/sycl/include/CL/sycl.hpp:67:
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/properties.hpp:99:[42](https://github.com/intel/llvm/runs/5358967864?check_suite_focus=true#step:9:42): error: unused parameter 'PropertyValues' [-Werror,-Wunused-parameter]
  Extract(std::tuple<PropertyValueTs...> PropertyValues) {
                                         ^
5 errors generated.

Could you fix these issues, please?

@steffenlarsen
Copy link
Contributor Author

@steffenlarsen, post-commit failed with

/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:54:51: error: unused parameter 'LHS' [-Werror,-Wunused-parameter]
operator==(const property_value<PropertyT, A...> &LHS,
                                                  ^
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:55:51: error: unused parameter 'RHS' [-Werror,-Wunused-parameter]
           const property_value<PropertyT, B...> &RHS) {
                                                  ^
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:62:51: error: unused parameter 'LHS' [-Werror,-Wunused-parameter]
operator!=(const property_value<PropertyT, A...> &LHS,
                                                  ^
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/property_value.hpp:63:51: error: unused parameter 'RHS' [-Werror,-Wunused-parameter]
           const property_value<PropertyT, B...> &RHS) {
                                                  ^
In file included from /home/runner/work/llvm/llvm/src/sycl/source/backend/level_zero.cpp:9:
In file included from /home/runner/work/llvm/llvm/src/sycl/include/CL/sycl.hpp:67:
/home/runner/work/llvm/llvm/build/include/sycl/ext/oneapi/properties/properties.hpp:99:[42](https://github.com/intel/llvm/runs/5358967864?check_suite_focus=true#step:9:42): error: unused parameter 'PropertyValues' [-Werror,-Wunused-parameter]
  Extract(std::tuple<PropertyValueTs...> PropertyValues) {
                                         ^
5 errors generated.

Could you fix these issues, please?

#5684 should fix it.

@steffenlarsen steffenlarsen deleted the steffen/compile_time_propperty_list branch December 6, 2023 11:38
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.

8 participants