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

Switch to using Query in insert generator and tree traversal #305

Closed
wants to merge 1 commit into from

Conversation

aprokop
Copy link
Contributor

@aprokop aprokop commented May 18, 2020

No description provided.

@aprokop
Copy link
Contributor Author

aprokop commented May 18, 2020

Comparing 8f22a7e with 722e82a:

BM_knn_search<ArborX::BVH<Serial>>/10000/10000/10/1/0/2/manual_time_median                          -0.0443         -0.0443         55336         52883         55329         52879
BM_knn_search<ArborX::BVH<Serial>>/100000/100000/10/1/0/2/manual_time_median                        -0.0393         -0.0393        579491        556730        579432        556673
BM_knn_search<ArborX::BVH<Serial>>/1000000/1000000/10/1/0/2/manual_time_median                      -0.0376         -0.0376       6155951       5924291       6155454       5923816
BM_knn_search<ArborX::BVH<Serial>>/10000/10000/10/1/1/3/manual_time_median                          -0.0473         -0.0473         55633         53003         55629         53000
BM_knn_search<ArborX::BVH<Serial>>/100000/100000/10/1/1/3/manual_time_median                        -0.0482         -0.0482        755898        719448        755823        719373
BM_knn_search<ArborX::BVH<Serial>>/1000000/1000000/10/1/1/3/manual_time_median                      -0.0437         -0.0437      10490501      10031738      10489623      10030904
BM_knn_search<ArborX::BVH<Serial>>/10000/10000/10/0/0/2/manual_time_median                          -0.0239         -0.0239         56173         54833         56169         54829
BM_knn_search<ArborX::BVH<Serial>>/100000/100000/10/0/0/2/manual_time_median                        -0.0240         -0.0240        606366        591812        606287        591756
BM_knn_search<ArborX::BVH<Serial>>/1000000/1000000/10/0/0/2/manual_time_median                      -0.0200         -0.0200       6810515       6674060       6808343       6672016
BM_knn_search<ArborX::BVH<Serial>>/10000/10000/10/0/1/3/manual_time_median                          -0.0185         -0.0185         61552         60416         61548         60412
BM_knn_search<ArborX::BVH<Serial>>/100000/100000/10/0/1/3/manual_time_median                        -0.0124         -0.0124        867864        857098        867756        856999
BM_knn_search<ArborX::BVH<Serial>>/1000000/1000000/10/0/1/3/manual_time_median                      -0.0068         -0.0068      12458810      12373720      12455266      12370241
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/1/0/0/2/manual_time_median                     +0.0191         +0.0191         76886         78355         76880         78349
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/1/0/0/2/manual_time_median                   +0.0176         +0.0176        805573        819724        805490        819645
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/1/0/0/2/manual_time_median                 +0.0172         +0.0172       8475033       8621038       8474413       8620416
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/1/0/1/3/manual_time_median                     +0.0145         +0.0145         18999         19274         18999         19274
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/1/0/1/3/manual_time_median                   +0.0101         +0.0101        136732        138117        136719        138106
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/1/0/1/3/manual_time_median                 +0.0055         +0.0055       1277277       1284321       1277040       1284099
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/1/10/0/2/manual_time_median                    -0.0029         -0.0030         80692         80455         80687         80448
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/1/10/0/2/manual_time_median                  -0.0052         -0.0052        845229        840823        845139        840736
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/1/10/0/2/manual_time_median                -0.0043         -0.0043       8942661       8904160       8942110       8903429
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/1/10/1/3/manual_time_median                    -0.0034         -0.0034         19950         19883         19950         19883
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/1/10/1/3/manual_time_median                  -0.0037         -0.0037        142300        141774        142287        141761
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/1/10/1/3/manual_time_median                -0.0028         -0.0028       1320049       1316329       1319812       1316096
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/0/0/0/2/manual_time_median                     +0.0018         +0.0018         82655         82803         82650         82799
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/0/0/0/2/manual_time_median                   +0.0008         +0.0009        896073        896803        895868        896715
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/0/0/0/2/manual_time_median                 +0.0020         +0.0020      10223683      10244240      10220150      10240697
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/0/0/1/3/manual_time_median                     -0.0063         -0.0063         24708         24551         24707         24550
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/0/0/1/3/manual_time_median                   -0.0094         -0.0094        169750        168157        169734        168146
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/0/0/1/3/manual_time_median                 -0.0120         -0.0120       1345627       1329503       1345460       1329344
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/0/10/0/2/manual_time_median                    +0.0501         +0.0501         81554         85639         81547         85631
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/0/10/0/2/manual_time_median                  +0.0489         +0.0489        882441        925580        882339        925475
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/0/10/0/2/manual_time_median                +0.0449         +0.0449      10108027      10561636      10104785      10558138
BM_radius_search<ArborX::BVH<Serial>>/10000/10000/10/0/10/1/3/manual_time_median                    +0.0301         +0.0301         24571         25311         24571         25310
BM_radius_search<ArborX::BVH<Serial>>/100000/100000/10/0/10/1/3/manual_time_median                  +0.0247         +0.0247        169169        173352        169154        173335
BM_radius_search<ArborX::BVH<Serial>>/1000000/1000000/10/0/10/1/3/manual_time_median                +0.0166         +0.0167       1350194       1372652       1349964       1372442
BM_knn_search<ArborX::BVH<OpenMP>>/10000/10000/10/1/0/2/manual_time_median                          -0.0236         -0.0236          1855          1811          1857          1813
BM_knn_search<ArborX::BVH<OpenMP>>/100000/100000/10/1/0/2/manual_time_median                        -0.0363         -0.0351         15971         15391         15536         14991
BM_knn_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/1/0/2/manual_time_median                      -0.0367         -0.0353        163101        157113        161110        155428
BM_knn_search<ArborX::BVH<OpenMP>>/10000/10000/10/1/1/3/manual_time_median                          -0.0345         -0.0344          2294          2215          2296          2217
BM_knn_search<ArborX::BVH<OpenMP>>/100000/100000/10/1/1/3/manual_time_median                        -0.0425         -0.0471         27973         26784         26076         24849
BM_knn_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/1/1/3/manual_time_median                      -0.0431         -0.0465        419246        401194        354676        338167
BM_knn_search<ArborX::BVH<OpenMP>>/10000/10000/10/0/0/2/manual_time_median                          -0.0305         -0.0302          1607          1558          1609          1560
BM_knn_search<ArborX::BVH<OpenMP>>/100000/100000/10/0/0/2/manual_time_median                        -0.0344         -0.0283         15567         15032         14791         14373
BM_knn_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/0/0/2/manual_time_median                      -0.0246         -0.0210        205136        200092        194831        190739
BM_knn_search<ArborX::BVH<OpenMP>>/10000/10000/10/0/1/3/manual_time_median                          -0.0253         -0.0251          1740          1696          1742          1698
BM_knn_search<ArborX::BVH<OpenMP>>/100000/100000/10/0/1/3/manual_time_median                        -0.0243         -0.0232         21792         21264         21770         21264
BM_knn_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/0/1/3/manual_time_median                      -0.0150         -0.0131        335021        329998        333587        329216
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/1/0/0/2/manual_time_median                     -0.0232         -0.0231          2472          2415          2474          2417
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/1/0/0/2/manual_time_median                   -0.0307         -0.0268         22776         22077         21814         21230
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/1/0/0/2/manual_time_median                 -0.0301         -0.0282        227735        220883        224319        217992
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/1/0/1/3/manual_time_median                     -0.0265         -0.0106          1480          1441           992           981
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/1/0/1/3/manual_time_median                   -0.0195         -0.0030          9199          9020          3395          3384
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/1/0/1/3/manual_time_median                 -0.0064         +0.0028         78505         78005         31216         31304
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/1/10/0/2/manual_time_median                    -0.0191         -0.0191          2538          2490          2540          2491
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/1/10/0/2/manual_time_median                  -0.0300         -0.0257         23139         22445         22152         21583
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/1/10/0/2/manual_time_median                -0.0299         -0.0277        233522        226539        229982        223610
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/1/10/1/3/manual_time_median                    -0.0239         -0.0121          1536          1500          1024          1012
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/1/10/1/3/manual_time_median                  -0.0177         -0.0004          9396          9230          3455          3454
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/1/10/1/3/manual_time_median                -0.0053         +0.0051         80736         80308         32338         32502
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/0/0/0/2/manual_time_median                     +0.0156         +0.0157          2190          2224          2192          2226
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/0/0/0/2/manual_time_median                   +0.0174         +0.0173         22514         22904         22514         22905
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/0/0/0/2/manual_time_median                 +0.0154         +0.0140        295473        300011        295653        299780
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/0/0/1/3/manual_time_median                     +0.0095         +0.0098           804           812           806           814
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/0/0/1/3/manual_time_median                   +0.0121         +0.0095          4568          4623          4562          4605
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/0/0/1/3/manual_time_median                 +0.0090         +0.0058         34061         34366         33573         33767
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/0/10/0/2/manual_time_median                    +0.0164         +0.0163          2242          2279          2244          2281
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/0/10/0/2/manual_time_median                  +0.0158         +0.0162         22821         23181         22811         23181
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/0/10/0/2/manual_time_median                +0.0133         +0.0143        299542        303537        298799        303058
BM_radius_search<ArborX::BVH<OpenMP>>/10000/10000/10/0/10/1/3/manual_time_median                    +0.0059         +0.0056           841           846           844           848
BM_radius_search<ArborX::BVH<OpenMP>>/100000/100000/10/0/10/1/3/manual_time_median                  +0.0130         +0.0128          4651          4712          4626          4685
BM_radius_search<ArborX::BVH<OpenMP>>/1000000/1000000/10/0/10/1/3/manual_time_median                +0.0072         +0.0059         35209         35461         34554         34757
BM_knn_search<ArborX::BVH<Cuda>>/10000/10000/10/1/0/2/manual_time_median                            +0.0033         +0.0031          1644          1649          1737          1743
BM_knn_search<ArborX::BVH<Cuda>>/100000/100000/10/1/0/2/manual_time_median                          -0.0065         -0.0061         10053          9988         10517         10453
BM_knn_search<ArborX::BVH<Cuda>>/1000000/1000000/10/1/0/2/manual_time_median                        +0.0052         +0.0057         76744         77144         77594         78037
BM_knn_search<ArborX::BVH<Cuda>>/10000/10000/10/1/1/3/manual_time_median                            +0.0037         +0.0038          1688          1694          1779          1786
BM_knn_search<ArborX::BVH<Cuda>>/100000/100000/10/1/1/3/manual_time_median                          +0.0099         -0.0090         12384         12506         12851         12736
BM_knn_search<ArborX::BVH<Cuda>>/1000000/1000000/10/1/1/3/manual_time_median                        +0.0135         +0.0123        139816        141697        140709        142435
BM_knn_search<ArborX::BVH<Cuda>>/10000/10000/10/0/0/2/manual_time_median                            +0.0023         +0.0016          1157          1160          1250          1252
BM_knn_search<ArborX::BVH<Cuda>>/100000/100000/10/0/0/2/manual_time_median                          +0.0058         +0.0016          9147          9200          9599          9614
BM_knn_search<ArborX::BVH<Cuda>>/1000000/1000000/10/0/0/2/manual_time_median                        +0.0040         +0.0043        102453        102861        103241        103683
BM_knn_search<ArborX::BVH<Cuda>>/10000/10000/10/0/1/3/manual_time_median                            +0.0009         +0.0017          1211          1212          1301          1303
BM_knn_search<ArborX::BVH<Cuda>>/100000/100000/10/0/1/3/manual_time_median                          +0.0086         +0.0086         18457         18615         18918         19081
BM_knn_search<ArborX::BVH<Cuda>>/1000000/1000000/10/0/1/3/manual_time_median                        +0.0207         +0.0202        303816        310099        304690        310847
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/1/0/0/2/manual_time_median                       +0.0096         +0.0095          1043          1053          1134          1145
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/1/0/0/2/manual_time_median                     +0.0241         +0.0228          5594          5728          6067          6206
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/1/0/0/2/manual_time_median                   +0.0054         +0.0040         53236         53521         54142         54362
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/1/0/1/3/manual_time_median                       +0.0076         +0.0077          1007          1015          1099          1107
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/1/0/1/3/manual_time_median                     -0.0009         +0.0023          2824          2821          3284          3292
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/1/0/1/3/manual_time_median                   -0.0093         +0.0039          9683          9593         10401         10442
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/1/10/0/2/manual_time_median                      +0.0127         +0.0123          1147          1162          1239          1254
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/1/10/0/2/manual_time_median                    +0.0204         +0.0200          7467          7619          7935          8093
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/1/10/0/2/manual_time_median                  +0.0031         +0.0023         67125         67336         67997         68156
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/1/10/1/3/manual_time_median                      +0.0083         +0.0081          1109          1118          1201          1211
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/1/10/1/3/manual_time_median                    +0.0010         +0.0007          3915          3919          4381          4384
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/1/10/1/3/manual_time_median                  +0.0080         +0.0073         11960         12056         12794         12887
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/0/0/0/2/manual_time_median                       +0.0025         +0.0035           647           649           737           740
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/0/0/0/2/manual_time_median                     +0.0273         +0.0250          4416          4537          4888          5011
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/0/0/0/2/manual_time_median                   -0.0005         -0.0001         98864         98810         99733         99718
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/0/0/1/3/manual_time_median                       +0.0033         +0.0041           610           612           702           705
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/0/0/1/3/manual_time_median                     +0.0213         +0.0170          1694          1730          2163          2200
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/0/0/1/3/manual_time_median                   +0.0708         +0.0633         12096         12953         12943         13762
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/0/10/0/2/manual_time_median                      +0.0022         +0.0027           748           750           839           841
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/0/10/0/2/manual_time_median                    +0.0076         +0.0076          6181          6228          6652          6703
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/0/10/0/2/manual_time_median                  +0.0017         -0.0026        107690        107868        108588        108311
BM_radius_search<ArborX::BVH<Cuda>>/10000/10000/10/0/10/1/3/manual_time_median                      +0.0044         +0.0048           722           726           815           819
BM_radius_search<ArborX::BVH<Cuda>>/100000/100000/10/0/10/1/3/manual_time_median                    +0.0378         +0.0302          2792          2898          3257          3356
BM_radius_search<ArborX::BVH<Cuda>>/1000000/1000000/10/0/10/1/3/manual_time_median                  +0.0568         +0.0532         14390         15207         15167         15974

