Skip to content

Commit 5384049

Browse files
committed
Revert "basics: update for Spack 1.0 and other minor improvements (#455)"
This reverts commit 0144c34.
1 parent 0144c34 commit 5384049

2 files changed

Lines changed: 39 additions & 72 deletions

File tree

outputs/basics.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ example basics/list-py "spack list 'py-*'"
2828
# spack install
2929
example basics/gmake "spack install gmake"
3030

31-
example basics/compiler-list "spack compilers"
32-
3331
example basics/mirror "spack mirror add tutorial /mirror"
3432
example basics/mirror "spack buildcache keys --install --trust"
3533

@@ -53,16 +51,15 @@ example basics/tcl-zlib-hash "spack install tcl ^/${zlib_hash}"
5351

5452
example basics/find-ldf "spack find -ldf"
5553

56-
example basics/graph-tcl "spack graph tcl"
57-
58-
example basics/hdf5-spec "spack spec hdf5"
5954
example basics/hdf5 "spack install hdf5"
6055
example basics/hdf5-no-mpi "spack install hdf5~mpi"
6156

62-
example basics/hdf5-hl-mpi "spack install hdf5+hl+mpi %c,cxx=gcc ^mpich"
57+
example basics/hdf5-hl-mpi "spack install hdf5+hl+mpi ^mpich"
6358

6459
example basics/find-ldf-2 "spack find -ldf"
6560

61+
example basics/graph-hdf5 "spack graph hdf5+hl+mpi ^mpich"
62+
6663
example basics/trilinos "spack install trilinos"
6764

6865
example basics/trilinos-hdf5 "spack install trilinos +hdf5 ^hdf5+hl+mpi ^mpich"
@@ -98,8 +95,8 @@ example basics/compilers "spack compilers"
9895

9996
example basics/install-gcc-12.1.0 "spack install gcc@12"
10097

101-
example basics/compilers-2 "spack compilers"
98+
example basics/find-p-gcc "spack find -p gcc"
10299

103-
example basics/spec-zziplib "spack spec zziplib"
100+
example basics/compiler-add-location 'spack compiler add "$(spack location -i gcc@12)"'
104101

105-
example basics/compiler-uninstall 'spack uninstall gcc@12'
102+
example basics/compiler-remove 'spack compiler remove gcc@12'

tutorial_basics.rst

Lines changed: 33 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,16 @@ Let's go ahead and install ``gmake``,
7272
.. literalinclude:: outputs/basics/gmake.out
7373
:language: console
7474

75-
You will see Spack installed ``gmake``, ``gcc``, ``gcc-runtime``, and ``glibc``.
75+
We see Spack installed ``gmake``, ``gcc-runtime``, and ``glibc``.
7676
The ``glibc`` and ``gcc-runtime`` packages are automatically tracked by Spack to manage consistency requirements among compiler runtimes.
77-
These do not represent separate software builds from source, but are records of the 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 and their listed dependencies.
79-
80-
The ``gcc`` package was found on the system and Spack used it because ``gmake`` requires a compiler to build from source.
81-
Compilers are handled somewhat specially in Spack; Spack searches the ``PATH`` environment variable for compilers automatically.
82-
We can run ``spack compiler list`` or simply ``spack compilers`` to show all the compilers Spack found.
83-
84-
.. literalinclude:: outputs/basics/compiler-list.out
85-
:language: console
86-
87-
All compilers that Spack found will be configured as external packages -- we'll talk more about externals in the "Spack Concepts" slides and in :ref:`Configuration Tutorial <configs-tutorial>` later on.
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.
8879

8980
Spack can install software either from source or from a binary cache.
9081
Packages in the binary cache are signed with GPG for security.
91-
For this tutorial we have prepared a binary cache so we don't have to wait for slow compilation from source.
92-
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 binaries were signed with.
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.
9385

9486
.. literalinclude:: outputs/basics/mirror.out
9587
:language: console
@@ -100,7 +92,7 @@ By default, this will install the binary cached version if it exists and fall ba
10092
Now that we understand how Spack handles installations, let's explore how we can customize what gets installed.
10193
Spack's "spec" syntax is the interface by which we can request specific configurations of a package.
10294
The ``%`` sigil is used to specify direct dependencies like a package's compiler.
103-
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.
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.
10496

10597
.. literalinclude:: outputs/basics/zlib-clang.out
10698
:language: console
@@ -115,13 +107,11 @@ Let's check what versions of zlib-ng are available, and then we'll install a dif
115107
.. literalinclude:: outputs/basics/versions-zlib.out
116108
:language: console
117109

118-
The ``@`` sigil is used to specify versions.
110+
The ``@`` sigil is used to specify versions, both of packages and of compilers.
119111

120112
.. literalinclude:: outputs/basics/zlib-2.0.7.out
121113
:language: console
122114

123-
The spec syntax is recursive -- any syntax we can specify for the "root" package (``zlib-ng``) we can also use for a dependency.
124-
125115
.. literalinclude:: outputs/basics/zlib-gcc-10.out
126116
:language: console
127117

@@ -144,7 +134,7 @@ Additionally, if we include the ``-f`` flag, Spack will show any non-empty compi
144134
.. literalinclude:: outputs/basics/find-lf.out
145135
:language: console
146136

147-
Spack generates a unique hash for each spec.
137+
Spack generates a unique hash for each spec we define.
148138
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.
149139
Spack uses these hashes both to compare specs and to create unique installation directories for every possible configuration.
150140

@@ -155,9 +145,7 @@ This approach helps us avoid unnecessary rebuilds of common dependencies, which
155145
.. literalinclude:: outputs/basics/tcl.out
156146
:language: console
157147

