Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To pre-empt any wrong interpretations or conclusions: The Rust version heavily relies on optimization annotations and using direct calls to SSE functions. The Fortran version uses no special code and relies purely on the compiler optimizing code and algorithms. The Rust version relies on hand tuned pieces and is several times longer. Just a matter of work for someone to write an equivalent version in Fortran or C that will be equally fast or faster.

If you want to get a real-world impression look at the other Rust implementations that roughly correspond to the Fortran code. They are almost 2 times as slow. This gives you some real-world insight on how much performance you can achieve using Fortran instead of Rust and spending the same time writing code.



That is the big point about Fortran that keeps getting overlooked. Sure heavily optimized C/Rust writting by an expert in writing fast numeric code will absolutely hold its own against the equivalent Fortran. However naively written C/Rust written by non-programmers in the clearest most obvious way possible will almost always be much slower than the equivalent Fortran code.


The C version was ported to be the Rust one, it seems, and uses those intrinsics too. And, eventually this code will get to be a bit higher level while having the same output; those libraries are still a bit experimental though.

Overall, good points!


> The C version was ported to be the Rust one, it seems, and uses those intrinsics too.

No. Although the Rust program was initially presented to me as a "port of fastest C SIMD variant" the programmer made additional optimizations not found in the C program:

- Moving the loop from outside into "bodies_advance(..)" (SSE pipelining(?))

- Bundle intermediate variables/arrays as struct NBodySim (caching)

- Fit array-sizes within struct NBodySim to the number of bodies (caching)

----

https://www.reddit.com/r/rust/comments/akgmef/rust_nbody_ben...


Nice, thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: