Skip to content

Commit 92d58c8

Browse files
committed
Update website
1 parent 7cd7ebc commit 92d58c8

File tree

5 files changed

+109
-79
lines changed

5 files changed

+109
-79
lines changed

Diff for: 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 = "l4_"
3+
incl = "l5_"
44
## Set `sol=true` to produce output with solutions contained and hints stripts. Otherwise the other way around.
55
sol = true
66
##

Diff for: slide-notebooks/notebooks/l5_1-cpu-parallel.ipynb

+53-38
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@
465465
"outputs": [],
466466
"cell_type": "code",
467467
"source": [
468-
"t_toc = ...\n",
469-
"A_eff = ... # Effective main memory access per iteration [GB]\n",
470-
"t_it = ... # Execution time per iteration [s]\n",
471-
"T_eff = A_eff/t_it # Effective memory throughput [GB/s]"
468+
"t_toc = Base.time() - t_tic\n",
469+
"A_eff = (3*2)/1e9*nx*ny*sizeof(Float64) # Effective main memory access per iteration [GB]\n",
470+
"t_it = t_toc/niter # Execution time per iteration [s]\n",
471+
"T_eff = A_eff/t_it # Effective memory throughput [GB/s]"
472472
],
473473
"metadata": {},
474474
"execution_count": null
@@ -480,7 +480,7 @@
480480
"- Round `T_eff` to the 3rd significant digit.\n",
481481
"\n",
482482
"```julia\n",
483-
"@printf(\"Time = %1.3f sec, ... \\n\", t_toc, ...)\n",
483+
"@printf(\"Time = %1.3f sec, T_eff = %1.2f GB/s (niter = %d)\\n\", t_toc, round(T_eff, sigdigits=3), niter)\n",
484484
"```"
485485
],
486486
"metadata": {
@@ -508,8 +508,10 @@
508508
"outputs": [],
509509
"cell_type": "code",
510510
"source": [
511-
"function Pf_diffusion_2D(;??)\n",
511+
"function Pf_diffusion_2D(;do_check=false)\n",
512+
" if do_check && (iter%ncheck == 0)\n",
512513
" ...\n",
514+
" end\n",
513515
" return\n",
514516
"end"
515517
],
@@ -672,19 +674,19 @@
672674
"outputs": [],
673675
"cell_type": "code",
674676
"source": [
675-
"for iy=??\n",
676-
" for ix=??\n",
677-
" qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ\n",
677+
"for iy=1:ny\n",
678+
" for ix=1:nx-1\n",
679+
" qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*(Pf[ix+1,iy]-Pf[ix,iy]))*_1_θ_dτ\n",
678680
" end\n",
679681
"end\n",
680-
"for iy=??\n",
681-
" for ix=??\n",
682-
" qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ\n",
682+
"for iy=1:ny-1\n",
683+
" for ix=1:nx\n",
684+
" qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*(Pf[ix,iy+1]-Pf[ix,iy]))*_1_θ_dτ\n",
683685
" end\n",
684686
"end\n",
685-
"for iy=??\n",
686-
" for ix=??\n",
687-
" Pf[??] -= ??\n",
687+
"for iy=1:ny\n",
688+
" for ix=1:nx\n",
689+
" Pf[ix,iy] -= ((qDx[ix+1,iy]-qDx[ix,iy])*_dx + (qDy[ix,iy+1]-qDy[ix,iy])*_dy)*_β_dτ\n",
688690
" end\n",
689691
"end"
690692
],
@@ -709,8 +711,8 @@
709711
"outputs": [],
710712
"cell_type": "code",
711713
"source": [
712-
"macro d_xa(A) esc(:( $A[??]-$A[??] )) end\n",
713-
"macro d_ya(A) esc(:( $A[??]-$A[??] )) end"
714+
"macro d_xa(A) esc(:( $A[ix+1,iy]-$A[ix,iy] )) end\n",
715+
"macro d_ya(A) esc(:( $A[ix,iy+1]-$A[ix,iy] )) end"
714716
],
715717
"metadata": {},
716718
"execution_count": null
@@ -726,19 +728,19 @@
726728
"outputs": [],
727729
"cell_type": "code",
728730
"source": [
729-
"for iy=??\n",
730-
" for ix=??\n",
731-
" qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ\n",
731+
"for iy=1:ny\n",
732+
" for ix=1:nx-1\n",
733+
" qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ\n",
732734
" end\n",
733735
"end\n",
734-
"for iy=??\n",
735-
" for ix=??\n",
736-
" qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ\n",
736+
"for iy=1:ny-1\n",
737+
" for ix=1:nx\n",
738+
" qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ\n",
737739
" end\n",
738740
"end\n",
739-
"for iy=??\n",
740-
" for ix=??\n",
741-
" Pf[??] -= ??\n",
741+
"for iy=1:ny\n",
742+
" for ix=1:nx\n",
743+
" Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ\n",
742744
" end\n",
743745
"end"
744746
],
@@ -803,15 +805,28 @@
803805
"outputs": [],
804806
"cell_type": "code",
805807
"source": [
806-
"function compute_flux!(...)\n",
808+
"function compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)\n",
807809
" nx,ny=size(Pf)\n",
808-
" ...\n",
810+
" for iy=1:ny,\n",
811+
" for ix=1:nx-1\n",
812+
" qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ\n",
813+
" end\n",
814+
" end\n",
815+
" for iy=1:ny-1\n",
816+
" for ix=1:nx\n",
817+
" qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ\n",
818+
" end\n",
819+
" end\n",
809820
" return nothing\n",
810821
"end\n",
811822
"\n",
812-
"function update_Pf!(Pf,...)\n",
823+
"function update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)\n",
813824
" nx,ny=size(Pf)\n",
814-
" ...\n",
825+
" for iy=1:ny\n",
826+
" for ix=1:nx\n",
827+
" Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ\n",
828+
" end\n",
829+
" end\n",
815830
" return nothing\n",
816831
"end"
817832
],
@@ -891,9 +906,9 @@
891906
"outputs": [],
892907
"cell_type": "code",
893908
"source": [
894-
"function compute!(Pf,qDx,qDy, ???)\n",
895-
" compute_flux!(...)\n",
896-
" update_Pf!(...)\n",
909+
"function compute!(Pf,qDx,qDy,k_ηf_dx,k_ηf_dy,_1_θ_dτ,_dx,_dy,_β_dτ)\n",
910+
" compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)\n",
911+
" update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)\n",
897912
" return nothing\n",
898913
"end"
899914
],
@@ -911,8 +926,8 @@
911926
"outputs": [],
912927
"cell_type": "code",
913928
"source": [
914-
"t_toc = @belapsed compute!($Pf,$qDx,$qDy,???)\n",
915-
"niter = ???"
929+
"t_toc = @belapsed compute!($Pf,$qDx,$qDy,$k_ηf_dx,$k_ηf_dy,$_1_θ_dτ,$_dx,$_dy,$_β_dτ)\n",
930+
"niter = 1"
916931
],
917932
"metadata": {},
918933
"execution_count": null
@@ -1024,11 +1039,11 @@
10241039
"file_extension": ".jl",
10251040
"mimetype": "application/julia",
10261041
"name": "julia",
1027-
"version": "1.10.5"
1042+
"version": "1.11.0"
10281043
},
10291044
"kernelspec": {
1030-
"name": "julia-1.10",
1031-
"display_name": "Julia 1.10.5",
1045+
"name": "julia-1.11",
1046+
"display_name": "Julia 1.11.0",
10321047
"language": "julia"
10331048
}
10341049
},

