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

New pivot selection algorithm to better handle many special cases #127

Merged
merged 6 commits into from
Feb 26, 2024

Conversation

sterrettm2
Copy link
Contributor

This changes the pivot selection algorithm to give better results when handling special cases, with only a minimal impact on random sorting performance

5d benchmarks (50% random data, 50% 0)

---------------------------------------------------------------------------------------------------------------------------------------------------
[simdsort/random_5d vs. simdsort/random_5d]/uint64_t                -0.8243         -0.8242        151220         26569        151234         26580
[simdsort/random_5d vs. simdsort/random_5d]/int64_t                 -0.9165         -0.9165        334204         27897        334232         27903
[simdsort/random_5d vs. simdsort/random_5d]/uint32_t                -0.8788         -0.8788        135372         16402        135385         16406
[simdsort/random_5d vs. simdsort/random_5d]/int32_t                 -0.9400         -0.9399        290022         17393        290049         17434
[simdsort/random_5d vs. simdsort/random_5d]/uint16_t                -0.0001         -0.0001        294730        294693        294728        294691
[simdsort/random_5d vs. simdsort/random_5d]/int16_t                 +0.0007         +0.0007        298364        298574        298366        298576
[simdsort/random_5d vs. simdsort/random_5d]/float                   -0.9187         -0.9187        213828         17389        213879         17395
[simdsort/random_5d vs. simdsort/random_5d]/double                  -0.8617         -0.8616        164907         22804        164909         22823
OVERALL_GEOMEAN                                                     -0.8181         -0.8180             0             0             0             0

The effect is even more dramatic with 5p (95% 0, 5% random data)

Benchmark                                                              Time             CPU      Time Old      Time New       CPU Old       CPU New
---------------------------------------------------------------------------------------------------------------------------------------------------
[simdsort/random_5p vs. simdsort/random_5p]/uint64_t                -0.9764         -0.9764        291537          6867        291545          6870
[simdsort/random_5p vs. simdsort/random_5p]/int64_t                 -0.9494         -0.9494        276980         14006        277013         14020
[simdsort/random_5p vs. simdsort/random_5p]/uint32_t                -0.9864         -0.9864        266197          3628        266206          3633
[simdsort/random_5p vs. simdsort/random_5p]/int32_t                 -0.9608         -0.9609        226929          8887        226950          8885
[simdsort/random_5p vs. simdsort/random_5p]/uint16_t                -0.0002         -0.0002         98157         98139         98159         98136
[simdsort/random_5p vs. simdsort/random_5p]/int16_t                 +0.0147         +0.0145        101119        102601        101137        102608
[simdsort/random_5p vs. simdsort/random_5p]/float                   -0.9890         -0.9890        334314          3677        334329          3686
[simdsort/random_5p vs. simdsort/random_5p]/double                  -0.9794         -0.9794        280964          5792        280992          5789
OVERALL_GEOMEAN                                                     -0.9410         -0.9410             0             0             0             0

And it has only minimal effect on random sorts

