Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the cpmd recipe #27

Open
wants to merge 1 commit into
base: releases/syrah
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 47 additions & 6 deletions packages/cpmd/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ class Cpmd(MakefilePackage):
variant('openmp', description='Enables the use of OpenMP instructions',
default=False)
variant('mpi', description='Build with MPI support', default=False)
variant('fftw', description='Build with external FFTW support', default=False)

depends_on('lapack')
depends_on('mpi', when='+mpi')
depends_on('fftw-api@3', when='+fftw')

conflicts('^openblas threads=none', when='+openmp')
conflicts('^openblas threads=pthreads', when='+openmp')
Expand All @@ -40,11 +42,21 @@ class Cpmd(MakefilePackage):
# patch('file://{0}/patch.to.4650'.format(basedir), sha256='70e752db0b454db39ebf703944f35b584cf5bafc9addf88d372c75d04ceadbf2', level=0, when='@4.3')

def edit(self, spec, prefix):

# patch configure file
cbase = 'LINUX-GFORTRAN'
if spec.satisfies('%gcc'):
cbase = 'LINUX-GFORTRAN'
elif spec.satisfies('%intel'):
cbase = 'LINUX-INTEL'
Comment on lines +47 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if spec.satisfies('%gcc'):
cbase = 'LINUX-GFORTRAN'
elif spec.satisfies('%intel'):
cbase = 'LINUX-INTEL'
cbase = 'LINUX-GFORTRAN'
if spec.satisfies('%intel'):
cbase = 'LINUX-INTEL'

Other why it will fail with any other compiler
If it should fail the conflicts() lines are missing

cp = FileFilter(join_path('configure', cbase))
# Compilers
if spec.satisfies('+mpi'):
## there's a bug and mpifc and mpicc are chosen
## resulting in the wrong compilers being chosen
#if spec.satisfies('^intel-oneapi-mpi'):
# fc = 'mpiifort'
# cc = 'mpiicc'
#else:
fc = spec["mpi"].mpifc
cc = spec["mpi"].mpicc
else:
Expand All @@ -57,17 +69,28 @@ def edit(self, spec, prefix):

# MPI flag
if spec.satisfies('+mpi'):
cp.filter('-D__Linux', '-D__Linux -D__PARALLEL')
cp.filter('-D__Linux', '-D__Linux -D__PARALLEL -D__HPC -D__HAS_SIZEOF')

# OpenMP flag
if spec.satisfies('+openmp'):
cp.filter('-fopenmp', self.compiler.openmp_flag)

# lapack
cp.filter(
'LIBS=.+',
"LIBS='{0}'".format(spec['lapack'].libs.ld_flags)
)
if not spec.satisfies('%intel'):
cp.filter(
'LIBS=.+',
"LIBS='{0}'".format(spec['lapack'].libs.ld_flags)
)

# External FFTW
if spec.satisfies('+fftw'):
cp.filter('-D__HAS_FFT_DEFAULT', '-D__HAS_FFT_FFTW3')
if not spec.satisfies('^mkl'):
cp.filter("FFLAGS='", "FFLAGS='-I{0}".format(spec['fftw'].include))
cp.filter(
"LIBS='",
"LIBS='{0} ".format(spec['fftw'].libs.ld_flags)
Comment on lines +89 to +92
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cp.filter("FFLAGS='", "FFLAGS='-I{0}".format(spec['fftw'].include))
cp.filter(
"LIBS='",
"LIBS='{0} ".format(spec['fftw'].libs.ld_flags)
cp.filter("FFLAGS='", "FFLAGS='-I{0}".format(spec['fftw-api'].include))
cp.filter(
"LIBS='",
"LIBS='{0} ".format(spec['fftw-api'].libs.ld_flags)

)

# LFLAGS
cp.filter("'-static '", '')
Expand All @@ -81,6 +104,24 @@ def edit(self, spec, prefix):
cp.filter('-ffree-line-length-none', '')
cp.filter('-falign-commons', '-Kalign_commons')

if spec.satisfies('%intel'):
cp.filter('CPP=', 'CPP=/lib/cpp -P -traditional')
#cp.filter("CPPFLAGS='-D__Linux", "CPPFLAGS='-D__Linux -DLINUX_IFC")
cp.filter("-D__HAS_FFT_DEFAULT", "-D__HAS_FFT_FFTW3")
Copy link
Contributor

@nrichart nrichart Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cp.filter("-D__HAS_FFT_DEFAULT", "-D__HAS_FFT_FFTW3")

It should be handled by the variant test higher

cp.filter('-O3 -pc64', '-O2 -m64 -unroll-aggressive')
cp.filter("LFLAGS='-static-intel '", "LFLAGS=")

# The intel configure file assumes intel-mkl
# I'm trying to generalize it
if not spec.satisfies('^mkl'):
cp.filter(
'LIBS=.+',
"LIBS='{0}'".format(spec['lapack'].libs.ld_flags)
)
Comment on lines +116 to +120
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work for intel-mkl also no ?
In which case it is already above other why the test can be combined with the previous one line 79
if not spec.satisfies('%intel') or not spec.satisfies('^mkl'):

# Due to deprecation warning (intel-oneapi-*)
elif spec.satisfies('^intel-oneapi-mkl'):
cp.filter('-mkl=', '-qmkl=')

# create Makefile
bash = which('bash')
if spec.satisfies('+openmp'):
Expand Down