Diff for: slide-notebooks/notebooks/l5_2-unit-test.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,11 @@
314314
"file_extension": ".jl",
315315
"mimetype": "application/julia",
316316
"name": "julia",
317-
"version": "1.10.5"
317+
"version": "1.11.0"
318318
},
319319
"kernelspec": {
320-
"name": "julia-1.10",
321-
"display_name": "Julia 1.10.5",
320+
"name": "julia-1.11",
321+
"display_name": "Julia 1.11.0",
322322
"language": "julia"
323323
}
324324
},

Diff for: website/_literate/l5_1-cpu-parallel_web.jl

+50-35
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ md"""
262262
- Compute the elapsed time `t_toc` at the end of the time loop and report:
263263
"""
264264

265-
t_toc = ...
266-
A_eff = ... # Effective main memory access per iteration [GB]
267-
t_it = ... # Execution time per iteration [s]
268-
T_eff = A_eff/t_it # Effective memory throughput [GB/s]
265+
t_toc = Base.time() - t_tic
266+
A_eff = (3*2)/1e9*nx*ny*sizeof(Float64) # Effective main memory access per iteration [GB]
267+
t_it = t_toc/niter # Execution time per iteration [s]
268+
T_eff = A_eff/t_it # Effective memory throughput [GB/s]
269269

