6

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?

rene
  • 41,474
  • 78
  • 114
  • 152
gpuguy
  • 4,607
  • 17
  • 67
  • 125

2 Answers2

3

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).

jev
  • 2,023
  • 1
  • 17
  • 26
  • Is this for linux or cmd in windows ? Also what is hostfile and hosts.cfg? is there any sample .cfg file? – gpuguy Oct 13 '13 at 14:10
  • The command is called `mpiexec.exe` on Windows, on Linux the command would be just `mpiexec`. Using SMPD (check install guide) should work on both Windows and Linux provided the mpich versions across machines are the same. mpiexec is just a wrapper script. Have you tried connecting a second node via ethernet and you can remotely login onto it? – jev Oct 13 '13 at 14:16
  • Yes, I can login in but this way: network=> double click icon of the second PC connected in ethernet.=>enter user ID & password. And now I am into this second PC. My question was what is machinefile and hosts.cfg? do I write something in these two files? – gpuguy Oct 17 '13 at 08:35
  • `-machinefile hosts.cfg` is a single switch. A machine file is a text file with one hostname per line that you want to be part of your job. You can just make one in Notepad. Jev named his file `hosts.cfg`, you can name it anything you want. – Adam Oct 17 '13 at 08:56
2

After much hard work I was able to contact the support team and teh answer which I got is:

Unfortunately the MPICH team no longer supports their Windows version

However, there is still some hope left as MS-MPI could still be used:

http://wiki.mpich.org/mpich/index.php/Frequently_Asked_Questions#Q:_Why_can.27t_I_build_MPICH_on_Windows_anymore.3F

Unfortunately, due to the lack of developer resources and interest, the last version of MPICH which was supported on Windows was MPICH2 1.4.1p. There is minimal support left for this version, but you can find it on the downloads page: http://www.mpich.org/downloads/ Alternatively, Microsoft maintains a derivative of MPICH which should provide the features you need. You also find a link to that on the downloads page above. That version is much more likely to work on your system and will continue to be updated in the future. We recommend all Windows users migrate to using MS-MPI.

gpuguy
  • 4,607
  • 17
  • 67
  • 125
  • I'd switch to Linux/Unix, ussually MPI works out of the box there without too much configuration hassle (e.g. [OpenMPI](http://www.open-mpi.org/)) – jev Oct 24 '13 at 09:47
  • @jev I did the same thing. But [facing some issues again](http://stackoverflow.com/questions/19565795/unable-to-execute-mpich2-on-multiple-machines-on-ubuntu-12-04-hydu-sock-connect) in Ubuntu 12.04 – gpuguy Oct 24 '13 at 12:23