Search code examples
cintel-mkl

Segmentation fault during running for mkl's interface


I am running mkl_lab_solution.c which is an example for using MKL, I can compile it correctly, while I run it, I got Segmentation fault.My runtime is below:

  1. OS is centos 6.3
  2. gcc's version is 4.1.2
  3. mkl is mkl_10.3.12.361
  4. makefile is below

    gcc -g -L/opt/intel/composer_xe_2011_sp1.12.361/mkl/lib/intel64 -lmkl_intel_ilp64 -lmkl_intel_lp64 -lmkl_intel_sp2dp -lmkl_intel_thread -lmkl_core -lpthread -L/opt/intel/composer_xe_2011_sp1.12.361/compiler/lib/intel64 -liomp5 -L/usr/lib64 -lstdc++ -I/opt/intel/composer_xe_2011_sp1.12.361/mkl/include -o test mkl-lab-solution.c


Solution

  • Since this works fine on my system, let me point you to possible errors. First, you need to run . /path/to/intel/compilervars.sh intel64 such all environment variables are set, like MKLROOT. Second, check on intel mkl link line advisor for the options on your system. So reading your compile command I guess: linux, gnu compiler, dynamic linked, 64 bit target architecture, 64 bit long pointer, multithreaded, intel omp library.

    These settings give me:

    linker options:

    -L$(MKLROOT)/lib/intel64 -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm

    compile options:

    -DMKL_ILP64 -m64 -I$(MKLROOT)/include

    For whatever reason the brackets around MKLROOT don't work on bash, so just remove them. Next remember to put all compile options in front of linker options. The final command line should read like this:

    gcc mkl-lab-solution.c -DMKL_ILP64 -m64 -I$MKLROOT/include -L$MKLROOT/lib/intel64 -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm

    Since you get runtime errors, I suspect that you are linking the Intel MKL libraries with objects compiled for different interface layers.