Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPI: MPICH2 Installation and programming in LAN with Windows

Tags:

mpi

mpich

I am learning MPI. The first tutorial I followed is here

The code that I run successfully on Windows 7 with MSVC 2010 is :

#include "mpi.h"
#include "iostream.h"

int main(int argc,char *argv [])
{
   int numtasks, rank, rc; 
   rc = MPI_Init(&argc,&argv);
   if (rc != MPI_SUCCESS) {
       printf ("Error starting MPI program. Terminating.\n");
       MPI_Abort(MPI_COMM_WORLD, rc);
   } 
   MPI_Comm_size(MPI_COMM_WORLD,&numtasks);
   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
   printf ("Number of tasks= %d My rank= %d\n", numtasks,rank);
   MPI_Finalize();
}

I am successfully running this code on my Pentium-4 machine (dont be surprised I am still having one Pentium-4).

Now I want to run this code (or any other MPI code) on multiple machines connected in a Ethernet LAN. Say for example each machine sums 1 to 1000, and send back to a master node, the master node then adds all those numbers to get the final sum.

My question is how to start MPI programming in a network? What all tools/softwares should I run in each machine.

I will really appreciate if you can give me a pointer to a tutorial.

MPI Implemnetation: MPICH2 
O.S:each machine is having Windows 7, 32 bit CPU: Intel's Pentium 4 and Dual core 
Network: Ethernet 
IDE:MSVC2010

UPDATE:

I got some of my doubts cleared with Jev's answer. My latest questions are:

Do I install MPICH2 in each machine. After writing names of each machine per line in the cfg file, Do I need do anything else or just give the command:

<path-to-mpich2>/bin/mpiexec.exe -machinefile hosts.cfg -n nPEs <your-executable>

how would I know that my application is running on every machine? While running the app do I need to do some special configuration etc on each machine?

like image 707
gpuguy Avatar asked Oct 12 '13 08:10

gpuguy


1 Answers

Add the connected machines to a hostfile and pass the file to the mpiexec:

<path-to-mpich2>/bin/mpiexec.exe -machinefile hosts.cfg -n nPEs <your-executable>

Check sections 5.4 and 9 from the MPICH user's guide.

Update:

Yes, you need to install the MPI library on each machine. Moreover, you need to start the process manager daemon on each machine and enable automatic remote login (e.g .using ssh). Then run a test using mpdtrace or a simple hello world program that prints out hostname of each machine. If it works and you will get different hostnames printed. If installation runs smoothly, there should be no need for special configuration (e.g. setting correct path to the library).

like image 73
jev Avatar answered Oct 23 '22 22:10

jev