From nakama at ki.rim.or.jp  Thu Mar 19 02:08:21 2009
From: nakama at ki.rim.or.jp (Ei-ji Nakama)
Date: Thu, 19 Mar 2009 10:08:21 +0900
Subject: [Rd] [R] R with MKL
In-Reply-To: <dc41e1260903180517i10ede2e1p73d2bf0750ac2d6b@mail.gmail.com>
References: <fb1538e20903161533u599d8c00mef61f71bf2427a39@mail.gmail.com>
	<dc41e1260903162012y2d3d2414o41fbe5082945b7ae@mail.gmail.com>
	<fb1538e20903172251u3ad9cd64lcc27d305b26acdce@mail.gmail.com>
	<dc41e1260903180517i10ede2e1p73d2bf0750ac2d6b@mail.gmail.com>
Message-ID: <dc41e1260903181808l58b9522bx977dca4b39b9cb4@mail.gmail.com>

bug of MKL 11.0...

_gfortran_internal_malloc64 and _gfortran_internal_free is needed by [cz]labrad
in libmkl_gnu_thread.
There is it in libgfortran of gfortran-4.1 as an outside symbol, but
there is not it for
gfortran-4.2 or latter.
Many people pushed forward old gfortran, but there was not the problem
in gfortran-4.2
or latter.
if I did it as follows in my environment because the contents were
malloc and free either.

  # my copy for editing
  MKL_LIB_PATH=/usr/local/mkl
  ORIG_MKL_LIB_PATH=/opt/intel/Compiler/11.0/*/mkl/lib/em64t/
  mkdir $MKL_LIB_PATH
  cp $ORIG_MKL_LIB_PATH/{libmkl_gf_lp64,libmkl_core}.a $MKL_LIB_PATH
  cp $ORIG_MKL_LIB_PATH/libmkl_gnu_thread.a $MKL_LIB_PATH

  # add of _gfortran_internal_malloc64 and _gfortran_internal_free to
libmkl_gnu_thread.a
  wget http://prs.ism.ac.jp/~nakama/mkl/mkl_gf.c
  gcc -O3 -fPIC -g -c mkl_gf.c
  ar r $MKL_LIB_PATH/libmkl_gnu_thread.a mkl_gf.o

Because I may be recovered in the newer version, this work is unnecessary for
outside symbol if _gfortran_internal_free disappears.

 $ nm -A libmkl_gnu_thread.a |grep _gfortran_internal   # MKL11.0 now
libmkl_gnu_thread.a:zlabrd_omp.o:                 U _gfortran_internal_free
libmkl_gnu_thread.a:zlabrd_omp.o:                 U _gfortran_internal_malloc64
libmkl_gnu_thread.a:clabrd_omp.o:                 U _gfortran_internal_free
libmkl_gnu_thread.a:clabrd_omp.o:                 U _gfortran_internal_malloc64

Welcome to Hell of MKL.;-)

2009/3/18 Ei-ji Nakama <nakama at ki.rim.or.jp>:
> Hi Cristi?n.
>
>>> However, It is a little different.( -lgomp and configure line)
>>>
>>> MKL=" ? -L$@{MKL_LIB_PATH@} ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> ? ? ? ?-Wl,--start-group ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> ? ? ? ? ? ? ? ?$@{MKL_LIB_PATH@}/libmkl_gf_lp64.a ? ? ? ?\
>>> ? ? ? ? ? ? ? ?$@{MKL_LIB_PATH@}/libmkl_gnu_thread.a ? ? \
>>> ? ? ? ? ? ? ? ?$@{MKL_LIB_PATH@}/libmkl_core.a ? ? ? ? ? \
>>> ? ? ? ?-Wl,--end-group ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
>>> ? ? ? ?-lgomp -lpthread"
>>> ./configure --with-blas="$MKL" --with-lapack="$MKL"
>>>
>> ...
>>
>> Thanks for all your answers. I read carefully the userguide and the
>> admin guide. I now understand that with gfortran I need to use
>> libmkl_gf_lp64 and libmkl_gnu_thread, either shared or static.
>> Unfortunately for MKL version 10.1.1.019, libmkl_gnu_thread links
>> against the symbol "_gfortran_internal_malloc64" which was present in
>> gcc-4.1 and is not present anymore in gcc-4.3.
>
> However, the support ?of openmp is gcc-4.2 or latter.
>
>> So my alternatives are installing an older compiler, waiting for a
>> newer MKL version, building R with Intel compiler or switching away
>> from MKL.
>
> Please download the following files, and test the procedure to which
> the file is written first.
>
> ? ? ?http://prs.ism.ac.jp/~nakama/mkl/mkl_gf.c
>

-- 
EI-JI Nakama  <nakama (a) ki.rim.or.jp>
"\u4e2d\u9593\u6804\u6cbb"  <nakama (a) ki.rim.or.jp>



[Rd] [R] R with MKL
Ei-ji Nakama