Major updates in jacobi method

This commit is contained in:
Francesc Verdugo 2024-09-09 16:59:37 +02:00
parent 4a9dc6f2c4
commit c35f674bd5
5 changed files with 1658 additions and 616 deletions

View File

@ -122,8 +122,8 @@ makedocs(;
#"Distributed computing with MPI" => "mpi_tutorial.md",
"Matrix-matrix multiplication"=>"matrix_matrix.md",
"MPI (point-to-point)" => "julia_mpi.md",
"Jacobi method" => "jacobi_method.md",
"MPI (collectives)" => "mpi_collectives.md",
"Jacobi method" => "jacobi_method.md",
#"All pairs of shortest paths" => "asp.md",
#"Gaussian elimination" => "LEQ.md",
#"Traveling salesperson problem" => "tsp.md",

View File

@ -19,7 +19,44 @@
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"
xml:space="preserve"><defs
id="defs2"><rect
id="defs2"><marker
inkscape:isstock="true"
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0"
refX="0"
id="marker27074"
style="overflow:visible"><path
inkscape:connector-curvature="0"
id="path27072"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" /></marker><marker
style="overflow:visible"
id="marker26176"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Mend"
inkscape:isstock="true"><path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path26174"
inkscape:connector-curvature="0" /></marker><marker
style="overflow:visible"
id="marker25136"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow2Mend"
inkscape:isstock="true"
inkscape:collect="always"><path
transform="scale(-0.6)"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path25134"
inkscape:connector-curvature="0" /></marker><rect
x="1741.4286"
y="2145.7143"
width="136.42857"
@ -2528,16 +2565,29 @@
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
id="path3068-9-0"
inkscape:connector-curvature="0" /></marker></defs><sodipodi:namedview
inkscape:connector-curvature="0" /></marker><marker
inkscape:isstock="true"
inkscape:stockid="Arrow2Mend"
orient="auto"
refY="0"
refX="0"
id="marker6411-7-1-9"
style="overflow:visible"
inkscape:collect="always"><path
inkscape:connector-curvature="0"
id="path6409-7-5-2"
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
transform="scale(-0.6)" /></marker></defs><sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.7690904"
inkscape:cx="187.63213"
inkscape:cy="-1572.4215"
inkscape:zoom="1.9580426"
inkscape:cx="-323.7677"
inkscape:cy="-1424.0943"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
@ -133946,4 +133996,689 @@
y="383.36475"
x="362.53436"
style="stroke-width:1.18108892">?</tspan></text>
</g></svg>
<g
id="g28304"
inkscape:export-filename="/home/francesc/g28304.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="218.77849"
height="5.1131492"
width="5.1131492"
id="rect847-5-7-49"
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="162.53386"
height="5.1131492"
width="5.1131492"
id="rect833-3-2"
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="167.64702"
height="5.1131492"
width="5.1131492"
id="rect835-61-0"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="172.76018"
height="5.1131492"
width="5.1131492"
id="rect837-0-68"
style="fill:#c5c5c5;fill-opacity:0.97619045;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="177.87331"
height="5.1131492"
width="5.1131492"
id="rect839-0-9"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="182.98647"
height="5.1131492"
width="5.1131492"
id="rect841-72-2"
style="fill:#c5c5c5;fill-opacity:0.97619045;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="188.09962"
height="5.1131492"
width="5.1131492"
id="rect843-3-6"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="193.21275"
height="5.1131492"
width="5.1131492"
id="rect845-1-6"
style="fill:#c5c5c5;fill-opacity:0.97619045;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="198.32588"
height="5.1131492"
width="5.1131492"
id="rect847-07-4"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="203.43907"
height="5.1131492"
width="5.1131492"
id="rect841-3-4-9"
style="fill:#c5c5c5;fill-opacity:0.97619045;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="208.5522"
height="5.1131492"
width="5.1131492"
id="rect843-6-8-50"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="303.1282"
x="213.66536"
height="5.1131492"
width="5.1131492"
id="rect845-7-0-48"
style="fill:#c5c5c5;fill-opacity:0.97619045;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8241-8);display:inline;stroke-width:1"
id="text8239-7-6"
xml:space="preserve"
x="5.1230903"
y="190.4624"><tspan
id="tspan51-1"
y="306.83755"
x="162.96684"
style="stroke-width:1">-1</tspan></text>
<text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8341);display:inline;stroke-width:1"
id="text8339-6"
xml:space="preserve"
x="62.376186"
y="190.4624"><tspan
id="tspan61-7"
y="306.83755"
x="220.21996"
style="stroke-width:1">1</tspan></text>
<text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_09.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1044-2-1-7);display:inline;stroke-width:1"
id="text1042-1-7-4-6"
xml:space="preserve"
x="108.95108"
y="250.83264"><tspan
id="tspan65-4"
y="302.11606"
x="172.97078"
style="stroke-width:1">i-1</tspan></text>
<text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_09.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect961-6-9-1-1);display:inline;stroke-width:1"
id="text959-2-1-1-4-3"
xml:space="preserve"
x="118.81889"
y="250.66995"><tspan
id="tspan66-0"
y="301.95334"
x="182.8385"
style="stroke-width:1">i+1</tspan></text>
<text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_09.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8986);display:inline;stroke-width:1"
id="text8984-3"
xml:space="preserve"
x="115.70671"
y="264.6026"><tspan
id="tspan67-0"
y="315.88599"
x="179.72638"
style="stroke-width:1">i</tspan></text>
<rect
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23749"
width="5.1131492"
height="5.1131492"
x="218.77849"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23751"
width="5.1131492"
height="5.1131492"
x="162.53386"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23753"
width="5.1131492"
height="5.1131492"
x="167.64702"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23755"
width="5.1131492"
height="5.1131492"
x="172.76018"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23757"
width="5.1131492"
height="5.1131492"
x="177.87331"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23759"
width="5.1131492"
height="5.1131492"
x="182.98647"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23761"
width="5.1131492"
height="5.1131492"
x="188.09962"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23763"
width="5.1131492"
height="5.1131492"
x="193.21275"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23765"
width="5.1131492"
height="5.1131492"
x="198.32588"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23767"
width="5.1131492"
height="5.1131492"
x="203.43907"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23769"
width="5.1131492"
height="5.1131492"
x="208.5522"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect23771"
width="5.1131492"
height="5.1131492"
x="213.66536"
y="316.91107"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><text
y="204.2453"
x="5.1230903"
xml:space="preserve"
id="text23775"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8241-8);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="162.96684"
y="320.62042"
id="tspan23773">-1</tspan></text>
<text
y="204.2453"
x="62.376186"
xml:space="preserve"
id="text23779"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8341);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="220.21996"
y="320.62042"
id="tspan23777">1</tspan></text>
<path
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/francesc/fig09.png"
style="fill:none;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker26176)"
d="m 175.04236,305.96308 4.22907,13.17794"
id="path6407-1-9-5"
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" /><path
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc"
id="path25132"
d="m 185.44939,305.96308 -4.22907,13.17794"
style="fill:none;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker27074)"
inkscape:export-filename="/home/francesc/fig09.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26090"
width="5.1131492"
height="5.1131492"
x="218.77849"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26092"
width="5.1131492"
height="5.1131492"
x="162.53386"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26094"
width="5.1131492"
height="5.1131492"
x="167.64702"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26096"
width="5.1131492"
height="5.1131492"
x="172.76018"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26098"
width="5.1131492"
height="5.1131492"
x="177.87331"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26100"
width="5.1131492"
height="5.1131492"
x="182.98647"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26102"
width="5.1131492"
height="5.1131492"
x="188.09962"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26104"
width="5.1131492"
height="5.1131492"
x="193.21275"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26106"
width="5.1131492"
height="5.1131492"
x="198.32588"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26108"
width="5.1131492"
height="5.1131492"
x="203.43907"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26110"
width="5.1131492"
height="5.1131492"
x="208.5522"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><rect
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none"
id="rect26112"
width="5.1131492"
height="5.1131492"
x="213.66536"
y="341.25217"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><text
y="228.58638"
x="5.1230903"
xml:space="preserve"
id="text26116"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8241-8);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="162.96684"
y="344.96152"
id="tspan26114">-1</tspan></text>
<text
y="228.58638"
x="62.376186"
xml:space="preserve"
id="text26120"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8341);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="220.21996"
y="344.96152"
id="tspan26118">1</tspan></text>
<text
y="288.9566"
x="114.24284"
xml:space="preserve"
id="text26126"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1044-2-1-7);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_09.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="178.26248"
y="340.24002"
id="tspan26124">i-1</tspan></text>
<text
y="288.79391"
x="124.1106"
xml:space="preserve"
id="text26130"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect961-6-9-1-1);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_09.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="188.1302"
y="340.0773"
id="tspan26128">i+1</tspan></text>
<text
y="302.72656"
x="120.99844"
xml:space="preserve"
id="text26134"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8986);display:inline;stroke-width:1"
inkscape:export-filename="/home/fverdugo/fig_jacobi_09.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1"
x="185.01808"
y="354.00995"
id="tspan26132">i</tspan></text>
<rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="218.77849"
height="5.1131492"
width="5.1131492"
id="rect26136"
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="162.53386"
height="5.1131492"
width="5.1131492"
id="rect26138"
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="167.64702"
height="5.1131492"
width="5.1131492"
id="rect26140"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="172.76018"
height="5.1131492"
width="5.1131492"
id="rect26142"
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="177.87331"
height="5.1131492"
width="5.1131492"
id="rect26144"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="182.98647"
height="5.1131492"
width="5.1131492"
id="rect26146"
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="188.09962"
height="5.1131492"
width="5.1131492"
id="rect26148"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="193.21275"
height="5.1131492"
width="5.1131492"
id="rect26150"
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="198.32588"
height="5.1131492"
width="5.1131492"
id="rect26152"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="203.43907"
height="5.1131492"
width="5.1131492"
id="rect26154"
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="208.5522"
height="5.1131492"
width="5.1131492"
id="rect26156"
style="fill:#c83737;fill-opacity:0.80476188;stroke:#000000;stroke-width:0.414;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
y="355.03506"
x="213.66536"
height="5.1131492"
width="5.1131492"
id="rect26158"
style="fill:#c6c6c6;fill-opacity:0.97647059;stroke:#000000;stroke-width:0.41446099;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /><text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8241-8);display:inline;stroke-width:1"
id="text26162"
xml:space="preserve"
x="5.1230903"
y="242.36928"><tspan
id="tspan26160"
y="358.74442"
x="162.96684"
style="stroke-width:1">-1</tspan></text>
<text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_08.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.17499995px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect8341);display:inline;stroke-width:1"
id="text26166"
xml:space="preserve"
x="62.376186"
y="242.36928"><tspan
id="tspan26164"
y="358.74442"
x="220.21996"
style="stroke-width:1">1</tspan></text>
<path
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc"
id="path26170"
d="m 180.33401,344.08706 4.22907,13.17794"
style="fill:none;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker6411-7-1-9)"
inkscape:export-filename="/home/francesc/fig09.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200" /><path
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/francesc/fig09.png"
style="fill:none;stroke:#000000;stroke-width:0.26499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker25136)"
d="M 190.74104,344.08706 186.51197,357.265"
id="path26172"
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0" /><text
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_06.png"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.69665527px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect7541);display:inline;stroke-width:1.16430092"
id="text7539-4"
xml:space="preserve"
x="169.92833"
y="225.73022"><tspan
id="tspan37-0"
y="296.20697"
x="180.60942"
style="stroke-width:1.16430092">&quot;red&quot; phase</tspan></text>
<text
y="264.14084"
x="169.92833"
xml:space="preserve"
id="text28138"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.69665527px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect7541);display:inline;stroke-width:1.16430092"
inkscape:export-filename="/home/fverdugo/fig_jacobi_06.png"
inkscape:export-xdpi="200"
inkscape:export-ydpi="200"><tspan
style="stroke-width:1.16430092"
x="180.60942"
y="334.61758"
id="tspan28136">&quot;black&quot; phase</tspan></text>
<rect
inkscape:export-ydpi="200"
inkscape:export-xdpi="200"
inkscape:export-filename="/home/fverdugo/fig_jacobi_06.png"
y="289.46509"
x="156.58347"
height="76.980339"
width="73.330498"
id="rect7758-5"
style="fill:none;fill-opacity:0.21383099;stroke:#999999;stroke-width:0.40000001;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none" /></g></g></svg>

