diff options
author | Glenn Johnson <glenn-johnson@uiowa.edu> | 2019-07-15 13:37:54 -0500 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2019-07-15 11:37:54 -0700 |
commit | 3f83a2a7d82067dd2e6dacb45572a4948dfda86a (patch) | |
tree | a7341d2a773973ebf6d3d1d72d11512428c23d1d /lib | |
parent | 5acbe449e5840a7592e93d3ba35ff10e45ebc8a0 (diff) | |
download | spack-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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/intel.py | 34 |
1 files changed, 33 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): |