270270
#src #########################################################################
271271
#nb # %% A slide [markdown] {"slideshow": {"slide_type": "slide"}}
@@ -274,7 +274,7 @@ md"""
274274
- Round `T_eff` to the 3rd significant digit.
275275
276276
```julia
277-
@printf("Time = %1.3f sec, ... \n", t_toc, ...)
277+
@printf("Time = %1.3f sec, T_eff = %1.2f GB/s (niter = %d)\n", t_toc, round(T_eff, sigdigits=3), niter)
278278
```
279279
"""
280280

@@ -286,8 +286,10 @@ md"""
286286
- Define a `do_check` flag set to `false`
287287
"""
288288

289-
function Pf_diffusion_2D(;??)
289+
function Pf_diffusion_2D(;do_check=false)
290+
if do_check && (iter%ncheck == 0)
290291
...
292+
end
291293
return
292294
end
293295

@@ -363,19 +365,19 @@ md"""
363365
Implement a nested loop, taking car of bounds and staggering.
364366
"""
365367

366-
for iy=??
367-
for ix=??
368-
qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ
368+
for iy=1:ny
369+
for ix=1:nx-1
370+
qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*(Pf[ix+1,iy]-Pf[ix,iy]))*_1_θ_dτ
369371
end
370372
end
371-
for iy=??
372-
for ix=??
373-
qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ
373+
for iy=1:ny-1
374+
for ix=1:nx
375+
qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*(Pf[ix,iy+1]-Pf[ix,iy]))*_1_θ_dτ
374376
end
375377
end
376-
for iy=??
377-
for ix=??
378-
Pf[??] -= ??
378+
for iy=1:ny
379+
for ix=1:nx
380+
Pf[ix,iy] -= ((qDx[ix+1,iy]-qDx[ix,iy])*_dx + (qDy[ix,iy+1]-qDy[ix,iy])*_dy)*_β_dτ
379381
end
380382
end
381383

