Skip to content

Commit

Permalink
tutorial: zlib -> gmake (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie authored Oct 31, 2023
1 parent bb74ea9 commit 9bebe83
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 44 deletions.
4 changes: 0 additions & 4 deletions docker/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
config:
suppress_gpg_warnings: true
# This is needed to be able to use [email protected]
# or earlier as of v0.18.0
deprecated: true

32 changes: 16 additions & 16 deletions outputs/basics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ cd ~/spack || exit
. share/spack/setup-env.sh
spack config add "config:suppress_gpg_warnings:true"

example basics/source-setup ". share/spack/setup-env.sh"
example basics/source-setup ". share/spack/setup-env.sh"

# spack list
example basics/list "spack list"
example basics/list-py "spack list 'py-*'"

# spack install
example basics/zlib "spack install zlib"
example basics/gmake "spack install gmake"

example basics/mirror "spack mirror add tutorial /mirror"
example basics/mirror "spack buildcache keys --install --trust"

example basics/zlib-clang "spack install zlib %clang"
example basics/gmake-clang "spack install gmake %clang"

example basics/versions-zlib "spack versions zlib"
example basics/zlib-1.2.8 "spack install [email protected]"
example basics/zlib-gcc-10.4.0 "spack install zlib %gcc@10"
example basics/versions-gmake "spack versions gmake"
example basics/gmake-4.3 "spack install [email protected]"
example basics/gmake-gcc-10 "spack install gmake %gcc@10"

example basics/zlib-O3 "spack install [email protected] cflags=-O3"
example basics/gmake-O3 "spack install [email protected] cflags=-O3"

example basics/find "spack find"
example basics/find-lf "spack find -lf"

example basics/tcl "spack install tcl"

example basics/tcl-zlib-clang "spack install tcl ^[email protected] %clang"
example basics/tcl-gmake-clang "spack install tcl ^[email protected] %clang"

zlib_hash=$(spack find --format "{hash:3}" zlib cflags=-O3)
example basics/tcl-zlib-hash "spack install tcl ^/${zlib_hash}"
gmake_hash=$(spack find --format "{hash:3}" gmake cflags=-O3)
example basics/tcl-gmake-hash "spack install tcl ^/${gmake_hash}"

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

Expand All @@ -66,15 +66,15 @@ example basics/graph-trilinos "spack graph trilinos"

example basics/find-d-tcl "spack find -d tcl"

example basics/find-zlib "spack find zlib"
example basics/find-gmake "spack find gmake"

example basics/uninstall-zlib "spack uninstall -y zlib %gcc@10"
example basics/uninstall-gmake "spack uninstall -y gmake %gcc@10"

example basics/find-lf-zlib "spack find -lf zlib"
example basics/find-lf-gmake "spack find -lf gmake"

zlib_hash="$(spack find --format '{hash:3}' [email protected] %clang)"
example --expect-error basics/uninstall-needed "spack uninstall zlib/$zlib_hash"
example basics/uninstall-r-needed "spack uninstall -y -R zlib/$zlib_hash"
gmake_hash="$(spack find --format '{hash:3}' [email protected] %clang)"
example --expect-error basics/uninstall-needed "spack uninstall gmake/$gmake_hash"
example basics/uninstall-r-needed "spack uninstall -y -R gmake/$gmake_hash"

example --expect-error basics/uninstall-ambiguous "spack uninstall trilinos"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions outputs/environments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ rm -rf "${raw_outputs:?}/environments"
# In the basics section a bunch of packages were already installed,
# they are referenced here. Reinstall them so we can generate outputs
# independently.
spack install zlib \
zlib %clang \
[email protected] \
[email protected] cflags=-O3 \
spack install gmake \
gmake %clang \
[email protected] \
[email protected] cflags=-O3 \
tcl \
tcl ^zlib cflags=-O3 \
tcl ^gmake cflags=-O3 \
hdf5 \
hdf5~mpi \
hdf5+hl+mpi ^mpich \
Expand Down Expand Up @@ -114,10 +114,10 @@ int main(int argc, char **argv) {
MPI_Finalize();
}
EOF
example environments/use-mpi-1 'mpicc ./mpi-hello.c -I$(spack location -i zlib)/include'
example environments/use-mpi-1 'mpicc ./mpi-hello.c -I$(spack location -i zlib-ng)/include'
example environments/use-mpi-1 "mpirun -n 4 ./a.out"

example environments/myproject-zlib-1 "spack find zlib"
example environments/myproject-zlib-ng-1 "spack find zlib-ng"

example --tee environments/filenames-1 "spack cd -e myproject"
spack cd -e myproject
Expand Down
File renamed without changes.
30 changes: 15 additions & 15 deletions tutorial_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Installing Packages
Installing a package with Spack is very simple. To install a piece of
software, simply type ``spack install <package_name>``.

.. literalinclude:: outputs/basics/zlib.out
.. literalinclude:: outputs/basics/gmake.out
:language: console

Spack can install software either from source or from a binary
Expand All @@ -94,7 +94,7 @@ Spack's spec syntax is the interface by which we can request specific
configurations of the package. The ``%`` sigil is used to specify
compilers.

.. literalinclude:: outputs/basics/zlib-clang.out
.. literalinclude:: outputs/basics/gmake-clang.out
:language: console

Note that this installation is located separately from the previous
Expand All @@ -103,18 +103,18 @@ allows Spack to support arbitrarily versioned software.

You can check for particular versions before requesting them. We will
use the ``spack versions`` command to see the available versions, and then
install a different version of ``zlib``.
install a different version of ``gmake``.

.. literalinclude:: outputs/basics/versions-zlib.out
.. literalinclude:: outputs/basics/versions-gmake.out
:language: console

The ``@`` sigil is used to specify versions, both of packages and of
compilers.

.. literalinclude:: outputs/basics/zlib-1.2.8.out
.. literalinclude:: outputs/basics/gmake-4.3.out
:language: console

.. literalinclude:: outputs/basics/zlib-gcc-10.4.0.out
.. literalinclude:: outputs/basics/gmake-gcc-10.out
:language: console

The spec syntax also includes compiler flags. Spack accepts
Expand All @@ -123,7 +123,7 @@ The spec syntax also includes compiler flags. Spack accepts
the command line if they include spaces. These values are injected
into the compile line automatically by the Spack compiler wrappers.

.. literalinclude:: outputs/basics/zlib-O3.out
.. literalinclude:: outputs/basics/gmake-O3.out
:language: console

The ``spack find`` command is used to query installed packages. Note that
Expand Down Expand Up @@ -154,20 +154,20 @@ Dependencies can be explicitly requested using the ``^`` sigil. Note that
the spec syntax is recursive. Anything we could specify about the
top-level package, we can also specify about a dependency using ``^``.

.. literalinclude:: outputs/basics/tcl-zlib-clang.out
.. literalinclude:: outputs/basics/tcl-gmake-clang.out
:language: console

Packages can also be referred to from the command line by their package
hash. Using the ``spack find -lf`` command earlier we saw that the hash
of our optimized installation of zlib (``cflags="-O3"``) began with
of our optimized installation of gmake (``cflags="-O3"``) began with
``iswfl``. We can now explicitly build with that package without typing
the entire spec, by using the ``/`` sigil to refer to it by hash. As with
other tools like Git, you do not need to specify an *entire* hash on the
command line. You can specify just enough digits to identify a hash
uniquely. If a hash prefix is ambiguous (i.e., two or more installed
packages share the prefix) then Spack will report an error.

.. literalinclude:: outputs/basics/tcl-zlib-hash.out
.. literalinclude:: outputs/basics/tcl-gmake-hash.out
:language: console

The ``spack find`` command can also take a ``-d`` flag, which can show
Expand Down Expand Up @@ -223,7 +223,7 @@ DAG as a graph.
.. literalinclude:: outputs/basics/graph-hdf5.out
:language: console

HDF5 is more complicated than our basic example of zlib and
HDF5 is more complicated than our basic example of gmake 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.
Now let's look at an even more complicated package.
Expand Down Expand Up @@ -278,22 +278,22 @@ complicated packages. The output can be changed to the Graphviz
Uninstalling Packages
---------------------

Earlier we installed many configurations each of zlib and Tcl. Now we
Earlier we installed many configurations each of gmake and Tcl. Now we
will go through and uninstall some of those packages that we didn't
really need.

.. literalinclude:: outputs/basics/find-d-tcl.out
:language: console

.. literalinclude:: outputs/basics/find-zlib.out
.. literalinclude:: outputs/basics/find-gmake.out
:language: console

We can uninstall packages by spec using the same syntax as install.

.. literalinclude:: outputs/basics/uninstall-zlib.out
.. literalinclude:: outputs/basics/uninstall-gmake.out
:language: console

.. literalinclude:: outputs/basics/find-lf-zlib.out
.. literalinclude:: outputs/basics/find-lf-gmake.out
:language: console

We can also uninstall packages by referring only to their hash.
Expand Down
4 changes: 2 additions & 2 deletions tutorial_environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Let's look at the output of ``spack find`` at this point in the tutorial.
This is a complete, but cluttered list of the installed packages and
their dependencies. It contains packages built with both ``openmpi``
and ``mpich``, as well as multiple variants of other packages, like
``hdf5`` and ``zlib``. The query mechanism we learned about with
``hdf5`` and ``zlib-ng``. The query mechanism we learned about with
``spack find`` can help, but it would be nice if we could start from
a clean slate without losing what we've already installed.

Expand Down Expand Up @@ -519,7 +519,7 @@ and the version of ``zlib`` used to build the program is printed.
We can confirm the version of ``zlib`` used to build the program
is in our environment using ``spack find``:

.. literalinclude:: outputs/environments/myproject-zlib-1.out
.. literalinclude:: outputs/environments/myproject-zlib-ng-1.out
:language: console

Note that the reported version *does* match that of our installation.
Expand Down

0 comments on commit 9bebe83

Please sign in to comment.