|
9 | 9 | }, |
10 | 10 | "outputs": [], |
11 | 11 | "source": [ |
12 | | - "## Setup on \n", |
13 | | - "MPIRUN=\"srun\"\n", |
| 12 | + " MPIRUN=\"mpirun\"\n", |
14 | 13 | "\n", |
15 | 14 | "import os\n", |
16 | 15 | "\n", |
17 | 16 | "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" |
20 | 18 | ] |
21 | 19 | }, |
22 | 20 | { |
|
56 | 54 | }, |
57 | 55 | "outputs": [], |
58 | 56 | "source": [ |
59 | | - "!$MPIRUN -n 4 -c 4 python hello_world.py" |
| 57 | + "!$MPIRUN -n 4 -c 4 python hello_world.py" |
60 | 58 | ] |
61 | 59 | }, |
62 | 60 | { |
|
77 | 75 | "name = MPI.Get_processor_name()\n", |
78 | 76 | "pid = os.getpid()\n", |
79 | 77 | "print(f\"Hello World! I am process {rank} of {size} on {name} \"\n", |
80 | | - " \"with pid {pid}.\\n\")\n" |
| 78 | + " \"with pid {pid}.\\n\")" |
81 | 79 | ] |
82 | 80 | }, |
83 | 81 | { |
|
110 | 108 | "metadata": {}, |
111 | 109 | "outputs": [], |
112 | 110 | "source": [ |
113 | | - "%%writefile fizzbuzz.py\n" |
| 111 | + "%%writefile fizzbuzz.py\n", |
| 112 | + "\n", |
| 113 | + "# TODO" |
114 | 114 | ] |
115 | 115 | }, |
116 | 116 | { |
|
144 | 144 | " comm.send(data, dest=1, tag=11)\n", |
145 | 145 | "elif rank == 1:\n", |
146 | 146 | " data = comm.recv(source=0, tag=11)\n", |
147 | | - " print(data)\n" |
| 147 | + " print(data)" |
148 | 148 | ] |
149 | 149 | }, |
150 | 150 | { |
|
169 | 169 | "outputs": [], |
170 | 170 | "source": [ |
171 | 171 | "%%writefile send_recv_eff.py\n", |
| 172 | + "\n", |
172 | 173 | "import numpy as np\n", |
173 | 174 | "from mpi4py import MPI\n", |
174 | 175 | "comm = MPI.COMM_WORLD\n", |
|
276 | 277 | "outputs": [], |
277 | 278 | "source": [ |
278 | 279 | "%%writefile scatter.py\n", |
| 280 | + "\n", |
279 | 281 | "from mpi4py import MPI\n", |
280 | 282 | "comm = MPI.COMM_WORLD\n", |
281 | 283 | "rank = comm.Get_rank()\n", |
|
314 | 316 | "outputs": [], |
315 | 317 | "source": [ |
316 | 318 | "%%writefile gather.py\n", |
| 319 | + "\n", |
317 | 320 | "from mpi4py import MPI\n", |
318 | 321 | "comm = MPI.COMM_WORLD\n", |
319 | 322 | "rank = comm.Get_rank()\n", |
|
355 | 358 | "outputs": [], |
356 | 359 | "source": [ |
357 | 360 | "%%writefile reduce.py\n", |
| 361 | + "\n", |
358 | 362 | "from mpi4py import MPI\n", |
359 | 363 | "comm = MPI.COMM_WORLD\n", |
360 | 364 | "rank = comm.Get_rank()\n", |
|
401 | 405 | "outputs": [], |
402 | 406 | "source": [ |
403 | 407 | "%%writefile compute_pi.py\n", |
| 408 | + "\n", |
404 | 409 | "from mpi4py import MPI\n", |
405 | 410 | "import math\n", |
406 | 411 | "\n", |
|
465 | 470 | "outputs": [], |
466 | 471 | "source": [ |
467 | 472 | "%%writefile compute_mandelbot.py\n", |
| 473 | + "\n", |
468 | 474 | "import matplotlib.pyplot as plt\n", |
469 | 475 | "import matplotlib.cm as cm\n", |
470 | 476 | "\n", |
|
554 | 560 | "from IPython.display import Image\n", |
555 | 561 | "Image(filename='test.png')" |
556 | 562 | ] |
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": [] |
567 | 563 | } |
568 | 564 | ], |
569 | 565 | "metadata": { |
|
0 commit comments