-
Notifications
You must be signed in to change notification settings - Fork 787
[sycl-post-link] Split SYCL and ESIMD kernels into separate modules #3044
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
Conversation
This patch is a preparation for spliting ESIMD and SYCL kernels.
This patch is a preparation for spliting ESIMD and SYCL kernels.
For now this change doesn't have any effect on existing programs since we don't allow mixing SYCL and ESIMD kernels in one source or in one program. But this is an essential step towards this goal since ESIMD kernels require specific processing as opposed to usual SYCL kernels.
4f79b5d
to
147eb5f
Compare
std::string RetStr = Dir + sys::path::stem(OutputFilename).str() + "_"; | ||
if (IsEsimd) | ||
RetStr += "esimd_"; | ||
return RetStr + std::to_string(I) + Ext.str(); |
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.
Am I right that this filename change was only introduced to simplify debugging, i.e. there is no functional need for it?
I have a small concern that a number of functions were changed just to have this prefix added and it is kind of a non-generic solution (like what if we decided to add one more level of device code split for some other feature?)
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.
Before my change the code was split into modules and saved to files with the name derived from OutputFilename
plus sequential index, i.e. /path/to/file_01.bc
, /path/to/file_02.bc
, etc.
Now, when we split ESIMD modules we cannot overwrite already processed SYCL files, this is why we need to change the name of the ESIMD files. We could have:
`/path/to/file_01.bc` // sycl
`/path/to/file_02.bc` // sycl
`/path/to/file_esimd_01.bc` // esimd
`/path/to/file_esimd_02.bc` // esimd
or
`/path/to/file_01.bc` // sycl
`/path/to/file_02.bc` // sycl
`/path/to/file_03.bc` // esimd
`/path/to/file_04.bc` // esimd
I choose the first scheme, since, as you said, it will be easier to find ESIMD modules, and the names of the files do not affect functionality. But I'm OK to change if you think the second is better. However, I think we need to propagate the IsEsimd
flag (or other parameter) regardless of the naming scheme.
We can introduce a class that will keep the state. Then all the propagation will go away. But we can do that later in further patches.
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.
I choose the first scheme, since, as you said, it will be easier to find ESIMD modules, and the names of the files do not affect functionality. But I'm OK to change if you think the second is better.
I don't have a strong opinion here, so, the proposed way looks fine to me. We can hear from @kbobrovs here to have another opinion
However, I think we need to propagate the IsEsimd flag (or other parameter) regardless of the naming scheme.
Right, but from functional point of view it is only needed in processOneModule
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.
We can introduce a class that will keep the state. Then all the propagation will go away. But we can do that later in further patches.
Personally, I'm not a fun of such states, because it makes it harder to understand where particular value is came from and how the call graph looks like
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.
Current scheme with _esimd
suffix seems clearer to me. Users don't care, but devs will appreciate it.
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.
This change should probably be updated to ToT because of the conflict, but in general I don't have any objections, LGTM
llvm/test/tools/sycl-post-link/sycl-esimd/basic-sycl-esimd-split.ll
Outdated
Show resolved
Hide resolved
llvm/test/tools/sycl-post-link/sycl-esimd/sycl-esimd-split-per-kernel.ll
Outdated
Show resolved
Hide resolved
llvm/test/tools/sycl-post-link/sycl-esimd/sycl-esimd-split-per-source.ll
Outdated
Show resolved
Hide resolved
std::string RetStr = Dir + sys::path::stem(OutputFilename).str() + "_"; | ||
if (IsEsimd) | ||
RetStr += "esimd_"; | ||
return RetStr + std::to_string(I) + Ext.str(); |
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.
Current scheme with _esimd
suffix seems clearer to me. Users don't care, but devs will appreciate it.
llvm/test/tools/sycl-post-link/sycl-esimd/sycl-esimd-split-per-kernel.ll
Show resolved
Hide resolved
@DenisBakhvalov, please, resolve merge conflicts. |
1. Check call graph deps in all added tests. 2. Changed signature of makeResultFileName: replaced `bool IsEsimd` flag with `StringRef suffix`. 3. Added -split-esimd option to control SYCL-ESIMD splitting. 4. The new -split-esimd options is not compatible with -ir-output-only. 5. Added a test that checks that SYCL-ESIMD splitting doesn't happen when no '-split-esimd' option provided.
Done. |
@@ -712,13 +793,19 @@ int main(int argc, char **argv) { | |||
"This is a collection of utilities run on device code's LLVM IR before\n" | |||
"handing off to back-end for further compilation or emitting SPIRV.\n" | |||
"The utilities are:\n" | |||
"- SYCL and ESIMD kernels can be split into separate modules with\n" | |||
" '-split-esimd' option. The option has no effect when there is only\n" | |||
" one type of kernels in the input module.\n" |
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.
Suggest to add:
Functions unreachable from any kernel (including those marked as with "explicit SIMD" metadata) are dropped from the resulting module(s).
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.
Added
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.
LGTM
treating this as approval from @AlexeySachkov. No other objections - merging... |
For now, this change doesn't have any effect on existing programs since we don't allow mixing SYCL and ESIMD kernels in one source or in one program.
But this is an essential step towards allowing such a mix since ESIMD kernels require specific processing as opposed to usual SYCL kernels.
PLEASE, only review commit: 147eb5f
Patch (1/3): #3042
Patch (2/3): #3043
Patch (3/3): this PR