cp2k, libxc, libint: fix builds with %intel, resp. intel-parallel-studio+mkl (#19522)

* cp2k: locate correct include dir when using intel-parallel-studio+mkl for fftw-api

* libxc: drop arch-specific intel opt. flags

fixes #17794

* libint: drop arch-specific intel opt. flags, always build Fortran example with FC

fixes #17509
This commit is contained in:
Tiziano Müller 2020-10-26 16:32:15 +01:00 committed by GitHub
parent fd6c163e02
commit f921bcbe0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 39 deletions

View file

@ -193,7 +193,12 @@ def edit(self, spec, prefix):
fftw_header_dir = fftw.headers.directories[0] + '/fftw'
elif '^intel-parallel-studio+mkl' in spec:
fftw = spec['intel-parallel-studio']
fftw_header_dir = fftw.headers.directories[0] + '/fftw'
fftw_header_dir = '<NOTFOUND>'
for incdir in [join_path(f, 'fftw')
for f in fftw.headers.directories]:
if os.path.exists(incdir):
fftw_header_dir = incdir
break
optimization_flags = {
'gcc': [

View file

@ -78,10 +78,10 @@ def autoreconf(self, spec, prefix):
@property
def optflags(self):
flags = '-O2'
# Optimizations for the Intel compiler, suggested by CP2K
# See ../libxc/package.py for rationale and doc.
if '%intel' in self.spec:
flags += ' -xSSE4.2 -axAVX,CORE-AVX2 -ipo'
# microarchitecture-specific optimization flags should be controlled
# by Spack, otherwise we may end up with contradictory or invalid flags
# see https://github.com/spack/spack/issues/17794
return flags
@ -99,18 +99,16 @@ def configure_args(self):
config_args = ['--enable-shared']
optflags = self.optflags
# Optimization flag names have changed in libint 2
if self.version < Version('2.0.0'):
config_args.extend([
'--with-cc-optflags={0}'.format(optflags),
'--with-cxx-optflags={0}'.format(optflags)
'--with-cc-optflags={0}'.format(self.optflags),
'--with-cxx-optflags={0}'.format(self.optflags)
])
else:
config_args.extend([
'--with-cxx-optflags={0}'.format(optflags),
'--with-cxxgen-optflags={0}'.format(optflags)
'--with-cxx-optflags={0}'.format(self.optflags),
'--with-cxxgen-optflags={0}'.format(self.optflags)
])
# Options required by CP2K, removed in libint 2
@ -199,6 +197,6 @@ def install(self, spec, prefix):
def patch(self):
# Use Fortran compiler to link the Fortran example, not the C++
# compiler
if '+fortran' in self.spec and self.spec.satisfies('%nvhpc'):
if '+fortran' in self.spec:
filter_file('$(CXX) $(CXXFLAGS)', '$(FC) $(FCFLAGS)',
'export/fortran/Makefile', string=True)

View file

@ -64,37 +64,18 @@ def libs(self):
)
def setup_build_environment(self, env):
optflags = '-O2'
if self.compiler.name == 'intel':
# Optimizations for the Intel compiler, suggested by CP2K
#
# Note that not every lowly login node has advanced CPUs:
#
# $ icc -xAVX -axCORE-AVX2 -ipo hello.c
# $ ./a.out
# Please verify that both the operating system and the \
# processor support Intel(R) AVX instructions.
#
# NB: The same flags are applied in:
# - ../libint/package.py
#
# Related:
# - ../fftw/package.py variants: simd, fma
# - ../c-blosc/package.py variant: avx2
# - ../r-rcppblaze/package.py AVX* in "info" but not in code?
# - ../openblas/package.py variants: cpu_target!?!
# - ../cp2k/package.py
#
# Documentation at:
# https://software.intel.com/en-us/cpp-compiler-18.0-developer-guide-and-reference-ax-qax
#
optflags += ' -xSSE4.2 -axAVX,CORE-AVX2 -ipo'
if which('xiar'):
env.set('AR', 'xiar')
# microarchitecture-specific optimization flags should be controlled
# by Spack, otherwise we may end up with contradictory or invalid flags
# see https://github.com/spack/spack/issues/17794
# libxc on the other hand only sets the generic -O2 when it detects GCC
optflags = '-O2'
env.append_flags('CFLAGS', optflags)
env.append_flags('FCFLAGS', optflags)
if '%intel' in self.spec and which('xiar'):
env.set('AR', 'xiar')
if '+cuda' in self.spec:
nvcc = self.spec['cuda'].prefix.bin.nvcc
env.set('CCLD', '{0} -ccbin {1}'.format(nvcc, spack_cc))