You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorial_basics.rst
+93-40Lines changed: 93 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,16 +72,34 @@ Let's go ahead and install ``gmake``,
72
72
.. literalinclude:: outputs/basics/gmake.out
73
73
:language: console
74
74
75
-
We see Spack installed ``gmake``, ``gcc-runtime``, and ``glibc``.
76
-
The ``glibc`` and ``gcc-runtime`` packages are automatically tracked by Spack to manage consistency requirements among compiler runtimes.
77
-
They do not represent separate software builds from source, but are records of the system's compiler runtime components Spack used for the install.
78
-
For the rest of this section, we'll ignore these components and focus on the packages explicitly installed.
79
-
80
-
Spack can install software either from source or from a binary cache.
81
-
Packages in the binary cache are signed with GPG for security.
82
-
For this tutorial, we've prepared a binary cache so we don't have to wait for slow compilation from source.
83
-
84
-
To enable installation from the binary cache, we'll need to configure Spack with the location of the cache and trust the GPG key that the cache was signed with.
75
+
You will see Spack installed ``gmake``, ``gcc``, ``gcc-runtime``, and
76
+
``glibc``. The ``glibc`` and ``gcc-runtime`` packages are
77
+
automatically tracked by Spack to manage consistency requirements
78
+
among compiler runtimes. These do not represent separate software
79
+
builds from source, but are records of the compiler runtime components
80
+
Spack used for the install. For the rest of this section, we'llignore
81
+
these components and focus on the packages explicitly installed and
82
+
their listed dependencies.
83
+
84
+
The ``gcc`` package was found on the system and Spack used it because
85
+
``gmake`` requires a compiler to build from source. Compilers are
86
+
handled somewhat specially in Spack; Spack searches the ``PATH``
87
+
environment variable for compilers automatically. We can run ``spack
88
+
compiler list`` or simply ``spack compilers`` to show all the
All compilers that Spack found will be configured as external packages
95
+
-- we'll talk more about externals in the "Spack Concepts" slides and
96
+
in :ref:`Configuration Tutorial <configs-tutorial>` later on.
97
+
98
+
Spack can install software either from source or from a binary
99
+
cache. Packages in the binary cache are signed with GPG for
100
+
security. For this tutorial we have prepared a binary cache so we
101
+
don't have to wait for slow compilation from source. To enable installation from the binary cache, we'll need to configure Spack with
102
+
the location of the cache and trust the GPG key that the binaries were signed with.
85
103
86
104
.. literalinclude:: outputs/basics/mirror.out
87
105
:language: console
@@ -92,7 +110,7 @@ By default, this will install the binary cached version if it exists and fall ba
92
110
Now that we understand how Spack handles installations, let's explore how we can customize what gets installed.
93
111
Spack's "spec" syntax is the interface by which we can request specific configurations of a package.
94
112
The ``%`` sigil is used to specify direct dependencies like a package's compiler.
95
-
For example, we can install zlib (a commonly used compression library), but instead of building it with the GCC compiler as we did for gmake previously, we'll install it with ``%clang`` to build it on top of the clang compiler.
113
+
For example, we can install zlib (a commonly used compression library), but instead of building it with the GCC compiler as we did for gmake previously, we'll install it with ``%clang`` to build it with the clang compiler.
96
114
97
115
.. literalinclude:: outputs/basics/zlib-clang.out
98
116
:language: console
@@ -107,11 +125,14 @@ Let's check what versions of zlib-ng are available, and then we'll install a dif
@@ -134,7 +155,7 @@ Additionally, if we include the ``-f`` flag, Spack will show any non-empty compi
134
155
.. literalinclude:: outputs/basics/find-lf.out
135
156
:language: console
136
157
137
-
Spack generates a unique hash for each spec we define.
158
+
Spack generates a unique hash for each spec.
138
159
This hash reflects the complete provenance of the package, so any change to the spec—such as compiler version, build options, or dependencies—will result in a different hash.
139
160
Spack uses these hashes both to compare specs and to create unique installation directories for every possible configuration.
140
161
@@ -145,7 +166,12 @@ This approach helps us avoid unnecessary rebuilds of common dependencies, which
145
166
.. literalinclude:: outputs/basics/tcl.out
146
167
:language: console
147
168
148
-
When we need to specify dependencies explicitly, we use the ``^`` sigil in the spec syntax. The syntax is recursive, meaning that anything we can specify for the top-level package can also be specified for a dependency using ``^``. This allows us to precisely control the configuration of both packages and their dependencies.
169
+
Sometimes it is simpler to specify dependencies without caring whether
170
+
they are direct or transitive dependencies. To do that, use the ``^``
171
+
sigil. Note that a dependency specified by ``^`` is always applied to
172
+
the root package, whereas a direct dependency specified by ``%`` is
173
+
applied to either the root or any intervening dependency specified by
@@ -166,9 +192,26 @@ Note that each package has a top-level entry, even if it also appears as a depen
166
192
.. literalinclude:: outputs/basics/find-ldf.out
167
193
:language: console
168
194
169
-
Let's move on to slightly more complicated packages.
170
-
HDF5 is a good example of a more complicated package, with an MPI dependency.
171
-
If we install it with default settings it will build with OpenMPI.
195
+
Spack models the dependencies of packages as a directed acyclic graph
196
+
(DAG). The ``spack find -d`` command shows the tree representation of
197
+
that graph, which loses some dependency relationship information. We
198
+
can also use the ``spack graph`` command to view the entire DAG as a
199
+
graph.
200
+
201
+
.. literalinclude:: outputs/basics/graph-tcl.out
202
+
:language: console
203
+
204
+
Let's move on to slightly more complicated packages. HDF5 is a good
205
+
example of a more complicated package, with an MPI dependency. If we
206
+
install it with default settings it will build with OpenMPI. We can
207
+
check the install plan in advance to ensure it's what we want to
208
+
install using the ``spack spec`` command. The ``spack spec`` command
209
+
accepts the same spec syntax.
210
+
211
+
.. literalinclude:: outputs/basics/hdf5-spec.out
212
+
:language: console
213
+
214
+
Assuming we're happy with that configuration, we will now install it.
172
215
173
216
.. literalinclude:: outputs/basics/hdf5.out
174
217
:language: console
@@ -193,19 +236,34 @@ Spack also supports versioning of virtual dependencies.
193
236
A package can depend on the MPI interface at version 3 (e.g., ``hdf5 ^mpi@3``), and provider packages specify what version of the interface *they* provide.
194
237
The partial spec ``^mpi@3`` can be satisfied by any of several MPI implementation packages that provide MPI version 3.
195
238
239
+
We've actually already been using virtual packages when we changed
240
+
compilers earlier. Compilers are providers for virtual packages like
241
+
``c``, ``cxx``, and ``fortran``. Because these are often provided by
242
+
the same package but we might want to use C and C++ from one compiler
243
+
and Fortran from another, we need a syntax to specify which virtual a
244
+
package provides. We call this "virtual assignment", and can be
245
+
specified by ``%virtual=provider`` or ``^virtual=provider``.
246
+
247
+
We will now install HDF5 with MPI support provided by MPICH, ensuring
248
+
that the C and C++ components of HDF5 are compiled with ``gcc``. We
249
+
could use the same syntax for ``^mpi=mpich``, but there's no need
250
+
because the only way for ``hdf5`` to depend on ``mpich`` is to provide
251
+
``mpi``. This is also why we didn't care to specify which virtuals
252
+
``gcc`` and ``clang`` provided earlier when building simpler packages.
We'll do a quick check in on what we have installed so far.
257
+
.. note::
200
258
201
-
.. literalinclude:: outputs/basics/find-ldf-2.out
202
-
:language: console
259
+
It is frequently sufficient to specify ``%gcc`` even for packages
260
+
that use multiple languages, because Spack prefers to minimize the
261
+
number of packages needed for a build. Later on we will discuss
262
+
more complex compiler requests, and how and when they are useful.
203
263
204
-
Spack models the dependencies of packages as a directed acyclic graph (DAG).
205
-
The ``spack find -d`` command shows the tree representation of that graph.
206
-
We can also use the ``spack graph`` command to view the entire DAG as a graph.
264
+
We'll do a quick check in on what we have installed so far.
207
265
208
-
.. literalinclude:: outputs/basics/graph-hdf5.out
266
+
.. literalinclude:: outputs/basics/find-ldf-2.out
209
267
:language: console
210
268
211
269
HDF5 is more complicated than our basic example of zlib-ng and Tcl, but it's still within the realm of software that an experienced HPC user could reasonably expect to manually install given a bit of time.
@@ -215,7 +273,7 @@ Now let's look at an even more complicated package.
215
273
:language: console
216
274
217
275
Now we're starting to see the power of Spack.
218
-
Trilinos in its default configuration has 23 direct dependencies, many of which have dependencies of their own.
276
+
Depending on the spec, Trilinos can have over 30 direct dependencies, many of which have dependencies of their own
219
277
Installing more complex packages can take days or weeks even for an experienced user.
220
278
Although we've done a binary installation for the tutorial, a source installation of Trilinos using Spack takes about 3 hours (depending on the system), but only 20 seconds of programmer time.
221
279
@@ -324,33 +382,28 @@ The ``spack compilers`` command is an alias for ``spack compiler list``.
324
382
.. literalinclude:: outputs/basics/compilers.out
325
383
:language: console
326
384
327
-
The compilers are maintained in a YAML file (``compilers.yaml``).
328
-
Later in the tutorial, you will learn how to configure compilers by hand for special cases.
329
-
Spack also has tools to add compilers, and compilers built with Spack can be added to the configuration.
385
+
These compilers are maintained in a YAML file.
386
+
Later in the tutorial we will discuss how to configure external compilers by hand for special cases.
387
+
Spack can also use compilersbuilt by Spack to compile later packages.
We can also remove compilers from our configuration using ``spack compiler remove <compiler_spec>``
402
+
For the test of the tutorial we will sometimes use this new compiler, and sometimes we want to demonstrate things without it. For now, we will uninstall it to avoid using it in the next section.
0 commit comments