Skip to content

[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

Merged
merged 7 commits into from
Jan 21, 2021

Conversation

DenisBakhvalov
Copy link
Contributor

@DenisBakhvalov DenisBakhvalov commented Jan 16, 2021

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

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.
Comment on lines 457 to 460
std::string RetStr = Dir + sys::path::stem(OutputFilename).str() + "_";
if (IsEsimd)
RetStr += "esimd_";
return RetStr + std::to_string(I) + Ext.str();
Copy link
Contributor

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?)

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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.

AlexeySachkov
AlexeySachkov previously approved these changes Jan 19, 2021
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.

This change should probably be updated to ToT because of the conflict, but in general I don't have any objections, LGTM

Comment on lines 457 to 460
std::string RetStr = Dir + sys::path::stem(OutputFilename).str() + "_";
if (IsEsimd)
RetStr += "esimd_";
return RetStr + std::to_string(I) + Ext.str();
Copy link
Contributor

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.

@bader
Copy link
Contributor

bader commented Jan 20, 2021

@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.
@DenisBakhvalov
Copy link
Contributor Author

@DenisBakhvalov, please, resolve merge conflicts.

Done.

@DenisBakhvalov
Copy link
Contributor Author

@kbobrovs, thanks for the review. I fixed your comments in 0b6c9c7. Please review.

@@ -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"
Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Copy link
Contributor

@kbobrovs kbobrovs left a comment

Choose a reason for hiding this comment

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

LGTM

@kbobrovs
Copy link
Contributor

This change should probably be updated to ToT because of the conflict, but in general I don't have any objections, LGTM

treating this as approval from @AlexeySachkov. No other objections - merging...

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.

4 participants