Skip to content

Static partition forward ranges correctly#1753

Merged
CaseyCarter merged 5 commits into
microsoft:mainfrom
BillyONeal:forward_algorithm_partitioning
Jun 4, 2021
Merged

Static partition forward ranges correctly#1753
CaseyCarter merged 5 commits into
microsoft:mainfrom
BillyONeal:forward_algorithm_partitioning

Conversation

@BillyONeal
Copy link
Copy Markdown
Member

@BillyONeal BillyONeal commented Mar 17, 2021

In DevCom-1326903 the user reports that forward ranges, specifically std::map in their case, produce incorrect results from std::equal. After reducing to forward_list and debugging through, the problem is that when processing "unchunked items" we aren't giving those initial chunks their extra item, so the std::equal call fails fast whenever there are unchunked items.

Testing before didn't catch this because the values I chose of being around the thread count didn't account for the underlying infrastructure using _Oversubscription_multiplier which meant that the partitioning edge cases were not exercised (in most cases the parallel algorithms tests were testing only 1 element per chunk).

<execution> Add the missing +1. Note that this +1 is the same +1 in the iterator-returning version on line 907.

$/tests/std/include/parallel_algorithms_utilities.hpp: Adjust the N constants to account for _Oversubscription_multiplier.

Resolves DevCom-1326903/VSO-1273957/AB#1273957.

@BillyONeal BillyONeal requested a review from a team as a code owner March 17, 2021 20:55
@CaseyCarter CaseyCarter added the bug Something isn't working label Mar 17, 2021
@StephanTLavavej StephanTLavavej removed their assignment Mar 20, 2021
Comment thread tests/std/include/parallel_algorithms_utilities.hpp Outdated
@StephanTLavavej StephanTLavavej removed their assignment Mar 22, 2021
@CaseyCarter CaseyCarter self-requested a review April 28, 2021 21:37
@CaseyCarter CaseyCarter self-assigned this Apr 28, 2021
In DevCom-1326903 the user reports that foward ranges, specifically std::map in their case, produce incorrect results from std::equal. After reducing to forward_list and debugging through, the problem is that when processing "unchunked items" we aren't giving those intitial chunks their extra item, so the std::equal call fails fast whenever there are unchunked items.

Testing before didn't catch this because the values I chose of being around the thread count didn't account for the underlying infrastructure using _Oversubscription_multiplier which meant that the partitioning edge cases were not exercised (in most cases the parallel algorithms tests were testing only 1 element per chunk).

<execution> Add the missing +1. Note that this +1 is the same +1 in the random-access version on line 907.

$/tests/std/include/parallel_algorithms_utilities.hpp: Adjust the N constants to account for _Oversubscription_multiplier.
@BillyONeal BillyONeal force-pushed the forward_algorithm_partitioning branch from ca234d7 to 6814762 Compare May 24, 2021 21:24
@BillyONeal BillyONeal force-pushed the forward_algorithm_partitioning branch from 6814762 to b32df54 Compare May 25, 2021 00:14
Comment thread tests/std/include/parallel_algorithms_utilities.hpp Outdated
Comment thread tests/std/tests/P0024R2_parallel_algorithms_adjacent_find/test.cpp Outdated
Comment thread tests/std/tests/P0024R2_parallel_algorithms_is_partitioned/test.cpp Outdated
@StephanTLavavej
Copy link
Copy Markdown
Member

FYI @mnatsuhara, I pushed minor changes after you approved.

@BillyONeal BillyONeal force-pushed the forward_algorithm_partitioning branch from 5a75db6 to 9d688d2 Compare May 25, 2021 21:55
@CaseyCarter CaseyCarter self-assigned this May 27, 2021
@CaseyCarter CaseyCarter changed the title Static partition forward ranges correctly. Static partition forward ranges correctly Jun 3, 2021
@CaseyCarter CaseyCarter merged commit 8a8e7cb into microsoft:main Jun 4, 2021
@CaseyCarter
Copy link
Copy Markdown
Contributor

Thanks for this involved fix, Billy-3!

@CaseyCarter CaseyCarter removed their assignment Jun 4, 2021
@BillyONeal
Copy link
Copy Markdown
Member Author

Thanks for this involved fix, Billy-3!

I’ll be sure to leave in lots of typos to get credit for fixing 🥲

At least it isn’t something like, I don’t know, not writing a copy ctor this time

@CaseyCarter
Copy link
Copy Markdown
Contributor

I’ll be sure to leave in lots of typos to get credit for fixing 🥲

Everyone writes bugs - that's normal. Not everyone is willing to donate their personal time to fix said bugs when it's no longer their day job. That said, there's also a chunk of bonus credit here since it would presumably take someone who didn't originally author the code twice as long to locate the problem and develop a clean fix.

At least it isn’t something like, I don’t know, not writing a copy ctor this time

I'd take your "missing copy constructor" bug over my use-after-free monotonic_buffer_resource bug any day of the week.

@BillyONeal
Copy link
Copy Markdown
Member Author

personal time

I wasn't getting paid for this?

I'd take your "missing copy constructor" bug over my use-after-free monotonic_buffer_resource bug any day of the week.

Bug off! Bug off! Bug off!....

@BillyONeal BillyONeal deleted the forward_algorithm_partitioning branch June 5, 2021 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants