Posted by marian
on October 26, 2009
First of all, a big plus to Intel for providing the compiler free on Linux, for non-comercial use. Compiling Erlang with the Intel Compiler has greatly increased the speed of the Erlang VM (in my case, with the trade-off of increasing slightly the memory requirements). You should expect something about 20% to 30% overall speedup.
But compilling it, took me some time. A succesful compilation envolves the followin steps:
- Prepare the source code, install the necessary libraries that Erlang needs to be compiled (see the previous post).
- Install Intel® C++ Compiler Professional Edition for Linux.
- Open a Bash console and go to your Erlang source directory.
- Set the paths to Intel’s compiler and libraries:
-
LD_LIBRARY_PATH=/opt/intel/Compiler/11.1/056/lib/intel64:$LD_LIBRARY_PATH
-
PATH=/opt/intel/Compiler/11.1/056/mkl/lib/em64t:/opt/intel/Compiler/11.1/056/lib/intel64:/opt/intel/Compiler/11.1/056/bin/intel64/:$PATH
- Run ./configure with the following options:
-
./configure CC=icc CFLAGS="-gcc-version=420 -xssse3 -mssse3 -ip -par-threshold=50 -fp-model strict -prec-div -prec-sqrt -pc80 -opt-streaming-stores always -par-threshold=50 -par-runtime-control -par-schedule-static-balanced -static-libgcc -static-intel" –enable-smp-support –enable-threads –enable-kernel-poll –enable-hipe –with-ssl
This optimizes:
- floating point operations they are more exact, and less fast (internal representation on 80 bit -pc80)
- memory operations
But to get this we need:
- we compile for Intel 64 bit processors
- we use the SSSE3 instructions that my processor is capable of
- we assume that threads are memory bounded so we use -opt-streaming-stores, and a static threading model
- we statically link any needed Intel libraries -static-intel
- we statically link libgcc, but I don’t think this is necessary (and increases the size of the executable)
Posted by marian
on October 26, 2009
There comes a day when you need to squize every bit of performance from Erlang or you need it for some exotic platform (or you are just a Slackware user). For doing this you either improve your program or use Erlang Virtual Machine optimization. This tutorial comprises the steps needed to compile Erlang.
- First get the tools needed for compilation: sudo apt-get install build-essential libncurses5-dev m4 openssl libssl-dev unixodbc-dev libstdc++5 libc6 .Please note that you need to install libstdc++5 R(compatibility) inspite the fact that you may have a newer version (they can co-exist). Regarding wx, well I had some issues with it. By some way you should have on your system:
libpthread-stubs0
libxcb1-dev
libx11-dev
mesa-common-dev
libgl1-mesa-dev
libglu1-mesa-dev
libice-dev
libsm-dev
x11proto-xext-dev
libxt-dev
freeglut3-dev
libglut3-dev
wx2.8-headers
libwxgtk2.8-dev
wx-common
wx2.8-i18n
- First go to you build directory (were you usually to the builds of you programs).
- Get the Erlang source. What a pity… there is no cvs or svn repository. Get Erlang source code
-
-
wget http://www.erlang.org/download/otp_src_R13B02.tar.gz
-
-
tar -xzf otp_src_R13B02.tar.gz
- In the Erlang source directory run the configuration script: ./configure. You can pass arguments to configure (see the docs), I use: ./configure –enable-smp-support –enable-threads –enable-kernel-poll –enable-hipe –with-ssl
- Compile the source code: make
- Install it using: sudo make install, but I do not recommend it. I generally have on my system multiple Erlang builds. Some of them use precise floating for backpropagation in neural network learning, others use fast floating point for instance in genetic algorithm testing, and last but not least some or compiled so that the node data throughtput is enhanced (crypto package, memory stores -> streaming).