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:
parent
5acbe449e5
commit
3f83a2a7d8
@ -25,11 +25,11 @@
|
|||||||
from spack.util.prefix import Prefix
|
from spack.util.prefix import Prefix
|
||||||
from spack.build_environment import dso_suffix
|
from spack.build_environment import dso_suffix
|
||||||
|
|
||||||
|
|
||||||
# A couple of utility functions that might be useful in general. If so, they
|
# A couple of utility functions that might be useful in general. If so, they
|
||||||
# should really be defined elsewhere, unless deemed heretical.
|
# should really be defined elsewhere, unless deemed heretical.
|
||||||
# (Or na"ive on my part).
|
# (Or na"ive on my part).
|
||||||
|
|
||||||
|
|
||||||
def debug_print(msg, *args):
|
def debug_print(msg, *args):
|
||||||
'''Prints a message (usu. a variable) and the callers' names for a couple
|
'''Prints a message (usu. a variable) and the callers' names for a couple
|
||||||
of stack frames.
|
of stack frames.
|
||||||
@ -115,6 +115,14 @@ class IntelPackage(PackageBase):
|
|||||||
'intel-mpi@5.1:5.99': 2016,
|
'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
|
@property
|
||||||
def license_required(self):
|
def license_required(self):
|
||||||
# The Intel libraries are provided without requiring a license as of
|
# 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:
|
with open(compiler_cfg, 'w') as fh:
|
||||||
fh.write('-Xlinker -rpath={0}\n'.format(compilers_lib_dir))
|
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')
|
@run_after('install')
|
||||||
def filter_compiler_wrappers(self):
|
def filter_compiler_wrappers(self):
|
||||||
if (('+mpi' in self.spec or self.provides('mpi')) and
|
if (('+mpi' in self.spec or self.provides('mpi')) and
|
||||||
|
@ -129,6 +129,13 @@ class IntelParallelStudio(IntelPackage):
|
|||||||
multi=False
|
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
|
# Components available in all editions
|
||||||
variant('daal', default=True,
|
variant('daal', default=True,
|
||||||
description='Install the Intel DAAL libraries')
|
description='Install the Intel DAAL libraries')
|
||||||
@ -186,6 +193,12 @@ class IntelParallelStudio(IntelPackage):
|
|||||||
conflicts('+daal', when='@cluster.0:cluster.2015.7')
|
conflicts('+daal', when='@cluster.0:cluster.2015.7')
|
||||||
conflicts('+daal', when='@composer.0:composer.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):
|
def setup_dependent_environment(self, *args):
|
||||||
# Handle in callback, conveying client's compilers in additional arg.
|
# Handle in callback, conveying client's compilers in additional arg.
|
||||||
# CAUTION - DUP code in:
|
# CAUTION - DUP code in:
|
||||||
|
@ -43,5 +43,18 @@ class Intel(IntelPackage):
|
|||||||
|
|
||||||
variant('rpath', default=True, description='Add rpath to .cfg files')
|
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',
|
# Since the current package is a subset of 'intel-parallel-studio',
|
||||||
# all remaining Spack actions are handled in the package class.
|
# all remaining Spack actions are handled in the package class.
|
||||||
|
Loading…
Reference in New Issue
Block a user