Skip to content

[SYCL][NATIVECPU] Support multiple SYCL targets in the same compiler invocation #10495

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 131 commits into from
Aug 9, 2023

Conversation

PietroGhg
Copy link
Contributor

This PR adds support to multiple SYCL targets alongside native_cpu in the same compiler invocation (e.g. clang++ -fsycl -fsycl-targets=native_cpu,spir64 input.cpp). In order to implement this we had to make changes to multiple components, here is a quick overview:

  • Driver: changes in the Driver allow to correctly parse all the targets passed to -fsycl-targets (before we were just looking for native_cpu, ignoring the others). The Driver now also calls sycl-post-link and clang-offload-wrapper, performing a compilation flow more similar to the one used for other targets.
  • Sema: since the kernel name needs to be the same for all the SYCL targets, the change to the kernel name in Sema has been removed, and replaced with an LLVM Pass that gets run when lowering the device module (llvm/lib/SYCLLowerIR/RenameKernelSYCLNativeCPU.cpp).
  • Runtime: The definition for _pi_program in the Native CPU Plug-In now supports multiple kernels in one program, and the __SYCL_PI_DEVICE_BINARY_TARGET_NATIVE_CPU binary type has been added in order to identify kernels compiled for Native CPU.
  • clang-offload-wrapper: for Native CPU, the offload-wrapper doesn't bundle the device code in the host module, but instead produces an array containing function declarations that are resolved by the linker, see sycl/doc/design/SYCLNativeCPU.md for more information.

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.

esimd lgtm

Copy link
Contributor

@AlexeySachkov AlexeySachkov left a comment

Choose a reason for hiding this comment

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

A few comments, but overall LGTM

@uwedolinsky uwedolinsky temporarily deployed to aws August 1, 2023 18:16 — with GitHub Actions Inactive
@uwedolinsky uwedolinsky temporarily deployed to aws August 1, 2023 19:36 — with GitHub Actions Inactive
@uwedolinsky uwedolinsky temporarily deployed to aws August 2, 2023 14:02 — with GitHub Actions Inactive
@uwedolinsky uwedolinsky temporarily deployed to aws August 2, 2023 15:00 — with GitHub Actions Inactive
@uwedolinsky
Copy link
Contributor

Hello @intel/dpcpp-l0-pi-reviewers, please could you review this PR? Thank you!

@PietroGhg PietroGhg temporarily deployed to aws August 7, 2023 13:58 — with GitHub Actions Inactive
@PietroGhg PietroGhg temporarily deployed to aws August 7, 2023 15:29 — with GitHub Actions Inactive
@PietroGhg PietroGhg temporarily deployed to aws August 8, 2023 08:23 — with GitHub Actions Inactive
@PietroGhg PietroGhg temporarily deployed to aws August 8, 2023 12:28 — with GitHub Actions Inactive
Copy link
Contributor

@smaslov-intel smaslov-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@PietroGhg
Copy link
Contributor Author

@intel/llvm-gatekeepers this looks ready to be merged thank you :)

@dm-vodopyanov dm-vodopyanov merged commit aab5d74 into intel:sycl Aug 9, 2023
mdtoguchi pushed a commit to mdtoguchi/llvm that referenced this pull request Oct 18, 2023
…invocation (intel#10495)

This PR adds support to multiple SYCL targets alongside `native_cpu` in
the same compiler invocation (e.g. `clang++ -fsycl
-fsycl-targets=native_cpu,spir64 input.cpp`). In order to implement this
we had to make changes to multiple components, here is a quick overview:
* Driver: changes in the Driver allow to correctly parse all the targets
passed to `-fsycl-targets` (before we were just looking for
`native_cpu`, ignoring the others). The Driver now also calls
`sycl-post-link` and `clang-offload-wrapper`, performing a compilation
flow more similar to the one used for other targets.
* Sema: since the kernel name needs to be the same for all the SYCL
targets, the change to the kernel name in Sema has been removed, and
replaced with an LLVM Pass that gets run when lowering the device module
(`llvm/lib/SYCLLowerIR/RenameKernelSYCLNativeCPU.cpp`).
* Runtime: The definition for `_pi_program` in the Native CPU Plug-In
now supports multiple kernels in one program, and the
`__SYCL_PI_DEVICE_BINARY_TARGET_NATIVE_CPU` binary type has been added
in order to identify kernels compiled for Native CPU.
* clang-offload-wrapper: for Native CPU, the offload-wrapper doesn't
bundle the device code in the host module, but instead produces an array
containing function declarations that are resolved by the linker, see
`sycl/doc/design/SYCLNativeCPU.md` for more information.

---------

Co-authored-by: Uwe Dolinsky <uwe@codeplay.com>
Co-authored-by: Alexey Sachkov <alexey.sachkov@intel.com>
Co-authored-by: Steffen Larsen <steffen.larsen@intel.com>
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.

10 participants