Posts Tagged ‘High Performance Computing’

Recently I tried to build a cluster out of my Laptop and Desktop using Ubuntu. Following is the step by step guideline on how to do same.

My PC is running Ubuntu 14.04 i386 and My Laptop is running Ubuntu x86_64 version. So yes, you can build a cluster successfully out of two different systems.
Both the systems should be on the same subnet.
In this case, IP address of my Laptop :
IP of my PC :

password-less ssh login for both the systems
Followed the tutorial from…

apt-get install following packages on both the systems:

and other basic developer tools such as gcc etc. which we normally need for development.
In my case openmpi libraries got installed to
So I added the following to my .bashrc file:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/openmpi/lib/

Now your system is ready.
Lets test it now.
Open a editor of your choice (I prefer vim) and type the following program:
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main ( int argc, char **argv )

int rank, size;
MPI_Init ( &argc, &argv );
MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
MPI_Comm_size ( MPI_COMM_WORLD, &size );
printf ( “Hi, I am %d of %d\n”, rank, size );
system ( “hostname” );
MPI_Finalize ();
exit ( EXIT_SUCCESS );

Save the program as hello.c in your home directory.
Now compile the above program as
mpicc -o hello hello.c

mpicc is nothing but a fancy wrapper of gcc.
repeat the above steps for another system also.

Create a file named hosts.txt (it can be any name) on either of the machine with the following contents.

You can replace above ip addresses with the ones you have for your nodes.
Now lets run it as follows:
mpirun -np 4 -hostfile hosts.txt ~/hello

You will see 4 outputs most probably two from either of the systems.
Hi, I am 0 of 4
Hi, I am 1 of 4
Hi, I am 2 of 4
Hi, I am 3 of 4

The order may get shuffled depending on the scheduling of the processes on both systems and which system return the output first.
But yes, it did not serve my purpose as I will have to search for now MPI enabled equivalents of the application I am using but yes, its a start.
Welcome to the world of Supercomputing.

Here is a link to Quora Post where I posted this in original.