-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][RTC] Hide user-facing RTC kernel ids #17356
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
Conversation
sycl/test-e2e/KernelCompiler/kernel_compiler_sycl_jit_cache.cpp
Outdated
Show resolved
Hide resolved
@jopperm I've restored |
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've restored test_lifetime using debug prints enabled under SYCL_RT_WARNING_LEVEL=2 as we discussed offline
Neat, thanks!
|
||
bool ok = | ||
q.get_device().ext_oneapi_can_compile(syclex::source_language::sycl_jit); | ||
if (!ok) { |
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.
why don't we fail test as done in the other tests?
I think if we expect these tests to work on specific devices (that is usually managed by REQUIRES) we should report error if conditions are not met unexpectedly.
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 thanks for pointing this out, I copy-pasted from test_warning
without noticing that it was returning 0. I checked offline with @jopperm and we decided to refactor the test a bit so that the check is done only once in main, also given how the test is structured there was no point in having test_warning
optional so we removed that, I also removed the capability check in the tests and put in main
so that it's done once.
@@ -76,15 +71,10 @@ int test_persistent_cache() { | |||
// CHECK: [kernel_compiler Persistent Cache]: cache miss: [[KEY1:.*]] | |||
// CHECK: [kernel_compiler Persistent Cache]: storing device code IR: {{.*}}/[[KEY1]] | |||
exe_kb kbExe1a = syclex::build(kbSrc1); | |||
dumpKernelIDs(); |
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.
does it make sense to replace it with check get_kernel_ids().size() == 0?
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've added test_no_visible_ids
in this PR which asserts for get_kernel_ids().size() == 0
, given that this is now always true regardless of persistent checks etc, I think we are already covered
@@ -0,0 +1,104 @@ | |||
//== kernel_compiler_sycl_jit_lifetimes.cpp - kernel_compiler lifetime tests |
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 a bit wrong formatting, I believe the beginning and the ending of copyright note should have the same length.
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.
Filename was a tad too long, I renamed it and fixed formatting
{ | ||
std::cout << "Scope3\n"; | ||
// CHECK: Scope3 | ||
exe_kb kbExe3 = syclex::build(kbSrc); |
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.
is this ProgramBuild & Release check skipped intentionally?
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 I didn't want to clutter the test too much, I think that just checking the kernel create/release calls here is enough
// Filter out kernel ids coming from RTC kernels in order to be | ||
// spec-compliant. Kernel ids from RTC are prefixed with rtc_NUM$, so looking | ||
// for '$' should be enough. | ||
ids.erase(std::remove_if(ids.begin(), ids.end(), |
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.
@cperkinsintel LGTM but I appreciate if you can take a look.
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.
But this would remove kernels defined using the SYCL_EXT_ONEAPI_FUNCTION_PROPERTY
attribute, correct? That doesn't seem right.
The function get_kernel_ids() returns the kernel identifiers for any free function kernels defined by the application, in addition to identifiers for any kernels defined as lambda expressions or named kernel objects.
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.
But this would remove kernels defined using the
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY
attribute, correct?
No, only kernels compiled through kernel_compiler
, which get a $
-sign prefix prepended to their offload entry's name, which ends up being the kernel_id
.
@@ -789,6 +789,11 @@ class kernel_bundle_impl { | |||
const std::vector<device> &get_devices() const noexcept { return MDevices; } | |||
|
|||
std::vector<kernel_id> get_kernel_ids() const { | |||
// RTC kernel bundles shouldn't have user-facing kernel ids, return an | |||
// empty vector when the bundle contains RTC kernels. | |||
if (MLanguage == syclex::source_language::sycl_jit) { |
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.
is this necessary? I thought this wasn't returning ids for any language?
Interaction with existing kernel bundle member functions
Kernels created from online compilation of source code do not have any associated kernel_id. Therefore, the function kernel_bundle::get_kernel_ids returns an empty vector of kernel_id objects if the kernel bundle was created from a bundle of state bundle_state::ext_oneapi_source.
But if it is necessary, maybe it should be MLanguage set at all, rather than just sycl_jit
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.
Good point, we can return early here for any kernel_compiler
-compiled bundle. The source_language
enum doesn't have a neutral element. In kernel_bundle_impl
, we check "being compiled from an ext_oneapi_source
bundle" as !MKernelNames.empty()
, so we could expose that check as kernel_bundle_impl::isBuiltFromSource()
or so.
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'm not sure this is correct. The specification for the free function kernel extension explicitly states that those kernels ARE retrievable by get_kernel_ids()
, which means they are user-facing and shouldn't be removed.
But maybe I'm misunderstanding what is going on here. It can be confusing because one can have a SYCL application that uses SYCL_EXT_ONEAPI_FUNCTION_PROPERTY
without using the kernel_compiler
at all.
Thanks for the review @cperkinsintel!
The
@gmlueck also confirmed this in offline conversation:
To your other point:
As @jopperm clarified above, all offline-compiled free-function kernels would still appear, so would continue to follow the behavior specified by the free function kernel extension that you mentioned. For all online-compiled free-function kernels, the specified behavior from the |
The SYCL spec mandates that kernel IDs for kernels generated through RTC shouldn't be accessible from the user application. This PR makes it so we filter out the output of
get_kernel_ids
so that we behave according to the spec.Removes some tests that were relying on kernel_ids being accessible from the user application, updates
test_lifetime
to check on debug prints.Refactors
kernel_compiler_sycl_jit_lt.cpp
to remove unnecessary device capability checks and use a commonsycl::queue
.