The most problematic are 1M hollow meshes on CUDA, about 5-7% slowdown. But this is acceptable.

@aprokop aprokop added the refactoring Code reorganization label May 18, 2020
Copy link
Contributor

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

This PR comes too early.

Without introducing the overload

template <typename ExecutionSpace, typename Predicates, typename Callback>
BVH::query(ExecutionSpace const &, Predicates const &, Callback const &);

and observing that the change you propose reconciliate the signature of the user-provided callback with what actually happens in the tree traversal implementation, this PR has a very weak rational.
And even so, say we have already introduced the new query overload, we would probably still need to make the case that this is better than wrapping the user callback.

Comment on lines +249 to +252
using NativePredicateType = std::decay_t<decltype(
Traits::Access<Predicates, Traits::PredicatesTag>::get(
std::declval<Predicates const &>(), std::declval<int>()))>;

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
using NativePredicateType = std::decay_t<decltype(
Traits::Access<Predicates, Traits::PredicatesTag>::get(
std::declval<Predicates const &>(), std::declval<int>()))>;
using NativePredicateType = typename Traits::Helper<Access>::type;

{
auto const predicate_index = getData(query);
auto const &predicate = static_cast<NativePredicateType const &>(query);
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment that you are slicing. This is easy to overlook.

@aprokop
Copy link
Contributor Author

aprokop commented May 18, 2020

OK, we can close this right now if you want. I wanted to show that there is a way to change the callback inside tree traversal to be closer to what we want with minor performance penalty.

@aprokop aprokop closed this May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code reorganization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants