Skip to content

Commit

Permalink
Update mpi4py_ex.md
Browse files Browse the repository at this point in the history
  • Loading branch information
WonyoungCho committed Jun 18, 2019
1 parent 2cb2f07 commit 4886908
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions docs/mpi4py_ex.md
Expand Up @@ -79,11 +79,11 @@ if rank == 0:
else:
data = np.array([0,0,0,0])
print *, 'rank = ', rank, ' before :', data
print 'rank = ', rank, ' before :', data
comm.Bcast(data, root=0)
print *, 'rank = ', rank, ' after :', data
print 'rank = ', rank, ' after :', data
```

```sh
Expand All @@ -97,3 +97,28 @@ rank = 1 after : [5 6 7 8]
rank = 2 after : [5 6 7 8]
rank = 3 after : [5 6 7 8]
```

# Scatter

```
from mpi4py import MPI
import numpy as np
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()
data = None
if rank == 0:
data = np.array([5,6,7,8])
else:
data = np.array([0,0,0,0])
print 'rank = ', rank, ' before :', data
comm.scatter(data, root=0)
print 'rank = ', rank, ' after :', data
```
```

0 comments on commit 4886908

Please sign in to comment.