mirror of
https://github.com/fverdugo/XM_40017.git
synced 2025-11-09 00:14:23 +01:00
Adding exercises to MPI tutorial
This commit is contained in:
parent
98ee1a2e08
commit
0b53e10b89
@ -119,7 +119,7 @@ makedocs(;
|
||||
"Julia Basics" => "julia_basics.md",
|
||||
"Tasks and channels" => "julia_async.md",
|
||||
"Remote calls and remote channels" => "julia_distributed.md",
|
||||
# "MPI" => "mpi_tutorial.md",
|
||||
"MPI" => "mpi_tutorial.md",
|
||||
"Matrix Multiplication"=>"matrix_matrix.md",
|
||||
# "Jacobi" => "jacobi_method.md",
|
||||
# "ASP" => "asp.md",
|
||||
|
||||
@ -19,6 +19,51 @@
|
||||
inkscape:export-ydpi="200">
|
||||
<defs
|
||||
id="defs2">
|
||||
<marker
|
||||
style="overflow:visible"
|
||||
id="marker4223"
|
||||
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:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||
id="path4221"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:isstock="true"
|
||||
inkscape:stockid="Arrow2Mend"
|
||||
orient="auto"
|
||||
refY="0"
|
||||
refX="0"
|
||||
id="marker4031"
|
||||
style="overflow:visible"
|
||||
inkscape:collect="always">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4029"
|
||||
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;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
|
||||
inkscape:stockid="Arrow2Mstart"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow2Mstart"
|
||||
style="overflow:visible"
|
||||
inkscape:isstock="true">
|
||||
<path
|
||||
id="path1465"
|
||||
style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#0000ff;stroke-opacity:1;fill:#0000ff;fill-opacity:1"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
|
||||
transform="scale(0.6) translate(0,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:isstock="true"
|
||||
inkscape:stockid="Arrow2Mend"
|
||||
@ -285,7 +330,7 @@
|
||||
<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"
|
||||
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||
id="path8527"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
@ -311,11 +356,12 @@
|
||||
refY="0"
|
||||
orient="auto"
|
||||
inkscape:stockid="Arrow2Mend"
|
||||
inkscape:isstock="true">
|
||||
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"
|
||||
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.625;stroke-linejoin:round;stroke-opacity:1"
|
||||
id="path8527-8"
|
||||
inkscape:connector-curvature="0" />
|
||||
</marker>
|
||||
@ -327,16 +373,16 @@
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.9899495"
|
||||
inkscape:cx="3591.8372"
|
||||
inkscape:cy="1568.0458"
|
||||
inkscape:zoom="1.4"
|
||||
inkscape:cx="4981.0264"
|
||||
inkscape:cy="680.67174"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1856"
|
||||
inkscape:window-height="1016"
|
||||
inkscape:window-x="64"
|
||||
inkscape:window-width="2496"
|
||||
inkscape:window-height="1376"
|
||||
inkscape:window-x="1984"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1"
|
||||
fit-margin-top="0"
|
||||
@ -1889,5 +1935,228 @@
|
||||
style="fill:#0000ff;fill-opacity:1;fill-rule:evenodd;stroke:#0000ff;stroke-width:0.19798951;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 975.70946,-223.09405 -1.84993,3.19013 -0.65743,-3.62865 c 0.64485,0.67413 1.65812,0.8481 2.50736,0.43852 z" />
|
||||
</g>
|
||||
<g
|
||||
id="g5148"
|
||||
inkscape:export-filename="/home/francesc/Downloads/g5148.png"
|
||||
inkscape:export-xdpi="200"
|
||||
inkscape:export-ydpi="200">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:0.529167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1359.9626,79.585912 h 20.9409"
|
||||
id="path978-3-6-3"
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc"
|
||||
id="path1168-6-1-6"
|
||||
d="m 1314.5268,79.585912 h 20.9408"
|
||||
style="fill:none;stroke:#000000;stroke-width:0.529167;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<g
|
||||
transform="translate(1155.5468,183.31702)"
|
||||
id="g1148-7-5-75">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1063-5-5-3"
|
||||
d="m 129.89807,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path1065-3-4-5"
|
||||
d="m 142.88845,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccc"
|
||||
id="path1067-56-7-62"
|
||||
d="m 129.89807,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1069-2-6-9"
|
||||
d="m 147.21857,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1071-91-5-1"
|
||||
d="m 145.48652,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1073-2-6-2"
|
||||
d="m 145.48652,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1075-7-9-7"
|
||||
d="m 145.48652,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<g
|
||||
transform="translate(1163.1327,183.31701)"
|
||||
id="g1157-09-3-0">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1086-3-7-93"
|
||||
d="m 169.05642,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc"
|
||||
id="path1088-6-4-6"
|
||||
d="m 182.0468,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccc"
|
||||
id="path1090-0-5-0"
|
||||
d="m 169.05642,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1092-6-2-6"
|
||||
d="m 186.37692,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1094-2-5-2"
|
||||
d="m 184.64487,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1096-6-4-6"
|
||||
d="m 184.64487,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1098-1-7-1"
|
||||
d="m 184.64487,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||
</g>
|
||||
<text
|
||||
y="15.986771"
|
||||
x="1244.8425"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);stroke-width:1.87007797"
|
||||
id="text1128-7-8-4-8"
|
||||
xml:space="preserve"><tspan
|
||||
style="stroke-width:1.87007797"
|
||||
id="tspan78-79-4-7"
|
||||
y="103.6842"
|
||||
x="1289.8303">rank 0<tspan
|
||||
id="tspan76-2-3-9"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;stroke-width:1.87007797" /></tspan></text>
|
||||
<text
|
||||
y="15.986771"
|
||||
x="1294.8483"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1184);stroke-width:1.87007797"
|
||||
id="text1182-0-0-2"
|
||||
xml:space="preserve"><tspan
|
||||
style="stroke-width:1.87007797"
|
||||
id="tspan83-2-7-0"
|
||||
y="103.6842"
|
||||
x="1339.8361">rank 1<tspan
|
||||
id="tspan81-3-8-2"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Hack;-inkscape-font-specification:Hack;stroke-width:1.87007797" /></tspan></text>
|
||||
<g
|
||||
id="g970-7-6-3"
|
||||
transform="translate(1209.6376,183.31701)">
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 169.05642,-136.23112 12.99038,7.5 17.32051,-10 -12.99038,-7.5 z"
|
||||
id="path956-5-8-7"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 182.0468,-128.73112 v 39.999996 l 17.32051,-10 v -39.999996"
|
||||
id="path958-92-8-5"
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.79374999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 169.05642,-136.23112 v 39.999996 l 12.99038,7.5"
|
||||
id="path960-2-4-9"
|
||||
sodipodi:nodetypes="ccc"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 186.37692,-126.23112 v 15 l 4.33013,-2.5 v -15 l -4.33013,2.5"
|
||||
id="path962-8-3-2"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 184.64487,-96.231123 v 1.999999 l 12.99038,-7.499996 v -2 z"
|
||||
id="path964-9-1-2"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 184.64487,-100.23111 v 2.000003 l 12.99038,-7.500013 v -2 z"
|
||||
id="path966-7-4-8"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#e6e6e6;stroke:#000000;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 184.64487,-104.23111 v 2 l 12.99038,-7.50001 v -2 z"
|
||||
id="path968-3-9-9"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
id="text976-6-2-7"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1184);stroke-width:1.87007797"
|
||||
x="1342.9568"
|
||||
y="15.986771"><tspan
|
||||
x="1387.9445"
|
||||
y="103.6842"
|
||||
id="tspan974-1-0-3"
|
||||
style="stroke-width:1.87007797">rank 2</tspan></text>
|
||||
<text
|
||||
y="-54.098297"
|
||||
x="1247.6248"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||
id="text1128-7-8-7-3-7-0"
|
||||
xml:space="preserve"><tspan
|
||||
style="fill:#0000ff;stroke-width:1.87007797"
|
||||
id="tspan78-79-8-2-1-3"
|
||||
y="33.599152"
|
||||
x="1292.6124">msg</tspan></text>
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path1386"
|
||||
d="m 1304.0316,27.773394 c 16.0706,-14.103005 27.5564,-13.085868 41.886,-0.615601"
|
||||
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker8529-3)" />
|
||||
<text
|
||||
y="-54.561871"
|
||||
x="1290.4174"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||
id="text1128-7-8-7-3-7-0-0"
|
||||
xml:space="preserve"><tspan
|
||||
style="fill:#0000ff;stroke-width:1.87007797"
|
||||
id="tspan78-79-8-2-1-3-6"
|
||||
y="33.135578"
|
||||
x="1335.405">msg+=1</tspan></text>
|
||||
<text
|
||||
y="-53.871326"
|
||||
x="1338.3951"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:5.93749809px;line-height:1.25;font-family:Hack;-inkscape-font-specification:Hack;letter-spacing:0px;word-spacing:0px;white-space:pre;shape-inside:url(#rect1130-2);fill:#0000ff;stroke-width:1.87007797"
|
||||
id="text1128-7-8-7-3-7-0-0-3"
|
||||
xml:space="preserve"><tspan
|
||||
style="fill:#0000ff;stroke-width:1.87007797"
|
||||
id="tspan78-79-8-2-1-3-6-2"
|
||||
y="33.826126"
|
||||
x="1383.3828">msg+=1</tspan></text>
|
||||
<path
|
||||
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4031)"
|
||||
d="m 1354.3024,27.773394 c 16.0706,-14.103005 27.5564,-13.085868 41.886,-0.615601"
|
||||
id="path4027"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4219"
|
||||
d="m 1402.8962,28.340358 c -14.7223,-30.9560949 -88.632,-34.6967981 -104.63,-1.371553"
|
||||
style="fill:none;stroke:#0000ff;stroke-width:0.76499999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#marker4223)" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 126 KiB |
File diff suppressed because one or more lines are too long
@ -291,6 +291,96 @@
|
||||
"rmprocs(workers())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "508125f9",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### New ring example"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7af4cfd0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"@everywhere workers() begin\n",
|
||||
" using MPI\n",
|
||||
" MPI.Init()\n",
|
||||
" comm = MPI.Comm_dup(MPI.COMM_WORLD)\n",
|
||||
" rank = MPI.Comm_rank(comm)\n",
|
||||
" nranks = MPI.Comm_size(comm)\n",
|
||||
" buffer = Ref(0)\n",
|
||||
" if rank == 0\n",
|
||||
" msg = rand(1:10)\n",
|
||||
" buffer[] = msg\n",
|
||||
" println(\"msg = $(buffer[])\")\n",
|
||||
" MPI.Send(buffer,comm;dest=rank+1,tag=0)\n",
|
||||
" MPI.Recv!(buffer,comm;source=nranks-1,tag=0)\n",
|
||||
" println(\"msg = $(buffer[])\")\n",
|
||||
" else\n",
|
||||
" dest = (rank != nranks-1) ? rank+1 : 0\n",
|
||||
" MPI.Recv!(buffer,comm;source=rank-1,tag=0)\n",
|
||||
" buffer[] += 1\n",
|
||||
" println(\"msg = $(buffer[])\")\n",
|
||||
" MPI.Send(buffer,comm;dest,tag=0)\n",
|
||||
" end\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "30ece423",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"ftrs = Vector{Future}(undef,nprocs())\n",
|
||||
"for p in 1:nprocs()\n",
|
||||
" ftrs[p] = @spawnat p RemoteChannel(()->Channel{Int}(1))\n",
|
||||
"end\n",
|
||||
"for p in 1:nprocs()\n",
|
||||
" @spawnat p begin \n",
|
||||
" chnl_snd = fetch(ftrs[p])\n",
|
||||
" source = (p != 1) ? p-1 : nprocs()\n",
|
||||
" chnl_rcv = fetch(ftrs[source])\n",
|
||||
" if p == 1\n",
|
||||
" msg = rand(1:10)\n",
|
||||
" @show msg\n",
|
||||
" put!(chnl_snd,msg)\n",
|
||||
" msg = take!(chnl_rcv)\n",
|
||||
" @show msg\n",
|
||||
" else\n",
|
||||
" msg = take!(chnl_rcv)\n",
|
||||
" msg += 1\n",
|
||||
" @show msg\n",
|
||||
" put!(chnl_snd,msg)\n",
|
||||
" end\n",
|
||||
" end\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "761ce452",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"@everywhere function work(msg)\n",
|
||||
" msg += 1\n",
|
||||
" println(\"msg = $msg\")\n",
|
||||
" if myid() == nprocs()\n",
|
||||
" @spawnat 1 println(\"msg = $msg\")\n",
|
||||
" else\n",
|
||||
" next = myid() + 1\n",
|
||||
" @spawnat next work(msg)\n",
|
||||
" end\n",
|
||||
"end"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "19641daf",
|
||||
@ -733,7 +823,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Julia 1.9.1",
|
||||
"display_name": "Julia 1.9.0",
|
||||
"language": "julia",
|
||||
"name": "julia-1.9"
|
||||
},
|
||||
@ -741,7 +831,7 @@
|
||||
"file_extension": ".jl",
|
||||
"mimetype": "application/julia",
|
||||
"name": "julia",
|
||||
"version": "1.9.1"
|
||||
"version": "1.9.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user