Skip to content

[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

Merged
merged 26 commits into from
Oct 24, 2023

Conversation

mdtoguchi
Copy link
Contributor

@mdtoguchi mdtoguchi commented Sep 8, 2023

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.

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.
// 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>(
Copy link
Contributor

Choose a reason for hiding this comment

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

here

// object file.
auto *backendAct = C.MakeAction<BackendJobAction>(
FullDeviceLinkAction, types::TY_PP_Asm);
auto *asmAct =
Copy link
Contributor

Choose a reason for hiding this comment

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

here

Copy link
Contributor

@srividya-sundaram srividya-sundaram left a 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.

@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 3, 2023 18:47 — with GitHub Actions Inactive
@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 3, 2023 20:19 — with GitHub Actions Inactive
@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 3, 2023 22:16 — with GitHub Actions Inactive
@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 4, 2023 00:19 — with GitHub Actions Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

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 = {

Copy link
Contributor

@sarnex sarnex left a 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!

@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 12, 2023 19:37 — with GitHub Actions Inactive
@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 12, 2023 20:24 — with GitHub Actions Inactive
@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 12, 2023 22:02 — with GitHub Actions Inactive
@asudarsa
Copy link
Contributor

I will provide my review tomorrow, Sorry for delay.

Copy link
Contributor

@againull againull left a 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

Copy link
Contributor

@hchilama hchilama left a comment

Choose a reason for hiding this comment

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

LGTM

@mdtoguchi
Copy link
Contributor Author

@intel/dpcpp-doc-reviewers, could you take a look?

@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 24, 2023 00:11 — with GitHub Actions Inactive
@mdtoguchi mdtoguchi temporarily deployed to WindowsCILock October 24, 2023 01:44 — with GitHub Actions Inactive
@againull againull merged commit 6f24808 into intel:sycl Oct 24, 2023
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.

7 participants