benchmark-leapfrog
benchmark-leapfrog copied to clipboard
julianized code
I originally tried to run the Julia benchmark, but the using LinearAlgebra: norm
was missing. Then I sort of "julianized" a little bit further the code. What I did is:
- Make the functions generic for the dimensions of the particles.
- Fused some loops into vectorized operations (just to shorten the code).
- Moved the system build-up to the global scope and pass the initial positions, velocities and masses to
main()
. That way the code is generic and, in principle, dynamic (one can run another simulation with different properties). The code is more flexible in the sense that you don't need to set the dimension and type of points toconst
anywhere (because these are parameters ofmain()
input variables now). - I have also removed some
@inbounds
flags and added--check-bounds=no
as a flag to theoptimized
run. (I don't think you have to discount compile time here, it is not relevant for the running time of your test).
Performance-wise there is not significant different relative to the original code, although in Julia 1.6.3 here I get 2 min 10s
for the rust
implementation vs. 2 min 24s
for the Julia one (thus not the big difference reported in the main readme).
Anyway, I was just playing with it, nice repository (do whatever you want with the pull request). If you are interest, I discuss some interesting properties of a Julia particle simulation code here: https://m3g.github.io/2021_FortranCon/