Skip to content

Commit e70f6e8

Browse files
committed
Deploy solutions
1 parent 5ba6535 commit e70f6e8

File tree

7 files changed

+46
-44
lines changed

7 files changed

+46
-44
lines changed

slide-notebooks/deploy_notebooks.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Literate
22
## include Literate scripts starting with following 3 letters in the deploy
3-
incl = "l5_"
3+
incl = "l9_"
44
## Set `sol=true` to produce output with solutions contained and hints stripts. Otherwise the other way around.
55
sol = true
66
##

slide-notebooks/notebooks/l7_1-xpu.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@
427427
"cell_type": "code",
428428
"source": [
429429
"@parallel function update_Pf!(Pf, qDx, qDy, _dx, _dy, _β_dτ)\n",
430-
" Pf = ...\n",
430+
" @all(Pf) = @all(Pf) - (@d_xa(qDx) * _dx + @d_ya(qDy) * _dy) * _β_dτ\n",
431431
" return nothing\n",
432432
"end"
433433
],

slide-notebooks/notebooks/l8_1-multi-xpu.ipynb

+20-19
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@
339339
"CL[2:end-1] .= CL[2:end-1] .+ dt*D*diff(diff(CL)/dx)/dx\n",
340340
"CR[2:end-1] .= CR[2:end-1] .+ dt*D*diff(diff(CR)/dx)/dx\n",
341341
"# Update boundaries (MPI)\n",
342-
"CL[end] = ...\n",
343-
"CR[1] = ...\n",
342+
"CL[end] = CR[2]\n",
343+
"CR[1] = CL[end-1]\n",
344344
"# Global picture\n",
345345
"C .= [CL[1:end-1]; CR[2:end]]\n",
346346
"```"
@@ -385,8 +385,8 @@
385385
"\n",
386386
"```julia\n",
387387
"# Update boundaries (MPI)\n",
388-
"CL[end] = ...\n",
389-
"CR[1] = ...\n",
388+
"CL[end] = CR[2]\n",
389+
"CR[1] = CL[end-1]\n",
390390
"```\n",
391391
"\n",
392392
"in order make the code work properly and run it again. Note what has changed in the visualisation."
@@ -422,7 +422,8 @@
422422
" C[2:end-1,ip] .= C[2:end-1,ip] .+ dt*D*diff(diff(C[:,ip])/dxg)/dxg\n",
423423
"end\n",
424424
"for ip = 1:np-1 # update boundaries\n",
425-
" # ...\n",
425+
" C[end,ip ] = C[ 2,ip+1]\n",
426+
" C[ 1,ip+1] = C[end-1,ip ]\n",
426427
"end\n",
427428
"for ip = 1:np # global picture\n",
428429
" i1 = 1 + (ip-1)*(nx-2)\n",
@@ -472,7 +473,7 @@
472473
"# Initial condition\n",
473474
"for ip = 1:np\n",
474475
" for ix = 1:nx\n",
475-
" x[ix,ip] = ...\n",
476+
" x[ix,ip] = ( (ip-1)*(nx-2) + (ix-0.5) )*dxg - 0.5*lx\n",
476477
" C[ix,ip] = exp(-x[ix,ip]^2)\n",
477478
" end\n",
478479
" i1 = 1 + (ip-1)*(nx-2)\n",
@@ -596,19 +597,19 @@
596597
"@views function update_halo!(A, neighbors_x, comm)\n",
597598
" # Send to / receive from neighbour 1 (\"left neighbor\")\n",
598599
" if neighbors_x[1] != MPI.PROC_NULL\n",
599-
" sendbuf = ??\n",
600-
" recvbuf = ??\n",
601-
" MPI.Send(??, neighbors_x[?], 0, comm)\n",
602-
" MPI.Recv!(??, neighbors_x[?], 1, comm)\n",
603-
" A[1] = ??\n",
600+
" sendbuf = A[2]\n",
601+
" recvbuf = zeros(1)\n",
602+
" MPI.Send(sendbuf, neighbors_x[1], 0, comm)\n",
603+
" MPI.Recv!(recvbuf, neighbors_x[1], 1, comm)\n",
604+
" A[1] = recvbuf[1]\n",
604605
" end\n",
605606
" # Send to / receive from neighbour 2 (\"right neighbor\")\n",
606607
" if neighbors_x[2] != MPI.PROC_NULL\n",
607-
" sendbuf = ??\n",
608-
" recvbuf = ??\n",
609-
" MPI.Recv!(??, neighbors_x[?], 0, comm)\n",
610-
" MPI.Send(??, neighbors_x[?], 1, comm)\n",
611-
" A[end] = ??\n",
608+
" sendbuf = A[end-1]\n",
609+
" recvbuf = zeros(1)\n",
610+
" MPI.Recv!(recvbuf, neighbors_x[2], 0, comm)\n",
611+
" MPI.Send(sendbuf, neighbors_x[2], 1, comm)\n",
612+
" A[end] = recvbuf[1]\n",
612613
" end\n",
613614
" return\n",
614615
"end\n",
@@ -1077,11 +1078,11 @@
10771078
"file_extension": ".jl",
10781079
"mimetype": "application/julia",
10791080
"name": "julia",
1080-
"version": "1.10.5"
1081+
"version": "1.11.1"
10811082
},
10821083
"kernelspec": {
1083-
"name": "julia-1.10",
1084-
"display_name": "Julia 1.10.5",
1084+
"name": "julia-1.11",
1085+
"display_name": "Julia 1.11.1",
10851086
"language": "julia"
10861087
}
10871088
},

