This is an archive of the discontinued LLVM Phabricator instance.

[libc++][PSTL] Implement std::sort
ClosedPublic

Authored by philnik on Jun 13 2023, 2:51 PM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rG37e5baf318b1: [libc++][PSTL] Implement std::sort

Diff Detail

Event Timeline

philnik created this revision.Jun 13 2023, 2:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 2:51 PM
Herald added a subscriber: mgrang. · View Herald Transcript
philnik requested review of this revision.Jun 13 2023, 2:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 2:51 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik updated this revision to Diff 531400.Jun 14 2023, 9:52 AM

Try to fix CI

ldionne requested changes to this revision.Jun 14 2023, 12:54 PM
ldionne added a subscriber: ldionne.
ldionne added inline comments.
libcxx/include/__algorithm/pstl_sort.h
32–38

This way of defining the "two overloads" (the one with and the one without a comp) will accept the following code, which shouldn't be valid:

std::sort(policy, it1, it2, {});

Instead, let's do like we do in the serial std::sort and have two separate overloads (and make the no-comp overload simply call the comp overload with std::less<>()).

Let's also add a SFINAE test to ensure that we don't accept that code (and while we're at it let's add one to the serial std::sort if we don't have one already).

41–42

Is there any reason we're not std::moveing the arguments like __g_comp into std::stable_sort? The same observation probably applies to all the other algorithms we have so far.

libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/pstl.sort.pass.cpp
37

I don't think you have any tests for the algorithm with a custom comparator.

libcxx/test/support/test_macros.h
278

Let's move this closer to line 366 where we define the other similar macros.

This revision now requires changes to proceed.Jun 14 2023, 12:54 PM
philnik updated this revision to Diff 539286.Jul 11 2023, 1:55 PM
philnik marked 4 inline comments as done.

Address comments

ldionne accepted this revision.Jul 17 2023, 1:40 PM
This revision is now accepted and ready to land.Jul 17 2023, 1:40 PM
philnik updated this revision to Diff 541241.Jul 17 2023, 2:52 PM

Try to fix CI

This revision was automatically updated to reflect the committed changes.