@@ -387,25 +389,25 @@ We could now use macros to make the code nicer and clearer. Macro expression wil
387389
Let's use macros to replace the derivative implementations
388390
"""
389391

390-
macro d_xa(A) esc(:( $A[??]-$A[??] )) end
391-
macro d_ya(A) esc(:( $A[??]-$A[??] )) end
392+
macro d_xa(A) esc(:( $A[ix+1,iy]-$A[ix,iy] )) end
393+
macro d_ya(A) esc(:( $A[ix,iy+1]-$A[ix,iy] )) end
392394

393395
md"""
394396
And update the code within the iteration loop:
395397
"""
396-
for iy=??
397-
for ix=??
398-
qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ
398+
for iy=1:ny
399+
for ix=1:nx-1
400+
qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ
399401
end
400402
end
401-
for iy=??
402-
for ix=??
403-
qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ
403+
for iy=1:ny-1
404+
for ix=1:nx
405+
qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ
404406
end
405407
end
406-
for iy=??
407-
for ix=??
408-
Pf[??] -= ??
408+
for iy=1:ny
409+
for ix=1:nx
410+
Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ
409411
end
410412
end
411413

@@ -438,15 +440,28 @@ md"""
438440
Create a `compute_flux!()` and `compute_Pf!()` functions that take input and output arrays and needed scalars as argument and return nothing.
439441
"""
440442

441-
function compute_flux!(...)
443+
function compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)
442444
nx,ny=size(Pf)
443-
...
445+
for iy=1:ny,
446+
for ix=1:nx-1
447+
qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ
448+
end
449+
end
450+
for iy=1:ny-1
451+
for ix=1:nx
452+
qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ
453+
end
454+
end
444455
return nothing
445456
end
446457

447-
function update_Pf!(Pf,...)
458+
function update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)
448459
nx,ny=size(Pf)
449-
...
460+
for iy=1:ny
461+
for ix=1:nx
462+
Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ
463+
end
464+
end
450465
return nothing
451466
end
452467

@@ -483,18 +498,18 @@ md"""
483498
The `compute!()` function:
484499
"""
485500

486-
function compute!(Pf,qDx,qDy, ???)
487-
compute_flux!(...)
488-
update_Pf!(...)
501+
function compute!(Pf,qDx,qDy,k_ηf_dx,k_ηf_dy,_1_θ_dτ,_dx,_dy,_β_dτ)
502+
compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)
503+
update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)
489504
return nothing
490505
end
491506

492507
md"""
493508
can then be called using `@belapsed` to return elapsed time for a single iteration, letting `BenchmarkTools` taking car about sampling
494509
"""
495510

496-
t_toc = @belapsed compute!($Pf,$qDx,$qDy,???)
497-
niter = ???
511+
t_toc = @belapsed compute!($Pf,$qDx,$qDy,$k_ηf_dx,$k_ηf_dy,$_1_θ_dτ,$_dx,$_dy,$_β_dτ)
512+
niter = 1
498513

499514
#nb # > 💡 note: Variables need to be interpolated into the function call, thus taking a `$` in front.
500515
#md # \note{Note that variables need to be interpolated into the function call, thus taking a `$` in front.}

Diff for: website/homework.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ hascode = false
1111
| Lect. 2 | 02.10.2024 - 23h59 CET | [Moodle (notebooks)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=1115224), [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=1103813) | For the notebooks submission, submit a folder containing all exercise notebooks from [JupyterHub](https://jhub-let-04-23586.ethz.ch/hub/home). For the commit hash + PR submission, copy the git commit hash (SHA) of the final push on the branch `homework-2` and open a pull request on the `main` branch. Paste both the commit hash and the PR link on Moodle (check [Logistics](/logistics/#submission) for more details on how to set up the GitHub repository).|
1212
| Lect. 3 | 11.10.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=1103821) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-3` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
1313
| Lect. 4 | 18.10.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=1103827) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-4` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
14-
<!-- | Lect. 5 | 25.10.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=966854) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-5` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
15-
| Lect. 6 | 01.11.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=969655) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-6` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
14+
| Lect. 5 | 25.10.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=1103833) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-5` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
15+
<!-- | Lect. 6 | 01.11.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=969655) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-6` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
1616
| Lect. 7 | 08.11.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=972195) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-7` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
1717
| Lect. 8 | 15.11.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=976353) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-8` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. |
1818
| Lect. 9 (first project hand in) | 01.12.2024 - 23h59 CET | [Moodle (commit hash + PR)](https://moodle-app2.let.ethz.ch/mod/assign/view.php?id=981745) | For the submission, copy the git commit hash (SHA) of the final push on the branch `homework-9` and open a pull request on the `main` branch. Paste both the SHA and the PR link on Moodle. Make sure that the project is contained inside the `PorousConvection` folder. |

0 commit comments

Comments
 (0)