-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlecture_03_GPU_computing.jl
More file actions
2653 lines (2179 loc) · 84.6 KB
/
lecture_03_GPU_computing.jl
File metadata and controls
2653 lines (2179 loc) · 84.6 KB
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
### A Pluto.jl notebook ###
# v0.20.18
#> [frontmatter]
#> title = "Lecture 03"
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
#! format: off
return quote
local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el)
el
end
#! format: on
end
# ╔═╡ f695f3c2-9215-11f0-1eb1-fde5e8318217
begin
using PlutoUI, PlutoTeachingTools
using PlutoUI: Slider
PlutoUI.TableOfContents(; depth=4)
end
# ╔═╡ 778871eb-7387-4046-afb2-eefe4bfd453f
begin
using CairoMakie
set_theme!(theme_latexfonts();
fontsize = 16,
Lines = (linewidth = 2,),
markersize = 16)
end
# ╔═╡ 4661f37a-a116-4f40-99fe-cf4314cfeeff
using LinearAlgebra, Random
# ╔═╡ 7379af68-0afd-4e26-b9f5-e239f677657d
using KernelAbstractions, BenchmarkTools
# ╔═╡ 910c0f4a-caa7-4482-ad03-a6224e8df409
using Atomix: @atomic, @atomicswap, @atomicreplace
# ╔═╡ cbdc2dc8-8246-4377-9d12-0bf748d3a158
using GPUArraysCore
# ╔═╡ 918f7bfe-dc80-418c-9ddf-99ff8907ff61
md"""
## Accessing the GPU node
Getting onto the remote server
1. User name `juliaXX`
2. `ssh juliaxx@licca-li-02.rz.uni-augsburg.de`
3. Jump to `ssh licca047`
4. `git clone https://github.com/hpsc-lab/spp2256-software-dev`
5. `cd spp2256-software-dev`
5. `./start_notebook.sh`
You will see something like:
```
On your local machine run
ssh -f -N licca-li-02.rz.uni-augsburg.de -L 1729:localhost:1729
```
And later:
```
┌ Info:
│ Go to http://localhost:1729/?secret=XXXXXX in your browser to start writing ~ have fun!
```
"""
# ╔═╡ ef309337-b906-4f77-9eb7-c373238e051e
md"""
# Accelerated Computing
"""
# ╔═╡ c656f4aa-697f-4a07-b8a4-242218c29a9d
md"""
A GPU has many "lightweight" threads
"""
# ╔═╡ b723a980-8e5c-4e96-9a9b-88e25857b651
md"""
#### CPU die shot
$(RobustLocalResource("https://s3.amazonaws.com/media-p.slid.es/uploads/779853/images/4399827/800px-coffee_lake_die__quad_core___annotated_.png", "quad_core.png"))
"""
# ╔═╡ 1a15dc6e-e190-4b83-89e0-45d62e131930
md"""
#### GPU block-diagram
$(RobustLocalResource("https://devblogs.nvidia.com/parallelforall/wp-content/uploads/2016/04/gp100_block_diagram-1-624x368.png", "p100.png"))
"""
# ╔═╡ 51d23938-fdef-414f-8912-2d9cc5c19dc6
md"""
#### Bottlenecks
$(RobustLocalResource("https://s3.amazonaws.com/media-p.slid.es/uploads/779853/images/4399848/pasted-from-clipboard.png", "gpu_system.png"))
"""
# ╔═╡ af917e4b-d13b-4477-bdda-df10eb0a01c7
md"""
#### Composable infrastructure
##### Core
- GPUCompiler.jl: Takes native Julia code and compiles it directly to GPUs
- GPUArrays.jl: High-level array based common functionality
- KerneAbstractions.jl: Vendor-agnostic kernel programming language
- Adapt.jl: Translate complex structs across the host-device boundary
##### Vendor specific
- CUDA.jl
- AMDGPU.jl
- oneAPI.jl
- Metal.jl
"""
# ╔═╡ 5db16d40-b38b-4f02-bfa5-9c54de107fff
md"""
#### Different layers of abstraction
##### Vendor-specific
```julia
using CUDA
function saxpy!(a,X,Y)
i = (blockIdx().x - 1) * blockDim().x + threadIdx().x
if i <= length(Y)
@inbounds Y[i] = a * X[i] + Y[i]
end
return nothing
end
@cuda threads=32 blocks=cld(length(Y), 32) saxpy!(a, X, Y)
```
##### KernelAbstractions
```julia
using KernelAbstractions
using CUDA
@kernel function saxpy!(a, @Const(X), Y)
I = @index(Global)
@inbounds Y[I] = a * X[I] + Y[I]
end
saxpy!(CUDABackend())(a, X, Y, ndrange=length(Y))
```
##### Array abstractions
```julia
Y .= a .* X .+ Y
```
"""
# ╔═╡ f9d99731-b26f-467b-8e09-215b35da978a
md"""
#### Asynchronous operations
!!! warn
GPU operations are asynchronous with regards to the host! They are **ordered** with respect to each other, but special care must be taken when using Julia's task based programming together with GPU programming.
The JuliaGPU ecosystem **synchronizes** the GPU on access, so when you move data from and to the GPU we wait for all the kernels to finish!
See the exercise "Introduction to KernelAbstractions" for more details on how to measure GPU kernels and performance.
"""
# ╔═╡ 7efdca23-1543-42bb-b9d4-56bc99e0239a
md"""
#### How to use KernelAbstractions
- Use `@kernel function mykernel(args...) end` to write a GPU-style program
- Instantiate kernel for a backend `kernel = mykernel(backend)`
- Backends come from Vendor specific libraries
- `KA.allocate(backend, ...)` to obtain memory
- Launch kernel `kernel(args..., ndrange=...)` while specifying the grid to execute over.
"""
# ╔═╡ 59e7ab7d-57e2-4a5f-9d30-0a569b188b36
TwoColumn(
md"""
```julia
function vadd(a, b, c)
for i in eachindex(c)
c[i] = a[i] + b[i]
end
end
a = rand(N)
b = rand(N)
c = similar(a)
vadd(a, b, c)
```
""",
md"""
```julia
import KernelAbstractions as KA
@kernel function vadd(a, b, c)
i = @index(Global)
c[i] = a[i] + b[i]
end
backend = CUDABackend()
a = KA.allocate(backend, Float32, N)
b = KA.allocate(backend, Float32, N)
c = similar(a)
vadd_kernel = vadd(backend)
vadd_kernel(a, b, c; ndrange=size(c))
```
""")
# ╔═╡ fa761189-630c-405e-88e3-c7eb727a3c45
md"""
!!! note
GPU execution is asynchronous! We will discuss the details in the later GPU lecture. When benchmarking you need to synchronize the device!
```julia
@benchmark begin
vadd_kernel(a, b, c; ndrange=size(c))
KA.synchronize(backend)
end
```
Otherwise you are only measuring the **launch** of the kernel.
"""
# ╔═╡ 87024a8a-2a31-48d7-b601-d7b49956165a
md"""
#### High-level array based programming
Julia and GPUArrays.jl provide support for an efficient GPU programming environment build around array abstractions and higher-order functions.
- **Vocabulary of operations**: `map`, `broadcast`, `scan`, `reduce`, ...
Map naturally onto GPU execution models
- **Compiled to efficient code**: multiple dispatch, specialization
Write generic, reusable applications
- BLAS (matrix-multiply, ...), and other libraries like FFT
"""
# ╔═╡ 6fdf71ca-a0b5-4031-8e03-1d11292bf0c8
md"""
Array types -- **where** memory resides and **how** code is executed.
| | |
| --- | --- |
| `A = Matrix{Float64}(undef, 64, 32)` | CPU |
| `A = CuMatrix{Float64}(undef, 64, 32)` | Nvidia GPU |
| `A = ROCMatrix{Float64}(undef, 64, 32)` | AMD GPU |
!!! info
Data movement is explicit.
"""
# ╔═╡ b9556ad1-0bf8-4cb1-b7aa-86238aefb60b
md"""
### What makes an application portable?
1. Can I **run** it on a different compute architecture
1. Different CPU architectures
2. We live in a mult GPU vendor world
2. Does it **compute** the same thing?
1. Can I develop on one platform and move to another later?
3. Does it achieve the same **performance**?
4. Can I take advantage of platform **specific** capabilities?
"""
# ╔═╡ ea0e9ceb-9aca-4c14-9c42-0da50b2d1e74
md"""
### Adapt.jl
[Adapt.jl](https://github.com/JuliaGPU/Adapt.jl) is a lightweight dependency that you can use to convert complex structures from CPU to GPU.
```julia
using Adapt
adapt(CuArray, ::Adjoint{Array})::Adjoint{CuArray}
```
```julia
struct Model{T<:Number, AT<:AbstractArray{T}}
data::AT
end
Adapt.adapt_structure(to, x::Model) = Model(adapt(to, x.data))
cpu = Model(rand(64, 64));
using CUDA
gpu = adapt(CuArray, cpu)
Model{Float64, CuArray{Float64, 2, CUDA.Mem.DeviceBuffer}}(...)
```
"""
# ╔═╡ 29f82a24-f8d8-408e-bbad-843f6cf52f15
md"""
## Putting it all together
"""
# ╔═╡ 94f1380b-a40a-468d-adbd-c105c08485b6
md"""
!!! note "An old example from Discourse"
[https://discourse.julialang.org/t/types-and-gradients-including-forward-gradient/946](https://discourse.julialang.org/t/types-and-gradients-including-forward-gradient/946)
"""
# ╔═╡ ad35943f-e323-45b1-a474-6274030a22ab
md"""
```julia
using LinearAlgebra
loss(w,b,x,y) = sum(abs2, y - (w*x .+ b)) / size(y,2)
loss∇w(w, b, x, y) = ...
lossdb(w, b, x, y) = ...
function train(w, b, x, y ; lr=.1)
w -= lmul!(lr, loss∇w(w, b, x, y))
b -= lr * lossdb(w, b, x, y)
return w, b
end
n = 100
p = 10
x = randn(n,p)'
y = sum(x[1:5,:]; dims=1) .+ randn(n)'*0.1
w = 0.0001*randn(1,p)
b = 0.0
for i=1:50
w, b = train(w, b, x, y)
end
```
"""
# ╔═╡ 47963ca4-e499-4065-a2cb-f3d8842a5bdc
md"""
How to execute it on the GPU?
"""
# ╔═╡ d6e1d716-d8a2-4448-9270-354184239fec
TwoColumn(md"""
```julia
x = CuArray(x)
y = CuArray(y)
w = CuArray(w)
```
""",
md"""
```julia
x = adapt(backend, x)
y = adapt(backend, y)
w = adapt(backend, w)
```
""")
# ╔═╡ 72b43b54-b7a6-4f1c-a647-7907fe913474
md"""
!!! info "Composability: reuse of libraries"
`loss∇w` & `lossdb` can be implemented with any of the autodiff libraries provided in Julia. AD and GPU accelerations are orthogonal problems.
"""
# ╔═╡ 96aa8dd9-8179-4b06-a496-ad76f04823fb
begin
import CUDA
import Metal
# Work around <https://github.com/JuliaGPU/oneAPI.jl/issues/445>.
ENV["SYCL_PI_LEVEL_ZERO_BATCH_SIZE"] = "1"
import oneAPI
# **sigh** Currently crashes inside Pluto
# import AMDGPU
end;
# ╔═╡ 570a6da5-0658-4500-a6e6-c1e32534f47b
md"""
Choose your own backend:
"""
# ╔═╡ c8ec8997-1009-4c7e-a24d-3945195db964
let
available_backends = KernelAbstractions.Backend[CPU()]
CI = get(ENV, "GITHUB_ACTIONS", "false") == "true"
# Always shows all backend when rendering the notebook on GitHub Actions,
# notebooks will be static anyway.
if CUDA.functional() || CI
push!(available_backends, CUDA.CUDABackend())
end
if oneAPI.functional() || CI
push!(available_backends, oneAPI.oneAPIBackend())
end
if Metal.functional() || CI
push!(available_backends, Metal.MetalBackend())
end
# if AMDGPU.functional() || CI
# push!(available_backends, AMDGPU.ROCBackend())
# end
@bind backend Select(available_backends)
end
# ╔═╡ 7dfb12da-a68c-497b-973f-72cad14be7a4
md"""
The below code implements a custom eigenvalue solver. We are interested in implementing porting it to the GPU.
For a momement let's forget about `GPUArrays` and all the high-level primitives it provides.
"""
# ╔═╡ da0a4612-f532-4bc0-8c84-38c7a8afc127
md"""
```
f(A::MyMatrix) = λ -> 1 + mapreduce((v) -> v^2 / (v - λ) , +, A.v)
f′(A::MyMatrix) = λ -> mapreduce((v) -> v^2 / (v - λ)^2, +, A.v)
function LinearAlgebra.eigmax(A::MyMatrix; tol = eps(2.0), debug = false)
x0 = maximum(A.v) + maximum(A.v)^2
δ = f(A)(x0)/f′(A)(x0)
while abs(δ) > x0 * tol
x0 -= δ
δ = f(A)(x0)/f′(A)(x0)
debug && println("x = $x0, δ = $δ") # Debugging
end
x0
end
```
"""
# ╔═╡ a40309cb-f5c1-4a51-8a8a-ffc33b07cf10
question_box(md"""
1. What fundamental operations do we need to implement?
2. Is there a synchronization point within this code?
""")
# ╔═╡ ce193fd6-637b-436f-9656-17397b788ddc
hint(md"""
1. `maximum(v)` can also be written as `reduce(max, v, init=typemin(eltype(v)))`
2. `reduce(op, v)` can also be written as `mapreduce(identity, op, f)`
So the only operation we need to implement is a `mapreduce`!
Yes, there are several synchronization points, most notably both `f` and `f′` have to wait for the GPU kernel to finish to return a scalar GPU value. An interesting optimization might be to better pipeline this code and try to avoid a bubble between `f` and `f′`. Or perhaps write a fully custom kernel!
""")
# ╔═╡ 961aac99-5370-416e-b4cd-40e8234de32b
md"""
We can only communicate with the GPU through Global Memory. A GPU kernel does not return anything. Thus we allocate a single "value" storage array.
!!! note "Shared Virtual Memory / Unified Virtual Memory"
SVM/UVM make memory on the GPU/CPU mutually accesibly, we could thus not use an array, but perhaps a `RefValue`, though this is not portable and would mean we miss the implicit syncronization semantics.
For our custom eigenvalue solver we need `mapreduce`, but for now let's just implement a non-generic `sum`.
"""
# ╔═╡ 4406606f-8098-4e32-8c57-f9bf698a7706
@kernel function naive_sum(val, data)
I = @index(Global)
x = data[I]
val[1] += x
end
# ╔═╡ ad9430ac-dcb6-4d08-8b26-bd0275ca5f46
data = KernelAbstractions.ones(backend, Int, 1024^2);
# ╔═╡ 41cf381c-485a-4ebf-b06b-d8be83d60e6f
sum(data)
# ╔═╡ b3ef6ecf-1530-4b30-85fd-f3f5790b646b
let
x = KernelAbstractions.zeros(backend, eltype(data), 1)
naive_sum(backend)(x, data, ndrange=length(data))
Array(x)[1]
end
# ╔═╡ 14085825-4990-4251-8810-aa05d96bead0
md"""
!!! note "Data-race"
This looks similar to our issues from earlier! Data races galore!
Let's use Atomix avoid these issues.
"""
# ╔═╡ b00d9c81-6584-4d47-9b0c-d7e2d4df901b
@kernel function naive_atomic_sum(val, data)
I = @index(Global)
x = data[I]
@atomic val[1] += x
end
# ╔═╡ 61ceb3fc-c617-4ce8-8902-a8767187d1b2
let
x = KernelAbstractions.zeros(backend, eltype(data), 1) # oops I used similar here...
naive_atomic_sum(backend)(x, data, ndrange=length(data))
Array(x)[1]
end
# ╔═╡ b10c2076-3c6a-4fa6-a9e3-0b891ecfaf1c
let
x = KernelAbstractions.zeros(backend, eltype(data), 1)
@benchmark begin
naive_atomic_sum($backend)($x, data, ndrange=length(data))
KernelAbstractions.synchronize($backend)
end
end
# ╔═╡ 786a2a6b-4b70-449b-b503-2bf27be05501
@benchmark sum(data)
# ╔═╡ 8478d7f6-c3e0-404c-87ef-a7b6792dfb5b
if backend isa CUDA.CUDABackend
CUDA.@profile sum(data)
end
# ╔═╡ 0f15901f-0825-47d1-8d11-0dc1d2d55119
md"""
Currently we have a big-bottle neck. The atomic summation on the global data!
KernelAbstraction provides a `@localmem` region that implements a memory region that is local to a work-group! So we can load all the data in parallel, then sum it up, and perform much fewer atomic stores.
"""
# ╔═╡ 6ce71f49-b55b-4102-8b27-6855ae1f1b11
@kernel function naive_shmem_sum(val, data::AbstractArray{T}) where T
I = @index(Global)
i = @index(Local)
N = @uniform prod(@groupsize())
tile = @localmem T (N,)
tile[i] = data[I]
@synchronize
if i == 1
acc = tile[1]
for i in 2:N
acc += tile[i]
end
@atomic val[1] += acc
end
end
# ╔═╡ c59aec82-53de-44b7-b32d-da810dff6e7b
let
x = KernelAbstractions.zeros(backend, eltype(data), 1)
naive_shmem_sum(backend, 64)(x, data, ndrange=length(data))
Array(x)[1]
end
# ╔═╡ fb6a460a-9bb0-408f-affa-f8db395b584e
let
x = KernelAbstractions.zeros(backend, eltype(data), 1)
@benchmark begin
naive_shmem_sum($backend, 64)($x, data, ndrange=length(data))
KernelAbstractions.synchronize($backend)
end
end
# ╔═╡ 3f9415e3-63a9-425b-ab3a-913bcbe29c73
md"""
!!! info
There are improvements we can do on this algorithm! As an example one thread is doing all the "sum" work per compute-group. We probably want to share that work. In CUDA there are also shuffle operations that can be used instead of the `localmem`.
"""
# ╔═╡ 6b73a14f-9003-4b7c-bee3-3780f2e9c517
@kernel function naive_shmem_mapsum(val, data::AbstractArray{T}, f::F) where {T, F}
I = @index(Global)
i = @index(Local)
N = @uniform prod(@groupsize())
tile = @localmem T (N,)
tile[i] = f(data[I])
@synchronize
if i == 1
acc = tile[1]
for i in 2:N
acc += tile[i]
end
@atomic val[1] += acc
end
end
# ╔═╡ 7383854f-f450-4fd5-b887-147a80c7c141
function my_mapsum(f, data)
backend = get_backend(data)
x = KernelAbstractions.zeros(backend, eltype(data), 1)
naive_shmem_mapsum(backend, 64)(x, data, f, ndrange=length(data))
GPUArraysCore.@allowscalar x[1]
end
# ╔═╡ 3164fb87-abbf-43c2-b154-ec22a5e6a757
my_mapsum(x->x^2, data)
# ╔═╡ fde79fb3-ab64-4b9c-93a5-31cbf58cebb4
mapreduce(x->x^2, +, data)
# ╔═╡ 0aff06d4-b207-432f-83e3-e9d8b97ee70c
@benchmark my_mapsum(x->x^2, $data)
# ╔═╡ 9ff55bd8-ab93-442b-af87-1c1765b8b453
@benchmark mapreduce(x->x^2, +, $data)
# ╔═╡ a9379ce2-b2ab-4e3c-b4b7-8df15e98226c
backend
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
PlutoTeachingTools = "661c6b06-c737-4d37-b85c-46df65de6f69"
PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
[compat]
Atomix = "~1.1.2"
BenchmarkTools = "~1.6.0"
CUDA = "~5.8.3"
CairoMakie = "~0.15.6"
GPUArraysCore = "~0.2.0"
KernelAbstractions = "~0.9.38"
Metal = "~1.8.0"
PlutoTeachingTools = "~0.4.5"
PlutoUI = "~0.7.71"
oneAPI = "~2.2.0"
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.11.6"
manifest_format = "2.0"
project_hash = "aab1f43101fc2c1027473c34c29a3eaa8322db49"
[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
git-tree-sha1 = "d92ad398961a3ed262d8bf04a1a2b8340f915fef"
uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c"
version = "1.5.0"
weakdeps = ["ChainRulesCore", "Test"]
[deps.AbstractFFTs.extensions]
AbstractFFTsChainRulesCoreExt = "ChainRulesCore"
AbstractFFTsTestExt = "Test"
[[deps.AbstractPlutoDingetjes]]
deps = ["Pkg"]
git-tree-sha1 = "6e1d2a35f2f90a4bc7c2ed98079b2ba09c35b83a"
uuid = "6e696c72-6542-2067-7265-42206c756150"
version = "1.3.2"
[[deps.AbstractTrees]]
git-tree-sha1 = "2d9c9a55f9c93e8887ad391fbae72f8ef55e1177"
uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
version = "0.4.5"
[[deps.Adapt]]
deps = ["LinearAlgebra", "Requires"]
git-tree-sha1 = "f7817e2e585aa6d924fd714df1e2a84be7896c60"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "4.3.0"
weakdeps = ["SparseArrays", "StaticArrays"]
[deps.Adapt.extensions]
AdaptSparseArraysExt = "SparseArrays"
AdaptStaticArraysExt = "StaticArrays"
[[deps.AdaptivePredicates]]
git-tree-sha1 = "7e651ea8d262d2d74ce75fdf47c4d63c07dba7a6"
uuid = "35492f91-a3bd-45ad-95db-fcad7dcfedb7"
version = "1.2.0"
[[deps.AliasTables]]
deps = ["PtrArrays", "Random"]
git-tree-sha1 = "9876e1e164b144ca45e9e3198d0b689cadfed9ff"
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
version = "1.1.3"
[[deps.Animations]]
deps = ["Colors"]
git-tree-sha1 = "e092fa223bf66a3c41f9c022bd074d916dc303e7"
uuid = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
version = "0.4.2"
[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.2"
[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
version = "1.11.0"
[[deps.Atomix]]
deps = ["UnsafeAtomics"]
git-tree-sha1 = "29bb0eb6f578a587a49da16564705968667f5fa8"
uuid = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
version = "1.1.2"
[deps.Atomix.extensions]
AtomixCUDAExt = "CUDA"
AtomixMetalExt = "Metal"
AtomixOpenCLExt = "OpenCL"
AtomixoneAPIExt = "oneAPI"
[deps.Atomix.weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
OpenCL = "08131aa3-fb12-5dee-8b74-c09406e224a2"
oneAPI = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
[[deps.Automa]]
deps = ["PrecompileTools", "SIMD", "TranscodingStreams"]
git-tree-sha1 = "a8f503e8e1a5f583fbef15a8440c8c7e32185df2"
uuid = "67c07d97-cdcb-5c2c-af73-a7f9c32a568b"
version = "1.1.0"
[[deps.AxisAlgorithms]]
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
git-tree-sha1 = "01b8ccb13d68535d73d2b0c23e39bd23155fb712"
uuid = "13072b0f-2c55-5437-9ae7-d433b7a33950"
version = "1.1.0"
[[deps.AxisArrays]]
deps = ["Dates", "IntervalSets", "IterTools", "RangeArrays"]
git-tree-sha1 = "16351be62963a67ac4083f748fdb3cca58bfd52f"
uuid = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
version = "0.4.7"
[[deps.BFloat16s]]
deps = ["LinearAlgebra", "Printf", "Random"]
git-tree-sha1 = "3b642331600250f592719140c60cf12372b82d66"
uuid = "ab4f0b2a-ad5b-11e8-123f-65d77653426b"
version = "0.5.1"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
version = "1.11.0"
[[deps.BaseDirs]]
git-tree-sha1 = "bca794632b8a9bbe159d56bf9e31c422671b35e0"
uuid = "18cc8868-cbac-4acf-b575-c8ff214dc66f"
version = "1.3.2"
[[deps.BenchmarkTools]]
deps = ["Compat", "JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"]
git-tree-sha1 = "e38fbc49a620f5d0b660d7f543db1009fe0f8336"
uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
version = "1.6.0"
[[deps.Bzip2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "1b96ea4a01afe0ea4090c5c8039690672dd13f2e"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.9+0"
[[deps.CEnum]]
git-tree-sha1 = "389ad5c84de1ae7cf0e28e381131c98ea87d54fc"
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
version = "0.5.0"
[[deps.CRC32c]]
uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
version = "1.11.0"
[[deps.CRlibm]]
deps = ["CRlibm_jll"]
git-tree-sha1 = "66188d9d103b92b6cd705214242e27f5737a1e5e"
uuid = "96374032-68de-5a5b-8d9e-752f78720389"
version = "1.0.2"
[[deps.CRlibm_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e329286945d0cfc04456972ea732551869af1cfc"
uuid = "4e9b3aee-d8a1-5a3d-ad8b-7d824db253f0"
version = "1.0.1+0"
[[deps.CUDA]]
deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Compiler_jll", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "Crayons", "DataFrames", "ExprTools", "GPUArrays", "GPUCompiler", "GPUToolbox", "KernelAbstractions", "LLVM", "LLVMLoopInfo", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "NVTX", "Preferences", "PrettyTables", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "StaticArrays", "Statistics", "demumble_jll"]
git-tree-sha1 = "27f69b3923e58730f0a71396070e9114fc0bba40"
uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
version = "5.8.3"
[deps.CUDA.extensions]
ChainRulesCoreExt = "ChainRulesCore"
EnzymeCoreExt = "EnzymeCore"
SparseMatricesCSRExt = "SparseMatricesCSR"
SpecialFunctionsExt = "SpecialFunctions"
[deps.CUDA.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
[[deps.CUDA_Compiler_jll]]
deps = ["Artifacts", "CUDA_Driver_jll", "CUDA_Runtime_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
git-tree-sha1 = "8c4f340dd6501a93c4b99b690797772e4a203099"
uuid = "d1e2174e-dfdc-576e-b43e-73b79eb1aca8"
version = "0.2.1+0"
[[deps.CUDA_Driver_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e6a1d9f5518122c186fd27786b61d2053cfa1b0c"
uuid = "4ee394cb-3365-5eb0-8335-949819d2adfc"
version = "13.0.1+0"
[[deps.CUDA_Runtime_Discovery]]
deps = ["Libdl"]
git-tree-sha1 = "f9a521f52d236fe49f1028d69e549e7f2644bb72"
uuid = "1af6417a-86b4-443c-805f-a4643ffb695f"
version = "1.0.0"
[[deps.CUDA_Runtime_jll]]
deps = ["Artifacts", "CUDA_Driver_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "TOML"]
git-tree-sha1 = "e24c6de116c0735c37e83b8bc05ed60d4d359693"
uuid = "76a88914-d11a-5bdc-97e0-2f5a05c973a2"
version = "0.19.1+0"
[[deps.Cairo]]
deps = ["Cairo_jll", "Colors", "Glib_jll", "Graphics", "Libdl", "Pango_jll"]
git-tree-sha1 = "71aa551c5c33f1a4415867fe06b7844faadb0ae9"
uuid = "159f3aea-2a34-519c-b102-8c37f9878175"
version = "1.1.1"
[[deps.CairoMakie]]
deps = ["CRC32c", "Cairo", "Cairo_jll", "Colors", "FileIO", "FreeType", "GeometryBasics", "LinearAlgebra", "Makie", "PrecompileTools"]
git-tree-sha1 = "f8caabc5a1c1fb88bcbf9bc4078e5656a477afd0"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
version = "0.15.6"
[[deps.Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
git-tree-sha1 = "fde3bf89aead2e723284a8ff9cdf5b551ed700e8"
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
version = "1.18.5+0"
[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra"]
git-tree-sha1 = "e4c6a16e77171a5f5e25e9646617ab1c276c5607"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.26.0"
weakdeps = ["SparseArrays"]
[deps.ChainRulesCore.extensions]
ChainRulesCoreSparseArraysExt = "SparseArrays"
[[deps.CodecBzip2]]
deps = ["Bzip2_jll", "TranscodingStreams"]
git-tree-sha1 = "84990fa864b7f2b4901901ca12736e45ee79068c"
uuid = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
version = "0.8.5"
[[deps.ColorBrewer]]
deps = ["Colors", "JSON"]
git-tree-sha1 = "e771a63cc8b539eca78c85b0cabd9233d6c8f06f"
uuid = "a2cac450-b92f-5266-8821-25eda20663c8"
version = "0.4.1"
[[deps.ColorSchemes]]
deps = ["ColorTypes", "ColorVectorSpace", "Colors", "FixedPointNumbers", "PrecompileTools", "Random"]
git-tree-sha1 = "a656525c8b46aa6a1c76891552ed5381bb32ae7b"
uuid = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
version = "3.30.0"
[[deps.ColorTypes]]
deps = ["FixedPointNumbers", "Random"]
git-tree-sha1 = "67e11ee83a43eb71ddc950302c53bf33f0690dfe"
uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
version = "0.12.1"
weakdeps = ["StyledStrings"]
[deps.ColorTypes.extensions]
StyledStringsExt = "StyledStrings"
[[deps.ColorVectorSpace]]
deps = ["ColorTypes", "FixedPointNumbers", "LinearAlgebra", "Requires", "Statistics", "TensorCore"]
git-tree-sha1 = "8b3b6f87ce8f65a2b4f857528fd8d70086cd72b1"
uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4"
version = "0.11.0"
weakdeps = ["SpecialFunctions"]
[deps.ColorVectorSpace.extensions]
SpecialFunctionsExt = "SpecialFunctions"
[[deps.Colors]]
deps = ["ColorTypes", "FixedPointNumbers", "Reexport"]
git-tree-sha1 = "37ea44092930b1811e666c3bc38065d7d87fcc74"
uuid = "5ae59095-9a9b-59fe-a467-6f913c188581"
version = "0.13.1"
[[deps.Compat]]
deps = ["TOML", "UUIDs"]
git-tree-sha1 = "0037835448781bb46feb39866934e243886d756a"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "4.18.0"
weakdeps = ["Dates", "LinearAlgebra"]
[deps.Compat.extensions]
CompatLinearAlgebraExt = "LinearAlgebra"
[[deps.CompilerSupportLibraries_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
version = "1.1.1+0"
[[deps.ComputePipeline]]
deps = ["Observables", "Preferences"]
git-tree-sha1 = "cb1299fee09da21e65ec88c1ff3a259f8d0b5802"
uuid = "95dc2771-c249-4cd0-9c9f-1f3b4330693c"
version = "0.1.4"
[[deps.ConstructionBase]]
git-tree-sha1 = "b4b092499347b18a015186eae3042f72267106cb"
uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
version = "1.6.0"
weakdeps = ["IntervalSets", "LinearAlgebra", "StaticArrays"]
[deps.ConstructionBase.extensions]
ConstructionBaseIntervalSetsExt = "IntervalSets"
ConstructionBaseLinearAlgebraExt = "LinearAlgebra"
ConstructionBaseStaticArraysExt = "StaticArrays"
[[deps.Contour]]
git-tree-sha1 = "439e35b0b36e2e5881738abc8857bd92ad6ff9a8"
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
version = "0.6.3"
[[deps.Crayons]]
git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15"
uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
version = "4.1.1"
[[deps.DataAPI]]
git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.16.0"
[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "c967271c27a95160e30432e011b58f42cd7501b5"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.8.0"
[[deps.DataStructures]]
deps = ["OrderedCollections"]
git-tree-sha1 = "6c72198e6a101cccdd4c9731d3985e904ba26037"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.19.1"
[[deps.DataValueInterfaces]]
git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6"
uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464"
version = "1.0.0"
[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
version = "1.11.0"
[[deps.DelaunayTriangulation]]
deps = ["AdaptivePredicates", "EnumX", "ExactPredicates", "Random"]
git-tree-sha1 = "5620ff4ee0084a6ab7097a27ba0c19290200b037"
uuid = "927a84f5-c5f4-47a5-9785-b46e178433df"
version = "1.6.4"
[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
version = "1.11.0"
[[deps.Distributions]]
deps = ["AliasTables", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns"]
git-tree-sha1 = "3e6d038b77f22791b8e3472b7c633acea1ecac06"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.120"
[deps.Distributions.extensions]
DistributionsChainRulesCoreExt = "ChainRulesCore"
DistributionsDensityInterfaceExt = "DensityInterface"
DistributionsTestExt = "Test"
[deps.Distributions.weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
DensityInterface = "b429d917-457f-4dbc-8f4c-0cc954292b1d"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[[deps.DocStringExtensions]]
git-tree-sha1 = "7442a5dfe1ebb773c29cc2962a8980f47221d76c"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.9.5"
[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]