Before

Width:  |  Height:  |  Size: 6.1 MiB

After

Width:  |  Height:  |  Size: 6.1 MiB

File diff suppressed because one or more lines are too long

View File

@ -1497,17 +1497,16 @@
"function matmul_mpi_3!(C,A,B)\n",
"```\n",
"\n",
"Assume that the input matrices `A` and `B` are given only on rank 0, the other ranks get dummy matrices with zero rows and zero columns to save memory. You need to communicate the required parts to other ranks. For simplicity you can assume that `A` and `B` are square matrices and that the number of rows is a multiple of the number of processes (on rank 0). The result `C` should be overwritten only on rank 0. You can use the following cell to implement and check your result."
"Assume that the input matrices `A` and `B` are given only on rank 0, the other ranks get dummy matrices with zero rows and zero columns to save memory. You need to communicate the required parts to other ranks. For simplicity you can assume that `A` and `B` are square matrices and that the number of rows is a multiple of the number of processes (on rank 0). The result `C` should be overwritten only on rank 0. You can use the following cell to implement and check your result. Copy the code below to a file called `ex1.jl`. Modify the file (e.g. with vscode). Run it from the Julia REPL using the `run` function as explained in the [Getting Started tutorial](https://www.francescverdugo.com/XM_40017/dev/getting_started_with_julia/#Running-MPI-code)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "265c4593",
"cell_type": "markdown",
"id": "4fa53366",
"metadata": {},
"outputs": [],
"source": [
"code = quote\n",
"```julia\n",
"# ex1.jl (begin)\n",
"using MPI\n",
"MPI.Init()\n",
"function matmul_mpi_3!(C,A,B)\n",
@ -1528,15 +1527,16 @@
" matmul_mpi_3!(C,A,B)\n",
" if rank == 0\n",
" if !(C ≈ A*B)\n",
" println(\"Check not passed\")\n",
" println(\"Test failed 😢\")\n",
" else\n",
" println(\"Check passed!\")\n",
" println(\"Test passed 🥳\")\n",
" end\n",
" end\n",
"end\n",
"testit(100)\n",
"end\n",
"run(`$(mpiexec()) -np 4 julia --project=. -e $code`);"
"# ex1.jl (end)\n",
"```"
]
},
{
@ -1548,7 +1548,7 @@
"\n",
"Implement this \"simple\" algorithm (the telephone game):\n",
"\n",
"Rank 0 generates a message (an integer). Rank 0 sends the message to rank 1. Rank 1 receives the message, increments the message by 1, and sends the result to rank 2. Rank 2 receives the message, increments the message by 1, and sends the result to rank 3. Etc. The last rank sends back the message to rank 0 closing the ring. See the next figure. Implement the communications using MPI. Do not use `Distributed`.\n"
"Rank 0 generates a message (an integer). Rank 0 sends the message to rank 1. Rank 1 receives the message, increments the message by 1, and sends the result to rank 2. Rank 2 receives the message, increments the message by 1, and sends the result to rank 3. Etc. The last rank sends back the message to rank 0 closing the ring. See the next figure. Implement the communications using MPI. Do not use `Distributed`. Use a text editor and the Julia REPL. Do not try to implement the code in a notebook.\n"
]
},
{

View File

@ -898,77 +898,6 @@
"After learning this material and the previous MPI notebook, you have a solid basis to start implementing sophisticated parallel algorithms using MPI."
]
},
{
"cell_type": "markdown",
"id": "c6b23485",
"metadata": {},
"source": [
"## Exercises"
]
},
{
"cell_type": "markdown",
"id": "90dc58bb",
"metadata": {},
"source": [
"### Exercise 1\n",
"\n",
"In the parallel implementation of the Jacobi method in previous notebook, we assumed that the method runs for a given number of iterations. However, other stopping criteria are used in practice. The following sequential code implements a version of Jacobi in which the method iterates until the norm of the difference between u and u_new is below a tolerance.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0fcb0cd6",
"metadata": {},
"outputs": [],
"source": [
"function jacobi_with_tol(n,tol)\n",
" u = zeros(n+2)\n",
" u[1] = -1\n",
" u[end] = 1\n",
" u_new = copy(u)\n",
" increment = similar(u)\n",
" while true\n",
" for i in 2:(n+1)\n",
" u_new[i] = 0.5*(u[i-1]+u[i+1])\n",
" end\n",
" increment .= u_new .- u\n",
" norm_increment = 0.0\n",
" for i in 1:n\n",
" increment_i = increment[i]\n",
" norm_increment += increment_i*increment_i\n",
" end\n",
" norm_increment = sqrt(norm_increment)\n",
" if norm_increment < tol*n\n",
" return u_new\n",
" end\n",
" u, u_new = u_new, u\n",
" end\n",
" u\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dbf0c3b8",
"metadata": {},
"outputs": [],
"source": [
"n = 10\n",
"tol = 1e-12\n",
"jacobi_with_tol(n,tol)"
]
},
{
"cell_type": "markdown",
"id": "aab1455e",
"metadata": {},
"source": [
"Implement a parallel version of this algorithm. Recommended: start with the parallel implementation given in the previous notebook (see function `jacobi_mpi`) and introduce the new stopping criteria. Think carefully about which MPI operations you need to use in this case."
]
},
{
"cell_type": "markdown",
"id": "5e8f6e6a",