Idiomatic Faster C N-Body Contribution - Eric Whitney
CONTRIBUTE SOURCE CODE
Idiomatic, Faster C N-Body - Eric J. Whitney
For fun I implemented a version using standard, idiomatic C99 with a few additional performance improvements. Speed of this version is about 7% faster than the fastest C benchmark that didn't use hand-coded or non-standard vector instructions (at the time of writing). Some more details are here.
Source Code File
Complete, tested, source-code is attached.
nbody.gcc-x.c [EDIT changed filename to -x for clarity]
Example Build & Test Command-Line
The same build command-line is used as per other C benchmarks. I used GCC:
gcc -pipe -Wall -O3 -fomit-frame-pointer -march=ivybridge -o nbody.gcc-x.gcc_run nbody.gcc-x.c -lm
Run as per other benchmarks:
./nbody.gcc-x.gcc_run 50000000
-0.169075164
-0.169068761
Edited by Eric Whitney