2015년 5월 20일 수요일

Intel Math Kernel Library (MKL) and FFTW3 링크하기

먼저 MKL library의 위치를 찾을 것. 
MKL library에 FFTW가 포함되어 있다고 하지만 FFTW의 위치도 알아둘 것.

MKL libary를 사용하는 방법은 두가지가 있다.

(1) -mkl 옵션을 사용하는 방법
(2) 모든 옵션을 일일이 지정해 주는 방법
-mkl 옵션의 경우 default 설정이 무엇인가에  따라 달라지게 된다.일반적인 경우라면,

ifort test.f90 -mkl -o test_f
icc test.c -mkl -o test_c

만으로 충분하고 FFTW를 사용하는 경우에는 

icc test.c -w -DMKL_DOUBLE -I/opt/intel/Compiler/11.1/069/mkl/include/fftw -mkl -o test_c

ifort -I/opt/intel/Compiler/11.1/069/mkl/include/fftw test.f90 -mkl -o test_f

icc test.c -I/opt/intel/Compiler/11.1/069/mkl/include/fftw -mkl -o test_c

ifort test.f90 -I/opt/intel/Compiler/11.1/069/mkl/include/fftw -mkl -o test_f

와 같이 include path를 지정해 주는 것이 좋다고 한다. 

-mkl 옵션을 쓰지 않으면 아래와 같이 일일이 써 주어야한다. 

icc test.c -I/opt/intel/Compiler/11.1/069/mkl/include -I/opt/intel/Compiler/11.1/069/mkl/include/fftw
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm 
-L/opt/intel/Compiler/11.1/069/mkl/lib/em64t -o c_test 

ifort test.f90 -I/opt/intel/Compiler/11.1/069/mkl/include -I/opt/intel/Compiler/11.1/069/mkl/include/fftw 
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm 
-L/opt/intel/Compiler/11.1/069/mkl/lib/em64t -o f_test


(주의1) -lmkl_intel_lp64 는 64bit cpu 용 libary를 사용한다는 뜻이고,  
-lmkl_intel_ilp64 는 64bit cpu 용 libary를 사용하되 
정수도 64bit인 libary를 사용한다는 뜻으로 compile 할 때 -i8 option을 추가해 주어야 한다.   
ilp64를 사용할 경우 FFTW와 integer type이 다를 수 있으므로 주의해야 한다.

(주의2) FFTW2 를 사용할 경우는 option을 다르게 주어야한다.
icc test2.c -o test2_c -I/opt/intel/Compiler/11.1/069/mkl/include/fftw 
-L/opt/intel/Compiler/11.1/069/mkl/lib/em64t -lfftw2xc_intel -mkl 

ifort test2.f -o test2_f -I/opt/intel/Compiler/11.1/069/mkl/include/fftw 
-L/opt/intel/Compiler/11.1/069/mkl/lib/em64t -lfftw2xf_intel -mkl

만약 외부 FFTW library를 사용하는 경우에는 아래와 같이 사용한다.
ifort -O3 -o fftw_example.exe fftw_example.f -I/u/username/fftw/include -L/u/username/fftw/lib -lfftw3

참고:

http://geco.mines.edu/software/mkl/fftw/

http://www.nas.nasa.gov/hecc/support/kb/MKL-FFTW-Interface_204.html



(Details on the -mkl option )


-mkl[=]
          link to the Intel(R) Math Kernel Library (Intel(R) MKL) and
          bring in the associated headers
            parallel   - link using the threaded Intel(R) MKL libraries.
                         This is the default when -mkl is specified
            sequential - link using the non-threaded Intel(R) MKL libraries
            cluster    - link using the Intel(R) MKL Cluster libraries plus
                         the sequential Intel(R) MKL libraries
The libraries that are linked in for:
    * -mkl=parallel

          --start-group \
          -lmkl_solver_lp64 \
          -lmkl_intel_lp64 \
          -lmkl_intel_thread \
          -lmkl_core \
          -liomp5 \
          --end-group \

    * -mkl=sequential

          --start-group \
          -lmkl_solver_lp64_sequential \
          -lmkl_intel_lp64 \
          -lmkl_sequential \
          -lmkl_core \
          --end-group \

    * -mkl=cluster

          --start-group \
          -lmkl_solver_lp64 \
          -lmkl_intel_lp64 \
          -lmkl_cdft_core \
          -lmkl_scalapack_lp64 \
          -lmkl_blacs_lp64 \
          -lmkl_sequential \
          -lmkl_core \
          -liomp5 \
          --end-group \

댓글 없음:

댓글 쓰기