[SYCL][NewOffloadModel] Refactor SYCL pipeline in clang-linker-wrapper#22153
[SYCL][NewOffloadModel] Refactor SYCL pipeline in clang-linker-wrapper#22153maksimsab wants to merge 2 commits into
Conversation
Extract SYCL offloading steps into named functions within the sycl namespace: runSYCLOffloadingPipeline, postLinkProcessModule, compileAndBundle and compileSYCLDevice. SYCL modifications of linkDevice function has been extracted to the dedicated function - compileSYCLDevice. Revert linkDevice function to its upstream state. Side effect of this revert: hipspv tests get resolved. Related tracker: CMPLRLLVM-73247 Functions containerizeRawImage and writeOffloadFile are moved so that their location corresponds to the upstream version.
|
Note: this refactoring is done in scope of the adding the support for |
| /// For spir[v]{32,64} performs SPIRV translation (JIT case) + possible AOT | ||
| /// compilation (Intel CPU/GPU). | ||
| Expected<StringRef> | ||
| compileSYCLDevice(ArrayRef<StringRef> InputFiles, const ArgList &Args, |
There was a problem hiding this comment.
Given this is a departure for linkDevice, should this be named to linkSYCLDevice instead? From a overall compilation standpoint, I see 'compile device' as the device compilation step that is performed earlier and not done during link.
There was a problem hiding this comment.
There is no actual linking happening for SYCL case. The input is always 1 file:
https://github.com/intel/llvm/pull/22153/changes#diff-f7dc51acede945c7c8481147e773e9c09230a93b937bee9eab08ee52826cfa8eR1869
So, the main functionality here is either invoke clang's backend for nvptx, amdgcn or invoke SPIRV translator + possible aot compilation.
There was a problem hiding this comment.
There's lots of different things going on, so maybe a more generic term like processSYCLDevice?
YuriPlyakhin
left a comment
There was a problem hiding this comment.
quite a lot of CI failed. Is it caused by this patch?
| case Triple::native_cpu: | ||
| if (IsSYCLKind) | ||
| return generic::clang(InputFiles, Args, IsSYCLKind); | ||
| return generic::clang(InputFiles, Args, /*IsSYCLKind*/ true); |
There was a problem hiding this comment.
now handling looks same as case Triple::amdgcn, can we just add one more case there, instead of duplicating the same line here?
| default: | ||
| return createStringError(Triple.getArchName() + | ||
| " linking is not supported other than for SYCL"); | ||
| " linking is not supported"); |
There was a problem hiding this comment.
The method is called compileSYCLDevice, yet the error message says linking. Should the error message be updated?
| } | ||
|
|
||
| /// Function invokes device compilation and bundling for NVPTX and AMDGCN cases. | ||
| Expected<StringRef> compileDeviceAndBundle(StringRef ModuleFilePath, |
There was a problem hiding this comment.
Comment says, this one is specific for NVPTX and AMDGCN, while function name is generic. What is correct: comment or function name? something needs to be updated.
| /// given | ||
| /// \p WrappedOutputCallback). |
There was a problem hiding this comment.
| /// given | |
| /// \p WrappedOutputCallback). | |
| /// given \p WrappedOutputCallback). |
| SmallVector<StringRef> InputFilesSYCL = {ModuleFilePath}; | ||
| Expected<std::vector<module_split::SplitModule>> SplitModulesOrErr = | ||
| UseSYCLPostLinkTool | ||
| ? sycl::runSYCLPostLinkTool(InputFilesSYCL, LinkerArgs, |
There was a problem hiding this comment.
just curious, what's still missing in PostLinkLibrary, that we have to call PostLinkTool?
| } | ||
|
|
||
| // TODO: Take into account Arch values considered as JIT: "native", | ||
| // "spir64", "spir", "spirv32" and "spirv64" for SPIR targets. |
There was a problem hiding this comment.
| // "spir64", "spir", "spirv32" and "spirv64" for SPIR targets. | |
| // "spir64", "spir", "spirv32" and "spirv64" for SPIR and SPIR-V targets. |
thank you for aligning the code to upstream! |
| bool IsJIT = | ||
| Triple.isSPIROrSPIRV() && Triple.getSubArch() == llvm::Triple::NoSubArch; | ||
| if (IsJIT) | ||
| std::for_each(SplitModules.begin(), SplitModules.end(), |
There was a problem hiding this comment.
Not a comment, but a question to help with my understanding:
In the old code, CompileOptions/LinkOptions are set inside the loop after the compile call. New code sets them before the compile (compileDeviceAndBundle). Is this an intentional ordering shift?
| } | ||
|
|
||
| /// Function invokes device compilation and bundling for NVPTX and AMDGCN cases. | ||
| Expected<StringRef> compileDeviceAndBundle(StringRef ModuleFilePath, |
There was a problem hiding this comment.
This function is only called from postLinkProcessModule. Should this be marked as 'static'?
| case Triple::aarch64_be: | ||
| case Triple::ppc64: | ||
| case Triple::ppc64le: | ||
| case Triple::spirv64: |
There was a problem hiding this comment.
L1830 handles SPIRV64 for SYCL offload, what is this SPIRV64 for? Non SYCL offload kind?
Extract SYCL offloading steps into named functions within the sycl namespace: runSYCLOffloadingPipeline, postLinkProcessModule, compileAndBundle and compileSYCLDevice.
SYCL modifications of linkDevice function has been extracted to the dedicated function - compileSYCLDevice.
Revert linkDevice function to its upstream state. Side effect of this revert: hipspv tests get resolved. Related tracker: CMPLRLLVM-73247
Functions containerizeRawImage and writeOffloadFile are moved so that their location corresponds to the upstream version.