-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.txt
More file actions
94 lines (47 loc) · 1.86 KB
/
Copy pathREADME.txt
File metadata and controls
94 lines (47 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
CMPE272-Extra-assignment
========================
Nishant Ajay Mehta
CMPE272 Extra Assignment for pyMPI
I have completed my extra credit assignment of topic:
Use pyMPI to implement a parallel program in python using MPI which send receives messages in parallel.http://pympi.sourceforge.net/
I have attached my code and print-screens of code being executed.
Send you two print-screens for execution execution (Saved with this project):
1. With mpi.barrier()
2. Without mpi.barrier() function.
Tutorial:
Pre-requisites:
Python (which will be already installed in most cases)
$sudo apt-get install python
Install openMPI using command:
$sudo apt-get libopenmpi-dev
or
$sudo apt-get libopenmpi1.5-dev
Now download pyMPI package to work with python from http://sourceforge.net/projects/pympi/files/latest/download
Extract the archive:
$tar -xvf pyMPI-2.5b0.tar.gz
Write your python code for MPI and save as msg.py:
import mpi
rank= mpi.rank
if rank == 0:
data = {'a': 7, 'b': 3.14}
mpi.send(data,1)
print ("Sending data from",rank,"data",data)
data,status = mpi.recv(source=1)
mpi.barrier()
print ("Receiving data at",rank,"data",data)
elif rank == 1:
data1 = {'a': 7, 'b': 'abc'}
mpi.send(data1,0)
print ("Sending data from",rank,"data",data1)
data,status = mpi.recv(source=0)
mpi.barrier()
print ("Receiving data at",rank,"data",data1)
Save the code in same folder as pyMPI and run:
$ mpirun -np 2 pyMPI msg.py
You can also use Synaptic Package Manager for installation:
Install Synaptic Package Manager:
$sudo apt-get install synaptic
Open Synaptic GUI tool, now directly search and select all the packages to be installed.
Nishant Ajay Mehta
smarts3.in
nishant.a.m@gmail.com