MPI: MPICH2 Installation and programming in LAN with Windows
Asked Answered
S

2

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?

Sinuous answered 12/10, 2013 at 8:45 Comment(0)
A
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).

Abhorrence answered 13/10, 2013 at 14:6 Comment(4)
Is this for linux or cmd in windows ? Also what is hostfile and hosts.cfg? is there any sample .cfg file?Sinuous
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?Abhorrence
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?Sinuous
-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.Thaddeusthaddus
S
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.

Sinuous answered 22/10, 2013 at 5:24 Comment(2)
I'd switch to Linux/Unix, ussually MPI works out of the box there without too much configuration hassle (e.g. OpenMPI)Abhorrence
@Abhorrence I did the same thing. But facing some issues again in Ubuntu 12.04Sinuous

© 2022 - 2024 — McMap. All rights reserved.