OpenMPI on Ubuntu 9.04

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_Hello

E. Execution

$ mpiexec -n 5 MPI_Hello
[MPI program compilation and execution on terminal]

F. 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:

  1. Install Geany.
    $ sudo apt-get install geany
  2. 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/
  3. Start Geany, and write MPI program example above.
  4. Compilation setting: Build - Set Includes and Arguments.
    Compile:
    mpicc -Wall "%f" -o "%e"
    Execute:
    mpiexec -n 5 "%e"
    [Geany 'Set Includes and Arguments' dialog window]
  5. To compile program: click Compile.
  6. To execute program: click Execute.

14.03.2009. 18:13 EDT

Jim Parker on 24.03.2009. 21:18 EDT

Great tutorial. Followed directions using Ubuntu 8.10 and all worked as advertised.
thanks.
--Jim

lgisenk on 14.04.2009. 13:59 EDT

[OOT]
Maaf OOT, saya kira google translatenya akan langsung menampilkan hasi terjemahan halaman ini, namun ternyata hanya memberikan keterangan bahwa halaman ini sudah diterjemahkan. Pencegahan spamnya menggunakan penambahan ya, alhamdulillah bilangan-bilangan yang ditambahkan kecil, sebab saya pernah mengunjungi situs yang menggunakan bilangan-bilangan yang besar untuk mencegah spam (>10).
Btw, the contents is nice!

Kirill Ponomaryov on 19.01.2010. 13:52 EST

Very useful tutorial. It helps me to set up openmpi on my Ubuntu 9.10. Thank you very much for this post.

Mostafijur on 03.03.2010. 19:18 EST

Thanks for the tutorial. Its working on my UBUNTU 9.04.

Auriza Akbar on 11.03.2010. 18:19 EST

I'm glad it's useful for you. Thank you for the comments.

Vojta on 10.04.2010. 15:40 EDT

I had some problems with compiling your example code using mpicc.
Solved - using mpic++, then no problem.
Maybe it could help someone...

Thanks for great tutorial

mpiManiac on 21.04.2010. 08:43 EDT

you should also do this, if you have created passphrase while creating key pairs. This will remove the prompt for passphrase eveytime to run mpirun (or mpiexec)

# ssh-add $HOME/.ssh/id_dsa

(check ssh-agent is running or not by # eval `ssh-agent`)

TSO on 14.06.2010. 14:59 EDT

Thank you for this tutorial. It is quite helpful.

calcpage@aol.com on 31.08.2010. 17:24 EDT

I'm confused on the setting up ssh. Do I have to enable sshd first? Do I set up ssh on each node? Will all cores be used, for example, if I set up 2 nodes each with dual-core, will I get 4 cores running?

TIA,
calcpage@aol.com

Auriza Akbar on 01.09.2010. 00:15 EDT

I'm sorry I can't explain it right now, because this was part of my college project one year ago, and honestly I don't remember the detail of the setup. If I recalled it correctly, you need to setup only one SSH server in the root/master SSH server on every node, and then add the root/master node's SSH key to every node. And yes, you'll get 4 cores running when you run MPI program on 2 nodes of dual-core PC (using command mpiexec -n 4 [executable]). Check out this link [ http://techtinkering.com/articles/?id=32 ] to help you set up the SSH. This guide was intended to set up OpenMPI on one node only. If you want to set up MPI cluster, there are additional requirements that you can find on the link above.

Zia on 10.10.2010. 18:26 EDT

Good job. Thank you.

irma on 20.10.2010. 04:44 EDT

Thanks for your information.
I want to search the source code using MPI in Windows XP, to:
1) matrix multiplication 900 x 901 and 901 x 900

2) searching


I hope, you can help me. tq

Auriza Akbar on 20.10.2010. 12:40 EDT

In this website, I wrote two post that contain Parallel Merge Sort and Fox's Matrix Multiplication Algorithm source code. I also included the presentation slides to explain how they work. You can find them here: [ http://auriza.site40.net/notes/docs/paralel/ ]. Parallel searching is relatively easy, just split the data, search individually per CPU, and gather the result.

Igor on 28.11.2010. 13:32 EST

Thank you lot! After so much googling on the net trying to find some simple and useful instructions, and getting just some complex documentation, I found this great article.
Thank you once again!

Stacy on 11.12.2010. 15:58 EST

Thank you, very useful and clear article.

Ediz Türkoğlu on 28.02.2011. 17:28 EST

Perfect tutorial! Thank you...

Seun on 16.03.2011. 01:49 EDT

Auriza,I am trying to get the fox algorithm source code, can you please direct me to where I can find it?

Thanks for your help.

Auriza Akbar on 18.03.2011. 00:36 EDT

http://auriza.site40.net/notes/docs/paralel/MPI_FoxMatrixMult.c

Xavier Bustos on 15.06.2011. 00:48 EDT

Very helpful indeed.thanks a lot.

boian on 26.07.2011. 16:50 EDT

Very helpful! Thanks!

Javier Ruiz on 16.09.2011. 07:51 EDT

Lots of fun! I already compiled my first MPI program!

Thank you very much from Tenerife.

Parzifal on 09.10.2011. 08:55 EDT

Great tutorial, saved me a lot of time. Parallel Computing done easy, thanks a lot!!

fatin on 08.12.2011. 11:01 EST

hello. i get a problem in cd ~/.ssh. there is no such file or directory. hope u can help me. thank you..

Auriza Akbar on 03.01.2012. 00:49 EST

Have you run "ssh-keygen" successfully?

student on 09.02.2012. 12:06 EST

Thanks!

SACHIN KANSAL on 25.07.2012. 11:25 EDT

I am getting this output,............

please help me out ....


SACHIN KANSAL
Process 0 on sachin-laptop out of 1

SACHIN KANSAL
Process 0 on sachin-laptop out of 1

SACHIN KANSAL
Process 0 on sachin-laptop out of 1

SACHIN KANSAL
Process 0 on sachin-laptop out of 1

Auriza Akbar on 25.07.2012. 22:34 EDT

Maybe your mpiexec command was wrong.

Valek on 03.09.2012. 14:03 EDT

I use fortran and I have some problem with launching.
First I compile a program mpif90 -o test test.py
then I try to run it mpirun -np 2 test
but there isn't any actions, nothing happends((

ShadoX on 02.12.2012. 12:26 EST

I'm getting the following error when I try to run the program:

Lamnodes Failed!
Check if you had booted lam before calling mpiexec else use -machinefile to pass host file to mpiexec

Slimen Belhaj Ali on 26.02.2013. 15:40 EST

thank your, it is very good :) :)

<< First < Previous [1 / 2] Next > Last >>

Write a comment

* = required field

:

:

:


2 + 7 =