Skip to content

Commit

Permalink
Update website
Browse files Browse the repository at this point in the history
  • Loading branch information
utkinis committed Oct 15, 2024
1 parent 7cd7ebc commit 92d58c8
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 79 deletions.
2 changes: 1 addition & 1 deletion slide-notebooks/deploy_notebooks.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Literate
## include Literate scripts starting with following 3 letters in the deploy
incl = "l4_"
incl = "l5_"
## Set `sol=true` to produce output with solutions contained and hints stripts. Otherwise the other way around.
sol = true
##
Expand Down
91 changes: 53 additions & 38 deletions slide-notebooks/notebooks/l5_1-cpu-parallel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@
"outputs": [],
"cell_type": "code",
"source": [
"t_toc = ...\n",
"A_eff = ... # Effective main memory access per iteration [GB]\n",
"t_it = ... # Execution time per iteration [s]\n",
"T_eff = A_eff/t_it # Effective memory throughput [GB/s]"
"t_toc = Base.time() - t_tic\n",
"A_eff = (3*2)/1e9*nx*ny*sizeof(Float64) # Effective main memory access per iteration [GB]\n",
"t_it = t_toc/niter # Execution time per iteration [s]\n",
"T_eff = A_eff/t_it # Effective memory throughput [GB/s]"
],
"metadata": {},
"execution_count": null
Expand All @@ -480,7 +480,7 @@
"- Round `T_eff` to the 3rd significant digit.\n",
"\n",
"```julia\n",
"@printf(\"Time = %1.3f sec, ... \\n\", t_toc, ...)\n",
"@printf(\"Time = %1.3f sec, T_eff = %1.2f GB/s (niter = %d)\\n\", t_toc, round(T_eff, sigdigits=3), niter)\n",
"```"
],
"metadata": {
Expand Down Expand Up @@ -508,8 +508,10 @@
"outputs": [],
"cell_type": "code",
"source": [
"function Pf_diffusion_2D(;??)\n",
"function Pf_diffusion_2D(;do_check=false)\n",
" if do_check && (iter%ncheck == 0)\n",
" ...\n",
" end\n",
" return\n",
"end"
],
Expand Down Expand Up @@ -672,19 +674,19 @@
"outputs": [],
"cell_type": "code",
"source": [
"for iy=??\n",
" for ix=??\n",
" qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ\n",
"for iy=1:ny\n",
" for ix=1:nx-1\n",
" qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*(Pf[ix+1,iy]-Pf[ix,iy]))*_1_θ_dτ\n",
" end\n",
"end\n",
"for iy=??\n",
" for ix=??\n",
" qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ\n",
"for iy=1:ny-1\n",
" for ix=1:nx\n",
" qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*(Pf[ix,iy+1]-Pf[ix,iy]))*_1_θ_dτ\n",
" end\n",
"end\n",
"for iy=??\n",
" for ix=??\n",
" Pf[??] -= ??\n",
"for iy=1:ny\n",
" for ix=1:nx\n",
" Pf[ix,iy] -= ((qDx[ix+1,iy]-qDx[ix,iy])*_dx + (qDy[ix,iy+1]-qDy[ix,iy])*_dy)*_β_dτ\n",
" end\n",
"end"
],
Expand All @@ -709,8 +711,8 @@
"outputs": [],
"cell_type": "code",
"source": [
"macro d_xa(A) esc(:( $A[??]-$A[??] )) end\n",
"macro d_ya(A) esc(:( $A[??]-$A[??] )) end"
"macro d_xa(A) esc(:( $A[ix+1,iy]-$A[ix,iy] )) end\n",
"macro d_ya(A) esc(:( $A[ix,iy+1]-$A[ix,iy] )) end"
],
"metadata": {},
"execution_count": null
Expand All @@ -726,19 +728,19 @@
"outputs": [],
"cell_type": "code",
"source": [
"for iy=??\n",
" for ix=??\n",
" qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ\n",
"for iy=1:ny\n",
" for ix=1:nx-1\n",
" qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ\n",
" end\n",
"end\n",
"for iy=??\n",
" for ix=??\n",
" qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ\n",
"for iy=1:ny-1\n",
" for ix=1:nx\n",
" qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ\n",
" end\n",
"end\n",
"for iy=??\n",
" for ix=??\n",
" Pf[??] -= ??\n",
"for iy=1:ny\n",
" for ix=1:nx\n",
" Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ\n",
" end\n",
"end"
],
Expand Down Expand Up @@ -803,15 +805,28 @@
"outputs": [],
"cell_type": "code",
"source": [
"function compute_flux!(...)\n",
"function compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)\n",
" nx,ny=size(Pf)\n",
" ...\n",
" for iy=1:ny,\n",
" for ix=1:nx-1\n",
" qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ\n",
" end\n",
" end\n",
" for iy=1:ny-1\n",
" for ix=1:nx\n",
" qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ\n",
" end\n",
" end\n",
" return nothing\n",
"end\n",
"\n",
"function update_Pf!(Pf,...)\n",
"function update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)\n",
" nx,ny=size(Pf)\n",
" ...\n",
" for iy=1:ny\n",
" for ix=1:nx\n",
" Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ\n",
" end\n",
" end\n",
" return nothing\n",
"end"
],
Expand Down Expand Up @@ -891,9 +906,9 @@
"outputs": [],
"cell_type": "code",
"source": [
"function compute!(Pf,qDx,qDy, ???)\n",
" compute_flux!(...)\n",
" update_Pf!(...)\n",
"function compute!(Pf,qDx,qDy,k_ηf_dx,k_ηf_dy,_1_θ_dτ,_dx,_dy,_β_dτ)\n",
" compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)\n",
" update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)\n",
" return nothing\n",
"end"
],
Expand All @@ -911,8 +926,8 @@
"outputs": [],
"cell_type": "code",
"source": [
"t_toc = @belapsed compute!($Pf,$qDx,$qDy,???)\n",
"niter = ???"
"t_toc = @belapsed compute!($Pf,$qDx,$qDy,$k_ηf_dx,$k_ηf_dy,$_1_θ_dτ,$_dx,$_dy,$_β_dτ)\n",
"niter = 1"
],
"metadata": {},
"execution_count": null
Expand Down Expand Up @@ -1024,11 +1039,11 @@
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.5"
"version": "1.11.0"
},
"kernelspec": {
"name": "julia-1.10",
"display_name": "Julia 1.10.5",
"name": "julia-1.11",
"display_name": "Julia 1.11.0",
"language": "julia"
}
},
Expand Down
6 changes: 3 additions & 3 deletions slide-notebooks/notebooks/l5_2-unit-test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.5"
"version": "1.11.0"
},
"kernelspec": {
"name": "julia-1.10",
"display_name": "Julia 1.10.5",
"name": "julia-1.11",
"display_name": "Julia 1.11.0",
"language": "julia"
}
},
Expand Down
85 changes: 50 additions & 35 deletions website/_literate/l5_1-cpu-parallel_web.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ md"""
- Compute the elapsed time `t_toc` at the end of the time loop and report:
"""

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

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

