Add auto-dispatch specification to Intel packages (#11697)

This PR adds the ability to specify the auto-dispatch targets that can
be used by the Intel compilers. The `-ax` flag will be written to the
respective compiler configuration files. This ability is very handy when
wanting to build optimized builds for various architectures. This PR
does not set any optimization flags, however.
This commit is contained in:
Glenn Johnson
2019-07-15 13:37:54 -05:00
committed by Peter Scheibel
parent 5acbe449e5
commit 3f83a2a7d8
3 changed files with 59 additions and 1 deletions

View File

@@ -25,11 +25,11 @@
from spack.util.prefix import Prefix
from spack.build_environment import dso_suffix
# A couple of utility functions that might be useful in general. If so, they
# should really be defined elsewhere, unless deemed heretical.
# (Or na"ive on my part).
def debug_print(msg, *args):
'''Prints a message (usu. a variable) and the callers' names for a couple
of stack frames.
@@ -115,6 +115,14 @@ class IntelPackage(PackageBase):
'intel-mpi@5.1:5.99': 2016,
}
# Below is the list of possible values for setting auto dispatch functions
# for the Intel compilers. Using these allows for the building of fat
# binaries that will detect the CPU SIMD capabilities at run time and
# activate the appropriate extensions.
auto_dispatch_options = ('COMMON-AVX512', 'MIC-AVX512', 'CORE-AVX512',
'CORE-AVX2', 'CORE-AVX-I', 'AVX', 'SSE4.2',
'SSE4.1', 'SSSE3', 'SSE3', 'SSE2')
@property
def license_required(self):
# The Intel libraries are provided without requiring a license as of
@@ -1241,6 +1249,30 @@ def configure_rpath(self):
with open(compiler_cfg, 'w') as fh:
fh.write('-Xlinker -rpath={0}\n'.format(compilers_lib_dir))
@run_after('install')
def configure_auto_dispatch(self):
if self._has_compilers:
if ('auto_dispatch=none' in self.spec):
return
compilers_bin_dir = self.component_bin_dir('compiler')
for compiler_name in 'icc icpc ifort'.split():
f = os.path.join(compilers_bin_dir, compiler_name)
if not os.path.isfile(f):
raise InstallError(
'Cannot find compiler command to configure '
'auto_dispatch:\n\t' + f)
ad = []
for x in IntelPackage.auto_dispatch_options:
if 'auto_dispatch={0}'.format(x) in self.spec:
ad.append(x)
compiler_cfg = os.path.abspath(f + '.cfg')
with open(compiler_cfg, 'a') as fh:
fh.write('-ax{0}\n'.format(','.join(ad)))
@run_after('install')
def filter_compiler_wrappers(self):
if (('+mpi' in self.spec or self.provides('mpi')) and