Skip to content

Commit

Permalink
Update HPX package (spack#25775)
Browse files Browse the repository at this point in the history
* Add support for C++20 to HPX package

* Enable unity builds in HPX package when available

* Add support for HIP/ROCm to HPX package

* Rearrange and update required versions for HPX package

* Add C++20 option to asio package
  • Loading branch information
msimberg authored Sep 16, 2021
1 parent ccfdac8 commit b09ad2c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 40 deletions.
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/asio/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Asio(AutotoolsPackage):
depends_on("m4", type="build")
depends_on("libtool", type="build")

stds = ("11", "14", "17")
stds = ("11", "14", "17", "2a")
variant(
"cxxstd",
default="11",
Expand Down
120 changes: 81 additions & 39 deletions var/spack/repos/builtin/packages/hpx/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from spack import *


class Hpx(CMakePackage, CudaPackage):
class Hpx(CMakePackage, CudaPackage, ROCmPackage):
"""C++ runtime system for parallel and distributed applications."""

homepage = "https://hpx.stellar-group.org/"
Expand All @@ -31,11 +31,12 @@ class Hpx(CMakePackage, CudaPackage):
version('1.1.0', sha256='1f28bbe58d8f0da600d60c3a74a644d75ac777b20a018a5c1c6030a470e8a1c9')

generator = 'Ninja'
depends_on('ninja', type='build')

map_cxxstd = lambda cxxstd: '2a' if cxxstd == '20' else cxxstd
cxxstds = ('11', '14', '17', '20')
variant('cxxstd',
default='17',
values=('11', '14', '17', '20'),
values=cxxstds,
description='Use the specified C++ standard when building.')

variant(
Expand Down Expand Up @@ -71,61 +72,91 @@ class Hpx(CMakePackage, CudaPackage):
variant('async_mpi', default=False, description='Enable MPI Futures.')
variant('async_cuda', default=False, description='Enable CUDA Futures.')

depends_on('hwloc')
# Build dependencies
depends_on('python', type=('build', 'test', 'run'))
depends_on('ninja', type='build')
depends_on('pkgconfig', type='build')
depends_on('git', type='build')
depends_on('cmake', type='build')

# Recommended dependency versions for 1.2.X
depends_on('[email protected]:', when='@:1.2.1', type='build')
depends_on('[email protected]:', when='@:1.2.1')
depends_on('[email protected]:', when='@:1.2.1')

# Recommended dependency versions before 1.2
depends_on('[email protected]:', when='@:1.1.0')
depends_on('[email protected]:', when='@:1.1.0')

# boost 1.73.0 build problem with HPX 1.4.0 and 1.4.1
# https://github.com/STEllAR-GROUP/hpx/issues/4728#issuecomment-640685308
depends_on('boost@:1.72.0', when='@:1.4')

# COROUTINES
# ~generic_coroutines conflict is not fully implemented
# for additional information see:
# https://github.com/spack/spack/pull/17654
# https://github.com/STEllAR-GROUP/hpx/issues/4829
depends_on('boost+context', when='+generic_coroutines')
_msg_generic_coroutines = 'This platform requires +generic_coroutines'
conflicts('~generic_coroutines', when='platform=darwin', msg=_msg_generic_coroutines)

# Asio
depends_on('asio cxxstd=11', when='@1.7: cxxstd=11')
depends_on('asio cxxstd=14', when='@1.7: cxxstd=14')
depends_on('asio cxxstd=17', when='@1.7: cxxstd=17')

# CXX Standard
depends_on('boost cxxstd=11', when='cxxstd=11')
depends_on('boost cxxstd=14', when='cxxstd=14')
depends_on('boost cxxstd=17', when='cxxstd=17')
# Other dependecies
depends_on('hwloc')
depends_on('boost')
for cxxstd in cxxstds:
depends_on(
"boost cxxstd={0}".format(map_cxxstd(cxxstd)),
when="cxxstd={0}".format(cxxstd)
)
depends_on('asio', when='@1.7:')
for cxxstd in cxxstds:
depends_on(
"asio cxxstd={0}".format(map_cxxstd(cxxstd)),
when="cxxstd={0} ^asio".format(cxxstd),
)

# Malloc
depends_on('gperftools', when='malloc=tcmalloc')
depends_on('jemalloc', when='malloc=jemalloc')
depends_on('tbb', when='malloc=tbbmalloc')

# MPI
depends_on('mpi', when='networking=mpi')
depends_on('mpi', when='+async_mpi')

# CUDA
depends_on('cuda', when='+async_cuda')

# Instrumentation
depends_on('otf2', when='instrumentation=apex')
depends_on('gperftools', when='instrumentation=google_perftools')
depends_on('papi', when='instrumentation=papi')
depends_on('valgrind', when='instrumentation=valgrind')

# Restrictions for stable/master
with when("@master"):
conflicts("cxxstd=14")
depends_on("cuda@11:", when="+cuda")

with when("@stable"):
conflicts("cxxstd=14")
depends_on("cuda@11:", when="+cuda")

# Restrictions for 1.7.X
with when('@1.7:'):
depends_on('[email protected]:', type='build')
depends_on('[email protected]:')
depends_on('[email protected]:')
conflicts('%gcc@:6')
conflicts('%clang@:6')

# Restrictions for 1.6.X
conflicts('+rocm', when='@:1.5')

# Restrictions for 1.5.x
conflicts('cxxstd=11', when='@1.5:')

# Restrictions for 1.2.X
with when('@:1.2.1'):
depends_on('[email protected]:', type='build')
depends_on('[email protected]:')
depends_on('[email protected]:')

# Restrictions before 1.2
with when('@:1.1.0'):
depends_on('[email protected]:')
depends_on('[email protected]:')

# Patches and one-off conflicts

# boost 1.73.0 build problem with HPX 1.4.0 and 1.4.1
# https://github.com/STEllAR-GROUP/hpx/issues/4728#issuecomment-640685308
depends_on('boost@:1.72.0', when='@:1.4')

# COROUTINES
# ~generic_coroutines conflict is not fully implemented
# for additional information see:
# https://github.com/spack/spack/pull/17654
# https://github.com/STEllAR-GROUP/hpx/issues/4829
depends_on('boost+context', when='+generic_coroutines')
_msg_generic_coroutines = 'This platform requires +generic_coroutines'
conflicts('~generic_coroutines', when='platform=darwin', msg=_msg_generic_coroutines)

# Patches APEX
patch('git_external.patch', when='@1.3.0 instrumentation=apex')

Expand All @@ -147,6 +178,7 @@ def cmake_args(self):

self.define_from_variant('HPX_WITH_MALLOC', 'malloc'),
self.define_from_variant('HPX_WITH_CUDA', 'cuda'),
self.define_from_variant('HPX_WITH_HIP', 'rocm'),
self.define_from_variant('HPX_WITH_TOOLS', 'tools'),
self.define_from_variant('HPX_WITH_EXAMPLES', 'examples'),
self.define_from_variant('HPX_WITH_ASYNC_MPI', 'async_mpi'),
Expand All @@ -169,6 +201,16 @@ def cmake_args(self):
self.define('HPX_DATASTRUCTURES_WITH_ADAPT_STD_TUPLE', False),
]

# Enable unity builds when available
if spec.satisfies("@1.7:"):
args += [self.define('HPX_WITH_UNITY_BUILD', True)]

# HIP support requires compiling with hipcc
if '+rocm' in self.spec:
args += [self.define('CMAKE_CXX_COMPILER', self.spec['hip'].hipcc)]
if self.spec.satisfies('^[email protected]:'):
args += [self.define('__skip_rocmclang', True)]

# Instrumentation
args += self.instrumentation_args()

Expand Down

0 comments on commit b09ad2c

Please sign in to comment.