Closed czgdp1807 closed 9 months ago
Not ready for review yet.
If you compile using:
$ clang++ -O3 -march=native -ffast-math nbody.cpp
Then I get 2.827s on Apple M1 Max and Clang 16.0.6.
I get the following timings without optimization:
$ lc nbody.cpp
$ time ./nbody.out
...
./nbody.out 1.30s user 0.00s system 99% cpu 1.305 total
And with optimizations:
$ CPATH=$CONDA_PREFIX/include lc --show-llvm integration_tests/nbody.cpp > x.ll
$ clang++ -O3 -march=native -ffast-math x.ll src/runtime/liblc_runtime_static.a
$ time ./a.out
[...]
./a.out 0.17s user 0.00s system 98% cpu 0.170 total
As far as compilation speed goes, I get 1.019s for LC and 1.428s for Clang++, in the default (no compiler options) mode.
I also tried the fastest C++ version from here: https://gist.github.com/certik/c7803fe6cbf4f8a5ec3070dd699ecad3
And I get
$ clang++ -O3 -march=native -ffast-math a.cpp
$ time ./a.out 1000000
-0.169075164
-0.169086185
./a.out 1000000 0.04s user 0.00s system 92% cpu 0.046 total
So 3.6x faster than our LC version. Overall not bad I think as a start. We'll optimize things more in the future.
This version https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/nbody-gpp-3.html runs at 0.073s, so only 2.3x faster.
Sure. I will work on these two examples next. There are excellent features which will be added through these two examples.
num = 1000000