Simplification of capture mode usages in submit
/ parallel_for
calls
#1959
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR we simplify our code in the part of capture modes in
submit
/parallel_for
calls:Justification.
sycl::submit
always executed synchronously till the call ofparallel_for
inside.This mean that no reasons to capture
by value
any variables used only insidesubmit
call but NOT insideparallel_for
sycl::parallel_for
function always captures all variablesby copy
([=]
).This mean that inside lambda, passed into
sycl::parallel_for
call all references and so on will be in real new local copies of source variables.SYCL™ 2020 Specification (revision 9).
As described at 4.6.5. Queue class, All member functions of the queue class are synchronous and errors are handled by throwing synchronous SYCL exceptions. The
submit
member function synchronously invokes the provided command group function object (as described in Section 3.7.1.2) in the calling thread, thereby scheduling a command group for asynchronous execution. Any error in the submission of a command group is handled by throwing a synchronous SYCL exception. Any errors from the command group after it has been submitted are handled by passing asynchronous errors at specific times to an async_handler, as described in Section 4.13.Example:
Thanks to @dmitriy-sobolev for this reference to
sycl
documentation.