Skip to content

Commit

Permalink
Merge pull request #3031 from appolloford/20231108160750_new_pr_suite…
Browse files Browse the repository at this point in the history
…sparse

add custom easyconfig parameter `cmake_options` to SuiteSparse easyblock
  • Loading branch information
boegel authored Dec 29, 2023
2 parents b21ada0 + be600d5 commit 8b569c0
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions easybuild/easyblocks/s/suitesparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from easybuild.tools import LooseVersion

from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools import toolchain
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import mkdir, write_file
from easybuild.tools.modules import get_software_root
Expand All @@ -49,6 +51,14 @@
class EB_SuiteSparse(ConfigureMake):
"""Support for building SuiteSparse."""

@staticmethod
def extra_options(extra_vars=None):
"""Define extra easyconfig parameters"""
extra_vars = {
'cmake_options': ['', "CMAKE_OPTIONS used by SuiteSparse since v6.0", CUSTOM],
}
return ConfigureMake.extra_options(extra_vars)

def __init__(self, *args, **kwargs):
"""Custom constructor for SuiteSparse easyblock, initialize custom class parameters."""
super(EB_SuiteSparse, self).__init__(*args, **kwargs)
Expand All @@ -75,6 +85,11 @@ def configure_step(self):
'LAPACK': os.getenv('LIBLAPACK_MT'),
}

cmake = get_software_root('CMake')
if not cmake and LooseVersion(self.version) >= LooseVersion('5.1.2'):
# graphblas exists from v5.1.2, needs cmake
raise EasyBuildError("CMake module is not loaded")

# Get CUDA and set it up appropriately
cuda = get_software_root('CUDA')
if cuda:
Expand Down Expand Up @@ -154,9 +169,7 @@ def configure_step(self):
self.cfg.update('installopts', 'LAPACK="%s"' % cfgvars.get('LAPACK'))

if LooseVersion(self.version) >= LooseVersion('5.1.2'):
# graphblas exists, needs cmake
# v5.0.0 until v5.1.2 has no CMAKE_OPTIONS to set
# probably need patch
# v5.0.0 until v5.1.2 has no CMAKE_OPTIONS to set, patches are needed
self.cfg.update('preinstallopts', 'CMAKE_OPTIONS="-DCMAKE_INSTALL_PREFIX=%s"' % self.installdir)

# set METIS library
Expand All @@ -172,8 +185,25 @@ def configure_step(self):

else:
# after v6.0.0, no option for metis, its own metis is used anyway
# nothing to do here, set the CMAKE_OPTIONS in easyconfigs
pass
# set CMAKE_OPTIONS if it is not specified in easyconfigs
# CMAKE_INSTALL_PREFIX is managed by easybuild
cmake_options = '-DCMAKE_INSTALL_PREFIX=%s' % self.installdir

lapack_lib = self.toolchain.lapack_family()
if '-DBLA_VENDOR=' in self.cfg['cmake_options']:
blas_lapack = ''
elif lapack_lib == toolchain.FLEXIBLAS:
blas_lapack = '-DBLA_VENDOR=FlexiBLAS'
elif lapack_lib == toolchain.INTELMKL:
blas_lapack = '-DBLA_VENDOR=Intel'
elif lapack_lib == toolchain.OPENBLAS:
blas_lapack = '-DBLA_VENDOR=OpenBLAS'
else:
raise EasyBuildError("BLA_VENDOR is not assigned and FlexiBLAS/MKL/OpenBLAS are not found. "
"Please assign BLA_VENDOR in cmake_options in easyconfigs")

cmake_options = ' '.join([cmake_options, blas_lapack, self.cfg['cmake_options']])
self.cfg.update('prebuildopts', 'CMAKE_OPTIONS="%s"' % cmake_options)

def install_step(self):
"""Install by copying the contents of the builddir to the installdir (preserving permissions)"""
Expand Down

0 comments on commit 8b569c0

Please sign in to comment.