Skip to content

[SYCL][Fusion] Interface with kernel fusion JIT #7831

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 1 commit into from
Jan 13, 2023

Conversation

sommerlukas
Copy link
Contributor

This is the fifth patch in a series of patches to add an implementation of the kernel fusion extension. We have split the implementation into multiple patches to make them more easy to review.

This patch connects the JIT compiler for kernel fusion (sycl-fusion) with the SYCL runtime.

  • Enable the feature by default and add an option to configure.py to disable it.
  • Link the runtime against the JIT compiler library as a shared library.
  • Add logic to retrieve binaries (SPIR-V) and other information (e.g., accessors) from the SYCL RT and invoke the JIT compiler.
  • Representation to store binaries (SPIR-V) returned by JIT compiler in memory for use as PI device binaries.

The integration of the JIT compiler into the SYCL RT is described in this design document.

Signed-off-by: Lukas Sommer [email protected]

@sommerlukas
Copy link
Contributor Author

sommerlukas commented Dec 19, 2022

The corresponding additions of tests to the LLVM test-suite are currently still a draft PR: sommerlukas/llvm-test-suite#1, because they are blocked by intel/llvm-test-suite#1416, which still requires reviews.

@sommerlukas sommerlukas force-pushed the kernel-fusion/fifth-patch branch from 86d9cb2 to 0b42d32 Compare December 19, 2022 13:42
@sommerlukas
Copy link
Contributor Author

I also tried adding a unit test for the complete_fusion route of the scheduler integration, as discussed with @sergey-semenov here.

Unfortunately, it was not possible to test this as an unit test. To completely test the route using complete_fusion, we would need the JIT compiler to successfully generate a fused kernel. However, the unit tests are generally not compiled with a SYCL-enabled compiler, so no SPIR-V for the kernels might be available to use as input to the JIT compiler.

However, various test cases using the complete_fusion route and the integration into the SYCL runtime scheduler are added as SYCL application tests in sommerlukas/llvm-test-suite#1, so this scenario is sufficiently covered by tests.

@sommerlukas
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1416

Copy link
Contributor

@Naghasan Naghasan left a comment

Choose a reason for hiding this comment

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

LGTM

@dm-vodopyanov
Copy link
Contributor

/summary:run

@sommerlukas sommerlukas force-pushed the kernel-fusion/fifth-patch branch from dfd2fd8 to e62aa6e Compare January 6, 2023 07:12
@sommerlukas
Copy link
Contributor Author

I rebased this PR and explicitly disabled kernel fusion on Windows, to avoid breaking the post-commit Windows CI while we work on finalizing Windows support.

The updated PR also addresses an issue around symbol visibility that was causing problems with the Intel GPU driver.

@sommerlukas sommerlukas temporarily deployed to aws January 6, 2023 07:37 — with GitHub Actions Inactive
@sommerlukas sommerlukas temporarily deployed to aws January 6, 2023 08:07 — with GitHub Actions Inactive
@bader
Copy link
Contributor

bader commented Jan 6, 2023

/testwin

@sommerlukas sommerlukas force-pushed the kernel-fusion/fifth-patch branch from e62aa6e to 8c71652 Compare January 12, 2023 08:04
@sommerlukas sommerlukas force-pushed the kernel-fusion/fifth-patch branch from 8c71652 to 0e2701f Compare January 12, 2023 08:24
@sommerlukas sommerlukas requested a review from bader January 12, 2023 10:47
@sommerlukas
Copy link
Contributor Author

Thanks for the feedback @dm-vodopyanov and @bader!

I addressed your comments in the latest version.

@sommerlukas sommerlukas temporarily deployed to aws January 12, 2023 11:55 — with GitHub Actions Inactive
@sommerlukas sommerlukas temporarily deployed to aws January 12, 2023 16:05 — with GitHub Actions Inactive
@sommerlukas
Copy link
Contributor Author

Thanks for the approval!

I'm not authorized to merge this, can someone of @bader or @intel/llvm-gatekeepers merge this please?