158-
Sometimes it is simpler to specify dependencies without caring whether they are direct or transitive dependencies.
159-
To do that, use the ``^`` sigil.
160-
Note that a dependency specified by ``^`` is always applied to the root package, whereas a direct dependency specified by ``%`` is applied to either the root or any intervening dependency specified by ``^``.
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.
161149

162150
.. literalinclude:: outputs/basics/tcl-zlib-clang.out
163151
:language: console
@@ -178,23 +166,9 @@ Note that each package has a top-level entry, even if it also appears as a depen
178166
.. literalinclude:: outputs/basics/find-ldf.out
179167
:language: console
180168

181-
Spack models the dependencies of packages as a directed acyclic graph (DAG).
182-
The ``spack find -d`` command shows the tree representation of that graph, which loses some dependency relationship information.
183-
We can also use the ``spack graph`` command to view the entire DAG as a graph.
184-
185-
.. literalinclude:: outputs/basics/graph-tcl.out
186-
:language: console
187-
188169
Let's move on to slightly more complicated packages.
189170
HDF5 is a good example of a more complicated package, with an MPI dependency.
190171
If we install it with default settings it will build with OpenMPI.
191-
We can check the install plan in advance to ensure it's what we want to install using the ``spack spec`` command.
192-
The ``spack spec`` command accepts the same spec syntax.
193-
194-
.. literalinclude:: outputs/basics/hdf5-spec.out
195-
:language: console
196-
197-
Assuming we're happy with that configuration, we will now install it.
198172

199173
.. literalinclude:: outputs/basics/hdf5.out
200174
:language: console
@@ -219,38 +193,29 @@ Spack also supports versioning of virtual dependencies.
219193
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.
220194
The partial spec ``^mpi@3`` can be satisfied by any of several MPI implementation packages that provide MPI version 3.
221195

222-
We've actually already been using virtual packages when we changed compilers earlier.
223-
Compilers are providers for virtual packages like ``c``, ``cxx``, and ``fortran``.
224-
Because these are often provided by the same package but we might want to use C and C++ from one compiler and Fortran from another, we need a syntax to specify which virtual a package provides.
225-
We call this "virtual assignment", and can be specified by ``%virtual=provider`` or ``^virtual=provider``.
226-
227-
We will now install HDF5 with MPI support provided by MPICH, ensuring that the C and C++ components of HDF5 are compiled with ``gcc``.
228-
We could use the same syntax for ``^mpi=mpich``, but there's no need because the only way for ``hdf5`` to depend on ``mpich`` is to provide ``mpi``.
229-
This is also why we didn't care to specify which virtuals ``gcc`` and ``clang`` provided earlier when building simpler packages.
230-
231196
.. literalinclude:: outputs/basics/hdf5-hl-mpi.out
232197
:language: console
233198

234-
.. note::
235-
236-
It is frequently sufficient to specify ``%gcc`` even for packages
237-
that use multiple languages, because Spack prefers to minimize the
238-
number of packages needed for a build. Later on we will discuss
239-
more complex compiler requests, and how and when they are useful.
240-
241199
We'll do a quick check in on what we have installed so far.
242200

243201
.. literalinclude:: outputs/basics/find-ldf-2.out
244202
:language: console
245203

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.
207+
208+
.. literalinclude:: outputs/basics/graph-hdf5.out
209+
:language: console
210+
246211
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.
247212
Now let's look at an even more complicated package.
248213

249214
.. literalinclude:: outputs/basics/trilinos.out
250215
:language: console
251216

252217
Now we're starting to see the power of Spack.
253-
Depending on the spec, Trilinos can have over 30 direct dependencies, many of which have dependencies of their own.
218+
Trilinos in its default configuration has 23 direct dependencies, many of which have dependencies of their own.
254219
Installing more complex packages can take days or weeks even for an experienced user.
255220
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.
256221

@@ -359,28 +324,33 @@ The ``spack compilers`` command is an alias for ``spack compiler list``.
359324
.. literalinclude:: outputs/basics/compilers.out
360325
:language: console
361326

362-
These compilers are maintained in a YAML file.
363-
Later in the tutorial we will discuss how to configure external compilers by hand for special cases.
364-
Spack can also use compilers built by Spack to compile later packages.
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.
365330

366331
.. literalinclude:: outputs/basics/install-gcc-12.1.0.out
367332
:language: console
368333

369-
.. literalinclude:: outputs/basics/compilers-2.out
334+
.. literalinclude:: outputs/basics/find-p-gcc.out
370335
:language: console
371336

372-
Because this compiler is a newer version than the external compilers Spack knows about, it will be the new default compiler.
373-
We will discuss changing these defaults in a later section.
374-
We can check that this compiler is preferred by looking at the install plan for a package that isn't being reused from binary.
337+
We can add GCC to Spack as an available compiler using the ``spack compiler add`` command.
338+
This will allow future packages to build with ``gcc@12.3.0``.
339+
To avoid having to copy and paste GCC's path, we can use ``spack location -i`` to get the installation prefix.
375340

376-
.. literalinclude:: outputs/basics/spec-zziplib
341+
.. literalinclude:: outputs/basics/compiler-add-location.out
377342
:language: console
378343

379-
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.
344+
We can also remove compilers from our configuration using ``spack compiler remove <compiler_spec>``
380345

381-
.. literalinclude:: outputs/basics/compiler-uninstall.out
346+
.. literalinclude:: outputs/basics/compiler-remove.out
382347
:language: console
383348

349+
.. tip::
350+
351+
Starting from Spack v1.0 it will be no longer necessary to add a Spack installed
352+
compilers to configuration, in order to use them.
353+
384354
.. note::
385355

386356
The spec syntax may be confusing for new users.

0 commit comments

Comments
 (0)