Skip to content

[Driver][SYCL][New offload] Support external host compiler #19505

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 2 commits into from
Jul 18, 2025

Conversation

mdtoguchi
Copy link
Contributor

Use of -fsycl-host-compiler allows for users to use an external compiler to perform the host compilation when performing offload builds. The new model has the expectation for the device 'object' to be embedded within the host object via the clang-offload-packager. These fat objects are consumed by the clang-linker-wrapper.

External host compilers do not have the ability to embed the device binary when creating the host object. Fortunately, the clang-linker-wrapper allows for consumption of bundled fat objects.

Update the driver when using -fsycl-host-compiler and the new offloading model to generate bundled files instead of embedded objects. This support is for object generation only at this time. Preprocessing and assembly file intermediates are not yet supported.

Use of -fsycl-host-compiler allows for users to use an external compiler
to perform the host compilation when performing offload builds.  The new
model has the expectation for the device 'object' to be embedded within
the host object via the `clang-offload-packager`.  These fat objects are
consumed by the `clang-linker-wrapper`.

External host compilers do not have the ability to embed the device
binary when creating the host object.  Fortunately, the
`clang-linker-wrapper` allows for consumption of bundled fat objects.

Update the driver when using -fsycl-host-compiler and the new offloading
model to generate bundled files instead of embedded objects.  This
support is for object generation only at this time.  Preprocessing and
assembly file intermediates are not yet supported.
@mdtoguchi mdtoguchi requested a review from a team as a code owner July 17, 2025 17:37
@mdtoguchi mdtoguchi requested a review from bader July 17, 2025 17:38
@bader bader merged commit abbba55 into intel:sycl Jul 18, 2025
25 checks passed
@@ -7758,9 +7758,17 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
return HostAction;
}

// For SYCL offloading with -fsycl-host-compiler enabled, we do not have the
// ability to embed the packaged file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you share info on why we do not have the ability to embed the packaged file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The clang based compiler has the ability to embed external binaries via the -fembed-offload-object option. This occurs when generating the host object. When we are using a 3rd party compiler to create the host object, there is no way to embed the device object into it during compile time, so we are using bundles instead (i.e. the old model fat object)

if (!(isa<CompileJobAction>(HostAction) ||
// preprocessing only ignore embedding. When needing to do bundling for
// SYCL, allow the building of offloading actions to add the device side to
// the bundle.
Copy link
Contributor

Choose a reason for hiding this comment

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

When needing to do bundling for
// SYCL, allow the building of offloading actions to add the device side to
// the bundle.

Can you elaborate what this means?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The device side actions are created below this. Typical compilations only need to go through this section when we know the device compilations are going to be packaged together. When using -fsycl-host-compiler, we need for these actions to occur beyond the IR stage of the host compilation, allowing the bundle call to contain the host object and the generated device binary.

// Tests the abilities involved with using an external host compiler
// with the new offload model.

/// Enabling with -fsycl-host-compiler
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is not descriptive. What are we enabling here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just enabling the compilation flow with -fsycl-host-compiler and testing the fundamental tool calls when the option is used.

@mdtoguchi mdtoguchi deleted the new-model-host-comp branch July 18, 2025 16:03
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.

4 participants