Skip to content
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

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from

Conversation

aelovikov-intel
Copy link
Contributor

  • 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

Comment on lines +2862 to +2864
// UseFallBackAssert as template param vs `#if` in function body is necessary
// to prevent ODR-violation between TUs built with different fallback assert
// modes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@steffenlarsen , any idea if

/// NOTE: Function is dependent to prevent the fallback kernels from
/// materializing without the use of the function.
is somehow related?

Copy link
Contributor

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.

@aelovikov-intel aelovikov-intel added the run-perf-tests Run performance tests in pre-commit (normally part of post-commit only) label Jan 16, 2025
* `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
Comment on lines +172 to +173
// TODO: Is that true?
// As such, we know that it can't be a [member] function pointer.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmlueck , is this true?

Comment on lines +102 to +108
Q.submit_without_event<
#if __SYCL_USE_FALLBACK_ASSERT
true
#else
false
#endif
>(Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc);
Copy link
Contributor

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?

Suggested change
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); }
};

Copy link
Contributor

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

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-perf-tests Run performance tests in pre-commit (normally part of post-commit only)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants