From pauljohn32 at gmail.com  Wed Nov 25 17:51:08 2015
From: pauljohn32 at gmail.com (Paul Johnson)
Date: Wed, 25 Nov 2015 10:51:08 -0600
Subject: [Rd] MKL Acceleration encouraging; need adjust package builds?
In-Reply-To: <DM2PR0301MB0848BF2B851C0D51A49629A3C8070@DM2PR0301MB0848.namprd03.prod.outlook.com>
References: <CAErODj87PsLYoihk8Cd+gd_oLLWx1oaxO-0G3rNe4i5j+AV38w@mail.gmail.com>
	<DM2PR0301MB0848BF2B851C0D51A49629A3C8070@DM2PR0301MB0848.namprd03.prod.outlook.com>
Message-ID: <CAErODj8USYxCbN5e2AB7nfFOX3zErQfPwKxHFew2+fcsHDdnsQ@mail.gmail.com>

On Mon, Nov 23, 2015 at 11:39 AM, David Smith <davidsmi at microsoft.com> wrote:
> Hi Paul,
>
> We've been through this process ourselves for the Revolution R Open project. There are a number of pitfalls to avoid, but you can take a look at how we achieved it in the build scripts at:
>
> https://github.com/RevolutionAnalytics/RRO
>
> There are also some very useful notes in the R Installation guide:
> https://cran.r-project.org/doc/manuals/r-release/R-admin.html#BLAS
>
> Most packages do benefit from MKL (or any multi-threaded BLAS) to some degree, although the actual benefit depends on the R functions they call. Some packages (and some built-in R functions) don't call into BLAS endpoints, so you won't see benefits in all cases.
>
> # David Smith
>
Dear David

I'm in the situation mentioned here in the docs, since BLAS is not shared.

"Note that under Unix (but not under Windows) if R is compiled against
a non-default BLAS and --enable-BLAS-shlib is not used, then all
BLAS-using packages must also be. So if R is re-built to use an
enhanced BLAS then packages such as quantreg will need to be
re-installed. "

I am building all of the modules from scratch, so if the default build
is sufficient, then I'll be done. When I asked the other day, I was
worried that packages would find the wrong shared library. As far as I
can tell now, I should not have been so worried.

Today, while browsing the R installation, I find the Makeconf file and
that has all the information a package should need.  I've verified
that the quantreg package detects this information, and we'll just
hope the others do too :)

In case anybody else comes along later and wonders how R can be
configured to make this go, here's the top of our Makeconf from the
installed R, which has the configure line as well as BLAS_LIBS, which,
so far as I can tell, is making all of this go.

Makeconf content

# etc/Makeconf.  Generated from Makeconf.in by configure.
#
# ${R_HOME}/etc/Makeconf
# R was configured using the following call
# (not including env. vars and site configuration)
# configure  '--prefix=/tools/cluster/6.2/R/3.2.2_mkl' '--with-tcltk'
'--enable-R-shlib' '--enable-shared' '--with-pic'
'--disable-BLAS-shlib'
'--with-blas=-L/panfs/pfs.acf.ku.edu/cluster/6.2/intel/2015/mkl/lib/intel64
-Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread
-lmkl_core  -Wl,--end-group -fopenmp  -ldl -lpthread -lm'
'--with-lapack'
'CFLAGS=-I/panfs/pfs.acf.ku.edu/cluster/system/pkg/R/curl7.45_install/include
-L/panfs/pfs.acf.ku.edu/cluster/6.2/R/3.2.2_mkl/lib64'
'JAVA_HOME=/tools/cluster/6.2/java/jdk1.8.0_66'

## This fails if it contains spaces, or if it is quoted
include $(R_SHARE_DIR)/make/vars.mk

AR = ar
## Used by packages 'maps' and 'mapdata'
AWK = gawk
BLAS_LIBS = -L/panfs/pfs.acf.ku.edu/cluster/6.2/intel/2015/mkl/lib/intel64
-Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread
-lmkl_core  -Wl,--end-group -fopenmp  -ldl -lpthread -lm
C_VISIBILITY = -fvisibility=hidden
...



pj

-- 
Paul E. Johnson
Professor, Political Science        Director
1541 Lilac Lane, Room 504      Center for Research Methods
University of Kansas                 University of Kansas
http://pj.freefaculty.org              http://crmda.ku.edu



[Rd] MKL Acceleration encouraging; need adjust package builds?
Paul Johnson