2019-01-01 14:04:23 +08:00
|
|
|
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
2016-05-12 12:22:25 +08:00
|
|
|
#
|
2018-10-08 04:52:23 +08:00
|
|
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2016-03-22 23:59:40 +08:00
|
|
|
from spack import *
|
|
|
|
import glob
|
2018-06-08 12:16:31 +08:00
|
|
|
import inspect
|
|
|
|
import platform
|
2016-03-22 23:59:40 +08:00
|
|
|
|
2016-05-18 05:35:05 +08:00
|
|
|
|
2017-08-17 01:21:07 +08:00
|
|
|
class IntelTbb(Package):
|
2016-03-22 23:59:40 +08:00
|
|
|
"""Widely used C++ template library for task parallelism.
|
|
|
|
Intel Threading Building Blocks (Intel TBB) lets you easily write parallel
|
|
|
|
C++ programs that take full advantage of multicore performance, that are
|
|
|
|
portable and composable, and that have future-proof scalability.
|
|
|
|
"""
|
|
|
|
homepage = "http://www.threadingbuildingblocks.org/"
|
|
|
|
|
2019-11-30 03:18:56 +08:00
|
|
|
# Note: when adding new versions, please check and update the
|
|
|
|
# patches and filters below as needed.
|
|
|
|
|
2018-06-08 12:16:31 +08:00
|
|
|
# See url_for_version() below.
|
2019-11-26 06:52:46 +08:00
|
|
|
version('2019.8', sha256='7b1fd8caea14be72ae4175896510bf99c809cd7031306a1917565e6de7382fba')
|
|
|
|
version('2019.7', sha256='4204a93f4c0fd989fb6f79acae74feb02ee39725c93968773d9b6efeb75c7a6a')
|
|
|
|
version('2019.6', sha256='2ba197b3964fce8a84429dd15b75eba7434cb89afc54f86d5ee6f726fdbe97fd')
|
|
|
|
version('2019.5', sha256='2ea82d74dec50e18075b4982b8d360f8bd2bf2950f38e2db483aef82e0047444')
|
2019-03-11 22:03:19 +08:00
|
|
|
version('2019.4', sha256='342a0a2cd583879850658284b86e9351ea019b4f3fcd731f4c18456f0ce9f900')
|
|
|
|
version('2019.3', sha256='b2244147bc8159cdd8f06a38afeb42f3237d3fc822555499d7ccfbd4b86f8ece')
|
|
|
|
version('2019.2', sha256='1245aa394a92099e23ce2f60cdd50c90eb3ddcd61d86cae010ef2f1de61f32d9')
|
|
|
|
version('2019.1', sha256='a4875c6b6853213083e52ecd303546bdf424568ec67cfc7e51d132a7c037c66a')
|
2019-10-11 13:44:41 +08:00
|
|
|
version('2019', sha256='4d149895826cea785cd3b9a14f4aa743b6ef0df520eca7ee27d438fdc3d73399')
|
|
|
|
version('2018.6', sha256='d3e5fbca3cc643d03bf332d576ff85e19aa774b483f148f95cd7d09958372109')
|
|
|
|
version('2018.5', sha256='c4c2896af527392496c5e01ef8579058a71b6eebbd695924cd138841c13f07be')
|
|
|
|
version('2018.4', sha256='d5604a04787c8a037d4944eeb89792e7c45f6a83c141b20df7ee89c2fb012ed1')
|
|
|
|
version('2018.3', sha256='23793c8645480148e9559df96b386b780f92194c80120acce79fcdaae0d81f45')
|
|
|
|
version('2018.2', sha256='78bb9bae474736d213342f01fe1a6d00c6939d5c75b367e2e43e7bf29a6d8eca')
|
|
|
|
version('2018.1', sha256='c6462217d4ecef2b44fce63cfdf31f9db4f6ff493869899d497a5aef68b05fc5')
|
|
|
|
version('2018', sha256='94f643f1edfaccb57d64b503c7c96f00dec64e8635c054bbaa33855d72c5822d')
|
|
|
|
version('2017.8', sha256='1b1357f280e750d42506212adad02f85ac07c9d3e3c0813104f9122ef350497f')
|
|
|
|
version('2017.7', sha256='78ad6ec9dd492b9dcc4753938b06716f7458506084adc138ced09aa0aa609b6b')
|
|
|
|
version('2017.6', sha256='40d5409a6fd7e214a21fd1949df422ba113fa78fde42a6aac40a2fba36e9bcdb')
|
|
|
|
version('2017.5', sha256='3122c87a35fde759567c8579ba36a36037c6df84c3f9c4df6c9e171f866f352f')
|
|
|
|
version('2017.4', sha256='ed4f0cfc4acec8a0cf253037e8c555dd32ebe1b80b34fb0e3b2bf54087932562')
|
|
|
|
version('2017.3', sha256='00a8b2798c498507572e24c2db7bf4896f05b760a38ed9ba566ffd348a7c6cef')
|
|
|
|
version('2017.2', sha256='85e44041d967ce8c70077dbb57941cfa1d351688855aec47eb14c74eb2075f28')
|
|
|
|
version('2017.1', sha256='a68bb7926fb9bee2a5f17b293c6d6aa33ccb089c3b321569bd4fe281cf65fa77')
|
|
|
|
version('2017', sha256='c49139279067df1260dae4f0fe7e4d485898ce45e5f7e314c37eb5da8a0c303a')
|
|
|
|
version('4.4.6', sha256='1d6b7e7db9141238c70984103f04280605dbcaa7fbcd049d332d2e73deed4f6d')
|
|
|
|
version('4.4.5', sha256='984308f9dd8a36ff274c124b6f7f7d0ff74d4b7ebdf06511af78e098b5b6e70f')
|
|
|
|
version('4.4.4', sha256='40e94c1adfd13308d207971629316ae9f76639b24f080bae8757c42d35778f10')
|
|
|
|
version('4.4.3', sha256='9acb1c4e71edc3d5004ab9f0ed2bbd697ecec28a4315bbd2be8c5365e8214b90')
|
|
|
|
version('4.4.2', sha256='3f6d7a32ac8b58469de7df3a2fcfe318793241ea39ce73aae1e637dbed833375')
|
|
|
|
version('4.4.1', sha256='d67c5860ba1116b320b0d60a0ce403b088dc19355ab32c28cdaa3e352609713a')
|
|
|
|
version('4.4', sha256='88e37f08ffcfaa24a2caf6c1a9084000cce689cc4b11edea7e89b20ab74ceceb')
|
2016-03-22 23:59:40 +08:00
|
|
|
|
2017-08-17 01:21:07 +08:00
|
|
|
provides('tbb')
|
|
|
|
|
2019-11-27 13:15:17 +08:00
|
|
|
# Clang builds incorrectly determine GCC version which in turn incorrectly
|
|
|
|
# causes a mismatch in C++ features resulting in a link error. This also
|
|
|
|
# means that clang builds require a gcc compiler to work correctly (this
|
|
|
|
# has always been the case).
|
|
|
|
#
|
|
|
|
# See https://github.com/intel/tbb/pull/147 for details.
|
|
|
|
#
|
2019-12-04 21:50:05 +08:00
|
|
|
conflicts('%clang', when='@:2019.6',
|
2019-11-27 13:15:17 +08:00
|
|
|
msg='2019.7 or later required for clang')
|
|
|
|
|
2018-06-08 12:16:31 +08:00
|
|
|
conflicts('%gcc@6.1:', when='@:4.4.3',
|
|
|
|
msg='4.4.4 or later required for GCC >= 6.1.')
|
|
|
|
|
2018-03-13 15:08:02 +08:00
|
|
|
variant('shared', default=True,
|
|
|
|
description='Builds a shared version of TBB libraries')
|
|
|
|
|
2018-06-08 12:16:31 +08:00
|
|
|
variant('cxxstd',
|
|
|
|
default='default',
|
|
|
|
values=('default', '98', '11', '14', '17'),
|
|
|
|
multi=False,
|
|
|
|
description='Use the specified C++ standard when building.')
|
|
|
|
|
2018-07-26 14:14:17 +08:00
|
|
|
variant('tm', default=True,
|
|
|
|
description='Enable use of transactional memory on x86')
|
|
|
|
|
2018-06-08 12:16:31 +08:00
|
|
|
# Build and install CMake config files if we're new enough.
|
|
|
|
depends_on('cmake@3.0.0:', type='build', when='@2017.0:')
|
|
|
|
|
2019-05-19 10:00:32 +08:00
|
|
|
# Note: see issues #11371 and #8957 to understand why 2019.x patches are
|
|
|
|
# specified one at a time. In a nutshell, it is currently impossible
|
|
|
|
# to patch `2019.1` without patching `2019`. When #8957 is fixed, this
|
|
|
|
# can be simplified.
|
|
|
|
|
2019-11-30 03:18:56 +08:00
|
|
|
# Patch for pedantic warnings (#10836). This was fixed in the TBB
|
|
|
|
# source tree in 2019.6. One patch file for 2019.1 and after...
|
|
|
|
patch("gcc_generic-pedantic-2019.patch", level=1,
|
|
|
|
when='@2019.1,2019.2,2019.3,2019.4,2019.5')
|
2019-05-19 10:00:32 +08:00
|
|
|
# ...another patch file for 2019 and before
|
|
|
|
patch("gcc_generic-pedantic-4.4.patch", level=1, when='@:2019.0')
|
2018-06-08 12:16:31 +08:00
|
|
|
|
|
|
|
# Patch cmakeConfig.cmake.in to find the libraries where we install them.
|
2019-11-30 03:18:56 +08:00
|
|
|
# Can't use '@2019.5:' because 2019.5 <= 2019 <= 2019.99. wtf!?
|
|
|
|
patch("tbb_cmakeConfig-2019.5.patch", level=0,
|
|
|
|
when='@2019.5,2019.6,2019.7,2019.8')
|
|
|
|
patch("tbb_cmakeConfig.patch", level=0, when='@2017.0:2019.4')
|
2018-06-08 12:16:31 +08:00
|
|
|
|
2018-07-26 14:14:17 +08:00
|
|
|
# Some very old systems don't support transactional memory.
|
|
|
|
patch("disable-tm.patch", when='~tm')
|
|
|
|
|
2018-06-08 12:16:31 +08:00
|
|
|
def url_for_version(self, version):
|
|
|
|
url = 'https://github.com/01org/tbb/archive/{0}.tar.gz'
|
|
|
|
if (version[0] >= 2017) and len(version) > 1:
|
|
|
|
return url.format('{0}_U{1}'.format(version[0], version[1]))
|
|
|
|
else:
|
|
|
|
return url.format(version)
|
2017-11-11 09:00:47 +08:00
|
|
|
|
2016-05-18 05:35:05 +08:00
|
|
|
def coerce_to_spack(self, tbb_build_subdir):
|
|
|
|
for compiler in ["icc", "gcc", "clang"]:
|
|
|
|
fs = glob.glob(join_path(tbb_build_subdir,
|
|
|
|
"*.%s.inc" % compiler))
|
|
|
|
for f in fs:
|
|
|
|
lines = open(f).readlines()
|
|
|
|
of = open(f, "w")
|
|
|
|
for l in lines:
|
|
|
|
if l.strip().startswith("CPLUS ="):
|
2016-03-22 23:59:40 +08:00
|
|
|
of.write("# coerced to spack\n")
|
|
|
|
of.write("CPLUS = $(CXX)\n")
|
2019-09-20 14:58:07 +08:00
|
|
|
elif l.strip().startswith("CONLY ="):
|
2016-03-22 23:59:40 +08:00
|
|
|
of.write("# coerced to spack\n")
|
|
|
|
of.write("CONLY = $(CC)\n")
|
2016-05-18 05:35:05 +08:00
|
|
|
else:
|
|
|
|
of.write(l)
|
2016-03-22 23:59:40 +08:00
|
|
|
|
|
|
|
def install(self, spec, prefix):
|
2019-11-30 03:18:56 +08:00
|
|
|
# Deactivate use of RTM with GCC when on an OS with a very old
|
|
|
|
# assembler.
|
|
|
|
if (spec.satisfies('%gcc@4.8.0: os=rhel6')
|
|
|
|
or spec.satisfies('%gcc@4.8.0: os=centos6')
|
|
|
|
or spec.satisfies('%gcc@4.8.0: os=scientific6')):
|
|
|
|
filter_file(r'RTM_KEY.*=.*rtm.*', 'RTM_KEY =',
|
|
|
|
join_path('build', 'linux.gcc.inc'))
|
|
|
|
|
2016-05-18 05:35:05 +08:00
|
|
|
# We need to follow TBB's compiler selection logic to get the proper
|
|
|
|
# build + link flags but we still need to use spack's compiler wrappers
|
2016-03-22 23:59:40 +08:00
|
|
|
# to accomplish this, we do two things:
|
|
|
|
#
|
2016-05-18 05:35:05 +08:00
|
|
|
# * Look at the spack spec to determine which compiler we should pass
|
|
|
|
# to tbb's Makefile;
|
2016-03-22 23:59:40 +08:00
|
|
|
#
|
|
|
|
# * patch tbb's build system to use the compiler wrappers (CC, CXX) for
|
2016-05-18 05:35:05 +08:00
|
|
|
# icc, gcc, clang (see coerce_to_spack());
|
2016-03-22 23:59:40 +08:00
|
|
|
#
|
|
|
|
self.coerce_to_spack("build")
|
|
|
|
|
|
|
|
if spec.satisfies('%clang'):
|
|
|
|
tbb_compiler = "clang"
|
|
|
|
elif spec.satisfies('%intel'):
|
|
|
|
tbb_compiler = "icc"
|
|
|
|
else:
|
|
|
|
tbb_compiler = "gcc"
|
|
|
|
|
|
|
|
mkdirp(prefix)
|
|
|
|
mkdirp(prefix.lib)
|
|
|
|
|
2018-03-13 15:08:02 +08:00
|
|
|
make_opts = []
|
|
|
|
|
|
|
|
# Static builds of TBB are enabled by including 'big_iron.inc' file
|
|
|
|
# See caveats in 'big_iron.inc' for limits on using TBB statically
|
|
|
|
# Lore states this file must be handed to make before other options
|
|
|
|
if '+shared' not in self.spec:
|
|
|
|
make_opts.append("extra_inc=big_iron.inc")
|
|
|
|
|
2018-06-08 12:16:31 +08:00
|
|
|
if spec.variants['cxxstd'].value != 'default':
|
|
|
|
make_opts.append('stdver=c++{0}'.
|
|
|
|
format(spec.variants['cxxstd'].value))
|
|
|
|
|
2016-03-22 23:59:40 +08:00
|
|
|
#
|
|
|
|
# tbb does not have a configure script or make install target
|
|
|
|
# we simply call make, and try to put the pieces together
|
|
|
|
#
|
2018-03-13 15:08:02 +08:00
|
|
|
make_opts.append("compiler={0}".format(tbb_compiler))
|
|
|
|
make(*make_opts)
|
2016-03-22 23:59:40 +08:00
|
|
|
|
|
|
|
# install headers to {prefix}/include
|
2016-05-18 05:35:05 +08:00
|
|
|
install_tree('include', prefix.include)
|
2016-03-22 23:59:40 +08:00
|
|
|
|
|
|
|
# install libs to {prefix}/lib
|
|
|
|
tbb_lib_names = ["libtbb",
|
|
|
|
"libtbbmalloc",
|
|
|
|
"libtbbmalloc_proxy"]
|
|
|
|
|
|
|
|
for lib_name in tbb_lib_names:
|
|
|
|
# install release libs
|
2016-05-18 05:35:05 +08:00
|
|
|
fs = glob.glob(join_path("build", "*release", lib_name + ".*"))
|
2016-03-22 23:59:40 +08:00
|
|
|
for f in fs:
|
|
|
|
install(f, prefix.lib)
|
|
|
|
# install debug libs if they exist
|
2016-05-18 05:35:05 +08:00
|
|
|
fs = glob.glob(join_path("build", "*debug", lib_name + "_debug.*"))
|
2016-03-22 23:59:40 +08:00
|
|
|
for f in fs:
|
|
|
|
install(f, prefix.lib)
|
2018-06-08 12:16:31 +08:00
|
|
|
|
|
|
|
if self.spec.satisfies('@2017.0:'):
|
|
|
|
# Generate and install the CMake Config file.
|
|
|
|
cmake_args = ('-DTBB_ROOT={0}'.format(prefix),
|
|
|
|
'-DTBB_OS={0}'.format(platform.system()),
|
|
|
|
'-P',
|
|
|
|
'tbb_config_generator.cmake')
|
|
|
|
with working_dir(join_path(self.stage.source_path, 'cmake')):
|
|
|
|
inspect.getmodule(self).cmake(*cmake_args)
|