summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Johnson <glenn-johnson@uiowa.edu>2019-07-15 13:37:54 -0500
committerPeter Scheibel <scheibel1@llnl.gov>2019-07-15 11:37:54 -0700
commit3f83a2a7d82067dd2e6dacb45572a4948dfda86a (patch)
treea7341d2a773973ebf6d3d1d72d11512428c23d1d
parent5acbe449e5840a7592e93d3ba35ff10e45ebc8a0 (diff)
downloadspack-3f83a2a7d82067dd2e6dacb45572a4948dfda86a.tar.gz
spack-3f83a2a7d82067dd2e6dacb45572a4948dfda86a.tar.bz2
spack-3f83a2a7d82067dd2e6dacb45572a4948dfda86a.tar.xz
spack-3f83a2a7d82067dd2e6dacb45572a4948dfda86a.zip
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.
-rw-r--r--lib/spack/spack/build_systems/intel.py34
-rw-r--r--var/spack/repos/builtin/packages/intel-parallel-studio/package.py13
-rw-r--r--var/spack/repos/builtin/packages/intel/package.py13
3 files changed, 59 insertions, 1 deletions
diff --git a/lib/spack/spack/build_systems/intel.py b/lib/spack/spack/build_systems/intel.py
index 73cdcd8eaf..0936eef07c 100644
--- a/lib/spack/spack/build_systems/intel.py
+++ b/lib/spack/spack/build_systems/intel.py
@@ -25,11 +25,11 @@ from spack.util.executable import Executable
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
@@ -1242,6 +1250,30 @@ class IntelPackage(PackageBase):
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
'~newdtags' in self.spec):
diff --git a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
index 73e63d7662..409e642000 100644
--- a/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
+++ b/var/spack/repos/builtin/packages/intel-parallel-studio/package.py
@@ -129,6 +129,13 @@ class IntelParallelStudio(IntelPackage):
multi=False
)
+ auto_dispatch_options = IntelPackage.auto_dispatch_options
+ variant(
+ 'auto_dispatch',
+ values=any_combination_of(*auto_dispatch_options),
+ description='Enable generation of multiple auto-dispatch code paths'
+ )
+
# Components available in all editions
variant('daal', default=True,
description='Install the Intel DAAL libraries')
@@ -186,6 +193,12 @@ class IntelParallelStudio(IntelPackage):
conflicts('+daal', when='@cluster.0:cluster.2015.7')
conflicts('+daal', when='@composer.0:composer.2015.7')
+ # MacOS does not support some of the auto dispatch settings
+ conflicts('auto_dispatch=SSE2', 'platform=darwin',
+ msg='SSE2 is not supported on MacOS')
+ conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64',
+ msg='SSE3 is not supported on MacOS x86_64')
+
def setup_dependent_environment(self, *args):
# Handle in callback, conveying client's compilers in additional arg.
# CAUTION - DUP code in:
diff --git a/var/spack/repos/builtin/packages/intel/package.py b/var/spack/repos/builtin/packages/intel/package.py
index 5f723b010f..a611c09fb7 100644
--- a/var/spack/repos/builtin/packages/intel/package.py
+++ b/var/spack/repos/builtin/packages/intel/package.py
@@ -43,5 +43,18 @@ class Intel(IntelPackage):
variant('rpath', default=True, description='Add rpath to .cfg files')
+ auto_dispatch_options = IntelPackage.auto_dispatch_options
+ variant(
+ 'auto_dispatch',
+ values=any_combination_of(*auto_dispatch_options),
+ description='Enable generation of multiple auto-dispatch code paths'
+ )
+
+ # MacOS does not support some of the auto dispatch settings
+ conflicts('auto_dispatch=SSE2', 'platform=darwin',
+ msg='SSE2 is not supported on MacOS')
+ conflicts('auto_dispatch=SSE3', 'platform=darwin target=x86_64',
+ msg='SSE3 is not supported on MacOS x86_64')
+
# Since the current package is a subset of 'intel-parallel-studio',
# all remaining Spack actions are handled in the package class.