Skip to content

[SYCL] sycl::kernel::get_kernel_bundle() may return a kernel_bundle with a null impl. #6598

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

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

zahiraam
Copy link
Contributor

@zahiraam zahiraam commented Aug 17, 2022

This is an issue complaining about that return from getSyclObjImpl can be null.
I talked to @steffenlarsen off line and although this is considered to be impossible (every constructor should create for itself and impl), it doesn't seem to be enforced anywhere in the code. We decided that would be a good compromise to make sure that impl is always non-null.

@zahiraam zahiraam requested a review from a team as a code owner August 17, 2022 19:52
@zahiraam zahiraam requested a review from againull August 17, 2022 19:52
@againull againull changed the title Fix for CMPLRLLVM-39605 Fix Klocwork warning Aug 17, 2022
@againull againull changed the title Fix Klocwork warning [SYCL] Fix Klocwork warning Aug 17, 2022
againull
againull previously approved these changes Aug 17, 2022
@againull
Copy link
Contributor

@zahiraam It looks like this change causes multiple LIT test failures, please address them.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

I wonder if that is just a warning or a real issue it found. If the latter, can we update the PR's title?

@@ -77,11 +77,25 @@ handler::getOrInsertHandlerKernelBundle(bool Insert) const {
}

// Sets kernel bundle to the provided one.
// If Kernel doesn't a kernel_bundle associated with it, the handler would
// still create a kernel_bundlxbe from a nullptr kernel_bundle_impl. This would
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// still create a kernel_bundlxbe from a nullptr kernel_bundle_impl. This would
// still create a kernel_bundle from a nullptr kernel_bundle_impl. This would

@@ -77,11 +77,25 @@ handler::getOrInsertHandlerKernelBundle(bool Insert) const {
}

// Sets kernel bundle to the provided one.
// If Kernel doesn't a kernel_bundle associated with it, the handler would
// still create a kernel_bundlxbe from a nullptr kernel_bundle_impl. This would
// have an invlaid impl and triggers an assertion in the handler. To remedy the
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// have an invlaid impl and triggers an assertion in the handler. To remedy the
// have an invalid impl and trigger an assertion in the handler. To remedy the

@zahiraam zahiraam changed the title [SYCL] Fix Klocwork warning [SYCL] sycl::kernel::get_kernel_bundle() may return a kernel_bundle with a null impl. Aug 19, 2022
@zahiraam
Copy link
Contributor Author

@aelovikov-intel Is the LIT fail a know issue? I don't see that's related to the patch?

@aelovikov-intel
Copy link
Contributor

I think it's related to this patch - you've added a new method that is visible outside libsycl.so. The failing test has instructions on how to update the CHECKs.

@zahiraam
Copy link
Contributor Author

I think it's related to this patch - you've added a new method that is visible outside libsycl.so. The failing test has instructions on how to update the CHECKs.

This is the command that I am using to add the symbol, but I am getting an error:
bash-4.4$ python3 sycl/tools/abi_check.py --mode dump_symbols --output ./output.dump /export/iusers/zahiraam/my-sycl/debugbuild/lib/libsycl.so
Traceback (most recent call last):
File "sycl/tools/abi_check.py", line 156, in
main()
File "sycl/tools/abi_check.py", line 152, in main
dump_symbols(args.target_library, args.output)
File "sycl/tools/abi_check.py", line 78, in dump_symbols
readobj_opts, target_path])
File "/nfs/sc/proj/icl/rdrive/ics/itools/pkgtools/python/v3_7_8/efi2_rhel70/lib/python3.7/subprocess.py", line 411, in check_output
**kwargs).stdout
File "/nfs/sc/proj/icl/rdrive/ics/itools/pkgtools/python/v3_7_8/efi2_rhel70/lib/python3.7/subprocess.py", line 488, in run
with Popen(*popenargs, **kwargs) as process:
File "/nfs/sc/proj/icl/rdrive/ics/itools/pkgtools/python/v3_7_8/efi2_rhel70/lib/python3.7/subprocess.py", line 800, in init
restore_signals, start_new_session)
File "/nfs/sc/proj/icl/rdrive/ics/itools/pkgtools/python/v3_7_8/efi2_rhel70/lib/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'llvm-readobj': 'llvm-readobj'
bash-4.4$
Is there an env variable that needs to be set to run the command?
Thanks.

@steffenlarsen
Copy link
Contributor

CUDA failure in Assert/assert_in_simultaneously_multiple_tus.cpp is known and the test has since been disabled.

@zahiraam
Copy link
Contributor Author

CUDA failure in Assert/assert_in_simultaneously_multiple_tus.cpp is known and the test has since been disabled.

Thanks @steffenlarsen . @againull Can this be checked in? Thanks.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

Functionally this change is good. I'd change some comments (see inline) but it might be just me.

@againull , WDYT?

@againull
Copy link
Contributor

Functionally this change is good. I'd change some comments (see inline) but it might be just me.

@againull , WDYT?

