Skip to content

Commit f567bf6

Browse files
committed
Accelerated Python/60 mpi4py: Fix MPIRUN and clean up notebook a little.
1 parent cfb4ec9 commit f567bf6

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

tutorials/accelerated-python/notebooks/distributed/60__mpi4py.ipynb

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
},
1010
"outputs": [],
1111
"source": [
12-
"## Setup on \n",
13-
"MPIRUN=\"srun\"\n",
12+
" MPIRUN=\"mpirun\"\n",
1413
"\n",
1514
"import os\n",
1615
"\n",
1716
"if os.getenv(\"COLAB_RELEASE_TAG\"): # If running in Google Colab\n",
18-
" !pip install mpi4py\n",
19-
" MPIRUN=\"mpirun --allow-run-as-root --oversubscribe\"\n"
17+
" !pip install mpi4py"
2018
]
2119
},
2220
{
@@ -56,7 +54,7 @@
5654
},
5755
"outputs": [],
5856
"source": [
59-
"!$MPIRUN -n 4 -c 4 python hello_world.py"
57+
"!$MPIRUN -n 4 -c 4 python hello_world.py"
6058
]
6159
},
6260
{
@@ -77,7 +75,7 @@
7775
"name = MPI.Get_processor_name()\n",
7876
"pid = os.getpid()\n",
7977
"print(f\"Hello World! I am process {rank} of {size} on {name} \"\n",
80-
" \"with pid {pid}.\\n\")\n"
78+
" \"with pid {pid}.\\n\")"
8179
]
8280
},
8381
{
@@ -110,7 +108,9 @@
110108
"metadata": {},
111109
"outputs": [],
112110
"source": [
113-
"%%writefile fizzbuzz.py\n"
111+
"%%writefile fizzbuzz.py\n",
112+
"\n",
113+
"# TODO"
114114
]
115115
},
116116
{
@@ -144,7 +144,7 @@
144144
" comm.send(data, dest=1, tag=11)\n",
145145
"elif rank == 1:\n",
146146
" data = comm.recv(source=0, tag=11)\n",
147-
" print(data)\n"
147+
" print(data)"
148148
]
149149
},
150150
{
@@ -169,6 +169,7 @@
169169
"outputs": [],
170170
"source": [
171171
"%%writefile send_recv_eff.py\n",
172+
"\n",
172173
"import numpy as np\n",
173174
"from mpi4py import MPI\n",
174175
"comm = MPI.COMM_WORLD\n",
@@ -276,6 +277,7 @@
276277
"outputs": [],
277278
"source": [
278279
"%%writefile scatter.py\n",
280+
"\n",
279281
"from mpi4py import MPI\n",
280282
"comm = MPI.COMM_WORLD\n",
281283
"rank = comm.Get_rank()\n",
@@ -314,6 +316,7 @@
314316
"outputs": [],
315317
"source": [
316318
"%%writefile gather.py\n",
319+
"\n",
317320
"from mpi4py import MPI\n",
318321
"comm = MPI.COMM_WORLD\n",
319322
"rank = comm.Get_rank()\n",
@@ -355,6 +358,7 @@
355358
"outputs": [],
356359
"source": [
357360
"%%writefile reduce.py\n",
361+
"\n",
358362
"from mpi4py import MPI\n",
359363
"comm = MPI.COMM_WORLD\n",
360364
"rank = comm.Get_rank()\n",
@@ -401,6 +405,7 @@
401405
"outputs": [],
402406
"source": [
403407
"%%writefile compute_pi.py\n",
408+
"\n",
404409
"from mpi4py import MPI\n",
405410
"import math\n",
406411
"\n",
@@ -465,6 +470,7 @@
465470
"outputs": [],
466471
"source": [
467472
"%%writefile compute_mandelbot.py\n",
473+
"\n",
468474
"import matplotlib.pyplot as plt\n",
469475
"import matplotlib.cm as cm\n",
470476
"\n",
@@ -554,16 +560,6 @@
554560
"from IPython.display import Image\n",
555561
"Image(filename='test.png')"
556562
]
557-
},
558-
{
559-
"cell_type": "code",
560-
"execution_count": null,
561-
"id": "6db131ed-12dd-4cfb-9101-5f8cf00a8eb3",
562-
"metadata": {
563-
"id": "6db131ed-12dd-4cfb-9101-5f8cf00a8eb3"
564-
},
565-
"outputs": [],
566-
"source": []
567563
}
568564
],
569565
"metadata": {

0 commit comments

Comments
 (0)