1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import llnl.util.lang as lang
import llnl.util.tty as tty
class Umpire(CMakePackage, CudaPackage, HipPackage):
"""An application-focused API for memory management on NUMA & GPU
architectures"""
homepage = 'https://github.com/LLNL/Umpire'
git = 'https://github.com/LLNL/Umpire.git'
maintainers = ['davidbeckingsale']
version('develop', branch='develop', submodules='True')
version('main', branch='main', submodules='True')
version('4.1.2', tag='v4.1.2', submodules='True')
version('4.1.1', tag='v4.1.1', submodules='True')
version('4.1.0', tag='v4.1.0', submodules='True')
version('4.0.1', tag='v4.0.1', submodules='True')
version('4.0.0', tag='v4.0.0', submodules='True')
version('3.0.0', tag='v3.0.0', submodules='True')
version('2.1.0', tag='v2.1.0', submodules='True')
version('2.0.0', tag='v2.0.0', submodules='True')
version('1.1.0', tag='v1.1.0', submodules='True')
version('1.0.1', tag='v1.0.1', submodules='True')
version('1.0.0', tag='v1.0.0', submodules='True')
version('0.3.5', tag='v0.3.5', submodules='True')
version('0.3.4', tag='v0.3.4', submodules='True')
version('0.3.3', tag='v0.3.3', submodules='True')
version('0.3.2', tag='v0.3.2', submodules='True')
version('0.3.1', tag='v0.3.1', submodules='True')
version('0.3.0', tag='v0.3.0', submodules='True')
version('0.2.4', tag='v0.2.4', submodules='True')
version('0.2.3', tag='v0.2.3', submodules='True')
version('0.2.2', tag='v0.2.2', submodules='True')
version('0.2.1', tag='v0.2.1', submodules='True')
version('0.2.0', tag='v0.2.0', submodules='True')
version('0.1.4', tag='v0.1.4', submodules='True')
version('0.1.3', tag='v0.1.3', submodules='True')
patch('camp_target_umpire_3.0.0.patch', when='@3.0.0')
patch('cmake_version_check.patch', when='@4.1.0:main')
variant('fortran', default=False, description='Build C/Fortran API')
variant('c', default=True, description='Build C API')
variant('numa', default=False, description='Enable NUMA support')
variant('shared', default=True, description='Enable Shared libs')
variant('openmp', default=False, description='Build with OpenMP support')
variant('deviceconst', default=False,
description='Enables support for constant device memory')
variant('examples', default=True, description='Build Umpire Examples')
variant('tests', default='none', values=('none', 'basic', 'benchmarks'),
multi=False, description='Tests to run')
depends_on('cmake@3.8:', type='build')
depends_on('cmake@3.9:', when='+cuda', type='build')
depends_on('blt', type='build')
# variants +hip and amdgpu_targets are not automatically passed to
# dependencies, so do it manually.
depends_on('camp+hip', when='+hip')
amdgpu_targets = HipPackage.amd_gputargets_list()
for val in amdgpu_targets:
depends_on('camp amdgpu_target=%s' % val, when='amdgpu_target=%s' % val)
depends_on('camp')
conflicts('+numa', when='@:0.3.2')
conflicts('~c', when='+fortran', msg='Fortran API requires C API')
def cmake_args(self):
spec = self.spec
options = []
options.append("-DBLT_SOURCE_DIR={0}".format(spec['blt'].prefix))
options.append("-Dcamp_DIR={0}".format(spec['camp'].prefix))
if '+cuda' in spec:
options.extend([
'-DENABLE_CUDA=On',
'-DCUDA_TOOLKIT_ROOT_DIR=%s' % (spec['cuda'].prefix)])
if not spec.satisfies('cuda_arch=none'):
cuda_arch = spec.variants['cuda_arch'].value
options.append('-DCUDA_ARCH=sm_{0}'.format(cuda_arch[0]))
flag = '-arch sm_{0}'.format(cuda_arch[0])
options.append('-DCMAKE_CUDA_FLAGS:STRING={0}'.format(flag))
if '+deviceconst' in spec:
options.append('-DENABLE_DEVICE_CONST=On')
else:
options.append('-DENABLE_CUDA=Off')
if '+hip' in spec:
arch = self.spec.variants['amdgpu_target'].value
options.extend([
'-DENABLE_HIP=ON',
'-DHIP_ROOT_DIR={0}'.format(spec['hip'].prefix),
'-DHIP_HIPCC_FLAGS=--amdgpu-target={0}'.format(arch)])
else:
options.append('-DENABLE_HIP=OFF')
options.append('-DENABLE_C={0}'.format(
'On' if '+c' in spec else 'Off'))
options.append('-DENABLE_FORTRAN={0}'.format(
'On' if '+fortran' in spec else 'Off'))
options.append('-DENABLE_NUMA={0}'.format(
'On' if '+numa' in spec else 'Off'))
options.append('-DENABLE_OPENMP={0}'.format(
'On' if '+openmp' in spec else 'Off'))
options.append('-DBUILD_SHARED_LIBS={0}'.format(
'On' if '+shared' in spec else 'Off'))
options.append('-DENABLE_BENCHMARKS={0}'.format(
'On' if 'tests=benchmarks' in spec else 'Off'))
options.append('-DENABLE_EXAMPLES={0}'.format(
'On' if '+examples' in spec else 'Off'))
options.append('-DENABLE_TESTS={0}'.format(
'Off' if 'tests=none' in spec else 'On'))
return options
@property
def build_relpath(self):
"""Relative path to the cmake build subdirectory."""
return join_path('..', self.build_dirname)
@run_after('install')
def setup_build_tests(self):
"""Copy the build test files after the package is installed to an
install test subdirectory for use during `spack test run`."""
# Now copy the relative files
self.cache_extra_test_sources(self.build_relpath)
# Ensure the path exists since relying on a relative path at the
# same level as the normal stage source path.
mkdirp(self.install_test_root)
@property
@lang.memoized
def _extra_tests_path(self):
# TODO: The tests should be converted to re-build and run examples
# TODO: using the installed libraries.
return join_path(self.install_test_root, self.build_relpath)
@property
@lang.memoized
def _has_bad_strategy(self):
return self.spec.satisfies('@0.2.0:0.2.3')
def _run_checks(self, dirs, checks):
"""Run the specified checks in the provided directories."""
if not dirs or not checks:
return
for exe in checks:
if exe == 'strategy_example' and self._has_bad_strategy:
# Skip this test until install testing can properly capture
# the abort associated with this version.
# (An umpire::util::Exception is thrown; status value is -6.)
tty.warn('Skipping {0} test until Spack can handle core dump'
.format(exe))
continue
expected, status = checks[exe]
for work_dir in dirs:
src = 'from build ' if 'spack-build' in work_dir else ''
reason = 'test {0} {1}output'.format(exe, src)
self.run_test(exe, [], expected, status, installed=False,
purpose=reason, skip_missing=True,
work_dir=work_dir)
def _run_bench_checks(self):
"""Run the benchmark smoke test checks."""
tty.info('Running benchmark checks')
dirs = []
if self.spec.satisfies('@0.3.3:1.0.1'):
dirs.append(join_path(self._extra_tests_path, 'benchmarks'))
elif self.spec.satisfies('@1.1.0:'):
dirs.append(self.prefix.bin)
checks = {
# Versions 0.3.3:1.0.1 (spack-build/bin/benchmarks)
# Versions 1.1.0:2.1.0 (spack-build/bin)
'allocator_benchmarks': (
['Malloc/malloc', 'Malloc/free', 'ns',
'Host/allocate', 'Host/deallocate',
'FixedPoolHost/allocate',
'FixedPoolHost/deallocate'], 0),
'copy_benchmarks': (['benchmark_copy/host_host', 'ns'], 0),
'debuglog_benchmarks': (['benchmark_DebugLogger', 'ns'], 0),
}
self._run_checks(dirs, checks)
def _run_cookbook_checks(self):
"""Run the cookbook smoke test checks."""
tty.info('Running cookbook checks')
dirs = []
cb_subdir = join_path('examples', 'cookbook')
if self.spec.satisfies('@0.3.3:1.0.1'):
dirs.append(join_path(self._extra_tests_path, cb_subdir))
elif self.spec.satisfies('@1.1.0'):
dirs.append(join_path(self.prefix.bin, cb_subdir))
elif self.spec.satisfies('@2.0.0:'):
dirs.append(self.prefix.bin)
checks = {
# Versions 0.3.3:1.0.1 (spack-build/bin/examples/cookbook)
# Versions 2.0.0:2.1.0 (spack-build/bin)
# Versions 1.1.0 (prefix.bin/examples/cookbook)
# Versions 2.0.0:2.1.0 (prefix.bin)
'recipe_dynamic_pool_heuristic': (['in the pool', 'releas'], 0),
'recipe_no_introspection': (['has allocated', 'used'], 0),
}
self._run_checks(dirs, checks)
def _run_example_checks(self):
"""Run the example smoke test checks."""
tty.info('Running example checks')
dirs = []
if self.spec.satisfies('@0.1.3:0.3.1'):
dirs.append(self._extra_tests_path)
elif self.spec.satisfies('@0.3.3:1.0.1'):
dirs.append(join_path(self._extra_tests_path, 'examples'))
elif self.spec.satisfies('@1.1.0'):
dirs.append(join_path(self.prefix.bin, 'examples'))
elif self.spec.satisfies('@2.0.0:'):
dirs.append(self.prefix.bin)
# Check the results from a subset of the (potentially) available
# executables
checks = {
# Versions 0.1.3:0.3.1 (spack-build/bin)
# Versions 0.3.3:1.0.1 (spack-build/bin/examples)
# Versions 2.0.0:2.1.0 (spack-build/bin)
# Version 1.1.0 (prefix.bin/examples)
# Versions 2.0.0:2.1.0 (prefix.bin)
'malloc': (['99 should be 99'], 0),
'strategy_example': (['Available allocators', 'HOST'], 0),
'vector_allocator': ([''], 0),
}
self._run_checks(dirs, checks)
def _run_plots_checks(self):
"""Run the plots smoke test checks."""
tty.info('Running plots checks')
dirs = [self.prefix.bin] if self.spec.satisfies('@0.3.3:0.3.5') else []
checks = {
# Versions 0.3.3:0.3.5 (prefix.bin)
'plot_allocations': ([''], 0),
}
self._run_checks(dirs, checks)
def _run_tools_checks(self):
"""Run the tools smoke test checks."""
tty.info('Running tools checks')
dirs = [self.prefix.bin] if self.spec.satisfies('@0.3.3:0.3.5') else []
checks = {
# Versions 0.3.3:0.3.5 (spack-build/bin/tools)
'replay': (['No input file'], 0),
}
self._run_checks(dirs, checks)
def _run_tut_checks(self):
"""Run the tutorial smoke test checks."""
tty.info('Running tutorials checks')
dirs = []
tut_subdir = join_path('examples', 'tutorial')
if self.spec.satisfies('@0.2.4:0.3.1'):
dirs.append(self._extra_tests_path)
elif self.spec.satisfies('@0.3.3:1.0.1'):
dirs.append(join_path(self._extra_tests_path, tut_subdir))
elif self.spec.satisfies('@1.1.0'):
dirs.append(join_path(self.prefix.bin, tut_subdir))
elif self.spec.satisfies('@2.0.0:'):
dirs.append(self.prefix.bin)
checks = {
# Versions 0.2.4:0.3.1 (spack-build/bin)
# Versions 0.3.3:1.0.1 (spack-build/bin/examples/tutorial)
# Versions 2.0.0:2.1.0 (spack-build/bin)
# Version 1.1.0 (prefix.bin/examples/tutorial)
# Versions 2.0.0:2.1.0 (prefix.bin)
'tut_copy': (['Copied source data'], 0),
'tut_introspection': (
['Allocator used is HOST', 'size of the allocation'], 0),
'tut_memset': (['Set data from HOST'], 0),
'tut_move': (['Moved source data', 'HOST'], 0),
'tut_reallocate': (['Reallocated data'], 0),
}
self._run_checks(dirs, checks)
def test(self):
"""Perform smoke tests on the installed package."""
self._run_bench_checks()
self._run_cookbook_checks()
self._run_example_checks()
self._run_plots_checks()
self._run_tools_checks()
self._run_tut_checks()
|