-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL][NewOffloadModel] Update SYCL device library generation for new offloading model #20512
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][NewOffloadModel] Update SYCL device library generation for new offloading model #20512
Conversation
|
The modifications to set the new offloading model as default in this PR were directly copied from (#15121). These changes will be removed once CI confirms there are no regressions. |
8257fbd to
76e101f
Compare
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.
thanks for the PR! one higher level comment below
| set(bc_device_compile_opts -fsycl-device-only -fsycl-device-obj=llvmir) | ||
| set(obj-new-offload_device_compile_opts -fsycl -c --offload-new-driver | ||
| set(obj-old-offload_device_compile_opts -fsycl -c ${sycl_targets_opt} --no-offload-new-driver) | ||
| set(obj_device_compile_opts -fsycl -c --offload-new-driver |
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.
my worry here is that it seems this PR enables the new offload model by default for some but not all compilation modes, and since we are setting the default device library files to be the new offloading model (since we pass --offload-new-driver), i am not sure of those compilation modes using the old offload model will be able to use libdevice. the new offload model supports using old libdevice files, but i had to explicitly implement that to get it working and i don't think anyone did the opposite case since it wasn't expected to be be needed, but it's possible it works automagically. can you make sure the cases using the old offload model still work?
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.
Thank you for raising this concern! I tried compiling a few SYCL E2E tests using the old offload model (by passing --no-offload-new-driver to clang++). The compilation appears to work correctly. For the old offload model, I found that llvm-link is called on libsycl-xxx.bc, whereas in the new offload model, libsycl-xxx.o is linked via the clang-linker-wrapper.
To further verify, I will remove the changes in this PR that enable the new offloading model by default and rerun the tests to see if any failures will occur in CI.
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.
Sounds good, thanks!
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 it necessary to enable new offload model by default for some compilation modes to resolve the original problem that PR is trying to solve?
76e101f to
89b35d5
Compare
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.
It seems the change is causing CI to fail. Could you please fix CI?
| if (IsNewOffload) | ||
| // For new offload model, we use packaged .bc files. | ||
| LibSuffix = IsWindowsMSVCEnv ? ".new.obj" : ".new.o"; | ||
| LibSuffix = IsWindowsMSVCEnv ? ".obj" : ".o"; |
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.
so, before this PR, old offloading model used name.ext library name pattern and new offloading model used name.new.ext library name pattern.
After the change as far as I can see both old and new offloading model use name.ext library.
Or what am I missing?
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.
Thank you for pointing this out! Yes, you are right that before this PR, the old offloading model used name.ext and the new offloading model used name.new.ext. Currently, name.ext is built with the old offloading model and name.new.ext is built with the new offloading model. However, if we enable the new offloading model by default in the future, both name.ext and name.new.ext will be built with the new offloading model.
In this PR, we update name.ext to be built with the new offloading model, and we introduce name.old.ext which will be built with the old offloading model. As we can see from the testing so far, when we are compiling tests with the old offloading model and linking the name.ext (which is built with the new offloading model), the tests are working fine. However, we still want to keep name.old.ext in case users still want to interact with the old offloading model, such as in some of the tests where they want to extract the device code from the fat object file, which is only supported for the object file built with the old offloading model.
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.
So, why not keep the names as is, and when we enable new offloading model by default, just stop using name.new.ext?
| RUN: clang-offload-bundler -type=o -unbundle \ | ||
| RUN: -targets=sycl-spir64-unknown-unknown \ | ||
| RUN: -input=%libsycldevice_obj_dir/libsycl-fallback-cassert.o -output=%t.bc | ||
| RUN: -input=%libsycldevice_obj_dir/libsycl-fallback-cassert.old.o -output=%t.bc |
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 it necessary to do this renaming now? why not keep default offloading model used now without additional suffixes and new offloading model to keep using new suffixes?
| // >> ---- unbundle compiler wrapper and asan device objects | ||
| // RUN: clang-offload-bundler -type=o -targets=sycl-spir64-unknown-unknown -input=%sycl_static_libs_dir/libsycl-itt-compiler-wrappers%obj_ext -output=%t_compiler_wrappers.bc -unbundle | ||
| // RUN: %if linux %{ clang-offload-bundler -type=o -targets=sycl-spir64-unknown-unknown -input=%sycl_static_libs_dir/libsycl-asan%obj_ext -output=%t_asan.bc -unbundle %} | ||
|
|
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 think we need to keep existing E2E tests as is, without changes to make sure backward compatibility.
And if you want to add new tests for new offloading model, please add them to https://github.com/intel/llvm/tree/sycl/sycl/test-e2e/NewOffloadDriver
| bool IsNewOffload = C.getDriver().getUseNewOffloadingDriver(); | ||
| StringRef LibSuffix = ".bc"; | ||
| if (IsNewOffload) | ||
| // For new offload model, we use packaged .bc files. |
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.
Please update the comment since we now use object files and not bitcode files.
| bool IsNewOffload = C.getDriver().getUseNewOffloadingDriver(); | ||
| StringRef LibSuffix = ".bc"; | ||
| if (IsNewOffload) | ||
| // For new offload model, we use packaged .bc files. |
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.
Same comment as above.
|
After discussion with @YuriPlyakhin and @sarnex, we have decided that we will not change the naming of the device library (from 'name.new.o' to 'name.old.o') in this PR. Instead, we will add The renaming (from 'name.new.o' to 'name.old.o') and setting the default device library to be built with the new offloading model will happen at the same time when we enable the new offloading model to be the default in the future. There should also be no change made to the tests This PR will be closed and a new PR will be opened soon with the changes discussed above. |
This pull request refactors the SYCL device library build and end-to-end tests to support the new offloading model, while maintaining backward compatibility for the old offloading model, with the following key changes.
libsycl-itt-compiler-wrappers.o) is now compiled using the new offloading model, and the library ending with.new.o(such aslibsycl-itt-compiler-wrappers.new.o) has been renamed to.old.o(such aslibsycl-itt-compiler-wrappers.old.o), representing builds with the old offloading model. These changes are made inlibdevice/cmake/modules/SYCLLibdevice.cmake.sycl/test-e2e/Config/kernel_from_file.cppandsycl/test-e2e/SeparateCompile/test.cpphave been updated. The tests now validate both the new offloading model, and the backward compatibility for the old model (usingclang-offload-bundlerto extract device code from libraries).