How to compile serial version of OpenMX software on linux using different compilers and scientific libraries.

This mini HOWTO describes different compilation scenarios on machines with AMD Opteron CPU. OpenMX source package contains makefile prepared for many compilers. Here I'll give some advises.

Intel icc compiler since version 10.0 is prepared especially for Intel CoreDuo processors. Switch -fast, used often during compilation of computational software, means -O3 optimization, which currently means you have to own Core Duo processor (or compatible). Best results on Opteron machines can now be obtained using following switches:
icc -ip -ipo -O2 -mcmodel=medium -m64 -xW -static -no-prec-div
Using -O3 optimization produces executable which fails during FT_NLP procedure with Segmentation fault.

I've tried few blas/lapack libraries. There's not so much difference in time used for computation. To link with Intel MKL libraries I'm using following parameters:
LIB = /opt/fftw3/lib/libfftw3.a -L/opt/intel/libraries/cmkl/9.1.023/lib/em64t -lmkl_lapack -lmkl_em64t -lguide -lpthread -lsvml -ip -ipo -static -i-static
Linking with Atlas library built by Axel Kohlmeyer (it's almost as good as the newest Intel MKL (9.1) library):
LIB = /opt/fftw3/lib/libfftw3.a /opt/atlas/libatlas_x86_64.a -ip -ipo -static -i-static

Now some tips for SUN compiler:
CC = /opt/sunstudio12/bin/cc -Dnompi -m64 -static -xO2 -xarch=sse2a -xchip=opteron -xipo=2 -fast
LD = /opt/sunstudio12/bin/f90 -Dnompi -m64
LIB = /opt/fftw3_sunstudio12/lib/libfftw3.a -L/opt/sunstudio12/lib -lsunperf -static
There's also one more change in makefile needed:
openmx: $(OBJS)
$(LD) $(OBJS) $(STACK) $(LIB) -o openmx

It's just one have to use fortran compiler when linking with SUN performance library, and OpenMX software is written in C. So makefile is prepared for linking using the same compiler all the time. Which is OK almost every time.

Lastly we'll take a look at GNU compiler. I'm using gcc4.0.3 and during linking one have to use gfortan, just like with SUN compilers. Parameters:
CC = gcc -Dnompi -O3 -march=opteron -m64 -ffast-math -static -I/opt/acml4.0.0/gfortran64/include
LD = gfortran -Dnompi -O2 -m64 -static -I/opt/acml4.0.0/gfortran64/include
LIB = /opt/fftw3_gfortran/lib/libfftw3.a /opt/acml4.0.0/gfortran64/lib/libacml.a -lpthread -static
And same like with SUN compilers, change in makefile:
openmx: $(OBJS)
$(LD) $(OBJS) $(STACK) $(LIB) -o openmx

And now some results. I've used machine with two dual core opteron 265 (1.8GHz) CPUs with 8GB of RAM. Using compilers and libraries described above I got following results for openmx -runtest:

  • icc9.1 / mkl 8.1.1 : 1451s
  • icc10.0 / mkl 8.1.1: 1476s
  • icc10.0 / mkl 9.1: 1418s
  • icc10.0 / atlas: 1443s
  • gcc/gfortran 4.0.3 / acml4.0.0: 1620s
  • suncc12 / sunperflib: 1541s

I had no luck compiling with suncc and acml (there's lack of acml for sunstudio under linux). Also I didn't manage to produce executable using icc and acml. There's a statement one should use gfortran version of acml library, but that's not working with C compiler or just I didn't try really hard.