-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
1361 lines (1317 loc) · 45.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<style>
.small-text {
font-size: large;
line-height: normal;
}
.tiny-text {
font-size: small;
line-height: normal;
}
</style>
<title>CSCS Spack Course 2024</title>
<link rel="stylesheet" href="dist/reset.css">
<link rel="stylesheet" href="dist/reveal.css">
<link rel="stylesheet" href="dist/theme/white.css">
<!-- Theme used for syntax highlighted code -->
<link rel="stylesheet" href="plugin/highlight/monokai.css">
<link rel="stylesheet" href="plugin/asciinema/asciinema-player.css">
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<section>
<img src="dist/images/logo.svg" />
<h1 class="r-fit-text">CSCS Spack Course 2024</h1>
<p>13.06.2024 — Massimiliano Culpo & Harmen Stoppels</p>
</section>
<section>
<img src="dist/images/commits-cscs.svg" class="stretch" />
</section>
</section>
<section>
<section>
<h2>Quick <img src="dist/images/logo.svg" style=" display: inline-block; vertical-align:middle;" /> refresher</h2>
</section>
<section>
<h2 class="r-fit-text">Software installations are <br/>more than name and version</h2>
<ul>
<li>Need to install multiple variants of the same package</li>
<li class="fragment"><code>cp2k-2024.1-avx2/</code></p>
<li class="fragment"><code>cp2k-2024.1-avx2-cuda/</code></p>
<li class="fragment"><code>cp2k-2024.1-avx2-cuda-patched/</code></p>
<li class="fragment"><code>cp2k-2024.1-avx2-cuda-patched-final/</code></p>
</ul>
</section>
<section>
<h2 class="r-fit-text">Software installations are <br/>more than name and version</h2>
<ul>
<li>What compiler did you use?</li>
<li>What architecture did you compile for?</li>
<li>What configure flags did you set?</li>
<li>What dependencies did you use?</li>
</ul>
</section>
<section>
<h2 class="r-fit-text">Identify installations by hash of inputs</h2>
<div class="r-stack stretch">
<img class="fragment current-visible" src="dist/images/hash.svg" />
<ul class="fragment">
<li>Merkel hash of dependency graph</li>
<li>Hash name, version, source, build instructions per node</li>
<li class="fragment"><code>cp2k-2024.1-xexq3v6d76uebivz44i7/</code></li>
</ul>
</div>
</section>
<section>
<h2 class="r-fit-text">Single package definitions</h2>
<ul>
<li>Single <strong><code>package.py</code></strong> for every package</li>
<li>Whether you're on your laptop, Alps, Lumi, Fugaku...</li>
<li>Avoids fragmentation</li>
<li>Hundreds of monthly contributors work together</li>
</ul>
</section>
<section>
<h2 class="r-fit-text">Highly flexible</h2>
<pre class="spec"><code data-trim data-noescape>
spack install hdf5
spack install [email protected] %gcc@10
spack install [email protected] +mpi ^[email protected]
</code></pre>
</section>
</section>
<!-- Concretizer -->
<section>
<section>
<h2>Why is the concretizer necessary?</h2>
</section>
<section>
Installations can be finely tuned with the <em>spec syntax</em>
<pre><code data-trim data-noescape class="spec">
# Specify a version range with `@`
# Specify a compiler toolchain with `%`
# Activate or deactivate boolean variants
[email protected] +szip ~fortran
# Set multi-valued variants, or reserved keywords
[email protected] build_type=Release target=x86_64_v4
</code></pre>
</section>
<section>
Each recipe can build a software in multiple ways
<pre><code class="python" data-trim>
class Hdf5(CMakePackage):
"""HDF5 is a data model, library, ... """
homepage = "https://portal.hdfgroup.org"
url = "https://.../hdf5-1.14.3.tar.gz"
version("1.14.2", sha256="4b4b4453251")
version("1.12.3", sha256="49d88f4494a")
variant("shared", default=True, description="...")
variant("mpi", default=True, description="...")
depends_on("mpi", when="+mpi")
</code></pre>
</section>
<section>
That's not alike other functional package managers...
<pre><code class="scheme" data-trim data-noescape>
(define-public hello
(package
(name "hello")
(version "2.10")
(source
(origin
(method url-fetch)
(uri (string-append "hello-" version ".tar.gz"))
(sha256 (base32 "0ssi1..."))))
(build-system gnu-build-system)
(synopsis "Hello, GNU world: An example GNU package")
(description "GNU Hello prints ...")
(home-page "https://www.gnu.org/software/hello/")
(license gpl3+)))
</code></pre>
</section>
<section>
... and must solve a SAT problem to get a configuration
<div>
<img class="r-stretch" src="dist/images/concretizer.svg" style="background: none; border: 0px">
</div>
</section>
<section>
Using the concretizer allows trying different configurations much more easily
</section>
<section>
<h2>Hands-on</h2>
<pre><code class="bash" data-trim>
# Try different variants, see how dependencies change
spack spec hdf5+mpi
spack spec hdf5~mpi
# Use spack graph to get more insight on DAG structure
# To visualize: https://dreampuf.github.io/GraphvizOnline/
spack graph -d --color hdf5~mpi
# Use a temporary environment to avoid reconcretizing
spack env activate --temp
spack add hdf5~mpi
spack concretize
spack graph -d --color
</code></pre>
</section>
</section>
<section>
<section>
<h2>Why is the concretizer so slow?</h2>
</section>
<section>
Dependency resolution is NP-hard!
<p class="fragment">Performance is a currency for buying features!</p>
</section>
<section>
Spack uses <em>clingo</em> and ASP to concretize
</section>
<section>
A crash course in the ASP language
<pre><code data-trim data-noescape data-line-numbers="1-3|5-7|9-10|12-16|18-23" class="prolog">
% Facts are specific "true" statements
node("lammps").
variant_set("laamps", "cuda", "false").
% Rules can derive additional facts
path(A, B) :- depends_on(A, B).
path(A, C) :- path(A, B), depends_on(B, C).
% Constraints say what cannot happen
:- path(A, B), path(B, A).
% Choice rules gives the solver freedom to choose
% from possible options
1 { version(Package, V)
: possible_version(Package, V) } 1
:- node(Package).
% Minimization defines the "optimal" solution
#minimize{
Weight,Package
: version_weight(Package, Weight),
node(Package)
}.
</code></pre>
</section>
<section>
How does clingo solve the ASP problem?
<div>
<img src="dist/images/asp-grounding.svg" style="background: none; border: 0px">
</div>
</section>
<section>
Where is time spent, then?
<pre><code data-trim data-noescape data-line-numbers="1|2,8|3,8|4,9|5,9|6,8-9" class="console">
$ spack solve --timers hdf5
setup 6.676s
load 0.979s
ground 3.700s
solve 7.666s
total 19.897s
[ ... ]
lib/spack/spack/solver/asp.py
lib/spack/spack/solver/concretize.lp
</code></pre>
</section>
<section>
<h2>Hands-on</h2>
<pre><code class="bash" data-trim>
# Try to time different concretizations
spack solve --timers ...
</code></pre>
</section>
</section>
<section>
<section>
<h2>How does reuse work?</h2>
</section>
<section>
"Reuse" actively tries to prefer known configurations to
configurations yet to be built.
</section>
<section>
Hash matches are very sensitive to small changes
<div>
<img class="r-stretch" src="dist/images/hash-cache.svg" style="background: none; border: 0px">
</div>
</section>
<section>
Spack can also actively try to reuse
<pre><code data-trim data-noescape class="yaml">
concretizer:
# Whether to consider installed packages or packages
# from buildcaches when concretizing specs. If `true`,
# we'll try to use as many installs/binaries as possible,
# rather than building. If `false`, we'll always give you
# a fresh concretization. If `dependencies`, we'll only
# reuse dependencies but give you a fresh concretization
# for your root specs.
reuse: true
</code></pre>
</section>
<section>
<pre><code data-trim data-noescape class="console">
spack solve --show=asp hdf5
</code></pre>
<pre><code data-trim data-noescape class="small-text prolog">
installed_hash("diffutils","cguhjk").
imposed_constraint("cguhjk","node","diffutils").
imposed_constraint("cguhjk","version","diffutils","3.10").
imposed_constraint("cguhjk","node_platform","diffutils","linux").
imposed_constraint("cguhjk","node_os","diffutils","ubuntu20.04").
imposed_constraint("cguhjk","node_target","diffutils","icelake").
imposed_constraint("cguhjk","variant_value","diffutils","build_system","autotools").
imposed_constraint("cguhjk","node_compiler","diffutils","gcc").
imposed_constraint("cguhjk","node_compiler_version","diffutils","gcc","9.4.0").
imposed_constraint("cguhjk","package_hash","diffutils","kbm...").
imposed_constraint("cguhjk","hash","diffutils","cguhjk").
imposed_constraint("cguhjk","compatible_libc","diffutils","glibc","2.31").
imposed_constraint("cguhjk","depends_on","diffutils","libiconv","link").
imposed_constraint("cguhjk","virtual_on_edge","diffutils","libiconv","iconv").
imposed_constraint("cguhjk","virtual_node","iconv").
imposed_constraint("cguhjk","hash","libiconv","iel...").
</code></pre>
</section>
<section>
Spack v0.22 allows a <em>fine-tuned</em> selection
</section>
<section>
Reuse only specs compiled with GCC
<pre><code data-trim data-noescape class="yaml">
concretizer:
reuse:
roots: true
include:
- "%gcc"
</code></pre>
</section>
<section>
Use OpenMPI from externals
<pre><code data-trim data-noescape class="yaml">
concretizer:
reuse:
roots: true
from:
# OpenMPI should not be reused
# from store or buildcache...
- type: local
exclude: ["openmpi"]
- type: buildcache
exclude: ["openmpi"]
# ...and it must be the only external used
- type: external
include: ["openmpi"]
</code></pre>
</section>
<section>
https://cache.spack.io/
<div>
<img height="40%" src="dist/images/build-cache.png" style="background: none; border: 0px">
</div>
</section>
<section>
<h2>Hands-on</h2>
<pre><code data-trim data-noescape class="bash">
# Check that using --fresh doesn't emit hash facts
spack solve --fresh --show=asp cmake | less
spack solve --fresh cmake
# Add a mirror, retry
spack mirror add developer-tools https://binaries.spack.io/develop/developer-tools-manylinux2014
spack buildcache keys --install --trust
spack solve --reuse --show=asp cmake | less
spack install cmake
# You can also install the latest GCC from binaries
spack install gcc
</code></pre>
</section>
</section>
<section>
<section>
<h2>What is an optimal solution?</h2>
</section>
<section>
<h3>Multiple optimization criteria</h3>
<ul>
<li>Prefer newer versions</li>
<li>Prefer default values for variants</li>
<li>Prefer to use the same compiler across a DAG</li>
<li>...</li>
</ul>
</section>
<section>
A lower penalty on higher priority criteria is preferred
<pre><code data-trim data-noescape class="prolog">
% Choose most recent versions (priority 25)
#minimize{
Weight@25,node(Package)
: version_weight(node(Package), Weight)
}.
% Use default values for variants (priority 20)
#minimize{
1@20,Package,Variant,Value
: variant_default_not_used(Package, Variant, Value)
}.
</code></pre>
</section>
<section>
<img class="r-stretch" src="dist/images/sums.svg" style="background: none; border: 0px">
</section>
<section>
<code data-trim data-noescape class="console">
spack solve hdf5
</code>
<pre><code data-trim data-noescape class="console small-text">
Priority Criterion Installed ToBuild
1 requirement weight - 0
2 number of packages to build (vs. reuse) - 5
3 number of nodes from the same package - 0
4 deprecated versions used 0 0
5 version badness (roots) 0 0
6 number of non-default variants (roots) 0 0
7 preferred providers for roots 0 0
8 default values of variants not being used (roots) 0 0
9 number of non-default variants (non-roots) 11 0
10 preferred providers (non-roots) 0 0
11 compiler mismatches that are not from CLI 23 0
12 compiler mismatches that are not from CLI 0 0
13 non-preferred OS's 33 0
14 version badness (non roots) 329 0
15 default values of variants not being used (non-roots) 2 0
16 non-preferred compilers 64 0
17 target mismatches 8 0
18 non-preferred targets 288 0
19 compiler mismatches (runtimes) 4 0
20 version badness (runtimes) 0 0
21 non-preferred targets (runtimes) 9 0
22 edge wiring 588 0
</code></pre>
</section>
<section>
<h2>Hands-on</h2>
<pre><code class="bash" data-trim>
# Check how weights are changing depending on the spec
# and the overall configuration.
spack solve --fresh cmake
spack solve --reuse cmake
spack solve --reuse hdf5
</code></pre>
</section>
</section>
<section>
<section>
<h1 class="r-fit-text">What are runtimes in Spack 0.22?</h1>
</section>
<section>
<h2>Compiler runtime packages</h2>
<pre><code data-trim data-noescape>
$ spack spec zlib
Input spec
--------------------------------
- zlib
Concretized
--------------------------------
- ^[email protected] %[email protected] ...
[e] ^[email protected] %[email protected] ...
- ^[email protected] %[email protected] ...
</code></pre>
</section>
<section>
<h2>What is <code>^gcc-runtime</code>?</h2>
<ul>
<li>A Spack installed package that copies
<ul>
<li><code>libstdc++.so.6</code></li>
<li><code>libgfortran.so.5</code></li>
<li><code>libgcc_s.so.1</code></li>
<li>and others</li>
</ul>
</li>
</ul>
</section>
<section>
<h2>What is <code>^libc</code></h2>
<ul>
<li>An external-only package</li>
<li>Virtual provided by <code>glibc</code> and <code>musl</code></li>
<li>Largely replaces the static <code>os</code> tag
<ul>
<li class="fragment semi-fade-out"><code>os=ubuntu24.04</code></li>
<li class="fragment fade-up"><code>^[email protected]</code></li>
</ul>
</li>
</ul>
</section>
<section>
<h2>But why?</h2>
<ul>
<li>Software does not break if compiler is uninstalled</li>
<li>Install from <strong>build cache</strong> without compilers</li>
<li>Share binaries <strong>across Linux distros</strong></li>
<li>Create small <strong>OCI container images</strong></li>
<li>Be able to express<pre>
<code class="spec" data-trim data-noescape>
depends_on("[email protected]:")
</code>
</pre></li>
</ul>
</section>
<section>
<h2>Can't Spack build <code>glibc</code>?</h2>
<ul>
<li>👍 Spack would be isolated from the system
<ul>
<li>Better build reproducibility</li>
</ul>
</li>
</ul>
<p>but...</p>
<ul>
<li>👎 Spack would be isolated from the system
<ul>
<li>Complicates use of system compilers</li>
<li>Complicates use of externals</li>
</ul>
</li>
</ul>
<p>currently a non-goal</p>
</section>
<section>
<h2>Why not <code>^glibc-runtime</code></h2>
<ul>
<li>... and copy <code>libc.so.6</code>, <code>libm.so.6</code></li>
<li>Issue is mostly with hard-coded (search) paths to and in the dynamic loader</li>
</ul>
</section>
<section>
<h2>So here we are in Spack 0.22</h2>
<pre><code data-trim data-noescape>
$ spack spec zlib
Input spec
--------------------------------
- zlib
Concretized
--------------------------------
- ^[email protected] %[email protected] ...
[e] ^[email protected] %[email protected] ...
- ^[email protected] %[email protected] ...
</code></pre>
</section>
<section>
<h2>Spack 0.22</h2>
<p>Compiler mixing support with <code>gcc-runtime</code></p>
<img src="dist/images/gcc-runtime-mixing.svg" class="stretch" />
</section>
<section>
<h2>Spack 0.22</h2>
<p>Compiler is still a node attribute</p>
<img class="stretch" src="dist/images/gcc-runtime-now.svg" />
</section>
<section>
<h2>Spack 0.23 🔮</h2>
<p>Compiler becomes an ordinary node itself</p>
<img src="dist/images/gcc-runtime-future.svg" class="stretch" />
</section>
<section>
<h2>Spack 0.23 🔮</h2>
<p>Express dependencies of compilers</p>
<div class="r-stack stretch">
<pre class="fragment current-visible"><code data-trim data-noescape>
$ clang -v
Ubuntu clang version 16.0.6 (15)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
$ $(clang -print-prog-name=as) --version | head -n1
GNU assembler (GNU Binutils for Ubuntu) 2.41
</code></pre>
<img src="dist/images/clang-runtime.svg" class="fragment" />
</div>
</section>
<section>
<h2>Spack 0.23 🔮</h2>
<ul>
<li>Packages can <strong>inject</strong> a runtime dependency into dependents</li>
<li>Runtimes will provide <strong>languages</strong> (partially in 0.22):
<pre><code class="python">depends_on("fortran")</code></pre>
</li>
<li>No compiler for data / pure Python packages</li>
<li>Runtimes for other things than compilers?</li>
</ul>
</section>
</section>
<section>
<section>
<h2>What is <code>python-venv</code>?</h2>
</section>
<section>
<h2>Python's injected runtime</h2>
<pre><code data-noescape class="spec">$ spack spec py-click
- ^ ...
- ^[email protected]</code></pre>
</section>
<section>
<h2>Why <code>python-venv</code>?</h2>
<ul>
<li>The least worst solution™ for <strong>build isolation</strong></li>
<li>Spack environment views = Python venvs</li>
<li>Support external Python better</li>
</ul>
</section>
<section>
<h3>Pip and Spack are different</h3>
<ul>
<li><code>pip install</code>: all packages in a single venv dir
<pre>
<code class="bash" data-trim data-noescape>
$ ls my_venv/lib/python3.12/site-packages
black click isort
</code>
</pre></li>
<li><code>spack install</code>: all packages in a unique dir
<pre>
<code class="bash" data-trim data-noescape>
$ tree spack/opt/spack
├── python-3.12.1-eu5igwm
│ └── lib/python3.12 # standard library
├── py-black-24.3.0-c5yefsp
│ └── lib/python3.12/site-packages/black
├── py-click-8.1.7-253ikya
│ └── lib/python3.12/site-packages/click
└── py-isort-5.12.0-yupkr4p
└── lib/python3.12/site-packages/isort
</code>
</pre></li>
</ul>
</section>
<section>
<h3>Pip and Spack are different</h3>
<ul>
<li>You <code>pip install</code> packages <strong>into a venv</strong></li>
<li>You <code>spack install</code> packages <strong>into the store</strong></li>
<li class="fragment">A Spack environment can be "installed", but no files are put "in the environment"</li>
<li class="fragment">Spack <strong>environment views</strong> make them look similar</li>
</ul>
</section>
<section>
<h2>Environment views</h2>
<pre>
<code class="shell" data-trim data-noescape>
$ spack env create --with-view ./view .
$ spack -e . add py-black py-isort
$ spack -e . install
$ ./view/bin/python3 -c 'import black' # works
</code>
</pre>
</section>
<section data-transition="fade-out">
<h2>Environment views</h2>
<p>Single, flattened dir with tons of symlinks</p>
<img src="dist/images/create-view.svg" class="stretch">
</section>
<section data-transition="fade-in">
<h2>environment views</h2>
<p style="font-size: 0.7em">with python-venv: <code style="color: rgb(145, 0, 0)">bin/activate</code> and <code style="color: rgb(145, 0, 0)">pyvenv.cfg</code></p>
<img src="dist/images/create-view-venv.svg" class="stretch">
</section>
<section>
<h2>What was the point again?</h2>
<ul>
<li>You can <code>source bin/activate</code></li>
<li>Editor support (completion etc)</li>
<li><code>pip list</code> and <code>pip install</code> interop</li>
</ul>
</section>
<section>
<h2>Hands-on</h2>
<ul>
<li>Create an environment with view
<pre><code>spack env create --with-view ./view .</code></pre>
</li>
<li>add and install <code>py-pip</code> and others
<pre><code>spack -e . install --add py-pip py-black</code></pre></li>
<li>try <code>source view/bin/activate</code></li>
<li>and <code>pip list</code> or <code>pip install</code></li>
</ul>
</section>
</section>
<section>
<section>
<h2>What are requirements and strong preferences?</h2>
</section>
<section>
Enforce constraints from <code>package.py</code> or configuration
</section>
<section>
In a recipe:
<pre><code data-trim data-noescape class="python">
class Hdf5(CMakePackage):
requires("%gcc", msg="This package must be built with GCC")
</code></pre>
From configuration:
<pre><code data-trim data-noescape class="YAML">
packages:
hdf5:
require:
- spec: "%gcc"
message: "This package must be built with GCC"
</code></pre>
</section>
<section>
Setting default requirements
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- "+shared +cuda"
</code></pre>
vs.
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- "+shared"
- "+cuda"
</code></pre>
</section>
<section>
Package specific requirements override defaults
<pre><code data-trim data-noescape class="YAML">
packages:
all:
require:
- 'build_type=Debug'
- '%clang'
cmake:
require:
- '%gcc'
</code></pre>
</section>
<section>
Requirements on virtual packages
<pre><code data-trim data-noescape class="YAML">
packages:
mpi:
require:
- 'mvapich2 %gcc'
mvapich2:
require:
- '~cuda'
</code></pre>
</section>
<section>
Strong preferences
<pre><code data-trim data-noescape class="YAML">
packages:
all:
prefer:
- 'build_type=Release'
- '+cuda'
</code></pre>
</section>
<section>
<h2>Hands-on</h2>
<pre><code data-trim data-noescape class="yaml">
# Try to violate this requirement, check the error message
packages:
hdf5:
require:
- spec: "~mpi"
message: "HDF5 must be compiled without MPI"
# Use a strong preference, and do the same
packages:
hdf5:
prefer:
- "~mpi"
# Enforce virtuals in an environment using requirements
</code></pre>
</section>
</section>
<section>
<section>
<h2>How can I constrain a virtual provider in a recipe?</h2>
</section>
<section>
🙁 Bad, clingo can choose to add a node!
<pre><code class="python" data-trim data-noescape>
class Hdf5VolAsync(CMakePackage):
depends_on("mpi")
# openmpi can be used as a "normal" dependency
# clingo can choose to add it or not
depends_on(
"openmpi +thread_multiple",
when="^openmpi@:2"
)
</code></pre>
</section>
<section>
😐 Acceptable, but only for providers
<pre><code class="python" data-trim data-noescape>
class Hdf5VolAsync(CMakePackage):
depends_on("mpi")
# If using openmpi as a provider, needs
# thread multiple support
depends_on(
"openmpi +thread_multiple",
when="^[virtuals=mpi] openmpi@:2"
)
</code></pre>
</section>
<section>
🙂 Good for any type of dependency!
<pre><code class="python" data-trim data-noescape>
class GribUtil(CMakePackage)::
depends_on("ip")
# If ip is at version 4.1 or later, then also
# require precision=d
requires("^ip precision=d", when="^[email protected]:")
</code></pre>
</section>
<section>
<h2>Hands-on</h2>
<pre><code data-trim data-noescape class="bash">
# Try to concretize hdf5-vol-async with different mpis
spack spec hdf5-vol-async ^mvapich2
spack spec hdf5-vol-async ^openmpi
# Edit hdf5-vol-async to use the wrong idiom and repeat
# https://dreampuf.github.io/GraphvizOnline
spack graph -d --color hdf5-vol-async ^mvapich2
</code></pre>
</section>
</section>
<section>
<section>
<h2>How are errors modeled?</h2>
</section>
<section>
<code>clingo</code> is not that helpful on unsat problems
<pre><code data-trim data-noescape data-line-numbers="1-4|4" class="prolog">
node("a").
attribute(P) :- node(P).
:- attribute(P).
</code></pre>
<pre><code data-trim data-noescape class="console">
$ clingo example.lp
clingo version 5.6.2
Reading from example.lp
Solving...
UNSATISFIABLE
</code></pre>
<pre><code data-trim data-noescape class="console">
$ spack spec foo
==> Error: UNSATISFIABLE
</code></pre>
</section>
<section>
Make errors part of a valid solution
<pre><code data-trim data-noescape data-line-numbers="1-4|4" class="prolog">
node("a").
attribute(P) :- node(P).
error("{P} cannot have an attribute!", P) :- attribute(P).
</code></pre>
<pre><code data-trim data-noescape class="console">
$ clingo example.lp
clingo version 5.6.2
Reading from example.lp
Solving...
Answer: 1
node("a") attribute("a") error("{P} cannot have an attribute!","a")
SATISFIABLE
</code></pre>
<pre><code data-trim data-noescape class="console">
$ spack spec foo
==> Error: foo cannot have an attribute!
</code></pre>
</section>
<section>
Highest priority optimization is <em>minimize errors</em>
</section>
<section>
<div>
<img src="dist/images/error-flow-chart.svg" style="background: none; border: 0px">
</div>
</section>
<section>
<pre><code data-trim data-noescape class="console tiny-text">
$ spack spec [email protected] ^[email protected]
==> Error: concretization failed for the following reasons:
1. Cannot select a single "version" for package "cmake"
2. Cannot satisfy 'cmake@:3.17'
3. Cannot satisfy 'cmake@:3.16'
4. Cannot satisfy '[email protected]:'
5. Cannot satisfy '[email protected]'
6. Cannot satisfy '[email protected]:'
required because hdf5 depends on [email protected]: when @1.13:
required because [email protected] ^[email protected] requested explicitly
7. Cannot satisfy '[email protected]'
required because [email protected] ^[email protected] requested explicitly
8. Cannot satisfy '[email protected]:' and '[email protected]
required because [email protected] ^[email protected] requested explicitly
required because hdf5 depends on [email protected]: when @1.13:
required because [email protected] ^[email protected] requested explicitly
9. Cannot satisfy '[email protected]' and '[email protected]:
required because [email protected] ^[email protected] requested explicitly
required because hdf5 depends on [email protected]: when @1.13:
required because [email protected] ^[email protected] requested explicitly
10. Cannot satisfy '[email protected]:' and '[email protected]
required because [email protected] ^[email protected] requested explicitly
required because hdf5 depends on [email protected]:
required because [email protected] ^[email protected] requested explicitly
</code></pre>
</section>
</section>
<!-- OCI build caches -->
<section>
<section>
<h2>How to use OCI build caches?</h2>
<ul>
<li>Learn about build caches</li>
<li>Create container images</li>
<li>GitHub Actions and Packages</li>
</ul>
</section>
<section>
<h2>Follow along</h2>
<ul>
<li><a href="https://spack-tutorial.rtfd.io" target="_blank">https://spack-tutorial.rtfd.io</a></li>
<li>Click <strong>Binary Caches Tutorial</strong></li>
</ul>
</section>
<section>
<div class="asciicast stretch">
<!--
{
"URL": "dist/recordings/1.cast"
}
-->
</div>
</section>
<section>
<div class="asciicast stretch">
<!--
{
"URL": "dist/recordings/2.cast"
}
-->
</div>
</section>
<section>
<h2>Setup GitHub API token</h2>
<a href="https://github.com/settings/tokens/new">https://github.com/settings/tokens/new</a>
</section>
<section data-background="dist/images/github-token.png"></section>
<section>
<div class="asciicast stretch">
<!--
{
"URL": "dist/recordings/3.cast"
}
-->
</div>
</section>
<section>
<h2>Make GitHub Package public</h2>
<a href="https://github.com/users/haampie/packages/container/cscs-tutorial/settings">https://github.com/users/haampie/packages/container/cscs-tutorial/settings</a>
<img src="dist/images/github-public.png" class="stretch" />
</section>
<section>
<h2>Try out the build cache</h2>
<ul>
<li><code>spack install</code> should use it</li>
<li>No GitHub token should be required if public</li>
</ul>
</section>
<section>
<div class="asciicast stretch">
<!--
{
"URL": "dist/recordings/4.cast"
}
-->
</div>
</section>
<section>
<h2>Reuse concretization</h2>
<ul>
<li>The concretizer needs a build cache index</li>
<li>It's a "remote" database</li>
<li>Concretizer warns if not available</li>
</ul>
</section>
<section>
<h2>Reuse concretization</h2>
<ul>
<li>Create index with <pre><code class="shell">$ spack buildcache update-index <name></code></pre></li>
<li>Slow reduction operation</li>
<li>Fetch all individual specs, upload single database</li>
</ul>
</section>