Repository navigation
optimise code - #16
Conversation
|
Thanks a lot! On my PC, this (sequential) C++ implementation is a bit faster than the (sequential) Python implementation using Pythran. It's a bit slower than the optimized Julia implementation. I'm going to mention that in the README. Other optimizations are of course welcome. |
|
See 0555e69 for the exact figures obtained with my PC. Besides, it is of course important to keep the suboptimal implementation got from nbabel.org ! |
Why is it important? The suboptimal implementation from nbabel.org does twice the work as any other implementation. |
@isuruf Because that code's performance was included in the published article (see Citation in the README) and should be kept as is for archival reasons. We do make it clear that the C++ and Fortran implementations were taken as is from nbabel.org. We also mention in the article: "Note that these implementations could have been further optimized, but are representative of code written by many scientists." @bolverk I do have a question: is this loop criterion correct? Wouldn't it short circuit halfway if Line 83 in 0555e69 |
|
@isuruf One of our points of our note in Nature Astro is that the implementation is more important than the language. This C++ implementation found in nbabel.org has been written by someone knowing C++ and has been used by Zwart (2020). Many real word C++ programs also miss simple algorithmic optimizations. The goal of our work is not to check how much C++ can be push. Of course, one can write in C++ a very efficient implementation of this problem. It's evident! We studied a question about Python. "Do we have to avoid this language for ecological reasons?" |
This is my whole point. In the other languages, the short circuit is there, but in C++ there isn't, which makes the C++ implementation twice as slow. As you can see in the original nbabel implementation at https://github.com/paugier/nbabel/blob/master/cpp/raw_code.txt#L83, the optimized code path is commented out. So, this optimization was already in the original nbabel implementation. |
|
I don't understand and it does not make sense even if I check the equations. The summations should be over all other particles and not all particles before its position in the vector. |
|
It's the same reason as the python implementation does the summation over all particle after its position as in https://github.com/paugier/nbabel/blob/master/py/bench.py#L43. The reason is |
This comment has been minimized.
This comment has been minimized.
OK I get it now. Thanks :) |
No description provided.