Benchmark                                                               Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------
[simdsort/random_1 vs. simdsort/random_1]28/uint64_t                 +0.0013         +0.0002          1064          1065          1066          1066
[simdsort/random_1 vs. simdsort/random_1]k/uint64_t                  -0.0828         -0.0789          4888          4483          4893          4507
[simdsort/random_1 vs. simdsort/random_1]0k/uint64_t                 +0.0284         +0.0288         48691         50075         48699         50101
[simdsort/random_1 vs. simdsort/random_1]00k/uint64_t                +0.0124         +0.0125        614858        622497        614800        622495
[simdsort/random_1 vs. simdsort/random_1]m/uint64_t                  -0.0016         -0.0016       7963406       7950498       7962454       7949389
[simdsort/random_1 vs. simdsort/random_1]0m/uint64_t                 +0.0016         +0.0015     102066488     102229047     102059570     102211370
[simdsort/random_1 vs. simdsort/random_1]00m/uint64_t                -0.0043         -0.0043    1261115514    1255706439    1260972344    1255555986
[simdsort/random_1 vs. simdsort/random_1]28/int64_t                  -0.0031         -0.0024          1079          1076          1080          1077
[simdsort/random_1 vs. simdsort/random_1]k/int64_t                   -0.0853         -0.0858          4898          4480          4906          4485
[simdsort/random_1 vs. simdsort/random_1]0k/int64_t                  +0.0193         +0.0193         48866         49809         48873         49815
[simdsort/random_1 vs. simdsort/random_1]00k/int64_t                 +0.0060         +0.0060        618016        621698        617904        621614
[simdsort/random_1 vs. simdsort/random_1]m/int64_t                   -0.0056         -0.0056       7975085       7930691       7973995       7929683
[simdsort/random_1 vs. simdsort/random_1]0m/int64_t                  -0.0049         -0.0049     102474572     101974270     102465490     101962091
[simdsort/random_1 vs. simdsort/random_1]00m/int64_t                 -0.0066         -0.0065    1263240116    1254923614    1263009455    1254839009
[simdsort/random_1 vs. simdsort/random_1]28/uint32_t                 +0.0051         +0.0053           935           940           937           942
[simdsort/random_1 vs. simdsort/random_1]k/uint32_t                  -0.1471         -0.1437          3347          2855          3353          2871
[simdsort/random_1 vs. simdsort/random_1]0k/uint32_t                 -0.0222         -0.0221         28865         28225         28874         28235
[simdsort/random_1 vs. simdsort/random_1]00k/uint32_t                +0.0054         +0.0053        324099        325843        324105        325827
[simdsort/random_1 vs. simdsort/random_1]m/uint32_t                  +0.0046         +0.0045       4117560       4136371       4117024       4135636
[simdsort/random_1 vs. simdsort/random_1]0m/uint32_t                 +0.0114         +0.0114      51561459      52150283      51556319      52141569
[simdsort/random_1 vs. simdsort/random_1]00m/uint32_t                +0.0082         +0.0082     632611014     637805043     632526787     637722054
[simdsort/random_1 vs. simdsort/random_1]28/int32_t                  +0.0009         +0.0007           936           937           938           939
[simdsort/random_1 vs. simdsort/random_1]k/int32_t                   -0.1457         -0.1450          3353          2865          3363          2875
[simdsort/random_1 vs. simdsort/random_1]0k/int32_t                  -0.0203         -0.0203         28924         28337         28934         28345
[simdsort/random_1 vs. simdsort/random_1]00k/int32_t                 +0.0133         +0.0133        325551        329877        325534        329863
[simdsort/random_1 vs. simdsort/random_1]m/int32_t                   +0.0097         +0.0096       4115448       4155258       4114830       4154388
[simdsort/random_1 vs. simdsort/random_1]0m/int32_t                  +0.0142         +0.0142      51585804      52320726      51583209      52313573
[simdsort/random_1 vs. simdsort/random_1]00m/int32_t                 +0.0084         +0.0085     631352251     636675270     631267985     636612649
[simdsort/random_1 vs. simdsort/random_1]28/uint16_t                 -0.0003         -0.0003          1492          1491          1494          1493
[simdsort/random_1 vs. simdsort/random_1]k/uint16_t                  -0.0090         -0.0091         18904         18734         18922         18750
[simdsort/random_1 vs. simdsort/random_1]0k/uint16_t                 +0.0030         +0.0030        468432        469831        468403        469828
[simdsort/random_1 vs. simdsort/random_1]00k/uint16_t                -0.0012         -0.0013       5744202       5737147       5743967       5736718
[simdsort/random_1 vs. simdsort/random_1]m/uint16_t                  -0.0017         -0.0017      61193873      61090475      61190918      61084877
[simdsort/random_1 vs. simdsort/random_1]0m/uint16_t                 -0.0016         -0.0015     600309938     599348331     600224176     599306133
[simdsort/random_1 vs. simdsort/random_1]00m/uint16_t                -0.0032         -0.0032    6191154992    6171530176    6190615025    6170971515
[simdsort/random_1 vs. simdsort/random_1]28/int16_t                  -0.0003         -0.0006          1437          1436          1439          1438
[simdsort/random_1 vs. simdsort/random_1]k/int16_t                   -0.0097         -0.0098         19681         19491         19704         19512
[simdsort/random_1 vs. simdsort/random_1]0k/int16_t                  -0.0006         -0.0005        466306        466035        466273        466033
[simdsort/random_1 vs. simdsort/random_1]00k/int16_t                 -0.0001         -0.0002       5723278       5722493       5723190       5722214
[simdsort/random_1 vs. simdsort/random_1]m/int16_t                   +0.0005         +0.0005      61277756      61308199      61274535      61304592
[simdsort/random_1 vs. simdsort/random_1]0m/int16_t                  +0.0014         +0.0014     600496331     601344388     600441525     601300594
[simdsort/random_1 vs. simdsort/random_1]00m/int16_t                 -0.0009         -0.0009    6194612836    6188971652    6194055312    6188366358
[simdsort/random_1 vs. simdsort/random_1]28/float                    -0.0001         +0.0001           942           942           944           944
[simdsort/random_1 vs. simdsort/random_1]k/float                     -0.1467         -0.1458          3351          2859          3359          2869
[simdsort/random_1 vs. simdsort/random_1]0k/float                    +0.0507         +0.0506         27523         28918         27534         28928
[simdsort/random_1 vs. simdsort/random_1]00k/float                   +0.0261         +0.0261        326930        335451        326925        335464
[simdsort/random_1 vs. simdsort/random_1]m/float                     +0.0231         +0.0230       4147265       4243189       4146860       4242178
[simdsort/random_1 vs. simdsort/random_1]0m/float                    +0.0122         +0.0122      51795113      52426061      51788024      52419588
[simdsort/random_1 vs. simdsort/random_1]00m/float                   +0.0092         +0.0093     635098275     640935123     635037557     640923078
[simdsort/random_1 vs. simdsort/random_1]28/double                   +0.0070         +0.0067           987           993           989           995
[simdsort/random_1 vs. simdsort/random_1]k/double                    +0.0640         +0.0652          3938          4190          3943          4200
[simdsort/random_1 vs. simdsort/random_1]0k/double                   +0.0059         +0.0062         40154         40389         40163         40414
[simdsort/random_1 vs. simdsort/random_1]00k/double                  -0.0159         -0.0159        522386        514063        522326        514025
[simdsort/random_1 vs. simdsort/random_1]m/double                    -0.0139         -0.0138       7014815       6917393       7013658       6916682
[simdsort/random_1 vs. simdsort/random_1]0m/double                   -0.0054         -0.0054      92820075      92320669      92805992      92308498
[simdsort/random_1 vs. simdsort/random_1]00m/double                  -0.0094         -0.0094    1163669840    1152740315    1163500804    1152540374
OVERALL_GEOMEAN                                                      -0.0079         -0.0077             0             0             0             0

@r-devulap
Copy link
Contributor

rebased with main.

Copy link
Contributor

@r-devulap r-devulap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. thanks!

@r-devulap r-devulap merged commit 0e9a9a1 into intel:main Feb 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants