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
320
321
322
323
324
325
326
327
328
329
330
331
|
# Copyright 2013-2022 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 os
import socket
import llnl.util.tty as tty
from spack import *
def cmake_cache_entry(name, value, vtype=None):
"""
Helper that creates CMake cache entry strings used in
'host-config' files.
"""
if vtype is None:
if value == "ON" or value == "OFF":
vtype = "BOOL"
else:
vtype = "PATH"
return 'set({0} "{1}" CACHE {2} "")\n\n'.format(name, value, vtype)
class Dray(Package, CudaPackage):
"""High-Order Mesh Ray Tracer."""
homepage = "https://github.com/LLNL/devil_ray"
git = "https://github.com/LLNL/devil_ray.git"
url = "https://github.com/LLNL/devil_ray/releases/download/v0.1.2/dray-v0.1.2.tar.gz"
maintainers = ['cyrush']
version('develop', branch='develop', submodules='True')
version('0.1.8', sha256='ae78ca6a5a31f06f6400a4a1ff6fc1d75347c8b41027a80662179f5b877eee30')
version('0.1.7', sha256='11ea794c1a24d7ed0d76bad7209d62bafc033ec40a2ea3a00e68fe598c6aa46d')
version('0.1.6', sha256='43f39039599e3493cbbaeaf5621b611bef301ff504bed6e32c98f30bb2179e92')
version('0.1.5', sha256='aaf0975561a8e7910b9353e2dc30bd78abf9f01c306ec042422b7da223d3a8b8')
version('0.1.4', sha256='e763a3aa537b23486a4788f9d68db0a3eb545f6a2e617cd7c8a876682ca2d0a0')
version('0.1.3', sha256='b2f624a072463189997343b1ed911cc34c9bb1b6c7f0c3e48efeb40c05dd0d92')
version('0.1.2', sha256='46937f20124b28dc78a634e8e063a3e7a3bbfd9f424ce2680b08417010c376da')
version('0.1.1', sha256='e5daa49ee3367c087f5028dc5a08655298beb318014c6f3f65ef4a08fcbe346c')
version('0.1.0', sha256='8b341138e1069361351e0a94478608c5af479cca76e2f97d556229aed45c0169')
variant('cuda', default=False, description='Build with CUDA backend')
variant('openmp', default=True, description='Build OpenMP backend')
variant("shared", default=True, description="Build as shared libs")
variant("test", default=True, description='Build unit tests')
variant("utils", default=True, description='Build utilities')
variant("logging", default=False, description='Enable logging')
variant("stats", default=False, description='Enable stats')
variant("mpi", default=True, description='Enable MPI compiler')
# set to false for systems that implicitly link mpi
variant('blt_find_mpi', default=True, description='Use BLT CMake Find MPI logic')
depends_on('cuda', when='+cuda')
depends_on('mpi', when='+mpi')
depends_on('cmake@3.9:', type='build')
depends_on('cmake@3.14:', when='+cuda', type='build')
depends_on("conduit~shared", when="~shared")
depends_on("conduit+shared", when="+shared")
depends_on("apcomp~shared+openmp+mpi", when="~shared+openmp+mpi")
depends_on("apcomp+shared+openmp+mpi", when="+shared+openmp+mpi")
depends_on("apcomp~shared~openmp+mpi", when="~shared~openmp+mpi")
depends_on("apcomp+shared~openmp+mpi", when="+shared~openmp+mpi")
depends_on("apcomp~shared+openmp~mpi", when="~shared+openmp~mpi")
depends_on("apcomp+shared+openmp~mpi", when="+shared+openmp~mpi")
depends_on("apcomp~shared~openmp~mpi", when="~shared~openmp~mpi")
depends_on("apcomp+shared~openmp~mpi", when="+shared~openmp~mpi")
depends_on("raja@:0.13", when="@:0.1.6")
depends_on("raja+cuda~openmp+shared", when="+cuda~openmp+shared")
depends_on("raja+cuda+openmp+shared", when="+cuda+openmp+shared")
depends_on("raja+cuda~openmp~shared", when="+cuda~openmp~shared")
depends_on("raja+cuda+openmp~shared", when="+cuda+openmp~shared")
depends_on("raja~cuda~openmp+shared", when="~cuda~openmp+shared")
depends_on("raja~cuda+openmp+shared", when="~cuda+openmp+shared")
depends_on("raja~cuda~openmp~shared", when="~cuda~openmp~shared")
depends_on("raja~cuda+openmp~shared", when="~cuda+openmp~shared")
depends_on("umpire@:4.9", when="@:0.1.6")
depends_on("umpire+cuda+shared", when="+cuda+shared")
depends_on("umpire+cuda~shared", when="+cuda~shared")
depends_on("umpire~cuda+shared", when="~cuda+shared")
depends_on("umpire~cuda~shared", when="~cuda~shared")
depends_on("mfem+shared+conduit~threadsafe", when="+shared")
depends_on("mfem~shared+conduit~threadsafe", when="~shared")
def setup_build_environment(self, env):
env.set('CTEST_OUTPUT_ON_FAILURE', '1')
def install(self, spec, prefix):
"""
Build and install Devil Ray.
"""
with working_dir('spack-build', create=True):
host_cfg_fname = self.create_host_config(spec,
prefix)
cmake_args = []
# if we have a static build, we need to avoid any of
# spack's default cmake settings related to rpaths
# (see: https://github.com/LLNL/spack/issues/2658)
if "+shared" in spec:
cmake_args.extend(std_cmake_args)
else:
for arg in std_cmake_args:
if arg.count("RPATH") == 0:
cmake_args.append(arg)
cmake_args.extend(["-C", host_cfg_fname, "../src"])
print("Configuring Devil Ray...")
cmake(*cmake_args)
print("Building Devil Ray...")
make()
# run unit tests if requested
if "+test" in spec and self.run_tests:
print("Running Devil Ray Unit Tests...")
make("test")
print("Installing Devil Ray...")
make("install")
# install copy of host config for provenance
install(host_cfg_fname, prefix)
def create_host_config(self, spec, prefix):
"""
This method creates a 'host-config' file that specifies
all of the options used to configure and build ascent.
For more details about 'host-config' files see:
https://ascent.readthedocs.io/en/latest/BuildingAscent.html
"""
#######################
# Compiler Info
#######################
c_compiler = env["SPACK_CC"]
cpp_compiler = env["SPACK_CXX"]
#######################################################################
# By directly fetching the names of the actual compilers we appear
# to doing something evil here, but this is necessary to create a
# 'host config' file that works outside of the spack install env.
#######################################################################
sys_type = spec.architecture
# if on llnl systems, we can use the SYS_TYPE
if "SYS_TYPE" in env:
sys_type = env["SYS_TYPE"]
##############################################
# Find and record what CMake is used
##############################################
if "+cmake" in spec:
cmake_exe = spec['cmake'].command.path
else:
cmake_exe = which("cmake")
if cmake_exe is None:
msg = 'failed to find CMake (and cmake variant is off)'
raise RuntimeError(msg)
cmake_exe = cmake_exe.path
host_cfg_fname = "%s-%s-%s-devil_ray.cmake" % (socket.gethostname(),
sys_type,
spec.compiler)
cfg = open(host_cfg_fname, "w")
cfg.write("##################################\n")
cfg.write("# spack generated host-config\n")
cfg.write("##################################\n")
cfg.write("# {0}-{1}\n".format(sys_type, spec.compiler))
cfg.write("##################################\n\n")
# Include path to cmake for reference
cfg.write("# cmake from spack \n")
cfg.write("# cmake executable path: %s\n\n" % cmake_exe)
#######################
# Compiler Settings
#######################
cfg.write("#######\n")
cfg.write("# using %s compiler spec\n" % spec.compiler)
cfg.write("#######\n\n")
cfg.write("# c compiler used by spack\n")
cfg.write(cmake_cache_entry("CMAKE_C_COMPILER", c_compiler))
cfg.write("# cpp compiler used by spack\n")
cfg.write(cmake_cache_entry("CMAKE_CXX_COMPILER", cpp_compiler))
if "+mpi" in spec:
mpicc_path = spec['mpi'].mpicc
mpicxx_path = spec['mpi'].mpicxx
# if we are using compiler wrappers on cray systems
# use those for mpi wrappers, b/c spec['mpi'].mpicxx
# etc make return the spack compiler wrappers
# which can trip up mpi detection in CMake 3.14
if spec['mpi'].mpicc == spack_cc:
mpicc_path = c_compiler
mpicxx_path = cpp_compiler
cfg.write(cmake_cache_entry("ENABLE_MPI", "ON"))
cfg.write(cmake_cache_entry("MPI_C_COMPILER", mpicc_path))
cfg.write(cmake_cache_entry("MPI_CXX_COMPILER", mpicxx_path))
if "+blt_find_mpi" in spec:
cfg.write(cmake_cache_entry("ENABLE_FIND_MPI", "ON"))
else:
cfg.write(cmake_cache_entry("ENABLE_FIND_MPI", "OFF"))
mpiexe_bin = join_path(spec['mpi'].prefix.bin, 'mpiexec')
if os.path.isfile(mpiexe_bin):
# starting with cmake 3.10, FindMPI expects MPIEXEC_EXECUTABLE
# vs the older versions which expect MPIEXEC
if self.spec["cmake"].satisfies('@3.10:'):
cfg.write(cmake_cache_entry("MPIEXEC_EXECUTABLE",
mpiexe_bin))
else:
cfg.write(cmake_cache_entry("MPIEXEC",
mpiexe_bin))
else:
cfg.write(cmake_cache_entry("ENABLE_MPI", "OFF"))
# use global spack compiler flags
cppflags = ' '.join(spec.compiler_flags['cppflags'])
if cppflags:
# avoid always ending up with ' ' with no flags defined
cppflags += ' '
cflags = cppflags + ' '.join(spec.compiler_flags['cflags'])
if cflags:
cfg.write(cmake_cache_entry("CMAKE_C_FLAGS", cflags))
cxxflags = cppflags + ' '.join(spec.compiler_flags['cxxflags'])
if cxxflags:
cfg.write(cmake_cache_entry("CMAKE_CXX_FLAGS", cxxflags))
fflags = ' '.join(spec.compiler_flags['fflags'])
if self.spec.satisfies('%cce'):
fflags += " -ef"
if fflags:
cfg.write(cmake_cache_entry("CMAKE_Fortran_FLAGS", fflags))
#######################
# Backends
#######################
cfg.write("# CUDA Support\n")
if "+cuda" in spec:
cfg.write(cmake_cache_entry("ENABLE_CUDA", "ON"))
if 'cuda_arch' in spec.variants:
cuda_value = spec.variants['cuda_arch'].value
cuda_arch = cuda_value[0]
cfg.write(cmake_cache_entry('CUDA_ARCH',
'sm_{0}'.format(cuda_arch)))
else:
cfg.write(cmake_cache_entry("ENABLE_CUDA", "OFF"))
if "+openmp" in spec:
cfg.write(cmake_cache_entry("ENABLE_OPENMP", "ON"))
else:
cfg.write(cmake_cache_entry("ENABLE_OPENMP", "OFF"))
# shared vs static libs
if "+shared" in spec:
cfg.write(cmake_cache_entry("BUILD_SHARED_LIBS", "ON"))
else:
cfg.write(cmake_cache_entry("BUILD_SHARED_LIBS", "OFF"))
#######################
# Unit Tests
#######################
if "+test" in spec:
cfg.write(cmake_cache_entry("DRAY_ENABLE_TESTS", "ON"))
# we need this to control BLT tests
cfg.write(cmake_cache_entry("ENABLE_TESTS", "ON"))
else:
cfg.write(cmake_cache_entry("DRAY_ENABLE_TESTS", "OFF"))
# we need this to control BLT tests
cfg.write(cmake_cache_entry("ENABLE_TESTS", "OFF"))
#######################
# Utilities
#######################
if "+utils" in spec:
cfg.write(cmake_cache_entry("DRAY_ENABLE_UTILS", "ON"))
else:
cfg.write(cmake_cache_entry("DRAY_ENABLE_UTILS", "OFF"))
#######################
# Logging
#######################
if "+logging" in spec:
cfg.write(cmake_cache_entry("ENABLE_LOGGING", "ON"))
else:
cfg.write(cmake_cache_entry("ENABLE_LOGGING", "OFF"))
#######################
# Status
#######################
if "+stats" in spec:
cfg.write(cmake_cache_entry("ENABLE_STATS", "ON"))
else:
cfg.write(cmake_cache_entry("ENABLE_STATS", "OFF"))
#######################################################################
# Core Dependencies
#######################################################################
cfg.write("# conduit from spack \n")
cfg.write(cmake_cache_entry("CONDUIT_DIR", spec['conduit'].prefix))
cfg.write("# mfem from spack \n")
cfg.write(cmake_cache_entry("MFEM_DIR", spec['mfem'].prefix))
cfg.write("# raja from spack \n")
cfg.write(cmake_cache_entry("RAJA_DIR", spec['raja'].prefix))
cfg.write("# umpire from spack \n")
cfg.write(cmake_cache_entry("UMPIRE_DIR", spec['umpire'].prefix))
cfg.write("# apcompositor from spack \n")
cfg.write(cmake_cache_entry("APCOMP_DIR", spec['apcomp'].prefix))
cfg.write("##################################\n")
cfg.write("# end spack generated host-config\n")
cfg.write("##################################\n")
cfg.close()
host_cfg_fname = os.path.abspath(host_cfg_fname)
tty.info("spack generated conduit host-config file: " + host_cfg_fname)
return host_cfg_fname
|