1
- # Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
1
+ # Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
2
2
# Spack Project Developers. See the top-level COPYRIGHT file for details.
3
3
#
4
4
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
5
5
6
+ import socket
7
+
6
8
from spack .package import *
7
9
10
+ from .camp import cuda_for_radiuss_projects
11
+ from .camp import hip_for_radiuss_projects
12
+ from .blt import llnl_link_helpers
13
+
8
14
9
- class Care (CMakePackage , CudaPackage , ROCmPackage ):
15
+ class Care (CachedCMakePackage , CudaPackage , ROCmPackage ):
10
16
"""
11
- Algorithms for chai managed arrays .
17
+ CHAI and RAJA extensions (includes data structures and algorithms) .
12
18
"""
13
19
14
20
homepage = "https://github.com/LLNL/CARE"
@@ -20,170 +26,256 @@ class Care(CMakePackage, CudaPackage, ROCmPackage):
20
26
maintainers ("adayton1" )
21
27
22
28
version ("develop" , branch = "develop" , submodules = "True" )
23
- version ("master" , branch = "main " , submodules = "True" )
29
+ version ("master" , branch = "master " , submodules = "True" )
24
30
version (
25
31
"0.13.1" ,
26
32
tag = "v0.13.1" ,
27
33
commit = "0fd0d47aaaa57076f26caad88e667fbc01ff7214" ,
28
- submodules = "True"
34
+ submodules = "True" ,
29
35
)
30
36
version (
31
37
"0.13.0" ,
32
38
tag = "v0.13.0" ,
33
39
commit = "2b288e2c557c3b14befeebc8e14a7d48348bd857" ,
34
- submodules = "True"
40
+ submodules = "True" ,
35
41
)
36
42
version (
37
43
"0.12.0" ,
38
44
tag = "v0.12.0" ,
39
45
commit = "a9978083035eb00a090451bd36d7987bc935204d" ,
40
- submodules = "True"
46
+ submodules = "True" ,
41
47
)
48
+ version ("0.10.0" , tag = "v0.10.0" , submodules = "True" )
42
49
version (
43
- "0.3.0" ,
44
- tag = "v0.3.0" ,
45
- commit = "5e2b69b2836c9f2215207ca9a36a690cb77eea33" ,
46
- submodules = "True"
50
+ "0.3.0" , tag = "v0.3.0" , commit = "5e2b69b2836c9f2215207ca9a36a690cb77eea33" , submodules = "True"
47
51
)
48
52
version (
49
- "0.2.0" ,
50
- tag = "v0.2.0" ,
51
- commit = "30135e03b14b1dc753634e9147dafede0663906f" ,
52
- submodules = "True"
53
+ "0.2.0" , tag = "v0.2.0" , commit = "30135e03b14b1dc753634e9147dafede0663906f" , submodules = "True"
53
54
)
54
55
55
- variant ("openmp" , default = False , description = "Build using OpenMP" )
56
+ variant ("openmp" , default = False , description = "Build with OpenMP support" )
57
+ variant ("mpi" , default = False , description = "Enable MPI support" )
56
58
variant (
57
59
"implicit_conversions" ,
58
- default = True ,
59
- description = "Enable implicit conversions to/from raw pointers" ,
60
+ default = False ,
61
+ description = "Enable implicit" " conversions to/from raw pointers" ,
60
62
)
61
- variant ("benchmarks" , default = True , description = "Build benchmarks." )
62
- variant ("examples" , default = True , description = "Build examples." )
63
- variant ("docs" , default = False , description = "Build documentation" )
64
63
variant ("tests" , default = False , description = "Build tests" )
64
+ variant ("benchmarks" , default = False , description = "Build benchmarks." )
65
+ variant ("examples" , default = False , description = "Build examples." )
66
+ variant ("docs" , default = False , description = "Build documentation" )
65
67
variant ("loop_fuser" , default = False , description = "Enable loop fusion capability" )
66
68
67
- depends_on ("cmake@3.8:" , type = "build" )
68
- depends_on ("cmake@3.9:" , type = "build" , when = "+cuda" )
69
- depends_on ("cmake@3.18:" , type = "build" , when = "@0.12.0:" )
70
69
depends_on ("cmake@3.21:" , type = "build" , when = "@0.12.0:+rocm" )
70
+ depends_on ("cmake@3.18:" , type = "build" , when = "@0.12.0:" )
71
+ depends_on ("cmake@3.14:" , type = "build" , when = "@0.10.0:" )
72
+ depends_on ("cmake@3.9:" , type = "build" , when = "+cuda" )
73
+ depends_on ("cmake@3.8:" , type = "build" )
71
74
72
75
depends_on ("blt" )
73
76
depends_on ("blt@0.6.2:" , type = "build" , when = "@0.13.0:" )
74
77
depends_on ("blt@0.6.1:" , type = "build" , when = "@0.12.0:" )
75
- depends_on ("blt@0.4.0:" , type = "build" , when = "@0.3.1:" )
78
+ depends_on ("blt@0.5.2:" , type = "build" , when = "@0.10.0:" )
79
+ depends_on ("blt@0.4.1:" , type = "build" , when = "@0.3.1:" )
76
80
depends_on ("blt@:0.3.6" , type = "build" , when = "@:0.3.0" )
77
81
conflicts ("^blt@:0.3.6" , when = "+rocm" )
78
82
79
83
depends_on ("camp" , when = "@:0.11.1" )
80
84
81
85
depends_on ("umpire" )
86
+ depends_on ("umpire+mpi" , when = "+mpi" )
82
87
depends_on ("umpire@2024.02.1:" , when = "@0.13.0:" )
83
88
depends_on ("umpire@2024.02.0:" , when = "@0.12.0:" )
89
+ depends_on ("umpire@2022.10.0:" , when = "@0.10.0:" )
84
90
85
91
depends_on ("raja" )
86
92
depends_on ("raja@2024.02.2:" , when = "@0.13.1:" )
87
93
depends_on ("raja@2024.02.1:" , when = "@0.13.0:" )
88
94
depends_on ("raja@2024.02.0:" , when = "@0.12.0:" )
95
+ depends_on ("raja@2022.10.5:" , when = "@0.10.0:" )
89
96
97
+ # TODO: Add an enable_pick variant
90
98
depends_on ("chai+enable_pick+raja" )
91
99
depends_on ("chai@2024.02.2:" , when = "@0.13.1:" )
92
100
depends_on ("chai@2024.02.1:" , when = "@0.13.0:" )
93
101
depends_on ("chai@2024.02.0:" , when = "@0.12.0:" )
102
+ depends_on ("chai@2022.10.0:" , when = "@0.10.0:" )
103
+
94
104
95
105
with when ("+openmp" ):
96
- depends_on ("llvm-openmp" , when = "%apple-clang" )
97
106
depends_on ("umpire+openmp" )
98
107
depends_on ("raja+openmp" )
99
108
depends_on ("chai+openmp" )
100
109
101
- with when ("+rocm" ):
102
- depends_on ("rocprim" )
103
-
104
- for arch in ROCmPackage .amdgpu_targets :
105
- depends_on ("umpire+rocm amdgpu_target={0}" .format (arch ), when = "amdgpu_target={0}" .format (arch ))
106
- depends_on ("raja+rocm amdgpu_target={0}" .format (arch ), when = "amdgpu_target={0}" .format (arch ))
107
- depends_on ("chai+rocm amdgpu_target={0}" .format (arch ), when = "amdgpu_target={0}" .format (arch ))
108
-
109
110
with when ("+cuda" ):
110
- depends_on ("cub" , when = "cuda@:10.2" )
111
+ # WARNING: this package currently only supports an internal cub
112
+ # package. This will cause a race condition if compiled with another
113
+ # package that uses cub. TODO: have all packages point to the same external
114
+ # cub package.
115
+ depends_on ("cub" )
116
+
117
+ depends_on ("umpire+cuda" )
118
+ depends_on ("raja+cuda" )
119
+ depends_on ("chai+cuda" )
111
120
112
121
for sm_ in CudaPackage .cuda_arch_values :
113
122
depends_on ("umpire+cuda cuda_arch={0}" .format (sm_ ), when = "cuda_arch={0}" .format (sm_ ))
114
123
depends_on ("raja+cuda cuda_arch={0}" .format (sm_ ), when = "cuda_arch={0}" .format (sm_ ))
115
124
depends_on ("chai+cuda cuda_arch={0}" .format (sm_ ), when = "cuda_arch={0}" .format (sm_ ))
116
125
126
+ with when ("+rocm" ):
127
+ depends_on ("umpire+rocm" )
128
+ depends_on ("raja+rocm" )
129
+ depends_on ("chai+rocm" )
117
130
118
- def cmake_args (self ):
131
+ for arch_ in ROCmPackage .amdgpu_targets :
132
+ depends_on ('umpire+rocm amdgpu_target={0}' .format (arch_ ), when = 'amdgpu_target={0}' .format (arch_ ))
133
+ depends_on ('raja+rocm amdgpu_target={0}' .format (arch_ ), when = 'amdgpu_target={0}' .format (arch_ ))
134
+ depends_on ('chai+rocm amdgpu_target={0}' .format (arch_ ), when = 'amdgpu_target={0}' .format (arch_ ))
135
+
136
+
137
+ def _get_sys_type (self , spec ):
138
+ sys_type = spec .architecture
139
+
140
+ if "SYS_TYPE" in env :
141
+ sys_type = env ["SYS_TYPE" ]
142
+ return sys_type
143
+
144
+
145
+ @property
146
+ def cache_name (self ):
147
+ hostname = socket .gethostname ()
148
+
149
+ if "SYS_TYPE" in env :
150
+ hostname = hostname .rstrip ("1234567890" )
151
+ return "{0}-{1}-{2}@{3}-{4}.cmake" .format (
152
+ hostname ,
153
+ self ._get_sys_type (self .spec ),
154
+ self .spec .compiler .name ,
155
+ self .spec .compiler .version ,
156
+ self .spec .dag_hash (8 )
157
+ )
158
+
159
+
160
+ def initconfig_compiler_entries (self ):
119
161
spec = self .spec
120
- from_variant = self .define_from_variant
162
+ compiler = self .compiler
163
+ entries = super ().initconfig_compiler_entries ()
121
164
122
- options = []
123
- options .append ("-DBLT_SOURCE_DIR={0}" .format (spec ["blt" ].prefix ))
165
+ #### BEGIN: Override CachedCMakePackage CMAKE_C_FLAGS and CMAKE_CXX_FLAGS
166
+ flags = spec .compiler_flags
167
+
168
+ # use global spack compiler flags
169
+ cppflags = " " .join (flags ["cppflags" ])
170
+
171
+ if cppflags :
172
+ # avoid always ending up with " " with no flags defined
173
+ cppflags += " "
174
+
175
+ cflags = cppflags + " " .join (flags ["cflags" ])
176
+
177
+ if cflags :
178
+ entries .append (cmake_cache_string ("CMAKE_C_FLAGS" , cflags ))
179
+
180
+ cxxflags = cppflags + " " .join (flags ["cxxflags" ])
181
+
182
+ if cxxflags :
183
+ entries .append (cmake_cache_string ("CMAKE_CXX_FLAGS" , cxxflags ))
184
+
185
+ fflags = " " .join (flags ["fflags" ])
186
+
187
+ if fflags :
188
+ entries .append (cmake_cache_string ("CMAKE_Fortran_FLAGS" , fflags ))
189
+
190
+ #### END: Override CachedCMakePackage CMAKE_C_FLAGS and CMAKE_CXX_FLAGS
191
+
192
+ llnl_link_helpers (entries , spec , compiler )
193
+
194
+ return entries
195
+
196
+
197
+ def initconfig_hardware_entries (self ):
198
+ spec = self .spec
199
+ compiler = self .compiler
200
+ entries = super ().initconfig_hardware_entries ()
201
+
202
+ entries .append (cmake_cache_option ("ENABLE_OPENMP" , "+openmp" in spec ))
124
203
125
204
if "+cuda" in spec :
126
- options .append ("-DENABLE_CUDA=ON" )
127
- options .append ("-DCUDA_TOOLKIT_ROOT_DIR=" + spec ["cuda" ].prefix )
128
- options .append ("-DNVTOOLSEXT_DIR=" + spec ["cuda" ].prefix )
129
-
130
- if spec .satisfies ("cuda@:10.2" ):
131
- options .append ("-DCUB_DIR=" + spec ["cub" ].prefix )
132
- else :
133
- options .append ("-DCUB_DIR=" + spec ["cuda" ].prefix )
134
-
135
- if not spec .satisfies ("cuda_arch=none" ):
136
- cuda_arch = spec .variants ["cuda_arch" ].value
137
- # Please note that within care, CUDA_ARCH is assigned to -code
138
- # and likewise CUDA_CODE is assigned to -arch, so these are
139
- # intentionally flipped here.
140
- options .append ("-DCUDA_ARCH=sm_{0}" .format (cuda_arch [0 ]))
141
- options .append ("-DCUDA_CODE=compute_{0}" .format (cuda_arch [0 ]))
205
+ entries .append (cmake_cache_option ("ENABLE_CUDA" , True ))
206
+ entries .append (cmake_cache_option ("CUDA_SEPARABLE_COMPILATION" , True ))
207
+ entries .append (cmake_cache_string ("CUDA_TOOLKIT_ROOT_DIR" , spec ["cuda" ].prefix ))
208
+ entries .append (cmake_cache_string ("CUB_DIR" , spec ["cub" ].prefix ))
209
+
210
+ cuda_for_radiuss_projects (entries , spec )
142
211
else :
143
- options .append ("-DENABLE_CUDA=OFF" )
212
+ entries .append (cmake_cache_option ( "ENABLE_CUDA" , False ) )
144
213
145
214
if "+rocm" in spec :
146
- options .append ("-DENABLE_HIP=ON" )
147
- options .append ("-DHIP_ROOT_DIR={0}" .format (spec ["hip" ].prefix ))
148
-
149
- archs = self .spec .variants ["amdgpu_target" ].value
215
+ entries .append (cmake_cache_option ("ENABLE_HIP" , True ))
216
+ entries .append (cmake_cache_string ("HIP_ROOT_DIR" , spec ["hip" ].prefix ))
150
217
151
- if archs != "none" :
152
- arch_str = "," .join (archs )
153
- options .append ("-DHIP_HIPCC_FLAGS=--amdgpu-target={0}" .format (arch_str ))
218
+ hip_for_radiuss_projects (entries , spec , compiler )
154
219
else :
155
- options .append ("-DENABLE_HIP=OFF" )
156
-
157
- options .extend (
158
- [
159
- self .define ("CAMP_DIR" , spec ["camp" ].prefix ),
160
- self .define ("UMPIRE_DIR" , spec ["umpire" ].prefix ),
161
- self .define ("RAJA_DIR" , spec ["raja" ].prefix ),
162
- self .define ("CHAI_DIR" , spec ["chai" ].prefix )
163
- ]
164
- )
220
+ entries .append (cmake_cache_option ("ENABLE_HIP" , False ))
165
221
166
- options .extend (
167
- [
168
- from_variant ("CARE_ENABLE_IMPLICIT_CONVERSIONS" , "implicit_conversions" ),
169
- from_variant ("CARE_ENABLE_LOOP_FUSER" , "loop_fuser" )
170
- ]
171
- )
222
+ return entries
172
223
173
- # For tests to work, we also need BLT_ENABLE_TESTS to be on.
174
- # This will take care of the gtest dependency. CARE developers should
175
- # consider consolidating these flags in the future.
176
- options .append (from_variant ("BLT_ENABLE_TESTS" , "tests" ))
177
224
178
- options .append (from_variant ("ENABLE_TESTS" , "tests" ))
179
- options .append (from_variant ("ENABLE_BENCHMARKS" , "benchmarks" ))
180
- options .append (from_variant ("ENABLE_EXAMPLES" , "examples" ))
181
- options .append (from_variant ("ENABLE_DOCS" , "docs" ))
225
+ def initconfig_mpi_entries (self ):
226
+ spec = self .spec
227
+
228
+ entries = super (Care , self ).initconfig_mpi_entries ()
229
+ entries .append (cmake_cache_option ("ENABLE_MPI" , "+mpi" in spec ))
182
230
183
- if spec .satisfies ("@:0.11.1" ):
184
- options .append (from_variant ("CARE_ENABLE_TESTS" , "tests" ))
185
- options .append (from_variant ("CARE_ENABLE_BENCHMARKS" , "benchmarks" ))
186
- options .append (from_variant ("CARE_ENABLE_EXAMPLES" , "examples" ))
187
- options .append (from_variant ("CARE_ENABLE_DOCS" , "docs" ))
231
+ return entries
188
232
233
+
234
+ def initconfig_package_entries (self ):
235
+ spec = self .spec
236
+ entries = []
237
+
238
+ # TPL locations
239
+ entries .append ("#------------------{0}" .format ("-" * 60 ))
240
+ entries .append ("# TPLs" )
241
+ entries .append ("#------------------{0}\n " .format ("-" * 60 ))
242
+
243
+ entries .append (cmake_cache_path ("BLT_SOURCE_DIR" , spec ["blt" ].prefix ))
244
+ entries .append (cmake_cache_path ("CAMP_DIR" , spec ["camp" ].prefix ))
245
+ entries .append (cmake_cache_path ("UMPIRE_DIR" , spec ["umpire" ].prefix ))
246
+ entries .append (cmake_cache_path ("RAJA_DIR" , spec ["raja" ].prefix ))
247
+ entries .append (cmake_cache_path ("CHAI_DIR" , spec ["chai" ].prefix ))
248
+
249
+ # Build options
250
+ entries .append ("#------------------{0}" .format ("-" * 60 ))
251
+ entries .append ("# Build Options" )
252
+ entries .append ("#------------------{0}\n " .format ("-" * 60 ))
253
+
254
+ entries .append (cmake_cache_string (
255
+ "CMAKE_BUILD_TYPE" , spec .variants ["build_type" ].value ))
256
+
257
+ entries .append (cmake_cache_option (
258
+ "ENABLE_TESTS" , "+tests" in spec ))
259
+
260
+ entries .append (cmake_cache_option (
261
+ "ENABLE_BENCHMARKS" , "+benchmarks" in spec ))
262
+
263
+ entries .append (cmake_cache_option (
264
+ "ENABLE_EXAMPLES" , "+examples" in spec ))
265
+
266
+ entries .append (cmake_cache_option (
267
+ "ENABLE_DOCS" , "+docs" in spec ))
268
+
269
+ entries .append (cmake_cache_option (
270
+ "CARE_ENABLE_IMPLICIT_CONVERSIONS" , "+implicit_conversions" in spec ))
271
+
272
+ entries .append (cmake_cache_option (
273
+ "CARE_ENABLE_LOOP_FUSER" , "+loop_fuser" in spec ))
274
+
275
+ return entries
276
+
277
+
278
+ def cmake_args (self ):
279
+ options = []
189
280
return options
281
+
0 commit comments