All in all I tried five different jags 4.2.0 versions on the same hardware (virtualized ubuntu guest, 256GB memory and 16 dedicated Intel Xeon Nehalem cores). The results are quite surprising, because gcc beats clang: The clang self-compiled version is slower than the pre-built binaries. And the HPC-optimized clang version is even slower. It's not a huge difference, but quite surprising. I will take a deeper look at the results in future if time permits it.
gcc -march=native -E -v - /null 2>&1 | grep cc1
In all self compiled versions, the same source code was used. Just the configuration was modified by adding flags or change the compiler. The following bash commands were used to download the source files:
wget -O jags.tar https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-4.2.0.tar.gz/download tar -xvf jags.tar cd JAGS-*
In the "not-HPC" optimized version, no extra flags were provided. I just called
./configure followed by
make -j 4 to build it.
This version should be optimized for high performance settings. Nice side-fact: These compiler flags are recommended by Intel for HPC :)
./configure OPT="-m64 -Ofast -flto -march=native -funroll-loops" make -j 4 clean all
Clang++ is a really nice C++ compiler-frontend and in combination with llvm you may get nice results. There are several possibilities to switch your compiler, I used environment variables:
export CC=clang export CXX=clang++
The same source and flags (Intels recommendation for HPC and no additional flags for default clang++) like before were used! And then I compiled it:
make -j 4 clean all
To install the self-compiled versions, I also used make like this:
sudo make install
Michael Rutter provides some pre-built binaries in his repository. You can install it like this:
sudo add-apt-repository ppa:marutter/rrutter sudo apt-get update sudo apt-get install r-cran-rjags
For benchmark purposes I used the mcmc-jags examples and measured the runtime.
wget -O jags-examples.tar https://sourceforge.net/projects/mcmc-jags/files/Examples/4.x/classic-bugs.tar.gz/download cd classic-bugs/vol1
export JAGS=`which jags` time make bench -j 10
- gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2)
- clang 3.8.0-2ubuntu4 (tags/RELEASE_380/final)