Re: Choosing Intel MKL BLAS when compiling R
On Nov 1, 2011, at 11:19 PM, Michael Braun wrote:
> Simon:
>
> Can you clarify your statement about OpenMP on OSX? Is this an issue with OpenMP in general, or just R's use
of it? Or just Intel's use of it?
>
It seems to be an issue in Apple's posix threads implementation that OpenMP relies on - it seems that the cost
of thread synchronization is several orders of magnitude higher than on Linux which mean you can't use it
for "short" tasks. It's deep enough the I don't think we can do anything about it. Luke Tierney has a good
test case that shows the problem, I'll see if I can forward it here.
Cheers,
Simon
> Michael
>
>
> On Nov 1, 2011, at 9:09 PM, Simon Urbanek wrote:
>
>>
>> On Nov 1, 2011, at 8:23 PM, Michael Braun wrote:
>>
>>> Jonathan:
>>>
>>> Compiling R, and linking to Intel MKL, is quite simple, as long as you are using a recent version of MKL.
Intel has a MKL Link Advisor at
>>>
>>> http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
>>>
>>> Choose the linking model you want, and then use the --with-blas option on configure. For example, on my
Mac, to link dynamically with the parallel version (which can be controlled with environment
variables), I use the following:
>>>
>>> '--with-blas=-L$(MKLROOT)/lib -lmkl_rt -lpthread -liomp5'
>>>
>>> I compiled R 2.14.0 this morning with this option, and it seems to work fine. I'm not sure what Dirk was
referencing about how MKL is no longer compatible with R. If there is an issue, it would be good to know about
it. Perhaps he can point us to the page in the documentation where this is mentioned.
>>>
>>
>> The issue is not relevant on OS X because OpenMP performance on OS X for vector parallelization is very
bad, so it is typically disabled.
>>
>> One comment to the earlier discussion - it's not always as simple as replacing the BLAS back-end due to ABI
difference in the different implementations. You'll notice, for example, when complex BLAS calls start
crashing (because R can work around such issues at configure time but not if you switch BLAS). On Debian I'm
usually compiling ATLAS by hand which yields the best performance so I don't run into that problem.
>>
>> Cheers,
>> Simon
>>
>>
>>
>>> I hope this helps.
>>>
>>> Michael
>>>
>>>
>>> On Nov 1, 2011, at 7:59 PM, <r-sig-hpc-request@...>
<r-sig-hpc-request@...> wrote:
>>>>
>>>>
>>>> Message: 1
>>>> Date: Tue, 1 Nov 2011 14:36:50 -0700
>>>> From: Jonathan Greenberg <jgrn@...>
>>>> To: r-sig-hpc@...
>>>> Subject: [R-sig-hpc] Choosing Intel MKL BLAS when compiling R
>>>> Message-ID:
>>>> <CABG0rfvnoswR+Hi7peaTAPczT_4j6FTV-H0rDLwqJOw05HrLuw@...>
>>>> Content-Type: text/plain; charset=ISO-8859-1
>>>>
>>>> r-sig-hpc'ers:
>>>>
>>>> I am compiling R 2.14 from scratch on a cluster computer (I can't use
>>>> any package managers for the install, unfortunately), and they have
>>>> the Intel MKL libraries available for BLAS/LAPACK. I have not
>>>> successfully gotten a configure/make/make install combo yet that uses
>>>> multiple CPUs to do, say:
>>>>
>>>> a = matrix(rnorm(5000*5000), 5000, 5000)
>>>> b = matrix(rnorm(5000*5000), 5000, 5000)
>>>> # This following line, minimally, should be getting distributed.
>>>> c = a%*%b
>>>>
>>>> First off, I've tried compiling it with the configure flags:
>>>> ./configure --prefix=/myprefix/ --enable-BLAS-shlib
>>>>
>>>> How do I then select the Intel MKL libraries to be used as the BLAS?
>>>> They are located in /usr/local/intel-11.1/mkl/lib/em64t
>>>>
>>>> Thanks!
>>>>
>>>> --j
>>>>
>>>>
>>>> --
>>>> Jonathan A. Greenberg, PhD
>>>> Assistant Professor
>>>> Department of Geography
>>>> University of Illinois at Urbana-Champaign
>>>> 607 South Mathews Avenue, MC 150
>>>> Urbana, IL 61801
>>>> Phone: 415-763-5476
>>>> AIM: jgrn307, MSN: jgrn307@..., Gchat: jgrn307, Skype: jgrn3007
>>>> http://www.geog.illinois.edu/people/JonathanGreenberg.html
>>>>
>>>>
>>>
>>> -------------------------------------------
>>> Michael Braun
>>> Associate Professor of Management Science (Marketing Group)
>>> MIT Sloan School of Management
>>> 100 Main St.., E62-535
>>> Cambridge, MA 02139
>>> braunm@...
>>> 617-253-3436
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> R-sig-hpc mailing list
>>> R-sig-hpc@...
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
>>
>
> -------------------------------------------
> Michael Braun
> Associate Professor of Management Science (Marketing Group)
> MIT Sloan School of Management
> 100 Main St.., E62-535
> Cambridge, MA 02139
> braunm@...
> 617-253-3436
>
>
>
>