-
Notifications
You must be signed in to change notification settings - Fork 282
/
Copy pathcblas.py
98 lines (82 loc) · 3.77 KB
/
cblas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##
# Copyright 2013-2024 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# https://github.com/easybuilders/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# EasyBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
"""
EasyBuild support for building and installing CBLAS, implemented as an easyblock
@author: Kenneth Hoste (Ghent University)
"""
import glob
import os
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.tools.filetools import copy_dir, copy_file
from easybuild.tools.modules import get_software_root
from easybuild.tools.systemtools import get_shared_lib_ext
class EB_CBLAS(ConfigureMake):
"""
Support for building CBLAS (BLAS C interface),
inspired by instructions to build CBLAS for ACML, see https://wiki.fysik.dtu.dk/gpaw/install/Linux/vsc.univie.html
"""
def configure_step(self):
"""
Configure CBLAS build by copying Makefile.LINUX to Makefile.in, and setting make options
"""
copy_file('Makefile.LINUX', 'Makefile.in')
if not self.cfg['buildopts']:
self.cfg.update('buildopts', 'all')
self.cfg.update('buildopts', 'CC="%s"' % os.getenv('CC'))
self.cfg.update('buildopts', 'FC="%s"' % os.getenv('F77'))
self.cfg.update('buildopts', 'CFLAGS="%s -DADD_"' % os.getenv('CFLAGS'))
self.cfg.update('buildopts', 'FFLAGS="%s -DADD_"' % os.getenv('FFLAGS'))
blas_lib_dir = os.getenv('BLAS_LIB_DIR')
blas_libs = []
for blas_lib in os.getenv('BLAS_STATIC_LIBS').split(','):
blas_lib = os.path.join(blas_lib_dir, blas_lib)
if os.path.exists(blas_lib):
blas_libs.append(blas_lib)
if get_software_root("imkl"):
extra_blas_libs = ['-lmkl_intel_thread', '-lmkl_lapack95_lp64', '-lmkl_intel_lp64', '-lmkl_core']
blas_libs += extra_blas_libs
self.cfg.update('buildopts', 'BLLIB="%s %s"' % (' '.join(blas_libs), os.getenv('LIBS', '')))
# default build procedure should do
def install_step(self):
"""
Install CBLAS: copy libraries to install path.
"""
srcdir = os.path.join(self.cfg['start_dir'], 'lib')
targetdir = os.path.join(self.installdir, 'lib')
copy_file(os.path.join(srcdir, 'cblas_LINUX.a'), os.path.join(targetdir, 'libcblas.a'))
srclib = os.path.join(srcdir, 'libcblas.so')
if os.path.exists(srclib):
for solib in glob.glob(os.path.join(srcdir, 'libcblas.so*')):
copy_file(solib, os.path.join(targetdir, os.path.basename(solib)))
copy_dir(os.path.join(self.cfg['start_dir'], 'include'), os.path.join(self.installdir, 'include'))
def sanity_check_step(self):
"""
Custom sanity check for CBLAS.
"""
custom_paths = {
'files': ['lib/libcblas.a', 'lib/libcblas.%s' % get_shared_lib_ext()],
'dirs': ['include'],
}
super(EB_CBLAS, self).sanity_check_step(custom_paths=custom_paths)