You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parallel_for_each writes to the elements in the zipped vector and matches the outcome of std::ranges::for_each.
TBB should be "smarter" about the range it's passed, the core issue seems to be what is described in this StackOverflow answer: https://stackoverflow.com/a/79451943/256138
Note the above example is simple, and the zip_view is passed directly to tbb::parallel_for_each. This case, as described in the comments to that SO answer, can be rewritten to function correctly with a proper wrapper. Unfortunately that inhibits further "range" operations such as std::views::filter, e.g.
Which may also change the range/view type that TBB sees in some way (although piping through std::views::all did nothing beneficial to the original issue.
Steps To Reproduce
See code above.
The text was updated successfully, but these errors were encountered:
rubenvb
changed the title
Unexpected result with zip_view and parallel_for_each
Unexpected result with read/write zip_view and parallel_for_each
Feb 20, 2025
Prior to oneTBB 2021.12, parallel_for_each contained an issue while working with C++20 iterators (including iterators of ranges).
It was fixed by de0a3a6
Consider updating the TBB version you use to at least oneTBB 2021.12 to get the fix.
I have tried locally and it fixed the code snippet you provided.
Summary
parallel_for_each gives a different result than std::ranges::for_each when passing a read/write std::ranges::zip_view.
Version
2021.4, 2021.10
Environment
Observed Behavior
parallel_for_each "loses" the writable reference to elements in a zip_view, in contrast to std::ranges::for_each, as demonstrated in this program:
https://godbolt.org/z/EvMWGsTP5
Expected Behavior
parallel_for_each writes to the elements in the zipped vector and matches the outcome of std::ranges::for_each.
TBB should be "smarter" about the range it's passed, the core issue seems to be what is described in this StackOverflow answer: https://stackoverflow.com/a/79451943/256138
Note the above example is simple, and the zip_view is passed directly to tbb::parallel_for_each. This case, as described in the comments to that SO answer, can be rewritten to function correctly with a proper wrapper. Unfortunately that inhibits further "range" operations such as
std::views::filter
, e.g.Which may also change the range/view type that TBB sees in some way (although piping through
std::views::all
did nothing beneficial to the original issue.Steps To Reproduce
See code above.
The text was updated successfully, but these errors were encountered: