A. Install OpenMPI
$ sudo apt-get install libopenmpi-dev openmpi-bin openmpi-doc $ sudo apt-get install ssh
B. Configure SSH
$ ssh-keygen -t dsa$ cd ~/.ssh
$ cat id_dsa.pub >> authorized_keys
C. MPI Program Example
Filename: MPI_Hello.c#include <stdio.h>
#include <mpi.h>
int main(int argc, char** argv)
{
int myrank, nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
printf("Hello from processor %d of %d\n", myrank, nprocs);
MPI_Finalize();
return 0;
}
D. Compilation
$ mpicc MPI_Hello.c -o MPI_HelloE. Execution
$ mpiexec -n 5 MPI_HelloF. Integrated Development Environment
We will use Geany as an IDE to make compilation process easier and faster. To compile MPI program with Geany, follow these steps:- Install Geany.
$ sudo apt-get install geany
- Download MPI tags file and copy to ~/.config/geany/tags/
$ wget http://auriza.site40.net/docs/paralel/openmpi.c.tags $ cp openmpi.c.tags ~/.config/geany/tags/
- Start Geany, and write MPI program example above.
- Compilation setting: Build - Set Includes and Arguments.
Compile: mpicc -Wall "%f" -o "%e" Execute: mpiexec -n 5 "%e"
6. To execute program: click Execute.
Hey
ReplyDeleteThanks for the tutorial but when i compiled my program i got the following error Plz help
/usr/bin/ld: cannot find -lcr
collect2: ld returned 1 exit status
sorry for the delay...i was caught up in lot of things...
DeleteThis error shows that you are not able to link with the 'cr' library.
Try installing it by -
$ sudo apt-get install libcr-dev
After installation is complete. Try to compile your mpi code again.
Thanks for the all-encompassing tutorial. It took me about 30 seconds as opposed to the hours I spent trying to get it working the other day.
ReplyDeleteThanks...really glad to hear that I could be of help. :-)
DeleteThanks buddy. IT works.
ReplyDeleteSaved my day, thanks
ReplyDeleteThank very much!
ReplyDeleteDear Gaurav,
ReplyDeleteThank you very much!
You've done a marvelous job! Thanks once again!
OpenMPI was successfully installed in my machine running Ubuntu 12.04.
By the way, there are a couple of problems in my installation as bellow
1) SSH configuration:
vishal@vishal-Inspiron-1525:~/.ssh$ cat id_dsa.pub >> authorized_keys
cat: id_dsa.pub: No such file or directory
2) Geany configuration (Site seems down)
/.ssh$ wget http://auriza.site40.net/docs/paralel/openmpi.c.tags
--2013-04-13 16:44:53-- http://auriza.site40.net/docs/paralel/openmpi.c.tags
Resolving auriza.site40.net (auriza.site40.net)... 31.170.162.203
Connecting to auriza.site40.net (auriza.site40.net)|31.170.162.203|:80...
failed: Connection timed out.
Retrying.
--2013-04-13 16:45:58-- (try: 2) http://auriza.site40.net/docs/paralel/openmpi.c.tags
Connecting to auriza.site40.net (auriza.site40.net)|31.170.162.203|:80... failed: Connection timed out.
Retrying.
Pl help.
Thanks in advance.
-
Vishal V. Parkar
Hi vishal,
Delete1. "cat: id_dsa.pub: No such file or directory" - This error indicates that the cat command cannot find your specified file. So check your current ssh directory for id_dsa.pub file. If its not generated, then generate it using ssh.
2. http://auriza.site40.net site seem to be down. So you are not getting the tag files. Actually these files are just required for auto completion feature in geany. So you don't necessarily need them. The main compilation and execution is done by the mpicc and mpiexec command which can be done without geany as well.
Let me know if there is any further complication.
DeleteThank you for your tutorial. It resulted in my very first MPI program. I hope you have a great weekend!
ReplyDeleteJust for anyone that might have any problems I found the following two terminal commands helpful.
$ mpicc --showme:link
$ mpicc --showme:compile
Also mpic++ can be used for fileName.cpp programs
Thanks a lot, it's really helpful artical
ReplyDeleteThankz a lot !!
ReplyDeleteTHANKS from Russia
ReplyDelete