From e2e72b14b2756f046eff185ef65d0ff393b383e2 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 10 May 2016 16:08:58 -0500 Subject: Use new openmp_flag and mpi attributes --- var/spack/repos/builtin/packages/elk/package.py | 39 +++++++++++++++---------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/var/spack/repos/builtin/packages/elk/package.py b/var/spack/repos/builtin/packages/elk/package.py index 9367dfdd78..9f36647eb6 100644 --- a/var/spack/repos/builtin/packages/elk/package.py +++ b/var/spack/repos/builtin/packages/elk/package.py @@ -25,6 +25,7 @@ from spack import * import spack + class Elk(Package): '''An all-electron full-potential linearised augmented-plane wave (FP-LAPW) code with many advanced features.''' @@ -58,34 +59,29 @@ class Elk(Package): # Dictionary of configuration options config = { 'MAKE': 'make', - 'F90': join_path(spack.build_env_path, 'f90'), - 'F77': join_path(spack.build_env_path, 'f77'), - 'AR': 'ar', - 'LIB_FFT': 'fftlib.a', - 'SRC_MPI': 'mpi_stub.f90', - 'SRC_OMP': 'omp_stub.f90', - 'SRC_libxc': 'libxcifc_stub.f90', - 'SRC_FFT': 'zfftifc.f90' + 'AR': 'ar' } # Compiler-specific flags flags = '' if self.compiler.name == 'intel': - flags = '-O3 -ip -unroll -no-prec-div -openmp' + flags = '-O3 -ip -unroll -no-prec-div' elif self.compiler.name == 'gcc': - flags = '-O3 -ffast-math -funroll-loops -fopenmp' + flags = '-O3 -ffast-math -funroll-loops' elif self.compiler.name == 'pgi': - flags = '-O3 -mp -lpthread' + flags = '-O3 -lpthread' elif self.compiler.name == 'g95': flags = '-O3 -fno-second-underscore' elif self.compiler.name == 'nag': flags = '-O4 -kind=byte -dusty -dcfuns' elif self.compiler.name == 'xl': - flags = '-O3 -qsmp=omp' + flags = '-O3' config['F90_OPTS'] = flags config['F77_OPTS'] = flags # BLAS/LAPACK support + # Note: BLAS/LAPACK must be compiled with OpenMP support + # if the +openmp variant is chosen blas = 'blas.a' lapack = 'lapack.a' if '+blas' in spec: @@ -98,16 +94,25 @@ class Elk(Package): if '+fft' in spec: config['LIB_FFT'] = join_path(spec['fftw'].prefix.lib, 'libfftw3.so') config['SRC_FFT'] = 'zfftifc_fftw.f90' + else: + config['LIB_FFT'] = 'fftlib.a' + config['SRC_FFT'] = 'zfftifc.f90' # MPI support if '+mpi' in spec: - config.pop('SRC_MPI') - config['F90'] = join_path(spec['mpi'].prefix.bin, 'mpif90') - config['F77'] = join_path(spec['mpi'].prefix.bin, 'mpif77') + config['F90'] = join_path(spec['mpi'].mpifc) + config['F77'] = join_path(spec['mpi'].mpif77) + else: + config['F90'] = join_path(spack.build_env_path, 'f90'), + config['F77'] = join_path(spack.build_env_path, 'f77'), + config['SRC_MPI'] = 'mpi_stub.f90' # OpenMP support if '+openmp' in spec: - config.pop('SRC_OMP') + config['F90_OPTS'] += ' ' + self.compiler.openmp_flag + config['F77_OPTS'] += ' ' + self.compiler.openmp_flag + else: + config['SRC_OMP'] = 'omp_stub.f90' # Libxc support if '+libxc' in spec: @@ -120,6 +125,8 @@ class Elk(Package): 'libxc.f90', 'libxcifc.f90' ]) + else: + config['SRC_libxc'] = 'libxcifc_stub.f90' # Write configuration options to include file with open('make.inc', 'w') as inc: -- cgit v1.2.3-70-g09d2 From d7020434d9175b1b831ad5c1b4b2c8d2c10d2df9 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 11 May 2016 10:22:59 -0500 Subject: Use new-ish blas_shared_lib and more flake8 fixes --- var/spack/repos/builtin/packages/elk/package.py | 44 ++++++++++++++----------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/var/spack/repos/builtin/packages/elk/package.py b/var/spack/repos/builtin/packages/elk/package.py index 9f36647eb6..18c8e9e7bf 100644 --- a/var/spack/repos/builtin/packages/elk/package.py +++ b/var/spack/repos/builtin/packages/elk/package.py @@ -22,8 +22,8 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## -from spack import * import spack +from spack import * class Elk(Package): @@ -36,14 +36,20 @@ class Elk(Package): version('3.3.17', 'f57f6230d14f3b3b558e5c71f62f0592') # Elk provides these libraries, but allows you to specify your own - variant('blas', default=True, description='Build with custom BLAS library') - variant('lapack', default=True, description='Build with custom LAPACK library') - variant('fft', default=True, description='Build with custom FFT library') + variant('blas', default=True, + description='Build with custom BLAS library') + variant('lapack', default=True, + description='Build with custom LAPACK library') + variant('fft', default=True, + description='Build with custom FFT library') # Elk does not provide these libraries, but allows you to use them - variant('mpi', default=True, description='Enable MPI parallelism') - variant('openmp', default=True, description='Enable OpenMP support') - variant('libxc', default=True, description='Link to Libxc functional library') + variant('mpi', default=True, + description='Enable MPI parallelism') + variant('openmp', default=True, + description='Enable OpenMP support') + variant('libxc', default=True, + description='Link to Libxc functional library') depends_on('blas', when='+blas') depends_on('lapack', when='+lapack') @@ -54,17 +60,16 @@ class Elk(Package): # Cannot be built in parallel parallel = False - def configure(self, spec): # Dictionary of configuration options config = { - 'MAKE': 'make', - 'AR': 'ar' + 'MAKE': 'make', + 'AR': 'ar' } # Compiler-specific flags flags = '' - if self.compiler.name == 'intel': + if self.compiler.name == 'intel': flags = '-O3 -ip -unroll -no-prec-div' elif self.compiler.name == 'gcc': flags = '-O3 -ffast-math -funroll-loops' @@ -84,15 +89,17 @@ class Elk(Package): # if the +openmp variant is chosen blas = 'blas.a' lapack = 'lapack.a' - if '+blas' in spec: - blas = join_path(spec['blas'].prefix.lib, 'libblas.so') + if '+blas' in spec: + blas = spec['blas'].blas_shared_lib if '+lapack' in spec: - lapack = join_path(spec['lapack'].prefix.lib, 'liblapack.so') - config['LIB_LPK'] = ' '.join([lapack, blas]) # lapack must come before blas + lapack = spec['lapack'].lapack_shared_lib + # lapack must come before blas + config['LIB_LPK'] = ' '.join([lapack, blas]) # FFT support if '+fft' in spec: - config['LIB_FFT'] = join_path(spec['fftw'].prefix.lib, 'libfftw3.so') + config['LIB_FFT'] = join_path(spec['fftw'].prefix.lib, + 'libfftw3.so') config['SRC_FFT'] = 'zfftifc_fftw.f90' else: config['LIB_FFT'] = 'fftlib.a' @@ -100,8 +107,8 @@ class Elk(Package): # MPI support if '+mpi' in spec: - config['F90'] = join_path(spec['mpi'].mpifc) - config['F77'] = join_path(spec['mpi'].mpif77) + config['F90'] = spec['mpi'].mpifc + config['F77'] = spec['mpi'].mpif77 else: config['F90'] = join_path(spack.build_env_path, 'f90'), config['F77'] = join_path(spack.build_env_path, 'f77'), @@ -133,7 +140,6 @@ class Elk(Package): for key in config: inc.write('{0} = {1}\n'.format(key, config[key])) - def install(self, spec, prefix): # Elk only provides an interactive setup script self.configure(spec) -- cgit v1.2.3-70-g09d2 From 3526d9266079a2371e8b2d615fdacd60c59721bc Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 11 May 2016 10:36:11 -0500 Subject: Indentation fix --- var/spack/repos/builtin/packages/elk/package.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/var/spack/repos/builtin/packages/elk/package.py b/var/spack/repos/builtin/packages/elk/package.py index 18c8e9e7bf..235b6fae0b 100644 --- a/var/spack/repos/builtin/packages/elk/package.py +++ b/var/spack/repos/builtin/packages/elk/package.py @@ -37,19 +37,19 @@ class Elk(Package): # Elk provides these libraries, but allows you to specify your own variant('blas', default=True, - description='Build with custom BLAS library') + description='Build with custom BLAS library') variant('lapack', default=True, - description='Build with custom LAPACK library') + description='Build with custom LAPACK library') variant('fft', default=True, - description='Build with custom FFT library') + description='Build with custom FFT library') # Elk does not provide these libraries, but allows you to use them variant('mpi', default=True, - description='Enable MPI parallelism') + description='Enable MPI parallelism') variant('openmp', default=True, - description='Enable OpenMP support') + description='Enable OpenMP support') variant('libxc', default=True, - description='Link to Libxc functional library') + description='Link to Libxc functional library') depends_on('blas', when='+blas') depends_on('lapack', when='+lapack') @@ -156,4 +156,3 @@ class Elk(Package): install_tree('examples', join_path(prefix, 'examples')) install_tree('species', join_path(prefix, 'species')) - -- cgit v1.2.3-70-g09d2 From 03307f91df80a52e424356f579c68a94a32e7ca7 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 11 May 2016 15:14:16 -0500 Subject: Fix bug when compiling elk~mpi --- var/spack/repos/builtin/packages/elk/package.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/var/spack/repos/builtin/packages/elk/package.py b/var/spack/repos/builtin/packages/elk/package.py index 235b6fae0b..b089e585dd 100644 --- a/var/spack/repos/builtin/packages/elk/package.py +++ b/var/spack/repos/builtin/packages/elk/package.py @@ -54,7 +54,7 @@ class Elk(Package): depends_on('blas', when='+blas') depends_on('lapack', when='+lapack') depends_on('fftw', when='+fft') - depends_on('mpi', when='+mpi') + depends_on('mpi@2:', when='+mpi') depends_on('libxc', when='+libxc') # Cannot be built in parallel @@ -110,8 +110,8 @@ class Elk(Package): config['F90'] = spec['mpi'].mpifc config['F77'] = spec['mpi'].mpif77 else: - config['F90'] = join_path(spack.build_env_path, 'f90'), - config['F77'] = join_path(spack.build_env_path, 'f77'), + config['F90'] = join_path(spack.build_env_path, 'f90') + config['F77'] = join_path(spack.build_env_path, 'f77') config['SRC_MPI'] = 'mpi_stub.f90' # OpenMP support -- cgit v1.2.3-70-g09d2