Skip to content

Commit 041f584

Browse files
Andor233StephanTLavavejCaseyCarter
authored
<execution>: parallel scans should avoid passing output values to the binary (reduce) operation (#4701)
Co-authored-by: Stephan T. Lavavej <[email protected]> Co-authored-by: Casey Carter <[email protected]>
1 parent 7f0f35d commit 041f584

File tree

7 files changed

+166
-88
lines changed

7 files changed

+166
-88
lines changed

stl/inc/execution

Lines changed: 154 additions & 56 deletions
Large diffs are not rendered by default.

stl/inc/vector

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ private:
788788
if constexpr (conjunction_v<is_nothrow_constructible<_Ty, _Valty...>,
789789
_Uses_default_construct<_Alloc, _Ty*, _Valty...>>) {
790790
_ASAN_VECTOR_MODIFY(1);
791-
_Construct_in_place(*_Mylast, _STD forward<_Valty>(_Val)...);
791+
_STD _Construct_in_place(*_Mylast, _STD forward<_Valty>(_Val)...);
792792
} else {
793793
_ASAN_VECTOR_EXTEND_GUARD(static_cast<size_type>(_Mylast - _My_data._Myfirst) + 1);
794794
_Alty_traits::construct(_Getal(), _Unfancy(_Mylast), _STD forward<_Valty>(_Val)...);
@@ -822,27 +822,27 @@ private:
822822
const size_type _Newsize = _Oldsize + 1;
823823
size_type _Newcapacity = _Calculate_growth(_Newsize);
824824

825-
const pointer _Newvec = _Allocate_at_least_helper(_Al, _Newcapacity);
825+
const pointer _Newvec = _STD _Allocate_at_least_helper(_Al, _Newcapacity);
826826
const pointer _Constructed_last = _Newvec + _Whereoff + 1;
827827
pointer _Constructed_first = _Constructed_last;
828828

829829
_TRY_BEGIN
830-
_Alty_traits::construct(_Al, _Unfancy(_Newvec + _Whereoff), _STD forward<_Valty>(_Val)...);
830+
_Alty_traits::construct(_Al, _STD _Unfancy(_Newvec + _Whereoff), _STD forward<_Valty>(_Val)...);
831831
_Constructed_first = _Newvec + _Whereoff;
832832

833833
if (_Whereptr == _Mylast) { // at back, provide strong guarantee
834834
if constexpr (is_nothrow_move_constructible_v<_Ty> || !is_copy_constructible_v<_Ty>) {
835-
_Uninitialized_move(_Myfirst, _Mylast, _Newvec, _Al);
835+
_STD _Uninitialized_move(_Myfirst, _Mylast, _Newvec, _Al);
836836
} else {
837-
_Uninitialized_copy(_Myfirst, _Mylast, _Newvec, _Al);
837+
_STD _Uninitialized_copy(_Myfirst, _Mylast, _Newvec, _Al);
838838
}
839839
} else { // provide basic guarantee
840-
_Uninitialized_move(_Myfirst, _Whereptr, _Newvec, _Al);
840+
_STD _Uninitialized_move(_Myfirst, _Whereptr, _Newvec, _Al);
841841
_Constructed_first = _Newvec;
842-
_Uninitialized_move(_Whereptr, _Mylast, _Newvec + _Whereoff + 1, _Al);
842+
_STD _Uninitialized_move(_Whereptr, _Mylast, _Newvec + _Whereoff + 1, _Al);
843843
}
844844
_CATCH_ALL
845-
_Destroy_range(_Constructed_first, _Constructed_last, _Al);
845+
_STD _Destroy_range(_Constructed_first, _Constructed_last, _Al);
846846
_Al.deallocate(_Newvec, _Newcapacity);
847847
_RERAISE;
848848
_CATCH_END
@@ -2024,7 +2024,7 @@ private:
20242024
_My_data._Orphan_all();
20252025

20262026
if (_Myfirst) { // destroy and deallocate old array
2027-
_Destroy_range(_Myfirst, _Mylast, _Al);
2027+
_STD _Destroy_range(_Myfirst, _Mylast, _Al);
20282028
_ASAN_VECTOR_REMOVE;
20292029
_Al.deallocate(_Myfirst, static_cast<size_type>(_Myend - _Myfirst));
20302030
}

stl/inc/xmemory

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,15 +1905,15 @@ _CONSTEXPR20 _Alloc_ptr_t<_Alloc> _Uninitialized_move(
19051905
// move [_First, _Last) to raw _Dest, using _Al
19061906
// note: only called internally from elsewhere in the STL
19071907
using _Ptrval = typename _Alloc::value_type*;
1908-
auto _UFirst = _Get_unwrapped(_First);
1909-
const auto _ULast = _Get_unwrapped(_Last);
1908+
auto _UFirst = _STD _Get_unwrapped(_First);
1909+
const auto _ULast = _STD _Get_unwrapped(_Last);
19101910
if constexpr (conjunction_v<bool_constant<_Iter_move_cat<decltype(_UFirst), _Ptrval>::_Bitcopy_constructible>,
19111911
_Uses_default_construct<_Alloc, _Ptrval, decltype(_STD move(*_UFirst))>>) {
19121912
#if _HAS_CXX20
19131913
if (!_STD is_constant_evaluated())
19141914
#endif // _HAS_CXX20
19151915
{
1916-
_Copy_memmove(_UFirst, _ULast, _Unfancy(_Dest));
1916+
_STD _Copy_memmove(_UFirst, _ULast, _STD _Unfancy(_Dest));
19171917
return _Dest + (_ULast - _UFirst);
19181918
}
19191919
}

tests/std/tests/P0024R2_parallel_algorithms_exclusive_scan/test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ struct typesBop {
184184
bopResult operator()(intermediateType&&, intermediateType&&) {
185185
return 0;
186186
}
187-
188-
// *result = binary_op(tmp, move(*result))
189-
bopResult operator()(intermediateType&, outputType&&) {
190-
return 0;
191-
}
192187
};
193188

194189
void test_case_exclusive_scan_init_writes_intermediate_type() {

tests/std/tests/P0024R2_parallel_algorithms_inclusive_scan/test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ struct typesBop {
193193
bopResult operator()(intermediateType&&, intermediateType&&) {
194194
return 0;
195195
}
196-
197-
// *result = binary_op(tmp, move(*result))
198-
bopResult operator()(intermediateType&, outputType&&) {
199-
return 0;
200-
}
201196
};
202197

203198
void test_case_inclusive_scan_init_writes_intermediate_type() {

tests/std/tests/P0024R2_parallel_algorithms_transform_exclusive_scan/test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ struct typesBop {
179179
bopResult operator()(intermediateType&&, intermediateType&&) {
180180
return 0;
181181
}
182-
183-
// *result = binary_op(tmp, move(*result))
184-
bopResult operator()(intermediateType&, outputType&&) {
185-
return 0;
186-
}
187182
};
188183

189184
void test_case_transform_exclusive_scan_init_writes_intermediate_type() {

tests/std/tests/P0024R2_parallel_algorithms_transform_inclusive_scan/test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,6 @@ struct typesBop {
203203
bopResult operator()(intermediateType&&, intermediateType&&) {
204204
return 0;
205205
}
206-
207-
// *result = binary_op(tmp, move(*result))
208-
bopResult operator()(intermediateType&, outputType&&) {
209-
return 0;
210-
}
211206
};
212207

213208
void test_case_transform_inclusive_scan_init_writes_intermediate_type() {

0 commit comments

Comments
 (0)