-
Notifications
You must be signed in to change notification settings - Fork 770
[SYCL] Fix linking of kernel-bundles. #4398
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 linking of kernel-bundles. #4398
Conversation
when fsycl-device-code-split=per_kernel is used in conjunction with multiple kernels, then explicit sycl::link(sycl::compile(my-kernel-bundle)) will fail, because we link all device images in a kernel together. But, the device-images are independent, there is presently no known situation where they should be linked together. So this PR works around this limitation by linking them seperately. This may have to be revisited once sharedlibrary style linking is supported, but that is likely true whether this bug is fixed or not. Signed-off-by: Chris Perkins <chris.perkins@intel.com>
I'd like to understand the test case that caused the original problem. Can you point me to it or send additional information? The description just says that |
Apologies in advance for a long comment. I'd like to explain how to think about the semantics of the kernel bundle linking operation. The semantics are easiest to describe if you think about an idealized implementation where a kernel bundle always contains just a single device image. In such an idealized case, If the an implementation has more than one device image in a kernel bundle, the semantics of the operations still need to match the idealized case. Consider the case above where At this point, we can see that your proposed fix does make sense. You've changed the code to link each device image separately, rather than linking them all together. As an aside, it would also be legal for the implementation to combine the physical device images together, either as part of the Now let's consider the case where the application links several kernel bundles together:
First, consider the idealized case. Bundles Now, let's consider the non-idealized case, but make the simplifying assumption that there are no undefined symbols in any device image. Even though Thus, we can see that your proposed solution works in this case too. Finally, let's consider the case where device images in As I said in another forum, there is no way in standard SYCL to create a kernel bundle that has an unresolved reference to a symbol. However, it is possible to get this situation using either OpenCL or Level Zero backend interop APIs. If we expect to support these scenarios, then I think more work needs to be done for the |
…07 which is not yet merged. Signed-off-by: Chris Perkins <chris.perkins@intel.com>
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
@@ -192,7 +192,6 @@ class kernel_bundle_impl { | |||
// TODO: Unify with c'tor for sycl::comile and sycl::build by calling |
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.
Can we add a test to sycl/unittests/SYCL2020 ?
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 a lit test for the multiple kernel stuff here: intel/llvm-test-suite#440
Is that what you are asking?
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.
No, I was asking about adding a unit/component test in sycl/unittests/SYCL2020
directory of this repo. This test should be able to validate this behavior without any backend available.
Let's do it in a separate PR?
I think it would be worth adding a comment explaining the limitations. Something like:
|
The matching test for this is here: intel/llvm-test-suite#440 |
Signed-off-by: Chris Perkins <chris.perkins@intel.com>
@gmlueck - thanks. I inserted your comment. |
when
fsycl-device-code-split=per_kernel
is used in conjunction with multiple kernels, then explicitsycl::link(sycl::compile(my-kernel-bundle))
will fail, because we link all device images in a kernel together. Any shared top level references will have conflicting symbols. But, the device-images are independent, there is presently no known situation where they need to be linked together. So this PR works around this limitation by linking them separately. This may have to be revisited once sharedlibrary style linking is supported, but that is likely true whether this bug is fixed or not.Signed-off-by: Chris Perkins chris.perkins@intel.com