plasma: extract plasma changes from xsdk-0.3.0 (#6280)

* plasma: extract plasma changes from xsdk-0.3.0

* plasma: cleanup per review
- netlib-lapack: add support for spec['lapack:c'].libs, spec['blas:c'].libs
- add getblaslapacklibs() to eliminate duplicate code in edit() and build_targets()
- eliminate string manipulation of ld_flags

- remove gfortran check (will check later)
- remove build() (will check later)

* netlib-lapack: fix tuple per review

* netlib-lapack: use  spec[lapack:c,fortran]
This commit is contained in:
Satish Balay 2017-11-27 13:38:10 -06:00 committed by Todd Gamblin
parent 557309618f
commit 23bedc276c
3 changed files with 77 additions and 11 deletions

View File

@ -73,15 +73,47 @@ def patch(self):
@property @property
def blas_libs(self): def blas_libs(self):
shared = True if '+shared' in self.spec else False shared = True if '+shared' in self.spec else False
query_parameters = self.spec.last_query.extra_parameters
query2libraries = {
tuple(): ['libblas'],
('c', 'fortran'): [
'libcblas',
'libblas',
],
('c',): [
'libcblas',
],
('fortran',): [
'libblas',
]
}
key = tuple(sorted(query_parameters))
libraries = query2libraries[key]
return find_libraries( return find_libraries(
'libblas', root=self.prefix, shared=shared, recurse=True libraries, root=self.prefix, shared=shared, recurse=True
) )
@property @property
def lapack_libs(self): def lapack_libs(self):
shared = True if '+shared' in self.spec else False shared = True if '+shared' in self.spec else False
query_parameters = self.spec.last_query.extra_parameters
query2libraries = {
tuple(): ['liblapack'],
('c', 'fortran'): [
'liblapacke',
'liblapack',
],
('c',): [
'liblapacke',
],
('fortran',): [
'liblapack',
]
}
key = tuple(sorted(query_parameters))
libraries = query2libraries[key]
return find_libraries( return find_libraries(
'liblapack', root=self.prefix, shared=shared, recurse=True libraries, root=self.prefix, shared=shared, recurse=True
) )
def install_one(self, spec, prefix, shared): def install_one(self, spec, prefix, shared):

View File

@ -0,0 +1,11 @@
--- a/include/core_lapack.h 2017-01-13 13:59:46.000000000 -0500
+++ b/include/core_lapack.h 2017-10-30 16:37:54.481966195 -0400
@@ -27,7 +27,7 @@
// Netlib cblas.h does: enum CBLAS_ORDER {...};
// OpenBLAS cblas.h does: typedef enum CBLAS_ORDER {...} CBLAS_ORDER;
// We use (CBLAS_ORDER), so add these typedefs for Netlib.
- #ifndef OPENBLAS_VERSION
+ #if ! defined(OPENBLAS_VERSION) && ! defined(F77_HEADER_INCLUDED)
typedef enum CBLAS_ORDER CBLAS_ORDER;
typedef enum CBLAS_TRANSPOSE CBLAS_TRANSPOSE;
typedef enum CBLAS_UPLO CBLAS_UPLO;

View File

@ -27,18 +27,25 @@ class Plasma(MakefilePackage):
version("develop", hg="https://luszczek@bitbucket.org/icl/plasma") version("develop", hg="https://luszczek@bitbucket.org/icl/plasma")
variant('shared', default=True, description="Build shared library (disables static library)")
depends_on("blas") depends_on("blas")
depends_on("lapack") depends_on("lapack")
conflicts("atlas") # does not have LAPACKE interface conflicts("atlas") # does not have LAPACKE interface
conflicts("netlib-lapack@:2.999") # missing LAPACKE features
# missing LAPACKE features and/or CBLAS headers
conflicts("netlib-lapack@:3.5.999")
# clashes with OpenBLAS declarations and has a problem compiling on its own # clashes with OpenBLAS declarations and has a problem compiling on its own
conflicts("cblas") conflicts("cblas")
conflicts("openblas-with-lapack") # incomplete LAPACK implementation conflicts("openblas-with-lapack") # incomplete LAPACK implementation
conflicts("veclibfort") conflicts("veclibfort")
# only GCC 7+ and higher have sufficient support for OpenMP 4+ tasks+deps # only GCC 4.9+ and higher have sufficient support for OpenMP 4+ tasks+deps
conflicts("%gcc@:6.999") conflicts("%gcc@:4.8.99")
conflicts("%cce") conflicts("%cce")
conflicts("%clang") conflicts("%clang")
conflicts("%intel") conflicts("%intel")
@ -48,6 +55,16 @@ class Plasma(MakefilePackage):
conflicts("%xl_r") conflicts("%xl_r")
patch("remove_absolute_mkl_include.patch", when="@17.1") patch("remove_absolute_mkl_include.patch", when="@17.1")
patch("add_netlib_lapacke_detection.patch", when="@17.1")
def getblaslapacklibs(self):
if '^netlib-lapack' in self.spec:
bl_attr = ':c,fortran'
else:
bl_attr = ''
return self.spec['lapack' + bl_attr].libs + \
self.spec['blas' + bl_attr].libs + \
find_system_libraries(['libm'])
def edit(self, spec, prefix): def edit(self, spec, prefix):
# copy "make.inc.mkl-gcc" provided by default into "make.inc" # copy "make.inc.mkl-gcc" provided by default into "make.inc"
@ -55,7 +72,10 @@ def edit(self, spec, prefix):
make_inc = FileFilter("make.inc") make_inc = FileFilter("make.inc")
if not spec.satisfies("^mkl"): if '~shared' in self.spec:
make_inc.filter("-fPIC", "") # not using fPIC
if "^mkl" not in spec:
make_inc.filter("-DPLASMA_WITH_MKL", "") # not using MKL make_inc.filter("-DPLASMA_WITH_MKL", "") # not using MKL
header_flags = "" header_flags = ""
@ -63,7 +83,7 @@ def edit(self, spec, prefix):
for dep in ("blas", "lapack"): for dep in ("blas", "lapack"):
try: # in case the dependency does not provide header flags try: # in case the dependency does not provide header flags
header_flags += " " + spec[dep].headers.cpp_flags header_flags += " " + spec[dep].headers.cpp_flags
except AttributeError: except Exception:
pass pass
make_inc.filter("CFLAGS +[+]=", "CFLAGS += " + header_flags + " ") make_inc.filter("CFLAGS +[+]=", "CFLAGS += " + header_flags + " ")
@ -74,6 +94,9 @@ def edit(self, spec, prefix):
# make sure CC variable comes from build environment # make sure CC variable comes from build environment
make_inc.filter("CC *[?]*= * .*cc", "") make_inc.filter("CC *[?]*= * .*cc", "")
make_inc.filter("LIBS *[?]*= * .*", "LIBS = " +
self.getblaslapacklibs().ld_flags)
@property @property
def build_targets(self): def build_targets(self):
targets = list() targets = list()
@ -81,10 +104,10 @@ def build_targets(self):
# use $CC set by Spack # use $CC set by Spack
targets.append("CC = {0}".format(self.compiler.cc)) targets.append("CC = {0}".format(self.compiler.cc))
if self.spec.satisfies("^mkl"): if "^mkl" in self.spec:
targets.append("MKLROOT = {0}/mkl".format(env["MKLROOT"])) targets.append("MKLROOT = {0}".format(env["MKLROOT"]))
# pass BLAS library flags targets.append("LIBS = {0}".format(
targets.append("LIBS = {0}".format(self.spec["blas"].libs.ld_flags)) self.getblaslapacklibs().ld_flags))
return targets return targets