-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL][RTC] Preliminary support for ESIMD kernels #16222
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
Changes from 2 commits
7d97996
89098b4
7ed02b0
fd7d901
78bc138
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| //===------------- ESIMD.cpp - Driver for ESIMD lowering ------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "ESIMD.h" | ||
|
|
||
| #include "llvm/Analysis/CGSCCPassManager.h" | ||
| #include "llvm/Analysis/LoopAnalysisManager.h" | ||
| #include "llvm/GenXIntrinsics/GenXSPIRVWriterAdaptor.h" | ||
| #include "llvm/IR/Module.h" | ||
| #include "llvm/IR/PassManager.h" | ||
| #include "llvm/Passes/PassBuilder.h" | ||
| #include "llvm/SYCLLowerIR/ESIMD/LowerESIMD.h" | ||
| #include "llvm/Transforms/InstCombine/InstCombine.h" | ||
| #include "llvm/Transforms/Scalar/DCE.h" | ||
| #include "llvm/Transforms/Scalar/EarlyCSE.h" | ||
| #include "llvm/Transforms/Scalar/SROA.h" | ||
|
|
||
| using namespace llvm; | ||
|
|
||
| using string_vector = std::vector<std::string>; | ||
|
|
||
| // When ESIMD code was separated from the regular SYCL code, | ||
| // we can safely process ESIMD part. | ||
| void jit_compiler::lowerEsimdConstructs(module_split::ModuleDesc &MD, | ||
| bool PerformOpts) { | ||
| LoopAnalysisManager LAM; | ||
| CGSCCAnalysisManager CGAM; | ||
| FunctionAnalysisManager FAM; | ||
| ModuleAnalysisManager MAM; | ||
|
|
||
| PassBuilder PB; | ||
| PB.registerModuleAnalyses(MAM); | ||
| PB.registerCGSCCAnalyses(CGAM); | ||
| PB.registerFunctionAnalyses(FAM); | ||
| PB.registerLoopAnalyses(LAM); | ||
| PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); | ||
|
|
||
| ModulePassManager MPM; | ||
| MPM.addPass(SYCLLowerESIMDPass(/*ModuleContainsScalar=*/false)); | ||
|
|
||
| if (PerformOpts) { | ||
| FunctionPassManager FPM; | ||
| FPM.addPass(SROAPass(SROAOptions::ModifyCFG)); | ||
| MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); | ||
| } | ||
| MPM.addPass(ESIMDOptimizeVecArgCallConvPass{}); | ||
| FunctionPassManager MainFPM; | ||
| MainFPM.addPass(ESIMDLowerLoadStorePass{}); | ||
|
|
||
| if (!PerformOpts) { | ||
|
||
| MainFPM.addPass(SROAPass(SROAOptions::ModifyCFG)); | ||
| MainFPM.addPass(EarlyCSEPass(true)); | ||
| MainFPM.addPass(InstCombinePass{}); | ||
| MainFPM.addPass(DCEPass{}); | ||
| // TODO: maybe remove some passes below that don't affect code quality | ||
| MainFPM.addPass(SROAPass(SROAOptions::ModifyCFG)); | ||
| MainFPM.addPass(EarlyCSEPass(true)); | ||
| MainFPM.addPass(InstCombinePass{}); | ||
| MainFPM.addPass(DCEPass{}); | ||
| } | ||
| MPM.addPass(ESIMDLowerSLMReservationCalls{}); | ||
| MPM.addPass(createModuleToFunctionPassAdaptor(std::move(MainFPM))); | ||
| MPM.addPass(GenXSPIRVWriterAdaptor(/*RewriteTypes=*/true, | ||
| /*RewriteSingleElementVectorsIn*/ false)); | ||
| // GenXSPIRVWriterAdaptor pass replaced some functions with "rewritten" | ||
| // versions so the entry point table must be rebuilt. | ||
| // TODO Change entry point search to analysis? | ||
| std::vector<std::string> Names; | ||
| MD.saveEntryPointNames(Names); | ||
| MPM.run(MD.getModule(), MAM); | ||
| MD.rebuildEntryPoints(Names); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| //===-------------- ESIMD.h - Driver for ESIMD lowering -------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef SYCL_JIT_COMPILER_RTC_ESIMD_H | ||
| #define SYCL_JIT_COMPILER_RTC_ESIMD_H | ||
|
|
||
| #include "llvm/SYCLLowerIR/ModuleSplitter.h" | ||
|
|
||
| namespace jit_compiler { | ||
|
|
||
| // Runs a pass pipeline to lower ESIMD constructs on the given split model, | ||
| // which may only contain ESIMD entrypoints. This is a copy of the similar | ||
|
||
| // function in `sycl-post-link`. | ||
| void lowerEsimdConstructs(llvm::module_split::ModuleDesc &MD, bool PerformOpts); | ||
|
|
||
| } // namespace jit_compiler | ||
|
|
||
| #endif // SYCL_JIT_COMPILER_RTC_ESIMD_H | ||
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.
How would it be deactivated? Through a user option?
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.
The driver would deactivate it (i.e. not pass
-lower-esimdtosycl-post-link) in the IR-only output mode, which is only relevant for spec constant processing IIUC. Otherwise it doesn't seem to be influenced by a user-option. I updated the comment to reflect this.