Skip to content

[SYCL] Separate jobs in sycl-post-link tool #854

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 5 commits into from
Nov 29, 2019

Conversation

Fznamznon
Copy link
Contributor

Clang driver will invoke sycl-post-link twice: one time for IR module
split and one time for entries list generation.
This patch makes possible do not perform same job twice in this case.

Signed-off-by: Mariya Podchishchaeva [email protected]

@Fznamznon Fznamznon requested a review from kbobrovs November 20, 2019 15:33
kbobrovs
kbobrovs previously approved these changes Nov 26, 2019
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, with minor request


if (BaseOutputFilename == "-")
BaseOutputFilename = "a.out";

saveResults(ResultModules, ResultSymbolsLists);
if (PerformSplit) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please add a comment that the default usage model is that the tool is called twice with the same inputs because clang does not support actions with multiple outputs, hence this workaround with ir/txt generation splitting. It should not bring much extra overhead because parseIRFile and collectKernelsSet are small (would be good to estimate) compared to either of

    splitModule(*M.get(), GlobalsSet, ResultModules);
    saveResultModules(ResultModules);

and

   collectSymbolsLists(GlobalsSet, ResultSymbolsLists);
   saveResultSymbolsLists(ResultSymbolsLists);

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.

std::vector<std::string> &ResSymbolsLists) {
for (auto &It : KernelsSet) {
std::string SymbolsList;
for (auto &F : It.second) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically it is a reduction algorithm such as std::accumulate...
Then why not just declaring SymbolsList to be a Twine to avoid the string conversions back-and-forth?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. According to LLVM docs, Twine is a temporary object and shouldn't be stored. I use the SymbolsList next...
https://llvm.org/doxygen/classllvm_1_1Twine.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @Fznamznon. += can't be done on Twines, AFAIK.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, it looks like the Twine API is quite lower level. Sorry for the noise. :-(

kbobrovs
kbobrovs previously approved these changes Nov 27, 2019
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

// Input parameter KernelsSet is a map containing groups of kernels with same
// values in the sycl-module-id attribute.
// ResSymbolsLists vector is output parameter.
// Collects set of kernel names for each group of kernels.
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 not what does 'collects' mean here, but I looks like this function converts std::map<std::string, std::vector<Function *>> into std::vectorstd::string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to improve the comment.

Clang driver will invoke sycl-post-link twice: one time for IR module
split and one time for entries list generation.
This patch makes possible do not perform same job twice in this case.

Signed-off-by: Mariya Podchishchaeva <[email protected]>
Signed-off-by: Mariya Podchishchaeva <[email protected]>
Signed-off-by: Mariya Podchishchaeva <[email protected]>
Signed-off-by: Mariya Podchishchaeva <[email protected]>
@bader bader merged commit 160684d into intel:sycl Nov 29, 2019
for (size_t I = 0; I < ResModules.size(); ++I) {
std::error_code EC;
std::string CurOutFileName = BaseOutputFilename + "_" +
std::to_string(NumOfFile) +
std::string CurOutFileName = BaseOutputFilename + "_" + std::to_string(I) +
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an issue if the user is compiling toto.cpp and toto_0.cpp at the same time?
I guess it would be in 2 different temporary directories and thus no possible conflict?

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