Skip to content
Snippets Groups Projects

Gajdusek cleaning

Merged Pavel Gajdušek requested to merge gajdusek_clean into master
Compare and
2 files
+ 40
39
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -20,7 +20,7 @@ $ ml av Python/
Python/2.7.11-foss-2016a Python/3.5.2-foss-2016a Python/3.5.1
Python/2.7.9-foss-2015g Python/3.4.3-intel-2015b Python/2.7.9
Python/2.7.11-intel-2015b Python/3.5.2
$ ml av OpenMPI/
--------------------------------------- /apps/modules/mpi --------------------------
OpenMPI/1.8.6-GCC-4.4.7-system OpenMPI/1.8.8-GNU-4.9.3-2.25 OpenMPI/1.10.1-GCC-4.9.3-2.25
@@ -28,7 +28,8 @@ OpenMPI/1.8.6-GNU-5.1.0-2.25 OpenMPI/1.8.8-GNU-5.1.0-2.25 OpenMPI/1.10.1-GN
OpenMPI/1.8.8-iccifort-2015.3.187-GNU-4.9.3-2.25 OpenMPI/2.0.2-GCC-6.3.0-2.27
```
!!! Warning ""
!!! Warning "Flavours"
* modules Python/x.x.x-intel... - intel MPI
* modules Python/x.x.x-foss... - OpenMPI
* modules Python/x.x.x - without MPI
@@ -37,8 +38,8 @@ OpenMPI/1.8.6-GNU-5.1.0-2.25 OpenMPI/1.8.8-GNU-5.1.0-2.25 OpenMPI/1.10.1-GN
You need to import MPI to your python program. Include the following line to the python script:
```cpp
from mpi4py import MPI
```python
from mpi4py import MPI
```
The MPI4Py enabled python programs [execute as any other OpenMPI](Running_OpenMPI/) code.The simpliest way is to run
@@ -57,43 +58,43 @@ $ mpiexec python hello_world.py
### Hello World!
```cpp
from mpi4py import MPI
```python
from mpi4py import MPI
comm = MPI.COMM_WORLD
comm = MPI.COMM_WORLD
print "Hello! I'm rank %d from %d running in total..." % (comm.rank, comm.size)
print "Hello! I'm rank %d from %d running in total..." % (comm.rank, comm.size)
comm.Barrier() # wait for everybody to synchronize
comm.Barrier() # wait for everybody to synchronize
```
### Collective Communication With NumPy Arrays
```cpp
from mpi4py import MPI
from __future__ import division
import numpy as np
```python
from mpi4py import MPI
from __future__ import division
import numpy as np
comm = MPI.COMM_WORLD
comm = MPI.COMM_WORLD
print("-"*78)
print(" Running on %d cores" % comm.size)
print("-"*78)
print("-"*78)
print(" Running on %d cores" % comm.size)
print("-"*78)
comm.Barrier()
comm.Barrier()
# Prepare a vector of N=5 elements to be broadcasted...
N = 5
if comm.rank == 0:
A = np.arange(N, dtype=np.float64) # rank 0 has proper data
else:
A = np.empty(N, dtype=np.float64) # all other just an empty array
# Prepare a vector of N=5 elements to be broadcasted...
N = 5
if comm.rank == 0:
A = np.arange(N, dtype=np.float64) # rank 0 has proper data
else:
A = np.empty(N, dtype=np.float64) # all other just an empty array
# Broadcast A from rank 0 to everybody
comm.Bcast( [A, MPI.DOUBLE] )
# Broadcast A from rank 0 to everybody
comm.Bcast( [A, MPI.DOUBLE] )
# Everybody should now have the same...
print "[%02d] %s" % (comm.rank, A)
# Everybody should now have the same...
print "[%02d] %s" % (comm.rank, A)
```
Execute the above code as:
Loading