slide-notebooks/notebooks/l9_1-projects.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,11 @@
469469
"file_extension": ".jl",
470470
"mimetype": "application/julia",
471471
"name": "julia",
472-
"version": "1.10.5"
472+
"version": "1.11.1"
473473
},
474474
"kernelspec": {
475-
"name": "julia-1.10",
476-
"display_name": "Julia 1.10.5",
475+
"name": "julia-1.11",
476+
"display_name": "Julia 1.11.1",
477477
"language": "julia"
478478
}
479479
},

slide-notebooks/notebooks/l9_2-doc.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@
324324
"file_extension": ".jl",
325325
"mimetype": "application/julia",
326326
"name": "julia",
327-
"version": "1.10.5"
327+
"version": "1.11.1"
328328
},
329329
"kernelspec": {
330-
"name": "julia-1.10",
331-
"display_name": "Julia 1.10.5",
330+
"name": "julia-1.11",
331+
"display_name": "Julia 1.11.1",
332332
"language": "julia"
333333
}
334334
},

website/_literate/l7_1-xpu_web.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Note that currently the shorthand `-=` notation is not supported and we need to
231231
By analogy, update `update_Pf!`.
232232
"""
233233
@parallel function update_Pf!(Pf, qDx, qDy, _dx, _dy, _β_dτ)
234-
Pf = ...
234+
@all(Pf) = @all(Pf) - (@d_xa(qDx) * _dx + @d_ya(qDy) * _dy) * _β_dτ
235235
return nothing
236236
end
237237

website/_literate/l8_1-multi-xpu_web.jl

+17-16
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ The idea of this fake parallelisation approach is the following:
182182
CL[2:end-1] .= CL[2:end-1] .+ dt*D*diff(diff(CL)/dx)/dx
183183
CR[2:end-1] .= CR[2:end-1] .+ dt*D*diff(diff(CR)/dx)/dx
184184
# Update boundaries (MPI)
185-
CL[end] = ...
186-
CR[1] = ...
185+
CL[end] = CR[2]
186+
CR[1] = CL[end-1]
187187
# Global picture
188188
C .= [CL[1:end-1]; CR[2:end]]
189189
```
@@ -209,8 +209,8 @@ Then, add the required boundary update:
209209
210210
```julia
211211
# Update boundaries (MPI)
212-
CL[end] = ...
213-
CR[1] = ...
212+
CL[end] = CR[2]
213+
CR[1] = CL[end-1]
214214
```
215215
216216
in order make the code work properly and run it again. Note what has changed in the visualisation.
@@ -234,7 +234,8 @@ for ip = 1:np # compute physics locally
234234
C[2:end-1,ip] .= C[2:end-1,ip] .+ dt*D*diff(diff(C[:,ip])/dxg)/dxg
235235
end
236236
for ip = 1:np-1 # update boundaries
237-
# ...
237+
C[end,ip ] = C[ 2,ip+1]
238+
C[ 1,ip+1] = C[end-1,ip ]
238239
end
239240
for ip = 1:np # global picture
240241
i1 = 1 + (ip-1)*(nx-2)
@@ -266,7 +267,7 @@ md"""
266267
# Initial condition
267268
for ip = 1:np
268269
for ix = 1:nx
269-
x[ix,ip] = ...
270+
x[ix,ip] = ( (ip-1)*(nx-2) + (ix-0.5) )*dxg - 0.5*lx
270271
C[ix,ip] = exp(-x[ix,ip]^2)
271272
end
272273
i1 = 1 + (ip-1)*(nx-2)
@@ -351,19 +352,19 @@ Then, we need to (2.) implement a boundary update routine, which can have the fo
351352
@views function update_halo!(A, neighbors_x, comm)
352353
# Send to / receive from neighbour 1 ("left neighbor")
353354
if neighbors_x[1] != MPI.PROC_NULL
354-
sendbuf = ??
355-
recvbuf = ??
356-
MPI.Send(??, neighbors_x[?], 0, comm)
357-
MPI.Recv!(??, neighbors_x[?], 1, comm)
358-
A[1] = ??
355+
sendbuf = A[2]
356+
recvbuf = zeros(1)
357+
MPI.Send(sendbuf, neighbors_x[1], 0, comm)
358+
MPI.Recv!(recvbuf, neighbors_x[1], 1, comm)
359+
A[1] = recvbuf[1]
359360
end
360361
# Send to / receive from neighbour 2 ("right neighbor")
361362
if neighbors_x[2] != MPI.PROC_NULL
362-
sendbuf = ??
363-
recvbuf = ??
364-
MPI.Recv!(??, neighbors_x[?], 0, comm)
365-
MPI.Send(??, neighbors_x[?], 1, comm)
366-
A[end] = ??
363+
sendbuf = A[end-1]
364+
recvbuf = zeros(1)
365+
MPI.Recv!(recvbuf, neighbors_x[2], 0, comm)
366+
MPI.Send(sendbuf, neighbors_x[2], 1, comm)
367+
A[end] = recvbuf[1]
367368
end
368369
return
369370
end

0 commit comments

Comments
 (0)