Hi, I have seen a lot of problems from people trying to compile R with MKL. So I am writing my experience in case it helps and to ask one question. I installed R-2.8.1.patched in Ubuntu 9.04 (gcc 4.3.3) using MKL 10.1.1.019. I configured correctly (following MKL userguide) with : sudo ./configure --with-blas="-I/opt/intel/mkl/10.1.1.019/include -L/opt/intel/mkl/10.1.1.019/lib/em64t -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread" --with-lapack="-I/opt/intel/mkl/10.1.1.019/include -L/opt/intel/mkl/10.1.1.019/lib/em64t -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread" But in order to compile had to edit src/modules/lapack/vecLibg95c.c and comment out the include. Weird, since I am not building for Mac. Make check returned no error. I checked with ldd that R is linked against MKL. All demos run. I set MKL_NUM_THREADS={1,2} environment var and run R-benchmark-25.R from (http://r.research.att.com/benchmarks/R-benchmark-25.R). Not all tests use MKL so you get around 20% improvement for 2 cores. Also monitoring with top you can see which tests use 2 cores. Question: Am I set? What was that error relating to vecLib? I need to install now on a bigger multicore server for data-mining and dont want to deliver a defective installation. Maybe I could run a larger check-benchmark. Thanx a lot, C.
Hi> I have seen a lot of problems from people trying to compile R with > MKL. So I am writing my experience in case it helps and to ask one > question. I installed R-2.8.1.patched in Ubuntu 9.04 (gcc 4.3.3) using > MKL 10.1.1.019.Do you use gcc and gfortran?> I configured correctly (following MKL userguide) with : > > sudo ./configure --with-blas="-I/opt/intel/mkl/10.1.1.019/include > -L/opt/intel/mkl/10.1.1.019/lib/em64t -lmkl_intel_lp64 > -lmkl_intel_thread -lmkl_core -liomp5 -lpthread" > --with-lapack="-I/opt/intel/mkl/10.1.1.019/include > -L/opt/intel/mkl/10.1.1.019/lib/em64t -lmkl_intel_lp64 > -lmkl_intel_thread -lmkl_core -liomp5 -lpthread"cited reference https://svn.r-project.org/R/trunk/doc/manual/R-admin.texi | You are strongly encouraged to read the MKL User's Guide | <snip> | @example | 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 \ | -liomp5 -lpthread" | @end example 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"> But in order to compile had to edit src/modules/lapack/vecLibg95c.c > and comment out the include. Weird, since I am not building for Mac.Please note the thing that ABI of fortran is different with Intel compiler and GNU compiler. difficult to detect the mistake. -- EI-JI Nakama <nakama (a) ki.rim.or.jp> "\u4e2d\u9593\u6804\u6cbb" <nakama (a) ki.rim.or.jp>
On Mon, 2009-03-16 at 18:33 -0400, Cristi?n wrote:> Hi, > > I have seen a lot of problems from people trying to compile R with > MKL. So I am writing my experience in case it helps and to ask one > question. I installed R-2.8.1.patched in Ubuntu 9.04 (gcc 4.3.3) using > MKL 10.1.1.019.The R-admin manual has been updated with instructions for MKL since the last thread on the topic. You should look there in section A.3.1.4.> I configured correctly (following MKL userguide) with : > > sudo ./configure --with-blas="-I/opt/intel/mkl/10.1.1.019/include > -L/opt/intel/mkl/10.1.1.019/lib/em64t -lmkl_intel_lp64 > -lmkl_intel_thread -lmkl_core -liomp5 -lpthread" > --with-lapack="-I/opt/intel/mkl/10.1.1.019/include > -L/opt/intel/mkl/10.1.1.019/lib/em64t -lmkl_intel_lp64 > -lmkl_intel_thread -lmkl_core -liomp5 -lpthread" > > But in order to compile had to edit src/modules/lapack/vecLibg95c.c > and comment out the include. Weird, since I am not building for Mac.OK. There are two things happening here. You are using the wrong interface layer. With gcc you need to use -lmkl_gf_lp64, since the way that complex numbers are represented differs between Intel and GNU compilers. There is a known workaround for this problem for MacOs X, using the cblas interface. Apparently, this workaround is also being applied here. I will look into it.> Make check returned no error. I checked with ldd that R is linked > against MKL. All demos run > > I set MKL_NUM_THREADS={1,2} environment var and run R-benchmark-25.R > from (http://r.research.att.com/benchmarks/R-benchmark-25.R). Not all > tests use MKL so you get around 20% improvement for 2 cores. Also > monitoring with top you can see which tests use 2 cores. > > Question: Am I set? What was that error relating to vecLib? I need to > install now on a bigger multicore server for data-mining and dont want > to deliver a defective installation. Maybe I could run a larger > check-benchmark. > > Thanx a lot, > > C. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.----------------------------------------------------------------------- This message and its attachments are strictly confidenti...{{dropped:8}}
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>
On Mon, Mar 16, 2009 at 3:33 PM, Cristi?n <cgarciaw at gmail.com> wrote:> Hi, > > I have seen a lot of problems from people trying to compile R with > MKL.It's not clear what platform you're on, but if you're just looking for a precompiled binary of R with the MKL libraries, you might want to try REvolution R (our distribution of R, currently based on R 2.7.2). You can download binary distribitions for Windows (32-bit) or MacOS here: http://www.revolution-computing.com/downloads/revolution-r.php # David Smith -- David M Smith <david at revolution-computing.com> Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (Seattle, USA) Check out our upcoming events schedule at www.revolution-computing.com/events
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>
Both gcc and MKL are moving targets. So if you are using a more recent version of gcc than the one used to compile MKL then you are potentially in trouble. In this case, you still have the option of using Intel threads (libmkl_intel_thread) instead of the GNU thread library. In this case you must dynamically link to the Intel OpenMP runtime library libiomp5 instead of the GNU library libgomp. Of course, this does not help if you want to make a portable version of R, statically linked to MKL. On Wed, 2009-03-18 at 21:17 +0900, Ei-ji Nakama wrote:> 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 >----------------------------------------------------------------------- This message and its attachments are strictly confidenti...{{dropped:8}}