Skip to content

[SYCL] Enable parallel execution of llvm-foreach commands under an option #4360

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 11 commits into from
Sep 8, 2021

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Aug 17, 2021

This improvement should speed up toolchain execution by launching underlying llvm-foreach commands in parallel.
The feature is available under --jobs/-j option that should be passed to the command line of llvm-foreach.

…tion

This improvement should speed up toolchain execution by launching underlying
llvm-foreach commands in parallel.
The feature can be enabled by passing '--parallel-exec' to the command line of
llvm-foreach.
@vmaksimo vmaksimo force-pushed the foreach_parallel_exec branch from 41dc82c to 535fb60 Compare August 19, 2021 15:26
@vmaksimo
Copy link
Contributor Author

/summary:run

continue;
}
if (WaitResult.ReturnCode != 0) {
errs() << "llvm-foreach: " << ErrMsg << '\n';
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, we should have launched command in the error message so it could be launched standalone to debug it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! We should maintain a map with the process id and the executed command (didn't find a way to get this info just from the process id) to support this with the parallel execution. I'll do it in a separate PR after this one is merged.

@vmaksimo
Copy link
Contributor Author

@AlexeySachkov thanks a lot for the review! I'll publish a patch with applied changes soon.

Co-authored-by: Alexey Sachkov <alexey.sachkov@intel.com>
@AlexeySachkov AlexeySachkov marked this pull request as ready for review September 1, 2021 12:20
@AlexeySachkov
Copy link
Contributor

AlexeySachkov commented Sep 1, 2021

@kbobrovs, @mdtoguchi : FYI. Note: for now we do not yet introduce any way of how to use this new functionality in SYCL/DPC++ toolchain, because we haven't yet settled down on how to properly document it and when to recommend for our users

Res = checkIfJobsAreFinished(JobsSubmitted, /*BlockingWait*/ false);

JobsSubmitted.emplace_back(sys::ExecuteNoWait(
Prog, Args, /*Env=*/None, /*Redirects=*/None, /*MemoryLimit=*/0));
Copy link
Contributor

Choose a reason for hiding this comment

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

If Res above is not zero, new jobs should not probably be started. Instead, all running could be killed and the tool would just exit with non-zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's a good thought, but it was done on purpose in c69a311:

"we also want to allow for the compilation to continue so the user can use the generated binary knowing the timing issue as stated.").

I believe I have a bug here (should not assign the result to Res if it was successful), I'll apply the fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

"we also want to allow for the compilation to continue so the user can use the generated binary knowing the timing issue as stated."

checkIfJobsAreFinished may return non-zero for a variety of reasons, not only due to a timeout. In fact timeout is not even possible, AFAICS, as SecondsToWait for sys::Wait is 0. So I believe the most likely reason for checkIfJobsAreFinished non-zero return is some error during tool execution, in which case the results will be discarded, and it does not seem to make sense to run any other tools after that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest that we discuss that matter separately and apply some changes (if needed) through a separate PR: apparently there was a decision to not to stop submitting further jobs if one of them failed when we executed them in serial manner. It is not clear to me why we shouldn't follow the same logic for parallel execution.

Submitting further jobs after the first failed also allows us to detect all issues in all submitted jobs and not just in the first one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Submitting further jobs after the first failed also allows us to detect all issues in all submitted jobs and not just in the first one.

that does not seem right to me, and can be resource-costly approach. All jobs in a llvm-foreach batch are similar and in most cases they will fail for the same reason, I believe.

@dm-vodopyanov
Copy link
Contributor

@vmaksimo PR has some unresolved threads. Is there any additional work expected in this PR?

@bader bader requested review from kbobrovs and Fznamznon September 8, 2021 10:53
@vmaksimo
Copy link
Contributor Author

vmaksimo commented Sep 8, 2021

@vmaksimo PR has some unresolved threads. Is there any additional work expected in this PR?

@dm-vodopyanov I believe there is no more work expected - all unresolved discussions can be addressed in separate PRs.

@dm-vodopyanov
Copy link
Contributor

@vmaksimo PR has some unresolved threads. Is there any additional work expected in this PR?

@dm-vodopyanov I believe there is no more work expected - all unresolved discussions can be addressed in separate PRs.

Thanks

@dm-vodopyanov dm-vodopyanov merged commit d6bf2b6 into intel:sycl Sep 8, 2021
DoyleLi pushed a commit to DoyleLi/intel_llvm that referenced this pull request Sep 13, 2021
…tion (intel#4360)

This improvement should speed up toolchain execution by launching underlying llvm-foreach commands in parallel.
The feature is available under `--jobs`/`-j` option that should be passed to the command line of llvm-foreach.
AGindinson pushed a commit to AlexeySachkov/llvm that referenced this pull request Sep 14, 2021
After intel#4360 extended `llvm-foreach`
with an option to specify the desired number of parallel jobs, expose
this functionality to the DPC++ compiler users.

Co-authored-by: Alexey Sachkov <alexey.sachkov@intel.com>
Co-authored-by: Artem Gindinson <artem.gindinson@intel.com>
bader pushed a commit that referenced this pull request Sep 22, 2021
…ver option (#4543)

After #4360 extended `llvm-foreach`
with an option to specify the desired number of parallel jobs, expose
this functionality to the DPC++ compiler users.

Co-authored-by: Alexey Sachkov <alexey.sachkov@intel.com>
Co-authored-by: Artem Gindinson <artem.gindinson@intel.com>
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.

5 participants