From 4a8db0069186f2bb47198ef868131b6ea075323f Mon Sep 17 00:00:00 2001 From: Martin Lang <67915889+lang-m@users.noreply.github.com> Date: Thu, 9 Jun 2022 17:47:12 +0200 Subject: [PATCH] nfft, pnfft: fix detection of fftw variants (precision) (#30935) * nfft, pnfft: fix detection of fftw variants (precision) * nfft, pnfft: use fftw's selected_precisions; avoid repetitive calls to spec Co-authored-by: Martin Lang --- .../repos/builtin/packages/nfft/package.py | 33 +++++++++++-------- .../repos/builtin/packages/pnfft/package.py | 33 +++++++++++-------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/var/spack/repos/builtin/packages/nfft/package.py b/var/spack/repos/builtin/packages/nfft/package.py index 549b4a5f25..eeab2da0d6 100644 --- a/var/spack/repos/builtin/packages/nfft/package.py +++ b/var/spack/repos/builtin/packages/nfft/package.py @@ -19,51 +19,58 @@ class Nfft(AutotoolsPackage): depends_on('fftw') + _fftw_precisions = None + + @property + def fftw_selected_precisions(self): + if not self._fftw_precisions: + self._fftw_precisions = self.spec['fftw'].package.selected_precisions + return self._fftw_precisions + def configure(self, spec, prefix): options = ['--prefix={0}'.format(prefix)] configure = Executable('../configure') - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double', create=True): configure(*options) - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float', create=True): configure('--enable-float', *options) - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double', create=True): configure('--enable-long-double', *options) def build(self, spec, prefix): - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double'): make() - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float'): make() - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double'): make() def check(self): - spec = self.spec - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double'): make("check") - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float'): make("check") - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double'): make("check") def install(self, spec, prefix): - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double'): make("install") - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float'): make("install") - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double'): make("install") diff --git a/var/spack/repos/builtin/packages/pnfft/package.py b/var/spack/repos/builtin/packages/pnfft/package.py index cb1d14c9ef..180b06bb5a 100644 --- a/var/spack/repos/builtin/packages/pnfft/package.py +++ b/var/spack/repos/builtin/packages/pnfft/package.py @@ -18,6 +18,14 @@ class Pnfft(AutotoolsPackage): depends_on('pfft') depends_on('gsl') + _fftw_precisions = None + + @property + def fftw_selected_precisions(self): + if not self._fftw_precisions: + self._fftw_precisions = self.spec['fftw'].package.selected_precisions + return self._fftw_precisions + def configure(self, spec, prefix): options = ['--prefix={0}'.format(prefix)] if not self.compiler.f77 or not self.compiler.fc: @@ -25,46 +33,45 @@ def configure(self, spec, prefix): configure = Executable('../configure') - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double', create=True): configure(*options) - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float', create=True): configure('--enable-float', *options) - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double', create=True): configure('--enable-long-double', *options) def build(self, spec, prefix): - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double'): make() - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float'): make() - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double'): make() def check(self): - spec = self.spec - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double'): make("check") - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float'): make("check") - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double'): make("check") def install(self, spec, prefix): - if '+double' in spec['fftw']: + if 'double' in self.fftw_selected_precisions: with working_dir('double'): make("install") - if '+float' in spec['fftw']: + if 'float' in self.fftw_selected_precisions: with working_dir('float'): make("install") - if '+long_double' in spec['fftw']: + if 'long_double' in self.fftw_selected_precisions: with working_dir('long-double'): make("install")