I agree that it would be nice to change the comments per suggestions. @zahiraam Could you please update comments per suggestions and I will merge afterwards.

@zahiraam
Copy link
Contributor Author

Functionally this change is good. I'd change some comments (see inline) but it might be just me.
@againull , WDYT?

I agree that it would be nice to change the comments per suggestions. @zahiraam Could you please update comments per suggestions and I will merge afterwards.

Thanks @aelovikov-intel and @againull. Done.

Copy link
Contributor

@aelovikov-intel aelovikov-intel left a comment

Choose a reason for hiding this comment

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

Thanks!

@gmlueck
Copy link
Contributor

gmlueck commented Aug 24, 2022

This PR seems to have some unrelated changes, for example those changes in "sycl/doc/design/OptionalDeviceFeatures.md". Is this due to a merge mistake?

@steffenlarsen
Copy link
Contributor

This PR seems to have some unrelated changes, for example those changes in "sycl/doc/design/OptionalDeviceFeatures.md". Is this due to a merge mistake?

Apologies, @gmlueck. There was some problems in a rebase. We are fixing it now.

…ith a null impl.

This is an issue complaining about that return from getSyclObjImpl can be null.
I talked to @steffenlarsen off line and although this is considered to be impossible (every constructor should create for itself and impl), it doesn't seem to be enforced anywhere in the code. We decided that would be a good compromise to make sure that impl is always non-null.

Signed-off-by: Zahira Ammarguellat <[email protected]>
@zahiraam
Copy link
Contributor Author

The PR is now clean. Thanks to @steffenlarsen who spent time looking at my ws and cleaning it up!

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

Apart from the rebase and squash, there are no changes since previous approvals.

@zahiraam
Copy link
Contributor Author

This PR seems to have some unrelated changes, for example those changes in "sycl/doc/design/OptionalDeviceFeatures.md". Is this due to a merge mistake?

Yes it is. Sorry about the confusion.

@steffenlarsen steffenlarsen removed the request for review from smaslov-intel August 24, 2022 13:03
void handler::setHandlerKernelBundle(kernel Kernel) {
// Kernel may not have an associated kernel bundle if it is created from a
// program. As such, apply getSyclObjImpl directly on the kernel, i.e. not
// the other way around: getSyclObjImp(Kernel->get_kernel_bundle()).
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not directly related to your change, but this comment makes me think there is a problem someplace. Why is there no kernel bundle for a kernel created from a program? The SYCL spec defines kernel::get_kernel_bundle() for all kernels, even those created from backend interop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Arguably there is, but since program is being removed I don't think it is worth the worry.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I was wondering if the issue about having no kernel bundle is limited to just the deprecated program case, or if it also included other cases like constructing a kernel from backend interop. If it is only the program case, I agree there is no need to fix it now. We should instead wait until program is removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

This problem should be unique to kernel bundles in kernels created from sycl::program. For sycl::make_kernel we either use a supplied kernel bundle (part of the L0 input type) or an empty "interop" kernel bundle.

@steffenlarsen steffenlarsen merged commit afb6dc3 into intel:sycl Aug 24, 2022
steffenlarsen added a commit to steffenlarsen/llvm-test-suite that referenced this pull request Aug 24, 2022
The SYCL 2020 specification states that the instance of a moved SYCL
object is invalid, so any operations after a move exhibit undefined
behaviour. sampler.cpp moves a sampler before hashing the moved object.
In that case, the hasher will extract a nullptr implementation, which
with intel/llvm#6598 will fail an assertion.
Since this is UB, failing the assertion is valid and the UB case should
be removed.
This commit removes the UB operation and removes the unnecessary
opencl_icd requirement in sampler.cpp.

Signed-off-by: Larsen, Steffen <[email protected]>
steffenlarsen added a commit to intel/llvm-test-suite that referenced this pull request Aug 24, 2022
The SYCL 2020 specification states that the instance of a moved SYCL
object is invalid, so any operations after a move exhibit undefined
behaviour. sampler.cpp moves a sampler before hashing the moved object.
In that case, the hasher will extract a nullptr implementation, which
with intel/llvm#6598 will fail an assertion.
Since this is UB, failing the assertion is valid and the UB case should
be removed.
This commit removes the UB operation and removes the unnecessary
opencl_icd requirement in sampler.cpp.

Signed-off-by: Larsen, Steffen <[email protected]>
@zahiraam zahiraam deleted the impl_branch branch August 25, 2022 19:01
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
The SYCL 2020 specification states that the instance of a moved SYCL
object is invalid, so any operations after a move exhibit undefined
behaviour. sampler.cpp moves a sampler before hashing the moved object.
In that case, the hasher will extract a nullptr implementation, which
with intel#6598 will fail an assertion.
Since this is UB, failing the assertion is valid and the UB case should
be removed.
This commit removes the UB operation and removes the unnecessary
opencl_icd requirement in sampler.cpp.

Signed-off-by: Larsen, Steffen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants