-
Notifications
You must be signed in to change notification settings - Fork 751
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] Use custom type to pass CGF around instead of std::function
#16668
base: sycl
Are you sure you want to change the base?
Conversation
// UseFallBackAssert as template param vs `#if` in function body is necessary | ||
// to prevent ODR-violation between TUs built with different fallback assert | ||
// modes. |
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.
@steffenlarsen , any idea if
llvm/sycl/include/sycl/queue.hpp
Lines 792 to 793 in a87ac06
/// NOTE: Function is dependent to prevent the fallback kernels from | |
/// materializing without the use of the function. |
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.
The "fallback kernel" in this case is not referring to fallback asserts. It's because the implementation of ext_oneapi_memcpy2d
has a kernel it uses if the operation isn't natively supported, but we don't want that kernel to pop up unless the user calls ext_oneapi_memcpy2d
in their code, so we make it dependent.
* `std::function` is affecting compile-time too much * our `queue::submit` is a *synchronous* operation, so we don't need to make any copy. Maybe `std::function_ref` would be a good choice here, but that's C++26. * Try to convert typed CGFO into type-erased version as soon as possible to limit number of template instantiations FE needs to perform
// TODO: Is that true? | ||
// As such, we know that it can't be a [member] function pointer. |
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.
@gmlueck , is this true?
Q.submit_without_event< | ||
#if __SYCL_USE_FALLBACK_ASSERT | ||
true | ||
#else | ||
false | ||
#endif | ||
>(Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc); |
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.
Looks like we always have __SYCL_USE_FALLBACK_ASSERT
set to a value, could we not just use it directly here?
Q.submit_without_event< | |
#if __SYCL_USE_FALLBACK_ASSERT | |
true | |
#else | |
false | |
#endif | |
>(Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc); | |
Q.submit_without_event<__SYCL_USE_FALLBACK_ASSERT>(Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc); |
|
||
void operator()(sycl::handler &cgh) const { invoker_f(object, cgh); } | ||
}; | ||
|
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.
When I first saw this I was wondering if we could use std::invokable
instead, but I think that'd change the ABI, plus it might have the same too-much-templating problem as std::function
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 don't see how it's applicable here. std::invokable
is a concept, not a data type; so more like std::is_invokable_r
trait that we are already using.
std::function
is affecting compile-time too muchqueue::submit
is a synchronous operation, so we don't need to make any copy. Maybestd::function_ref
would be a good choice here, but that's C++26.