Compiling Erlang with Intel® C++ Compiler Professional Edition for Linux

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:

  1. Prepare the source code, install the necessary libraries that Erlang needs to be compiled (see the previous post).
  2. Install Intel® C++ Compiler Professional Edition for Linux.
  3. Open a Bash console and go to your Erlang source directory.
  4. Set the paths to Intel’s compiler and libraries:
    1. LD_LIBRARY_PATH=/opt/intel/Compiler/11.1/056/lib/intel64:$LD_LIBRARY_PATH
    2. 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
  5. Run ./configure with the following options:
    1. ./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)

Compiling Erlang

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.

  1. 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
  2. First go to you build directory (were you usually to the builds of you programs).
  3. Get the Erlang source. What a pity… there is no cvs or svn repository. Get Erlang source code
      1. wget http://www.erlang.org/download/otp_src_R13B02.tar.gz
      1. tar -xzf otp_src_R13B02.tar.gz
  4. 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
  5. Compile the source code: make
  6. 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).