@steffenlarsen steffenlarsen merged commit 5d7e86d into intel:sycl Jan 13, 2023
Comment on lines +12 to +17
if(WIN32)
message(WARNING "Kernel fusion not yet supported on Windows")
else(WIN32)
add_subdirectory(jit-compiler)
add_subdirectory(passes)
add_subdirectory(test)
Copy link
Contributor

Choose a reason for hiding this comment

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

@sommerlukas, unfortunately, compilation of jit-compiler with clang (XCode compiler to be precise) fails.

See https://github.com/intel/llvm/actions/runs/3910984924/jobs/6683827601.

/Users/runner/work/llvm/llvm/src/llvm/include/llvm/Support/Casting.h:280:45: error: unused parameter 'f' [-Werror,-Wunused-parameter]
  static inline bool isPossible(const From &f) { return true; }
                                            ^
/Users/runner/work/llvm/llvm/src/llvm/include/llvm/Support/Casting.h:604:41: error: unused parameter 't' [-Werror,-Wunused-parameter]
  static inline bool isPresent(const T &t) { return true; }
                                        ^
2 errors generated.

It's a bit surprising, but it looks like LLVM is less strict on enforcing "no warnings" policy.
I think we should avoid mis-compilations due to errors in external code like this.
To be honest, I'm sure how did we end-up with enabling -Werror for jit-compiler project. I know that we enabled it for sycl project by setting SYCL_ENABLE_WERROR CMake variable, but it should not impact jit-compiler. Could you investigate, please?

Copy link
Contributor Author

@sommerlukas sommerlukas Jan 16, 2023

Choose a reason for hiding this comment

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

Hi @bader,

thanks for reporting this.

The file which causes this error is jit_compiler.cpp, which is not part of sycl-fusion (i.e., the JIT compiler), but sycl itself (lives in sycl/source/detail) and connects the SYCL runtime to the JIT compiler. As it is compiled as part of the SYCL runtime, I think it is expected that it is compiled with -Werror if SYCL_ENABLE_WERROR is set.

The warnings (which then become errors with -Werror) are caused by including LLVMContext.h in JITContext.h, which in turn is included by jit_compiler.cpp. I'll look into how we can avoid including LLVMContext.h here by using an opaque pointer or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bader: I've opened #8017 to address this issue.

With the fix from this PR, I'm able to compile with SYCL_ENABLE_WERROR=ON in my local build (Linux, Clang 10).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm able to compile with SYCL_ENABLE_WERROR=ON in my local build (Linux, Clang 10).

Were you able to reproduce the problem before the fix with your local build (i.e. Linux, Clang 10)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, with SYCL_ENABLE_WERROR=ON, my local build failed with the same error message before implementing this fix.

steffenlarsen pushed a commit to intel/llvm-test-suite that referenced this pull request Jan 27, 2023
Test different scenarios for kernel fusion, including creation of the fused kernel by the JIT compiler and performance optimizations such as dataflow internalization.

Automatically detect availability of the kernel fusion extension in the DPC++ build in `lit.cfg.py` and make it available for `REQUIRES` clauses.

Spec: intel/llvm#7098
Implementation: intel/llvm#7831

Signed-off-by: Lukas Sommer <[email protected]>
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Feb 23, 2023
Test different scenarios for kernel fusion, including creation of the fused kernel by the JIT compiler and performance optimizations such as dataflow internalization.

Automatically detect availability of the kernel fusion extension in the DPC++ build in `lit.cfg.py` and make it available for `REQUIRES` clauses.

Spec: intel#7098
Implementation: intel#7831

Signed-off-by: Lukas Sommer <[email protected]>
aelovikov-intel pushed a commit to aelovikov-intel/llvm that referenced this pull request Mar 27, 2023
…uite#1535)

Test different scenarios for kernel fusion, including creation of the fused kernel by the JIT compiler and performance optimizations such as dataflow internalization.

Automatically detect availability of the kernel fusion extension in the DPC++ build in `lit.cfg.py` and make it available for `REQUIRES` clauses.

Spec: intel#7098
Implementation: intel#7831

Signed-off-by: Lukas Sommer <[email protected]>
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.

6 participants