-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL] Fix performance regression in parallel_for with using id class #5385
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
[SYCL] Fix performance regression in parallel_for with using id class #5385
Conversation
c2a3033
to
78f2888
Compare
@aobolensk is it possible to add test? Generate some IR and check that type is actually used? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems useful but please all the _t
and _v
versions of the type traits.
Done |
@keryell, does it look good now? |
sycl/include/CL/sycl/handler.hpp
Outdated
using type = typename std::conditional_t< | ||
std::is_same<id<Dims>, LambdaArgType>::value, LambdaArgType, | ||
typename std::conditional_t< | ||
std::is_convertible<nd_item<Dims>, LambdaArgType>::value, | ||
nd_item<Dims>, | ||
typename std::conditional_t< | ||
std::is_convertible<item<Dims>, LambdaArgType>::value, | ||
item<Dims>, LambdaArgType>>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using at least C++17, right?
using type = typename std::conditional_t< | |
std::is_same<id<Dims>, LambdaArgType>::value, LambdaArgType, | |
typename std::conditional_t< | |
std::is_convertible<nd_item<Dims>, LambdaArgType>::value, | |
nd_item<Dims>, | |
typename std::conditional_t< | |
std::is_convertible<item<Dims>, LambdaArgType>::value, | |
item<Dims>, LambdaArgType>>>; | |
using type = typename std::conditional_t< | |
std::is_same_v<id<Dims>, LambdaArgType>, LambdaArgType, | |
typename std::conditional_t< | |
std::is_convertible_v<nd_item<Dims>, LambdaArgType>, | |
nd_item<Dims>, | |
typename std::conditional_t< | |
std::is_convertible_v<item<Dims>, LambdaArgType>, | |
item<Dims>, LambdaArgType>>>; |
Perhaps you can try whether you can remove the typename
and see whether it still compiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to replace std::is_same
with std::is_same_v
too, but it leads to basic_tests/stdcpp_compat.cpp
failure (https://github.com/intel/llvm/runs/4948816096?check_suite_focus=true)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at the compilation line in your CI test I can see: "/__w/llvm/llvm/build/bin/clang" "--driver-mode=g++" "-Xsycl-target-backend=amdgcn-amd-amdhsa" "--offload-arch=gfx906" "-D_GLIBCXX_ASSERTIONS=1" "-std=c++14"
C++14 whaaaat? :-)
@bader do you still have some old C++14 while SYCL 2020 is requiring at least C++17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
https://github.com/intel/llvm/blob/sycl/sycl/test/basic_tests/stdcpp_compat.cpp#L13 - as you can see this comment says that some features can be unavailable. We are trying to transition old codes written in SYCL-1.2.1 softly.
New code requiring c++17 features can be added under #ifdef __cplusplus >= 201703L
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this is a good opportunity to extend https://github.com/intel/llvm/blob/54ede407edeb93b7e9334d1e725f48bf981b2965/sycl/include/CL/sycl/detail/stl_type_traits.hpp with a few _v
ones in the meantime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bader do we need to add missing _v
functions to stl_type_traits.hpp or we are going to leave it as it is now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add missing
_v
functions to stl_type_traits.hpp
@aobolensk, I think this is what @keryell requests. Do you have any objections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add missing
_v
functions to stl_type_traits.hpp@aobolensk, I think this is what @keryell requests. Do you have any objections?
@bader No objections. I will add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the simplifications!
…id class (intel#5385)" This reverts commit a5760aa. Test is kept to check that id is converted from item within kernel.
In #5118 conversion for user defined types which are implicitly converted from sycl::items was added. It caused regression in case when sycl::id type is used, because with this change it converts to sycl::item but in fact it is not needed. That is why sycl::id class case should be checked explicitly.