Add a System
Glossary terms: Package, Spec, Variant, System
Create the System Definition
This example defines the fluxtainer system. Start systems/fluxtainer/system.py
with the definition below. The steps that follow add the components omitted from this
initial version.
1# Copyright 2023 Lawrence Livermore National Security, LLC and other
2# Benchpark Project Developers. See the top-level COPYRIGHT file for details.
3#
4# SPDX-License-Identifier: Apache-2.0
5
6from benchpark.directives import maintainers, variant
7from benchpark.openmpsystem import OpenMPCPUOnlySystem
8from benchpark.system import System, compiler_def, compiler_section_for
9
10
11class Fluxtainer(System):
12 """This is the system class for a container running Flux.
13 See https://flux-framework.readthedocs.io/en/latest/tutorials/containers/index.html for more
14 information."""
15
16 maintainers("nhanford")
17
18 id_to_resources = {
19 # Step 1 adds the ARM64 resource mappings here.
20 "amd64": {"cpu_arch": "x86_64_v3", "sys_cores_per_node": 4},
21 "amd64-aws": {"cpu_arch": "x86_64_v3", "sys_cores_per_node": 32},
22 }
23
24 variant(
25 "instance_type",
26 values=(
27 "amd64",
28 "amd64-aws",
29 # Step 1 adds the ARM64 instance types here.
30 ),
31 default="amd64",
32 description="Target architecture and instance size",
33 )
34
35 variant(
36 "compiler",
37 default="gcc",
38 values=(
39 "gcc",
40 # Step 3 adds the Clang compiler value here.
41 ),
42 description="Which compiler to use",
43 )
44
45 def __init__(self, spec):
46 super().__init__(spec)
47 # Step 2 adds runtime and resource attributes here.
48
49 def compute_compilers_section(self):
50 cfg = compiler_section_for(
51 "gcc",
52 [
53 compiler_def(
54 "gcc@14.3.1 languages=c,c++,fortran",
55 "/usr/",
56 {"c": "gcc", "cxx": "g++", "fortran": "gfortran"},
57 )
58 ],
59 )
60
61 # Step 3 adds the Clang compiler definition here.
62
63 return cfg
64
65 def compute_packages_section(self):
66 return {
67 "packages": {
68 "mpi": {"buildable": False},
69 "mpich": {
70 "externals": [
71 {
72 "spec": "mpich@4.1.2",
73 "prefix": "/usr/lib64/mpich",
74 }
75 ]
76 },
77 "cmake": {
78 "externals": [{"spec": "cmake@3.30.5", "prefix": "/usr"}],
79 "buildable": False,
80 },
81 "git": {
82 "externals": [{"spec": "git@2.47.3~tcltk", "prefix": "/usr"}],
83 "buildable": False,
84 },
85 "openssl": {
86 "externals": [{"spec": "openssl@3.0.2", "prefix": "/usr"}],
87 "buildable": False,
88 },
89 "automake": {
90 "externals": [{"spec": "automake@1.16.5", "prefix": "/usr"}],
91 "buildable": False,
92 },
93 "openssh": {
94 "externals": [{"spec": "openssh@9.9p1", "prefix": "/usr"}],
95 "buildable": False,
96 },
97 "m4": {
98 "externals": [{"spec": "m4@1.4.19", "prefix": "/usr"}],
99 "buildable": False,
100 },
101 "sed": {
102 "externals": [{"spec": "sed@4.9", "prefix": "/usr"}],
103 "buildable": False,
104 },
105 "autoconf": {
106 "externals": [{"spec": "autoconf@2.71", "prefix": "/usr"}],
107 "buildable": False,
108 },
109 "diffutils": {
110 "externals": [{"spec": "diffutils@3.10", "prefix": "/usr"}],
111 "buildable": False,
112 },
113 "coreutils": {
114 "externals": [{"spec": "coreutils@8.32", "prefix": "/usr"}],
115 "buildable": False,
116 },
117 "findutils": {
118 "externals": [{"spec": "findutils@4.10.0", "prefix": "/usr"}],
119 "buildable": False,
120 },
121 "binutils": {
122 "externals": [
123 {"spec": "binutils@2.41+gold~headers", "prefix": "/usr"}
124 ],
125 "buildable": False,
126 },
127 "perl": {
128 "externals": [
129 {
130 "spec": "perl@5.74.0~cpanm+opcode+open+shared+threads",
131 "prefix": "/usr",
132 }
133 ],
134 "buildable": False,
135 },
136 "groff": {
137 "externals": [{"spec": "groff@1.22.4", "prefix": "/usr"}],
138 "buildable": False,
139 },
140 "curl": {
141 "externals": [
142 {"spec": "curl@8.12.1+gssapi+ldap+nghttp2", "prefix": "/usr"}
143 ],
144 "buildable": False,
145 },
146 "ccache": {
147 "externals": [{"spec": "ccache@4.11.3", "prefix": "/usr"}],
148 "buildable": False,
149 },
150 "flex": {
151 "externals": [{"spec": "flex@2.6.4+lex", "prefix": "/usr"}],
152 "buildable": False,
153 },
154 "pkg-config": {
155 "externals": [{"spec": "pkg-config@0.29.2", "prefix": "/usr"}],
156 "buildable": False,
157 },
158 "zlib-ng": {
159 "externals": [{"spec": "zlib-ng@2.2.3", "prefix": "/usr"}],
160 "buildable": False,
161 },
162 "ninja": {
163 "externals": [{"spec": "ninja@1.11.1", "prefix": "/usr"}],
164 "buildable": False,
165 },
166 "libtool": {
167 "externals": [{"spec": "libtool@2.4.7", "prefix": "/usr"}],
168 "buildable": False,
169 },
170 "bzip2": {
171 "externals": [{"spec": "bzip2@1.0.8", "prefix": "/usr"}],
172 "buildable": False,
173 },
174 "expat": {
175 "externals": [{"spec": "expat@2.7.1", "prefix": "/usr"}],
176 "buildable": False,
177 },
178 "gdbm": {
179 "externals": [{"spec": "gdbm@1.23", "prefix": "/usr"}],
180 "buildable": False,
181 },
182 "gettext": {
183 "externals": [{"spec": "gettext@0.22.5", "prefix": "/usr"}],
184 "buildable": False,
185 },
186 "libffi": {
187 "externals": [{"spec": "libffi@3.4.4", "prefix": "/usr"}],
188 "buildable": False,
189 },
190 "libxml2": {
191 "externals": [{"spec": "libxml2@2.12.5", "prefix": "/usr"}],
192 "buildable": False,
193 },
194 "ncurses": {
195 "externals": [{"spec": "ncurses@6.4", "prefix": "/usr"}],
196 "buildable": False,
197 },
198 "readline": {
199 "externals": [{"spec": "readline@8.2", "prefix": "/usr"}],
200 "buildable": False,
201 },
202 "sqlite": {
203 "externals": [{"spec": "sqlite@3.46.1", "prefix": "/usr"}],
204 "buildable": False,
205 },
206 # Step 4 adds the external tar package here.
207 "util-linux-uuid": {
208 "externals": [{"spec": "util-linux-uuid@2.40.2", "prefix": "/usr"}],
209 "buildable": False,
210 },
211 "xz": {
212 "externals": [{"spec": "xz@5.6.2", "prefix": "/usr"}],
213 "buildable": False,
214 },
215 "zstd": {
216 "externals": [{"spec": "zstd@1.5.5", "prefix": "/usr"}],
217 "buildable": False,
218 },
219 "gmake": {
220 "externals": [{"spec": "gmake@4.4.1", "prefix": "/usr"}],
221 "buildable": False,
222 },
223 "pigz": {
224 "externals": [{"spec": "pigz@2.8.7", "prefix": "/usr"}],
225 "buildable": False,
226 },
227 "libmd": {
228 "externals": [{"spec": "libmd@1.2.0", "prefix": "/usr"}],
229 "buildable": False,
230 },
231 "libbsd": {
232 "externals": [{"spec": "libbsd@0.12.2", "prefix": "/usr"}],
233 "buildable": False,
234 },
235 "python": {
236 "externals": [{"spec": "python@3.12.12", "prefix": "/usr"}],
237 "buildable": False,
238 },
239 "blas": {"require": "netlib-lapack", "buildable": False},
240 "lapack": {"require": "netlib-lapack", "buildable": False},
241 "netlib-lapack": {
242 "externals": [
243 {"spec": "netlib-lapack@3.12.0", "prefix": "/usr"}
244 ],
245 "buildable": False,
246 },
247 }
248 }
249
250 def compute_software_section(self):
251 default_compiler = "gcc"
252 if self.spec.satisfies("compiler=clang"):
253 default_compiler = "llvm"
254 return {
255 "software": {
256 "packages": {
257 "default-compiler": {"pkg_spec": default_compiler},
258 "compiler-gcc": {"pkg_spec": "gcc"},
259 "default-mpi": {"pkg_spec": "mpich"},
260 }
261 }
262 }
1. Add Another Target Architecture
The starter definition supports amd64 with 4 or 32 cores per node. Adding the
matching arm64 configurations requires resource mappings and corresponding values in
the instance_type variant.
Replace the first Step 1 placeholder in id_to_resources with:
# In id_to_resources:
"arm64": {"cpu_arch": "arm64", "sys_cores_per_node": 4},
"arm64-aws": {"cpu_arch": "arm64", "sys_cores_per_node": 32},
Replace the second Step 1 placeholder in the instance_type variant with:
# In the instance_type values tuple:
"arm64",
"arm64-aws",
2. Set Runtime and Resource Attributes
The system initializer specifies how Benchpark runs workloads and allocates resources.
Replace the Step 2 placeholder in __init__() with:
# In __init__():
self.programming_models = [OpenMPCPUOnlySystem()]
self.scheduler = "flux"
setattr(self, "sys_mem_per_node_GB", 1)
attrs = self.id_to_resources[self.spec.variants["instance_type"][0]]
for k, v in attrs.items():
setattr(self, k, v)
3. Add Clang
The compiler variant exposes the compiler choice in the system spec. Replace the
first Step 3 placeholder in its values tuple with:
# In the compiler values tuple:
"clang",
compute_compilers_section() tells Spack which LLVM installation and Clang
executables are available. Replace the second Step 3 placeholder, immediately before
return cfg, with:
# In compute_compilers_section():
if self.spec.satisfies("compiler=clang"):
cfg = compiler_section_for(
"llvm",
[
compiler_def(
"llvm@20.1.8 +clang +flang",
"/opt/llvm",
{"c": "clang", "cxx": "clang++", "fortran": "flang"},
)
],
)
4. Add the Tar Package
compute_packages_section() records software already installed on the system. Replace
the Step 4 placeholder with the external tar package definition:
# In the packages dictionary:
"tar": {
"externals": [{"spec": "tar@1.35", "prefix": "/usr"}],
"buildable": False,
},
Initialize the system to validate the definition:
$ benchpark system init --dest=fluxtainer fluxtainer
To initialize the AWS configuration with 32 cores per node, select the amd64-aws
instance type:
$ benchpark system init --dest=fluxtainer-aws fluxtainer instance_type=amd64-aws
For the complete system authoring reference, see Adding a System.