Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly configure R for BLAS/LAPACK & check configure output #1292

Merged
merged 2 commits into from Nov 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 30 additions & 7 deletions easybuild/easyblocks/r/r.py
Expand Up @@ -26,12 +26,15 @@
EasyBuild support for building and installing R, implemented as an easyblock

@author: Jens Timmerman (Ghent University)
@author: Kenneth Hoste (Ghent University)
"""
import os
import re
from distutils.version import LooseVersion

import easybuild.tools.environment as env
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.tools import environment
from easybuild.tools.build_log import print_warning
from easybuild.tools.modules import get_software_root
from easybuild.tools.systemtools import get_shared_lib_ext

Expand All @@ -55,19 +58,39 @@ def prepare_for_extensions(self):
self.cfg['exts_filter'] = EXTS_FILTER_R_PACKAGES

def configure_step(self):
"""Configuration step, we set FC, F77 is already set by EasyBuild to the right compiler,
FC is used for Fortan90"""
environment.setvar('FC', self.toolchain.get_variable('F90'))
"""Custom configuration for R."""

# define $BLAS_LIBS to build R correctly against BLAS/LAPACK library
# $LAPACK_LIBS should *not* be specified since that may lead to using generic LAPACK
# see https://github.com/easybuilders/easybuild-easyconfigs/issues/1435
env.setvar('BLAS_LIBS', os.getenv('LIBBLAS_MT'))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using $LIBBLAS_MT here, while existing R easyconfigs use $LIBBLAS.

This matter mainly when using Intel MKL, i.e. multithreaded vs sequential, see also the discussion in #202.

We could/should make this configurable, and stick to linking with the sequential BLAS library by default?

self.cfg.update('configopts', "--with-blas --with-lapack")

# make sure correct config script is used for Tcl/Tk
for dep in ['Tcl', 'Tk']:
root = get_software_root(dep)
if root:
dep_config = os.path.join(root, 'lib', '%sConfig.sh' % dep.lower())
self.cfg.update('configopts', '-with-%s-config=%s' % (dep.lower(), dep_config))
self.cfg.update('configopts', '--with-%s-config=%s' % (dep.lower(), dep_config))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nasty typo here, this went undetected because the existing R easyconfigs already include --with-tcl-config and --with-tk-config in configopts...


out = ConfigureMake.configure_step(self)

# check output of configure command to verify BLAS/LAPACK settings
ext_libs_regex = re.compile("External libraries:.*BLAS\((?P<BLAS>.*)\).*LAPACK\((?P<LAPACK>.*)\)")
res = ext_libs_regex.search(out)
if res:
for lib in ['BLAS', 'LAPACK']:
if res.group(lib) == 'generic':
warn_msg = "R will be built with generic %s, which will result in poor performance." % lib
self.log.warning(warn_msg)
print_warning(warn_msg)
else:
self.log.info("R is configured to use non-generic %s: %s", lib, res.group(lib))
else:
warn_msg = "R is configured to be built without BLAS/LAPACK, which will result in (very) poor performance"
self.log.warning(warn_msg)
print_warning(warn_msg)

ConfigureMake.configure_step(self)

def make_module_req_guess(self):
"""
Add extra paths to modulefile
Expand Down