Make sure Matrix::waitLocalTiles
actually consumes the tile wrappers immediately
#1257
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.
Together with pika-org/pika#1373, this should be at least another step towards avoiding yielding after calling
waitLocalTiles
. pika-org/pika#1373 made sure that the continuation that gets access to a wrapper, actually contains the last reference to the internal shared state and thus is able to release the next access as soon as that wrapper is released.This PR ensures that the wrapper is actually used by the continuation in
waitLocalTiles
. I had implementedwaitLocalTiles
wrongly in the sense thatdrop_value
does indeed ignore the value sent from the predecessor, but it takes the value by forwarding reference and thus doesn't actually consume the wrapper. Before this PR, whensync_wait
returns the last access is semantically "done", but the wrapper has not necessarily been released by that time. Most of the time this is good enough to guarantee that the next access is inline, but sometimes the wrapper will be released too late. By actually waiting for the wrapper(s) and taking them into the local function scope wheresync_wait
is called, we guarantee that the wrapper is released in the function scope.An alternative way to implement this would be to replace
drop_value
bythen([](auto){})
.drop_value
is effectivelythen([](auto&&){})
. The former consumes the wrapper in the continuation while the latter only takes a reference and releases the wrapper much later.Since CI is still using pika 0.30.1 and pika-org/pika#1373 is in 0.31.0 this PR alone won't get rid of issues in e.g.
test_bt_reduction_to_band
, but it's a necessary step.