-
Notifications
You must be signed in to change notification settings - Fork 738
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][NVPTX] Create one bitcode library for NVPTX #15048
Conversation
Create one single bitcode library for NVPTX by compiling each libdev file into bitcode first, linking these together and running opt on them. Strip away metadata by reusing prepare_builtins from libclc. Remove NVPTX bundles from the libdev object files and remove any unbundling action spawned by the Clang driver for the SYCL toolchain when compiling for the NVPTX backend. Make the driver link against the single bitcode libraries for NVPTX for the SYCL toolchain when device library linkage is not excluded. Ensure that the clang tests check for the correctness of the new clang driver actions and check if the driver still links the device code against the itt device libraries when device library linkage has been excluded. Refactor SYCLLibdevice.cmake by creating functions and grouping e.g. the same compilation flags for a filetype together in one variable. Reuse these variables and call functions to remove redundancies.
@MartinWehking, why this change is done only for NVPTX target? Can't we make the same change for other targets as well? |
Hi @bader It is probably possible to copy the work for the SPIRV target. We encountered several issues with enabling it for AMD as well. |
I would like @jinge90 to review this and maybe share some thoughts on the discussions above, especially pertaining to doing this for SPIR-V. |
The libdevice cmake change looks good to me. |
That sounds like a reasonable concern. |
Ensure that when subsets of devicelibs are excluded or included by fno-sycl-device-lib or fsycl-device-lib, the correct libraries are linked. For -fsycl-device-lib this means that regardless of which libraries are specified, the full single devicelib for NVPTX will be used. For -fno-sycl-device-lib it means that its values will be ignored, unless it contains "all", in which case only internal libraries will be linked against. Fix an error when printing a warning that some device libraries have been ignored for -fno-sycl-device-lib
Check if device lib flags get treated correctly for NVPTX and that the linking actions for the correct device libraries are generated.
Ensure that devicelib--cuda.bc is never linked against, when -fno-sycl-devicle-lib contains the value "all". Fix formatting of comments + run lines.
ping @intel/dpcpp-cfe-reviewers @steffenlarsen given @jinge90 's input are you happy with this PR? It seems like it still makes sense for Nvidia and AMD but that we maybe shouldn't extend it to SPIR-V. But either way this also gives the CMake a much needed cleanup. |
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.
Let's do it! 👍
Co-authored-by: Michael Toguchi <michael.d.toguchi@intel.com>
ping @intel/llvm-gatekeepers to get this merged |
Create one single bitcode library for NVPTX by compiling each libdev file into
bitcode first, linking these together and running opt on them.
Strip away metadata by reusing prepare_builtins from libclc.
Remove NVPTX bundles from the libdev object files and remove any unbundling
action spawned by the Clang driver for the SYCL toolchain when compiling for the
NVPTX backend.
Make the driver link against the single bitcode libraries for NVPTX for the SYCL
toolchain when device library linkage is not excluded.
Ensure that the clang tests check for the correctness of the new clang driver
actions and check if the driver still links the device code against the itt
device libraries when device library linkage has been excluded.
Refactor SYCLLibdevice.cmake by creating functions and grouping e.g. the same
compilation flags for a filetype together in one variable. Reuse these variables
and call functions to remove redundancies.