Expand All @@ -286,8 +286,10 @@ md"""
- Define a `do_check` flag set to `false`
"""

function Pf_diffusion_2D(;??)
function Pf_diffusion_2D(;do_check=false)
if do_check && (iter%ncheck == 0)
...
end
return
end

Expand Down Expand Up @@ -363,19 +365,19 @@ md"""
Implement a nested loop, taking car of bounds and staggering.
"""

for iy=??
for ix=??
qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ
for iy=1:ny
for ix=1:nx-1
qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*(Pf[ix+1,iy]-Pf[ix,iy]))*_1_θ_dτ
end
end
for iy=??
for ix=??
qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ
for iy=1:ny-1
for ix=1:nx
qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*(Pf[ix,iy+1]-Pf[ix,iy]))*_1_θ_dτ
end
end
for iy=??
for ix=??
Pf[??] -= ??
for iy=1:ny
for ix=1:nx
Pf[ix,iy] -= ((qDx[ix+1,iy]-qDx[ix,iy])*_dx + (qDy[ix,iy+1]-qDy[ix,iy])*_dy)*_β_dτ
end
end

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

macro d_xa(A) esc(:( $A[??]-$A[??] )) end
macro d_ya(A) esc(:( $A[??]-$A[??] )) end
macro d_xa(A) esc(:( $A[ix+1,iy]-$A[ix,iy] )) end
macro d_ya(A) esc(:( $A[ix,iy+1]-$A[ix,iy] )) end

md"""
And update the code within the iteration loop:
"""
for iy=??
for ix=??
qDx[??] -= (qDx[??] + k_ηf_dx* ?? )*_1_θ_dτ
for iy=1:ny
for ix=1:nx-1
qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ
end
end
for iy=??
for ix=??
qDy[??] -= (qDy[??] + k_ηf_dy* ?? )*_1_θ_dτ
for iy=1:ny-1
for ix=1:nx
qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ
end
end
for iy=??
for ix=??
Pf[??] -= ??
for iy=1:ny
for ix=1:nx
Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ
end
end

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

function compute_flux!(...)
function compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)
nx,ny=size(Pf)
...
for iy=1:ny,
for ix=1:nx-1
qDx[ix+1,iy] -= (qDx[ix+1,iy] + k_ηf_dx*@d_xa(Pf))*_1_θ_dτ
end
end
for iy=1:ny-1
for ix=1:nx
qDy[ix,iy+1] -= (qDy[ix,iy+1] + k_ηf_dy*@d_ya(Pf))*_1_θ_dτ
end
end
return nothing
end

function update_Pf!(Pf,...)
function update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)
nx,ny=size(Pf)
...
for iy=1:ny
for ix=1:nx
Pf[ix,iy] -= (@d_xa(qDx)*_dx + @d_ya(qDy)*_dy)*_β_dτ
end
end
return nothing
end

Expand Down Expand Up @@ -483,18 +498,18 @@ md"""
The `compute!()` function:
"""

function compute!(Pf,qDx,qDy, ???)
compute_flux!(...)
update_Pf!(...)
function compute!(Pf,qDx,qDy,k_ηf_dx,k_ηf_dy,_1_θ_dτ,_dx,_dy,_β_dτ)
compute_flux!(qDx,qDy,Pf,k_ηf_dx,k_ηf_dy,_1_θ_dτ)
update_Pf!(Pf,qDx,qDy,_dx,_dy,_β_dτ)
return nothing
end

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

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

#nb # > 💡 note: Variables need to be interpolated into the function call, thus taking a `$` in front.
#md # \note{Note that variables need to be interpolated into the function call, thus taking a `$` in front.}
Expand Down
4 changes: 2 additions & 2 deletions website/homework.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ hascode = false
| 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).|
| 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. |
| 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. |
<!-- | 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. |
| 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. |
| 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. |
<!-- | 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. |
| 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. |
| 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. |
| 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. |
Expand Down

0 comments on commit 92d58c8

Please sign in to comment.