-
Notifications
You must be signed in to change notification settings - Fork 787
[Driver][SYCL] Enable early AOT abilities when creating objects #11130
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
Adds support for enabling the ability to perform a full device compilation and link. Use the -ftarget-device-link option when also compiling to object with -c. This will trigger the additional device linking steps to be performed after the device compilation is completed. Currently only supported for spir64_gen targets, as we rely on the addition of the -device <arg> values to differentiate the fat objects that are generated. Upon consumption of these new fat objects, the driver will scan for these unique binaries and instead of going through the device link, these binaries will be sent directly to the host link step to be added to the final executable. Performs some refactoring of the device link code, allowing for a common platform for compile and link to access.
clang/lib/Driver/Driver.cpp
Outdated
// for SYCL Native CPU, we just take the linked device | ||
// modules, lower them to an object file , and link it to the host | ||
// object file. | ||
auto *backendAct = C.MakeAction<BackendJobAction>( |
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.
here
clang/lib/Driver/Driver.cpp
Outdated
// object file. | ||
auto *backendAct = C.MakeAction<BackendJobAction>( | ||
FullDeviceLinkAction, types::TY_PP_Asm); | ||
auto *asmAct = |
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.
here
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.
Adding some tests would be helpful.
use spir64_gen_image as the arch/subarch for the image based bundles. This is used regardless of GPU device specified.
You can test this locally with the following command:git-clang-format --diff acd38b4393f37439b08b485c924be1c15e575033 26dd6793ddd087f1161d7abe8099651061b97b52 -- clang/test/Driver/sycl-early-device-link.cpp clang/include/clang/Driver/Action.h clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Gnu.cpp llvm/include/llvm/TargetParser/Triple.h llvm/lib/TargetParser/Triple.cpp View the diff from clang-format here.diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index cfc689a58452..5c4dafe8a0dd 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5857,17 +5857,18 @@ class OffloadingActionBuilder final {
using SYCLDeviceLibsList = SmallVector<DeviceLibOptInfo, 5>;
const SYCLDeviceLibsList sycl_device_wrapper_libs = {
- {"libsycl-crt", "libc"},
- {"libsycl-complex", "libm-fp32"},
- {"libsycl-complex-fp64", "libm-fp64"},
- {"libsycl-cmath", "libm-fp32"},
- {"libsycl-cmath-fp64", "libm-fp64"},
+ {"libsycl-crt", "libc"},
+ {"libsycl-complex", "libm-fp32"},
+ {"libsycl-complex-fp64", "libm-fp64"},
+ {"libsycl-cmath", "libm-fp32"},
+ {"libsycl-cmath-fp64", "libm-fp64"},
#if defined(_WIN32)
- {"libsycl-msvc-math", "libm-fp32"},
+ {"libsycl-msvc-math", "libm-fp32"},
#endif
- {"libsycl-imf", "libimf-fp32"},
- {"libsycl-imf-fp64", "libimf-fp64"},
- {"libsycl-imf-bf16", "libimf-bf16"}};
+ {"libsycl-imf", "libimf-fp32"},
+ {"libsycl-imf-fp64", "libimf-fp64"},
+ {"libsycl-imf-bf16", "libimf-bf16"}
+ };
// For AOT compilation, we need to link sycl_device_fallback_libs as
// default too.
const SYCLDeviceLibsList sycl_device_fallback_libs = {
|
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.
LGTM! Thanks for doing this and for answering all my questions!
I will provide my review tomorrow, Sorry for delay. |
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.
sycl/doc/design/* LGTM
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.
LGTM
@intel/dpcpp-doc-reviewers, could you take a look? |
Adds support for enabling the ability to perform a full device compilation and link. Use the -fno-sycl-rdc option when also compiling to object with -c. This will trigger the additional device linking steps to be performed after the device compilation is completed.
Currently only supported for AOT enabled targets for spir64.
Upon consumption of these new fat objects, the driver will scan for these unique binaries and instead of going through the device link, these binaries will be sent directly to the host link step to be added to the final executable. This is done by introducing a few triple architecture values to designate target images in the fat objects (spir64_gen_image, spir64_fpga_image, spir64_x86_64_image)
Performs some refactoring of the device link code, allowing for a common platform for compile and link to access.