Merge pull request #231 from epfl-scitas/packages/scotch
scotch: adding dependencies + variants for mpi, shared, compression and esmumps
This commit is contained in:
commit
bb329d8a5c
1 changed files with 101 additions and 15 deletions
|
@ -1,5 +1,4 @@
|
||||||
from spack import *
|
from spack import *
|
||||||
import glob
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class Scotch(Package):
|
class Scotch(Package):
|
||||||
|
@ -11,27 +10,114 @@ class Scotch(Package):
|
||||||
|
|
||||||
version('6.0.3', '10b0cc0f184de2de99859eafaca83cfc')
|
version('6.0.3', '10b0cc0f184de2de99859eafaca83cfc')
|
||||||
|
|
||||||
depends_on('mpi')
|
variant('mpi', default=False, description='Activate the compilation of PT-Scotch')
|
||||||
|
variant('compression', default=True, description='Activate the posibility to use compressed files')
|
||||||
|
variant('esmumps', default=False, description='Activate the compilation of the lib esmumps needed by mumps')
|
||||||
|
variant('shared', default=True, description='Build shared libraries')
|
||||||
|
|
||||||
|
depends_on('mpi', when='+mpi')
|
||||||
|
depends_on('zlib', when='+compression')
|
||||||
|
depends_on('flex')
|
||||||
|
depends_on('bison')
|
||||||
|
|
||||||
|
def compiler_specifics(self, makefile_inc, defines):
|
||||||
|
if self.compiler.name == 'gcc':
|
||||||
|
defines.append('-Drestrict=__restrict')
|
||||||
|
elif self.compiler.name == 'intel':
|
||||||
|
defines.append('-restrict')
|
||||||
|
|
||||||
|
makefile_inc.append('CCS = $(CC)')
|
||||||
|
|
||||||
|
if '+mpi' in self.spec:
|
||||||
|
makefile_inc.extend([
|
||||||
|
'CCP = %s' % os.path.join(self.spec['mpi'].prefix.bin, 'mpicc'),
|
||||||
|
'CCD = $(CCP)'
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
makefile_inc.extend([
|
||||||
|
'CCP = mpicc', # It is set but not used
|
||||||
|
'CCD = $(CCS)'
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def library_build_type(self, makefile_inc, defines):
|
||||||
|
makefile_inc.extend([
|
||||||
|
'LIB = .a',
|
||||||
|
'CLIBFLAGS = ',
|
||||||
|
'RANLIB = ranlib',
|
||||||
|
'AR = ar',
|
||||||
|
'ARFLAGS = -ruv '
|
||||||
|
])
|
||||||
|
|
||||||
|
@when('+shared')
|
||||||
|
def library_build_type(self, makefile_inc, defines):
|
||||||
|
makefile_inc.extend([
|
||||||
|
'LIB = .so',
|
||||||
|
'CLIBFLAGS = -shared -fPIC',
|
||||||
|
'RANLIB = echo',
|
||||||
|
'AR = $(CC)',
|
||||||
|
'ARFLAGS = -shared $(LDFLAGS) -o'
|
||||||
|
])
|
||||||
|
|
||||||
|
def extra_features(self, makefile_inc, defines):
|
||||||
|
ldflags = []
|
||||||
|
|
||||||
|
if '+compression' in self.spec:
|
||||||
|
defines.append('-DCOMMON_FILE_COMPRESS_GZ')
|
||||||
|
ldflags.append('-L%s -lz' % (self.spec['zlib'].prefix.lib))
|
||||||
|
|
||||||
|
defines.append('-DCOMMON_PTHREAD')
|
||||||
|
ldflags.append('-lm -lrt -pthread')
|
||||||
|
|
||||||
|
makefile_inc.append('LDFLAGS = %s' % ' '.join(ldflags))
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
with working_dir('src/Make.inc'):
|
makefile_inc = []
|
||||||
makefiles = glob.glob('Makefile.inc.x86-64_pc_linux2*')
|
defines = [
|
||||||
filter_file(r'^CCS\s*=.*$', 'CCS = cc', *makefiles)
|
'-DCOMMON_RANDOM_FIXED_SEED',
|
||||||
filter_file(r'^CCD\s*=.*$', 'CCD = cc', *makefiles)
|
'-DSCOTCH_DETERMINISTIC',
|
||||||
|
'-DSCOTCH_RENAME',
|
||||||
|
'-DIDXSIZE64' ]
|
||||||
|
|
||||||
|
self.library_build_type(makefile_inc, defines)
|
||||||
|
self.compiler_specifics(makefile_inc, defines)
|
||||||
|
self.extra_features(makefile_inc, defines)
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
makefile_inc.extend([
|
||||||
# Currently support gcc and icc on x86_64 (maybe others with
|
'EXE =',
|
||||||
# vanilla makefile)
|
'OBJ = .o',
|
||||||
makefile = 'Make.inc/Makefile.inc.x86-64_pc_linux2'
|
'MAKE = make',
|
||||||
if spec.satisfies('%icc'):
|
'CAT = cat',
|
||||||
makefile += '.icc'
|
'LN = ln',
|
||||||
|
'MKDIR = mkdir',
|
||||||
|
'MV = mv',
|
||||||
|
'CP = cp',
|
||||||
|
'CFLAGS = -O3 %s' % (' '.join(defines)),
|
||||||
|
'LEX = %s -Pscotchyy -olex.yy.c' % os.path.join(self.spec['flex'].prefix.bin , 'flex'),
|
||||||
|
'YACC = %s -pscotchyy -y -b y' % os.path.join(self.spec['bison'].prefix.bin, 'bison'),
|
||||||
|
'prefix = %s' % self.prefix,
|
||||||
|
''
|
||||||
|
])
|
||||||
|
|
||||||
with working_dir('src'):
|
with working_dir('src'):
|
||||||
force_symlink(makefile, 'Makefile.inc')
|
with open('Makefile.inc', 'w') as fh:
|
||||||
for app in ('scotch', 'ptscotch'):
|
fh.write('\n'.join(makefile_inc))
|
||||||
make(app)
|
|
||||||
|
def install(self, spec, prefix):
|
||||||
|
targets = ['scotch']
|
||||||
|
if '+mpi' in self.spec:
|
||||||
|
targets.append('ptscotch')
|
||||||
|
|
||||||
|
if '+esmumps' in self.spec:
|
||||||
|
targets.append('esmumps')
|
||||||
|
if '+mpi' in self.spec:
|
||||||
|
targets.append('ptesmumps')
|
||||||
|
|
||||||
|
with working_dir('src'):
|
||||||
|
for app in targets:
|
||||||
|
make(app, parallel=(not app=='ptesmumps'))
|
||||||
|
|
||||||
|
|
||||||
install_tree('bin', prefix.bin)
|
install_tree('bin', prefix.bin)
|
||||||
install_tree('lib', prefix.lib)
|
install_tree('lib', prefix.lib)
|
||||||
|
|
Loading…
Reference in a new issue