Commit 456e9088 authored by Dmytro Kresan's avatar Dmytro Kresan
Browse files

Backport amdblis and amdlibflame.

parent 80a33f77
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack.pkg.vae_backports.blis import BlisBase
class Amdblis(BlisBase):
"""AMD Optimized BLIS.
BLIS is a portable software framework for instantiating high-performance
BLAS-like dense linear algebra libraries. The framework was designed to
isolate essential kernels of computation that, when optimized, immediately
enable optimized implementations of most of its commonly used and
computationally intensive operations.
"""
_name = 'amdblis'
homepage = "https://developer.amd.com/amd-aocl/blas-library/"
url = "https://github.com/amd/blis/archive/3.0.tar.gz"
git = "https://github.com/amd/blis.git"
maintainers = ['amd-toolchain-support']
version('3.0', sha256='ac848c040cd6c3550fe49148dbdf109216cad72d3235763ee7ee8134e1528517')
version('2.2', sha256='e1feb60ac919cf6d233c43c424f6a8a11eab2c62c2c6e3f2652c15ee9063c0c9')
def configure_args(self):
spec = self.spec
args = super(Amdblis, self).configure_args()
if spec.satisfies('@3.0 %aocc'):
""" To enabled Fortran to C calling convention for
complex types when compiling with aocc flang"""
args.append('CFLAGS={0}'.format("-DAOCL_F2C"))
args.append('CXXFLAGS={0}'.format("-DAOCL_F2C"))
return args
--- a/configure 2020-09-09 18:44:01.241188553 +0530
+++ b/configure 2020-09-09 18:46:51.672191301 +0530
@@ -6513,6 +6513,9 @@
gcc)
fla_c_openmp_flags='-fopenmp'
;;
+ clang)
+ fla_c_openmp_flags='-fopenmp'
+ ;;
pathcc)
fla_c_openmp_flags='-mp'
;;
commit 8c06c4fd8b3f5b41431a06eb72bcc827b729db86
Author: Tiziano Müller <tiziano.mueller@chem.uzh.ch>
Date: Mon Jun 14 22:20:17 2021 +0200
use separate whole-archive/no-whole-archive to fix build with Cray compiler wrappers
diff --git a/Makefile b/Makefile
index d50f9d19..0c7c15c4 100644
--- a/Makefile
+++ b/Makefile
@@ -566,7 +566,7 @@ ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
ifeq ($(OS_NAME),Darwin)
$(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A) $(LDFLAGS)
else
- $(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),--no-whole-archive $(LDFLAGS)
+ $(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive $(LIBFLAME_A) -Wl,--no-whole-archive $(LDFLAGS)
endif
else
# NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in
@@ -580,7 +580,7 @@ ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
ifeq ($(OS_NAME),Darwin)
@$(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A) $(LDFLAGS)
else
- @$(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),--no-whole-archive $(LDFLAGS)
+ @$(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive $(LIBFLAME_A) -Wl,--no-whole-archive $(LDFLAGS)
endif
else
# NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# ----------------------------------------------------------------------------\
from spack.pkg.vae_backports.libflame import LibflameBase
class Amdlibflame(LibflameBase):
"""libFLAME (AMD Optimized version) is a portable library for
dense matrix computations, providing much of the functionality
present in Linear Algebra Package (LAPACK). It includes a
compatibility layer, FLAPACK, which includes complete LAPACK
implementation.
The library provides scientific and numerical computing communities
with a modern, high-performance dense linear algebra library that is
extensible, easy to use, and available under an open source
license. libFLAME is a C-only implementation and does not
depend on any external FORTRAN libraries including LAPACK.
There is an optional backward compatibility layer, lapack2flame
that maps LAPACK routine invocations to their corresponding
native C implementations in libFLAME. This allows legacy
applications to start taking advantage of libFLAME with
virtually no changes to their source code.
In combination with BLIS library which includes optimizations
for the AMD EPYC processor family, libFLAME enables running
high performing LAPACK functionalities on AMD platform.
"""
_name = 'amdlibflame'
homepage = "https://developer.amd.com/amd-cpu-libraries/blas-library/#libflame"
url = "https://github.com/amd/libflame/archive/3.0.tar.gz"
git = "https://github.com/amd/libflame.git"
maintainers = ['amd-toolchain-support']
version('3.0', sha256='d94e08b688539748571e6d4c1ec1ce42732eac18bd75de989234983c33f01ced')
version('2.2', sha256='12b9c1f92d2c2fa637305aaa15cf706652406f210eaa5cbc17aaea9fcfa576dc')
patch('aocc-2.2.0.patch', when="@:2", level=1)
patch('cray-compiler-wrapper.patch')
provides('flame@5.2', when='@2:')
depends_on('python+pythoncmd', type='build')
@property
def lapack_libs(self):
"""find lapack_libs function"""
shared = True if '+shared' in self.spec else False
return find_libraries(
'libflame', root=self.prefix, shared=shared, recursive=True
)
def configure_args(self):
"""configure_args function"""
args = super(Amdlibflame, self).configure_args()
args.append("--enable-external-lapack-interfaces")
"""To enabled Fortran to C calling convention for
complex types when compiling with aocc flang"""
if "@3.0: %aocc" in self.spec:
args.append("--enable-f2c-dotc")
return args
def install(self, spec, prefix):
"""make install function"""
# make install in parallel fails with message 'File already exists'
make("install", parallel=False)
From bc16ec7d1e2a30ce4a751255b70c9cbe87409e4f Mon Sep 17 00:00:00 2001
From: "Field G. Van Zee" <field@cs.utexas.edu>
Date: Mon, 23 Sep 2019 15:37:33 -0500
Subject: [PATCH] Set execute bits of shared library at install-time.
Details:
- Modified the 0644 octal code used during installation of shared
libraries to 0755 (for Linux/OSX only). Thanks to Adam J. Stewart
for reporting this issue via #343.
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 9cc81c9d..3c0e27f3 100644
--- a/Makefile
+++ b/Makefile
@@ -953,11 +953,11 @@ ifeq ($(IS_WIN),no)
$(INSTALL_LIBDIR)/%.$(LIBBLIS_SO_MMB_EXT): $(BASE_LIB_PATH)/%.$(SHLIB_EXT) $(CONFIG_MK_FILE)
ifeq ($(ENABLE_VERBOSE),yes)
$(MKDIR) $(@D)
- $(INSTALL) -m 0644 $< $@
+ $(INSTALL) -m 0755 $< $@
else
@echo "Installing $(@F) into $(INSTALL_LIBDIR)/"
@$(MKDIR) $(@D)
- @$(INSTALL) -m 0644 $< $@
+ @$(INSTALL) -m 0755 $< $@
endif
else # ifeq ($(IS_WIN),yes)
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
# Although this looks like an Autotools package, it's not one. Refer to:
# https://github.com/flame/blis/issues/17
# https://github.com/flame/blis/issues/195
# https://github.com/flame/blis/issues/197
class BlisBase(Package):
"""Base class for building BLIS, shared with the AMD optimized version
of the library in the 'amdblis' package.
"""
depends_on('python@2.7:2.8,3.4:', type=('build', 'run'))
variant(
'threads', default='none',
description='Multithreading support',
values=('pthreads', 'openmp', 'none'),
multi=False
)
variant(
'blas', default=True,
description='BLAS compatibility',
)
variant(
'cblas', default=True,
description='CBLAS compatibility',
)
variant(
'shared', default=True,
description='Build shared library',
)
variant(
'static', default=True,
description='Build static library',
)
# TODO: add cpu variants. Currently using auto.
# If one knl, should the default be memkind ?
# BLIS has it's own API but can be made compatible with BLAS
# enabling CBLAS automatically enables BLAS.
provides('blas', when="+blas")
provides('blas', when="+cblas")
phases = ['configure', 'build', 'install']
def configure_args(self):
spec = self.spec
config_args = []
config_args.append("--enable-threading=" +
spec.variants['threads'].value)
if '+cblas' in spec:
config_args.append("--enable-cblas")
else:
config_args.append("--disable-cblas")
if '+blas' in spec:
config_args.append("--enable-blas")
else:
config_args.append("--disable-blas")
if '+shared' in spec:
config_args.append("--enable-shared")
else:
config_args.append("--disable-shared")
if '+static' in spec:
config_args.append("--enable-static")
else:
config_args.append("--disable-static")
return config_args
def configure(self, spec, prefix):
config_args = self.configure_args()
# To ensure auto should always be the
# last argument for base and derived class
config_args.append("auto")
configure("--prefix=" + prefix,
*config_args)
def build(self, spec, prefix):
make()
@run_after('build')
@on_package_attributes(run_tests=True)
def check(self):
make('check')
def install(self, spec, prefix):
make('install')
@run_after('install')
def darwin_fix(self):
# The shared library is not installed correctly on Darwin; fix this
if self.spec.satisfies('platform=darwin'):
fix_darwin_install_name(self.prefix.lib)
@property
def libs(self):
return find_libraries(
["libblis", "libblis-mt"],
root=self.prefix,
shared='+shared' in self.spec,
recursive=True
)
class Blis(BlisBase):
"""BLIS is a portable software framework for instantiating high-performance
BLAS-like dense linear algebra libraries.
The framework was designed to isolate essential kernels of computation
that, when optimized, immediately enable optimized implementations of
most of its commonly used and computationally intensive operations. BLIS
is written in ISO C99 and available under a new/modified/3-clause BSD
license. While BLIS exports a new BLAS-like API, it also includes a
BLAS compatibility layer which gives application developers access to
BLIS implementations via traditional BLAS routine calls.
An object-based API unique to BLIS is also available.
"""
homepage = "https://github.com/flame/blis"
url = "https://github.com/flame/blis/archive/0.7.0.tar.gz"
git = "https://github.com/flame/blis.git"
version('master', branch='master')
version('0.8.1', sha256='729694128719801e82fae7b5f2489ab73e4a467f46271beff09588c9265a697b')
version('0.8.0', sha256='5e05868c4a6cf5032a7492f8861653e939a8f907a4fa524bbb6e14394e170a3d')
version('0.7.0', sha256='7e345d666799e15bba570bd125f97042f17bf752a61dcf314486a6cd096d5f68')
version('0.6.1', sha256='76b22f29b7789cf117c0873d2a6b2a6d61f903869168148f2e7306353c105c37')
version('0.6.0', sha256='ad5765cc3f492d0c663f494850dafc4d72f901c332eb442f404814ff2995e5a9')
version('0.5.0', sha256='1a004d69c139e8a0448c6a6007863af3a8c3551b8d9b8b73fe08e8009f165fa8')
version('0.4.0', sha256='9c7efd75365a833614c01b5adfba93210f869d92e7649e0b5d9edc93fc20ea76')
version('0.3.2', sha256='b87e42c73a06107d647a890cbf12855925777dc7124b0c7698b90c5effa7f58f')
version('0.3.1', sha256='957f28d47c5cf71ffc62ce8cc1277e17e44d305b1c2fa8506b0b55617a9f28e4')
version('0.3.0', sha256='d34d17df7bdc2be8771fe0b7f867109fd10437ac91e2a29000a4a23164c7f0da')
version('0.2.2', sha256='4a7ecb56034fb20e9d1d8b16e2ef587abbc3d30cb728e70629ca7e795a7998e8')
# Problems with permissions on installed libraries:
# https://github.com/flame/blis/issues/343
patch('Makefile_0.6.0.patch', when='@0.4.0:0.6.0')
--- a/Makefile 2019-07-30 00:12:13.030672681 -0500
+++ b/Makefile 2019-07-30 00:14:16.535602616 -0500
@@ -370,10 +370,8 @@
# --- Static library archiver rules for libflame ---
$(MK_ALL_FLAMEC_LIB): $(MK_ALL_FLAMEC_OBJS)
-define EOL
-endef
ifeq ($(FLA_ENABLE_VERBOSE_MAKE_OUTPUT),yes)
ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes)
@$(eval ar_args:=)
From 4356779fe843fb30b3728f5fdab049c7291d89c6 Mon Sep 17 00:00:00 2001
From: "Field G. Van Zee" <field@cs.utexas.edu>
Date: Mon, 23 Sep 2019 15:15:15 -0500
Subject: [PATCH] Set execute bits of shared library at install-time.
Details:
- Modified the 0644 octal code used during installation of shared
libraries to 0755. Thanks to Adam J. Stewart for reporting this
issue in #24.
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index d856af4c..6bd8bdce 100644
--- a/Makefile
+++ b/Makefile
@@ -643,11 +643,11 @@ endif
$(INSTALL_LIBDIR)/%.$(LIBFLAME_SO_MMB_EXT): $(BASE_LIB_PATH)/%.$(SHLIB_EXT) $(CONFIG_MK_FILE)
ifeq ($(ENABLE_VERBOSE),yes)
$(MKDIR) $(@D)
- $(INSTALL) -m 0644 $< $@
+ $(INSTALL) -m 0755 $< $@
else
@echo "Installing $(@F) into $(INSTALL_LIBDIR)/"
@$(MKDIR) $(@D)
- @$(INSTALL) -m 0644 $< $@
+ @$(INSTALL) -m 0755 $< $@
endif
From 6dd3c19978a0b805b0e294271ce8f5ef2f421425 Mon Sep 17 00:00:00 2001
From: "Field G. Van Zee" <field@cs.utexas.edu>
Date: Wed, 25 Sep 2019 12:46:23 -0500
Subject: [PATCH] Use OSX-specific SOFLAGS when building shared lib.
Details:
- Use linker flags and shared library suffix specific to OSX/Darwin when
the user appears to be building in OSX/Darwin. The OS is queried using
'uname -s'. Thanks to Adam J. Stewart for reporting this issue in #23.
- Substitute os_name from configure into config.mk (and echo in
post-configure.sh).
- Substitute CC_VENDOR from configure into config.mk (and echo in
post-configure.sh). This variable isn't needed yet, but may be in the
future.
- Autoconf update to configure.
- Whitespace changes.
---
Makefile | 22 +++++++++++++++++++++-
build/ac-macros/fla_observe_os_name.m4 | 11 +++++++++++
build/ac-macros/fla_require_cc.m4 | 8 ++++++--
build/config.mk.in | 5 +++++
build/post-configure.sh.in | 5 +++++
configure | 15 +++++++++++++++
configure.ac | 3 +++
7 files changed, 66 insertions(+), 3 deletions(-)
create mode 100644 build/ac-macros/fla_observe_os_name.m4
diff --git a/Makefile b/Makefile
index 6bd8bdce..f9681439 100644
--- a/Makefile
+++ b/Makefile
@@ -92,7 +92,12 @@ endif
# --- Shared library extension ---
-SHLIB_EXT := so
+# The shared (dynamic) library file suffix is different for Linux and OS X.
+ifeq ($(OS_NAME),Darwin)
+SHLIB_EXT := dylib
+else
+SHLIB_EXT := so
+endif
# --- Library names ---
@@ -107,8 +112,15 @@ LIBFLAME_SO := $(LIBFLAME).$(SHLIB_EXT)
LIBFLAME_A_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_A)
LIBFLAME_SO_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_SO)
+ifeq ($(OS_NAME),Darwin)
+# OS X shared library extensions.
+LIBFLAME_SO_MAJ_EXT := $(SO_MAJOR).$(SHLIB_EXT)
+LIBFLAME_SO_MMB_EXT := $(SO_MMB).$(SHLIB_EXT)
+else
+# Linux shared library extensions.
LIBFLAME_SO_MAJ_EXT := $(SHLIB_EXT).$(SO_MAJOR)
LIBFLAME_SO_MMB_EXT := $(SHLIB_EXT).$(SO_MMB)
+endif
LIBFLAME_SONAME := $(LIBFLAME).$(LIBFLAME_SO_MAJ_EXT)
LIBFLAME_SO_MAJ_PATH := $(BASE_LIB_PATH)/$(LIBFLAME_SONAME)
@@ -124,8 +136,15 @@ LIBFLAME_SO_OUTPUT_NAME := $(LIBFLAME_SO_PATH)
# Specify the shared library's 'soname' field.
# NOTE: The flag for creating shared objects is different for Linux and OS X.
+ifeq ($(OS_NAME),Darwin)
+# OS X shared library link flags.
+SOFLAGS := -dynamiclib
+SOFLAGS += -Wl,-install_name,$(LIBFLAME_SONAME)
+else
SOFLAGS := -shared
+# Linux shared library link flags.
SOFLAGS += -Wl,-soname,$(LIBFLAME_SONAME)
+endif
diff --git a/build/ac-macros/fla_observe_os_name.m4 b/build/ac-macros/fla_observe_os_name.m4
new file mode 100644
index 00000000..d3dbbf99
--- /dev/null
+++ b/build/ac-macros/fla_observe_os_name.m4
@@ -0,0 +1,11 @@
+AC_DEFUN([FLA_OBSERVE_OS_NAME],
+[
+ os_name=$(uname -s)
+ os_vers=$(uname -r)
+
+ dnl os_name_esc=$(echo "${os_name}" | sed 's/\//\\\//g')
+
+ dnl Substitute the OS name and version into autoconf output files
+ AC_SUBST(os_name)
+ AC_SUBST(os_vers)
+])
diff --git a/build/ac-macros/fla_require_cc.m4 b/build/ac-macros/fla_require_cc.m4
index 7f8131d8..5dd7cd38 100644
--- a/build/ac-macros/fla_require_cc.m4
+++ b/build/ac-macros/fla_require_cc.m4
@@ -6,19 +6,23 @@ AC_DEFUN([FLA_REQUIRE_CC],
dnl whether the user provided his own definition of CFLAGS.
fla_userdef_cflags=$CFLAGS
- dnl Find a C compiler.
+ dnl Find a C compiler.
dnl If the CC environment variable is not already set, search for the
dnl compiler defined by fla_requested_cc (which may be empty) and then
dnl continue searching for the compilers in $fla_c_compiler_list, if
dnl necessary. Also, if the C compiler found is not in ANSI mode, then
dnl try to add an option to make it so. If the GNU gcc was found, then
- dnl GCC shell variable is set to `yes'.
+ dnl GCC shell variable is set to `yes'.
AC_PROG_CC([$fla_requested_cc $fla_c_compiler_list])
if test "$CC" = "" ; then
AC_MSG_ERROR([Could not locate any of the following C compilers: $CC $fla_requested_cc $fla_c_compiler_list. Cannot continue without a C compiler.],[1])
fi
+
+ dnl Ascertain the compiler "vendor".
+ CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
dnl Substitute the user-defined CFLAGS into the autoconf output files.
AC_SUBST(fla_userdef_cflags)
+ AC_SUBST(CC_VENDOR)
])
diff --git a/build/config.mk.in b/build/config.mk.in
index c4679b51..37cedb96 100644
--- a/build/config.mk.in
+++ b/build/config.mk.in
@@ -28,6 +28,10 @@ SO_MMB := $(SO_MAJOR).$(SO_MINORB)
# library name.
ARCH := @fla_host_cpu@
+# This variable identifies the operating system / kernel. It is the result of
+# 'uname -s'.
+OS_NAME := @os_name@
+
# We have to set these particular variables because some of the @anchors@
# that are substituted in via configure may be defined *in terms of* these
# variables. For example, @libdir@ may be replaced with '${exec_prefix}/lib',
@@ -101,6 +105,7 @@ EMPTY_FILE := /dev/null
# --- Determine the C compiler and related flags ---
CC := @CC@
+CC_VENDOR := @CC_VENDOR@
CPPROCFLAGS := -D_POSIX_C_SOURCE=200809L @DEFS@ @fla_blis_flags@
CMISCFLAGS := @fla_c_lang_flags@ @fla_c_openmp_flags@ @fla_c_prof_flags@
CDBGFLAGS := @fla_c_debug_flags@
diff --git a/build/post-configure.sh.in b/build/post-configure.sh.in
index 26f9110d..61d59bca 100755
--- a/build/post-configure.sh.in
+++ b/build/post-configure.sh.in
@@ -17,6 +17,10 @@ echo ""
echo "build system type............................... : @build@"
echo "host system type................................ : @host@"
+echo ""
+echo "OS name......................................... : @os_name@"
+echo "OS version...................................... : @os_vers@"
+
echo ""
echo "Enable verbose make output...................... : @fla_enable_verbose_make_output@"
@@ -25,6 +29,7 @@ echo "Enable maximum argument list hack............... : @fla_enable_max_arg_lis
echo ""
echo "C compiler...................................... : @CC@"
+echo "C compiler vendor............................... : @CC_VENDOR@"
echo "Library archiver................................ : @AR@"
echo "Library archive indexer......................... : @RANLIB@"
diff --git a/configure b/configure
index c3d19bbc..1e24f9a5 100755
--- a/configure
+++ b/configure
@@ -698,6 +698,7 @@ INSTALL_SCRIPT
INSTALL_PROGRAM
RANLIB
AR
+CC_VENDOR
fla_userdef_cflags
OBJEXT
EXEEXT
@@ -707,6 +708,8 @@ LDFLAGS
CFLAGS
CC
fla_gnu_make_found
+os_vers
+os_name
fla_host_cpu
host_os
host_vendor
@@ -2738,6 +2741,15 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+ os_name=$(uname -s)
+ os_vers=$(uname -r)
+
+
+
+
+
+
+
@@ -3462,6 +3474,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
as_fn_error 1 "Could not locate any of the following C compilers: $CC $fla_requested_cc $fla_c_compiler_list. Cannot continue without a C compiler." "$LINENO" 5
fi
+ CC_VENDOR=$(echo "$CC" | egrep -o 'icc|gcc|clang|emcc|pnacl|IBM' | { read first rest ; echo $first ; })
+
+
diff --git a/configure.ac b/configure.ac
index 790ac90e..d8b0e6b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -227,6 +227,9 @@ dnl AC_PROG_CC and AC_PROG_F77 marcos in the variables fla_c_compiler_list and
dnl fla_f77_compiler_list, respectively.
FLA_OBSERVE_HOST_CPU_TYPE
+dnl Set the @os_name@ output variable to the output of 'uname -s'.
+FLA_OBSERVE_OS_NAME
+