Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parallel merge is not stable #2964

Closed
jefftrull opened this issue Oct 17, 2017 · 17 comments · Fixed by #3095
Closed

parallel merge is not stable #2964

jefftrull opened this issue Oct 17, 2017 · 17 comments · Fixed by #3095

Comments

@jefftrull
Copy link
Contributor

jefftrull commented Oct 17, 2017

merge_testcase.zip
The documentation for the merge algorithm states For equivalent elements in the original two ranges, the elements from the first range precede the elements from the second range. I find that this is sometimes not the case when the parallel execution policy is chosen.

The attached testcase merges two ranges of <int, char> pairs, ordered by the first value. For my compiler (gcc 6.3.0) I find that the resulting merged sequence interleaves equivalent elements from the input ranges, instead of using all of the equivalent elements from the first range first. Specifically, when merging (3,a), (3,b) with (3,c) the result is (3,a), (3,c), (3,b).

Due to the high threshold (65536) for using the parallel version of the algorithm, reproducing this requires modifying this line so the threshold is something low (I used 10).

@hkaiser
Copy link
Member

hkaiser commented Oct 17, 2017

@taeguk: any comments?

@taeguk
Copy link
Member

taeguk commented Oct 18, 2017

@jefftrull Thanks for your bug report! I'll take a look in this weekend.

@hkaiser
Copy link
Member

hkaiser commented Oct 18, 2017

@taeguk: I added the test on a branch here: https://github.com/STEllAR-GROUP/hpx/tree/fixing_2964

@jefftrull: the problem is not reproducible for me (at least not with the test case you provided). This might become interesting ... ;-)

@jefftrull
Copy link
Contributor Author

Hi @hkaiser ! Did you try that threshold hack...

@hkaiser
Copy link
Member

hkaiser commented Oct 18, 2017

@jefftrull Ahh no. Will try, thanks.

@hkaiser
Copy link
Member

hkaiser commented Oct 18, 2017

@taeguk: we need to find a way to modify this value without editing the code. Executor parameters for the win! Something like:

merge(execution::par.with(threshold([]() { return 10; })), ...)

or

merge(execution::par.with(threshold(10)), ...)

or somesuch...

taeguk added a commit to taeguk/hpx that referenced this issue Oct 21, 2017
@taeguk
Copy link
Member

taeguk commented Oct 21, 2017

@jefftrull In PR #2967, I fixed the problem which you reported! Really thanks for your bug reporting! :)

taeguk added a commit to taeguk/hpx that referenced this issue Oct 21, 2017
@taeguk
Copy link
Member

taeguk commented Oct 21, 2017

@hkaiser I agree that we need to find a way to modify the thredhold. The things you suggested seem good to me. execution::par.with(...) can be possible in now? Or we need to design and implement that to execution policy?

@hkaiser hkaiser closed this as completed in 26942b9 Nov 1, 2017
hkaiser added a commit that referenced this issue Nov 1, 2017
Make parallel::merge is stable. (Fix #2964.)
@sithhell sithhell reopened this Nov 22, 2017
@hkaiser
Copy link
Member

hkaiser commented Nov 25, 2017

@taeguk would you be able to look into this error, please?

@taeguk
Copy link
Member

taeguk commented Nov 27, 2017

@hkaiser I will look that in this weekend.

@taeguk
Copy link
Member

taeguk commented Dec 2, 2017

@hkaiser @sithhell I looked into this error.
It seems the bug of libc++, not of our code.
https://git.codingcafe.org/Mirrors/llvm-mirror/libcxx/commit/25a78dcd773ce509469a2b892adbeac0c230cdb9

@hkaiser
Copy link
Member

hkaiser commented Dec 2, 2017

Ahh, thanks for investigating this more closely. Is it possible to disable the failing tests for the platforms we know are broken?

@taeguk
Copy link
Member

taeguk commented Dec 3, 2017

@hkaiser For doing what you said, we may be able to use conditional build with checking HPX_CLANG_VERSION. We should search that bug was fixed since exactly what version of libc++.

@sithhell
Copy link
Member

sithhell commented Dec 3, 2017

You shouldn't check the clang version, but the stdlib version. This is a bug in libc++, you could also use libstdc++ with clang

@taeguk
Copy link
Member

taeguk commented Dec 3, 2017

@sithhell Oops. Yes, you're right. I was strange...

@jefftrull
Copy link
Contributor Author

Thanks all!

@hkaiser hkaiser added this to Merged to master in Standard Algorithms Jan 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Standard Algorithms
  
Merged to master
Development

Successfully merging a pull request may close this issue.

4 participants