benchmark-leapfrog icon indicating copy to clipboard operation
benchmark-leapfrog copied to clipboard

julianized code

Open lmiq opened this issue 3 years ago • 0 comments

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:

  1. Make the functions generic for the dimensions of the particles.
  2. Fused some loops into vectorized operations (just to shorten the code).
  3. 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 to const anywhere (because these are parameters of main() input variables now).
  4. I have also removed some @inbounds flags and added --check-bounds=no as a flag to the optimized 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/

lmiq avatar Oct 04 '21 17:10 lmiq