Skip to content
Snippets Groups Projects
Commit 064d3584 authored by Joseph Ciurej's avatar Joseph Ciurej
Browse files

Updating 'metis' and 'parmetis' to conform to PEP8 standards.

parent 0ef6843d
Branches
Tags
No related merge requests found
...@@ -24,14 +24,17 @@ ...@@ -24,14 +24,17 @@
############################################################################## ##############################################################################
from spack import * from spack import *
import glob, sys, os import glob
import sys
import os
class Metis(Package): class Metis(Package):
""" """METIS is a set of serial programs for partitioning graphs, partitioning
METIS is a set of serial programs for partitioning graphs, partitioning finite element meshes, and producing fill finite element meshes, and producing fill reducing orderings for sparse
reducing orderings for sparse matrices. The algorithms implemented in METIS are based on the multilevel matrices. The algorithms implemented in METIS are based on the
recursive-bisection, multilevel k-way, and multi-constraint partitioning schemes. multilevel recursive-bisection, multilevel k-way, and multi-constraint
""" partitioning schemes."""
homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview" homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview"
base_url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis" base_url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis"
...@@ -47,22 +50,20 @@ class Metis(Package): ...@@ -47,22 +50,20 @@ class Metis(Package):
variant('idx64', default=False, description='Use int64_t as default index type') variant('idx64', default=False, description='Use int64_t as default index type')
variant('real64', default=False, description='Use double precision floating point types') variant('real64', default=False, description='Use double precision floating point types')
depends_on('cmake @2.8:', when='@5:') # build-time dependency depends_on('cmake@2.8:', when='@5:') # build-time dependency
patch('install_gklib_defs_rename.patch', when='@5:') patch('install_gklib_defs_rename.patch', when='@5:')
def url_for_version(self, version): def url_for_version(self, version):
version_dir = 'OLD/' if version < Version('4.0.3') else '' verdir = 'OLD/' if version < Version('4.0.3') else ''
return '%s/%smetis-%s.tar.gz' % (Metis.base_url, version_dir, version) return '%s/%smetis-%s.tar.gz' % (Metis.base_url, verdir, version)
@when('@4:4.0.3') @when('@4')
def install(self, spec, prefix): def install(self, spec, prefix):
if '+gdb' in spec: unsupp_vars = [v for v in ('+gdb', '+idx64', '+real64') if v in spec]
raise InstallError('gdb support not implemented in METIS 4!') if unsupp_vars:
if '+idx64' in spec: msg = 'Given variants %s are unsupported by METIS 4!' % unsupp_vars
raise InstallError('idx64 option not implemented in METIS 4!') raise InstallError(msg)
if '+double' in spec:
raise InstallError('double option not implemented for METIS 4!')
options = ['COPTIONS=-fPIC'] options = ['COPTIONS=-fPIC']
if '+debug' in spec: if '+debug' in spec:
...@@ -70,9 +71,10 @@ def install(self, spec, prefix): ...@@ -70,9 +71,10 @@ def install(self, spec, prefix):
make(*options) make(*options)
mkdir(prefix.bin) mkdir(prefix.bin)
for x in ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh', binfiles = ('pmetis', 'kmetis', 'oemetis', 'onmetis', 'partnmesh',
'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk'): 'partdmesh', 'mesh2nodal', 'mesh2dual', 'graphchk')
install(x, prefix.bin) for binfile in binfiles:
install(binfile, prefix.bin)
mkdir(prefix.lib) mkdir(prefix.lib)
install('libmetis.a', prefix.lib) install('libmetis.a', prefix.lib)
...@@ -82,12 +84,10 @@ def install(self, spec, prefix): ...@@ -82,12 +84,10 @@ def install(self, spec, prefix):
install(h, prefix.include) install(h, prefix.include)
mkdir(prefix.share) mkdir(prefix.share)
for f in (join_path(*p) sharefiles = (('Programs', 'io.c'), ('Test', 'mtest.c'),
for p in (('Programs', 'io.c'), ('Graphs', '4elt.graph'), ('Graphs', 'metis.mesh'),
('Test','mtest.c'), ('Graphs', 'test.mgraph'))
('Graphs','4elt.graph'), for sharefile in tuple(join_path(*sf) for sf in sharefiles):
('Graphs', 'metis.mesh'),
('Graphs', 'test.mgraph'))):
install(f, prefix.share) install(f, prefix.share)
if '+shared' in spec: if '+shared' in spec:
...@@ -100,10 +100,10 @@ def install(self, spec, prefix): ...@@ -100,10 +100,10 @@ def install(self, spec, prefix):
load_flag = '-Wl,-whole-archive' load_flag = '-Wl,-whole-archive'
no_load_flag = '-Wl,-no-whole-archive' no_load_flag = '-Wl,-no-whole-archive'
os.system(spack_cc + ' -fPIC -shared ' + load_flag + flags = (self.compiler.cc, load_flag, no_load_flag, lib_dsuffix)
' libmetis.a ' + no_load_flag + ' -o libmetis.' + build_cmd = '%s -fPIC -shared %s libmetis.a %s libmetis.%s' % flags
lib_dsuffix) os.system(build_cmd)
install('libmetis.' + lib_dsuffix, prefix.lib) install('libmetis.%s' % lib_dsuffix, prefix.lib)
# Set up and run tests on installation # Set up and run tests on installation
symlink(join_path(prefix.share, 'io.c'), 'io.c') symlink(join_path(prefix.share, 'io.c'), 'io.c')
...@@ -125,7 +125,6 @@ def install(self, spec, prefix): ...@@ -125,7 +125,6 @@ def install(self, spec, prefix):
os.system(join_path(prefix.bin, 'partdmesh') + metis_mesh + ' 10') os.system(join_path(prefix.bin, 'partdmesh') + metis_mesh + ' 10')
os.system(join_path(prefix.bin, 'mesh2dual') + metis_mesh) os.system(join_path(prefix.bin, 'mesh2dual') + metis_mesh)
@when('@5:') @when('@5:')
def install(self, spec, prefix): def install(self, spec, prefix):
options = [] options = []
...@@ -134,13 +133,14 @@ def install(self, spec, prefix): ...@@ -134,13 +133,14 @@ def install(self, spec, prefix):
build_directory = join_path(self.stage.path, 'spack-build') build_directory = join_path(self.stage.path, 'spack-build')
source_directory = self.stage.source_path source_directory = self.stage.source_path
options.append('-DGKLIB_PATH:PATH={metis_source}/GKlib'.format(metis_source=source_directory)) options.append('-DGKLIB_PATH:PATH=%s/GKlib' % source_directory)
options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix) options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)
if '+shared' in spec: if '+shared' in spec:
options.append('-DSHARED:BOOL=ON') options.append('-DSHARED:BOOL=ON')
if '+debug' in spec: if '+debug' in spec:
options.extend(['-DDEBUG:BOOL=ON', '-DCMAKE_BUILD_TYPE:STRING=Debug']) options.extend(['-DDEBUG:BOOL=ON',
'-DCMAKE_BUILD_TYPE:STRING=Debug'])
if '+gdb' in spec: if '+gdb' in spec:
options.append('-DGDB:BOOL=ON') options.append('-DGDB:BOOL=ON')
...@@ -153,9 +153,10 @@ def install(self, spec, prefix): ...@@ -153,9 +153,10 @@ def install(self, spec, prefix):
# Make clang 7.3 happy. # Make clang 7.3 happy.
# Prevents "ld: section __DATA/__thread_bss extends beyond end of file" # Prevents "ld: section __DATA/__thread_bss extends beyond end of file"
# See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059 # See upstream LLVM issue https://llvm.org/bugs/show_bug.cgi?id=27059
# Adopted from https://github.com/Homebrew/homebrew-science/blob/master/metis.rb # and https://github.com/Homebrew/homebrew-science/blob/master/metis.rb
if spec.satisfies('%clang@7.3.0'): if spec.satisfies('%clang@7.3.0'):
filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24', join_path(source_directory, 'GKlib', 'error.c')) filter_file('#define MAX_JBUFS 128', '#define MAX_JBUFS 24',
join_path(source_directory, 'GKlib', 'error.c'))
with working_dir(build_directory, create=True): with working_dir(build_directory, create=True):
cmake(source_directory, *options) cmake(source_directory, *options)
...@@ -164,19 +165,19 @@ def install(self, spec, prefix): ...@@ -164,19 +165,19 @@ def install(self, spec, prefix):
# now run some tests: # now run some tests:
for f in ['4elt', 'copter2', 'mdual']: for f in ['4elt', 'copter2', 'mdual']:
graph = join_path(source_directory,'graphs','%s.graph' % f) graph = join_path(source_directory, 'graphs', '%s.graph' % f)
Executable(join_path(prefix.bin,'graphchk'))(graph) Executable(join_path(prefix.bin, 'graphchk'))(graph)
Executable(join_path(prefix.bin,'gpmetis'))(graph,'2') Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')
Executable(join_path(prefix.bin,'ndmetis'))(graph) Executable(join_path(prefix.bin, 'ndmetis'))(graph)
graph = join_path(source_directory,'graphs','test.mgraph') graph = join_path(source_directory, 'graphs', 'test.mgraph')
Executable(join_path(prefix.bin,'gpmetis'))(graph,'2') Executable(join_path(prefix.bin, 'gpmetis'))(graph, '2')
graph = join_path(source_directory,'graphs','metis.mesh') graph = join_path(source_directory, 'graphs', 'metis.mesh')
Executable(join_path(prefix.bin,'mpmetis'))(graph,'2') Executable(join_path(prefix.bin, 'mpmetis'))(graph, '2')
# install GKlib headers, which will be needed for ParMETIS # install GKlib headers, which will be needed for ParMETIS
GKlib_dist = join_path(prefix.include,'GKlib') GKlib_dist = join_path(prefix.include, 'GKlib')
mkdirp(GKlib_dist) mkdirp(GKlib_dist)
fs = glob.glob(join_path(source_directory,'GKlib','*.h')) hfiles = glob.glob(join_path(source_directory, 'GKlib', '*.h'))
for f in fs: for hfile in hfiles:
install(f, GKlib_dist) install(hfile, GKlib_dist)
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
from spack import * from spack import *
import sys import sys
class Parmetis(Package): class Parmetis(Package):
""" """ParMETIS is an MPI-based parallel library that implements a variety of
ParMETIS is an MPI-based parallel library that implements a variety of algorithms for partitioning unstructured algorithms for partitioning unstructured graphs, meshes, and for
graphs, meshes, and for computing fill-reducing orderings of sparse matrices. computing fill-reducing orderings of sparse matrices."""
"""
homepage = 'http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview' homepage = 'http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview'
base_url = 'http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis' base_url = 'http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis'
...@@ -42,20 +42,20 @@ class Parmetis(Package): ...@@ -42,20 +42,20 @@ class Parmetis(Package):
variant('debug', default=False, description='Builds the library in debug mode') variant('debug', default=False, description='Builds the library in debug mode')
variant('gdb', default=False, description='Enables gdb support') variant('gdb', default=False, description='Enables gdb support')
depends_on('cmake @2.8:') # build dependency depends_on('cmake@2.8:') # build dependency
depends_on('mpi') depends_on('mpi')
depends_on('metis@5:') depends_on('metis@5:')
patch('enable_external_metis.patch') patch('enable_external_metis.patch')
# bug fixes from PETSc developers # bug fixes from PETSc developers
# https://bitbucket.org/petsc/pkg-parmetis/commits/1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b/raw/ # https://bitbucket.org/petsc/pkg-parmetis/commits/1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b/raw/ # NOQA: ignore=E501
patch('pkg-parmetis-1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b.patch') patch('pkg-parmetis-1c1a9fd0f408dc4d42c57f5c3ee6ace411eb222b.patch')
# https://bitbucket.org/petsc/pkg-parmetis/commits/82409d68aa1d6cbc70740d0f35024aae17f7d5cb/raw/ # https://bitbucket.org/petsc/pkg-parmetis/commits/82409d68aa1d6cbc70740d0f35024aae17f7d5cb/raw/ # NOQA: ignore=E501
patch('pkg-parmetis-82409d68aa1d6cbc70740d0f35024aae17f7d5cb.patch') patch('pkg-parmetis-82409d68aa1d6cbc70740d0f35024aae17f7d5cb.patch')
def url_for_version(self, version): def url_for_version(self, version):
version_dir = 'OLD/' if version < Version('3.2.0') else '' verdir = 'OLD/' if version < Version('3.2.0') else ''
return '%s/%sparmetis-%s.tar.gz' % (Parmetis.base_url, version_dir, version) return '%s/%sparmetis-%s.tar.gz' % (Parmetis.base_url, verdir, version)
def install(self, spec, prefix): def install(self, spec, prefix):
options = [] options = []
...@@ -63,17 +63,19 @@ def install(self, spec, prefix): ...@@ -63,17 +63,19 @@ def install(self, spec, prefix):
build_directory = join_path(self.stage.path, 'spack-build') build_directory = join_path(self.stage.path, 'spack-build')
source_directory = self.stage.source_path source_directory = self.stage.source_path
metis_source = join_path(source_directory, 'metis')
options.extend(['-DGKLIB_PATH:PATH={metis_source}/GKlib'.format(metis_source=spec['metis'].prefix.include), options.extend([
'-DMETIS_PATH:PATH={metis_source}'.format(metis_source=spec['metis'].prefix), '-DGKLIB_PATH:PATH=%s/GKlib' % spec['metis'].prefix.include,
'-DCMAKE_C_COMPILER:STRING={mpicc}'.format(mpicc=spec['mpi'].mpicc), '-DMETIS_PATH:PATH=%s' % spec['metis'].prefix,
'-DCMAKE_CXX_COMPILER:STRING={mpicxx}'.format(mpicxx=spec['mpi'].mpicxx)]) '-DCMAKE_C_COMPILER:STRING=%s' % spec['mpi'].mpicc,
'-DCMAKE_CXX_COMPILER:STRING=%s' % spec['mpi'].mpicxx
])
if '+shared' in spec: if '+shared' in spec:
options.append('-DSHARED:BOOL=ON') options.append('-DSHARED:BOOL=ON')
if '+debug' in spec: if '+debug' in spec:
options.extend(['-DDEBUG:BOOL=ON', '-DCMAKE_BUILD_TYPE:STRING=Debug']) options.extend(['-DDEBUG:BOOL=ON',
'-DCMAKE_BUILD_TYPE:STRING=Debug'])
if '+gdb' in spec: if '+gdb' in spec:
options.append('-DGDB:BOOL=ON') options.append('-DGDB:BOOL=ON')
...@@ -82,6 +84,6 @@ def install(self, spec, prefix): ...@@ -82,6 +84,6 @@ def install(self, spec, prefix):
make() make()
make('install') make('install')
# The shared library is not installed correctly on Darwin; correct this # The shared library is not installed correctly on Darwin; fix this
if (sys.platform == 'darwin') and ('+shared' in spec): if (sys.platform == 'darwin') and ('+shared' in spec):
fix_darwin_install_name(prefix.lib) fix_darwin_install_name(prefix.lib)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment