Installing MPI on a Microsoft Windows machine
This page describes how I set up MPI on a Microsoft Windows machine. This is not the only way, or even the simplest way, to set up MPI under Windows, but it worked for me. If you download a Windows version of MPI, you will install libraries for use with Microsoft Visual C++. If you have Microsoft Visual C++, you can probably get it to work pretty easily.
I did not have Microsoft Visual C++, so had to use a more complicated method, described below.
Note: Before installing MPI, I had already installed PVM on my machine. There may well be parts of the PVM installation that are necessary for MPI. So if something does not work for you, you might go to pvm.htm and install PVM and get it working, then return to installing MPI.
Things to Download
The latest release of MPICH, from http://www-unix.mcs.anl.gov/mpi/mpich/. Make sure you download the Unix version (unless you have Visual C++, then feel free to download the Windows version, but the rest of these instructions will not work for you).
The latest version of Cygwin from www.cygwin.com. Look for the "Install Now" icon about halfway down the page. This will download an installation program for Cygwin.
Where to Put Things
First, install the latest version of Cygwin. This will take quite some time, as the installation program downloads everything it needs from the Internet. On a 56K modem, it took me a couple of hours to download the full version of Cygwin. The default installation location is C:\Cygwin.
Second, unzip the MPI files into your main Cygwin directory, also keeping the directory structure from the zip file. This will create an mpich-1.2.2.2 directory underneath C:\Cygwin.
How to Get it Working
1) MPICH does not explicitly support Cygwin, so we must let it think we are using a generic version of Unix. Start a Cygwin shell and go to the /mpich-1.2.2.2 directory. Type:
configure --prefix=/mpich-1.2.2.2 --with-arch=freebsd
This will take a few minutes, while the configure script determines what your computer can and cannot do. Makefiles tailored to your setup are created during this process.
2) Edit /mpich-1.2.2.2/romio/adio/include/adio.h, and add a #include <sys/vfs.h> statement.
3) If you have not already installed PVM on your machine, go to pvm.htm and follow the directions for downloading and unzipping the Unix version of PVM. Then, do these three steps (steps taken from an older document on porting MPICH to Cygwin, at http://www.csa.ru/~il/Parallel/mpich4win32.shtml. These were the only steps that needed to be done out of that document).
3.1 in file types.h comment this block:
typedef char *caddr_t; typedef unsigned int u_int; typedef unsigned long u_long; typedef unsigned short u_short;3.2 Create the file inst_xdr and paste in this (if your PVM root directory is not /PVM3.4, change the PVM_PATH option to where ever yours is):
#!/bin/sh # This is 'inst_xdr' script #-----------------# Options # PVM_PATH=/PVM3.4 LIB_NAME=/usr/lib/libcygwin.a [ -d $PVM_PATH ] || (echo ERROR: incorrect PVM_PATH value; exit 1) [ -f $LIB_NAME ] || (echo ERROR: incorrect LIB_NAME value; exit 1) cd ${PVM_PATH}/xdr test -d /usr/include/rpc || mkdir /usr/include/rpc cp *.h /usr/include/rpc cat>/usr/include/rpc/rpc.h<<XPEH_BAM_BCEM_B_POT /* written by EBCEEB */ #ifndef _RPC_RPC_H_ #define _RPC_RPC_H_ #include <rpc/types.h> #include <rpc/xdr.h> #include <netinet/in.h> #include <netdb.h> #endif XPEH_BAM_BCEM_B_POT cc -c *.c test -f ${LIB_NAME}.bak || cp ${LIB_NAME} ${LIB_NAME}.bak ar rs ${LIB_NAME} *.o 3.3 Run inst_xdr
4) You should now be able to compile MPICH by going to /mpich-1.2.2.2 and typing make. This will take quite some time, but should compile everything. At the end, you may get an error about mpicc, but it doesn't seem to affect anything. You will also see some warnings about multiple definitions of INADDR_LOOPBAC, but it also doesn't affect anything.
5) The directory /mpich-1.2.2.2/examples/basic has simple examples and a makefile you can adapt for your own assignment. Make sure you can compile the examples by going to /mpich-1.2.2.2/examples/basic and typing make. After the compile is finished, you should be able to type /mpich-1.2.2.2/bin/mpirun -np 1 cpi to run the estimating PI example.
The -np flag to mpirun tells the number of processes you want to use. I have not been able to get more than one process working, but even so you should be ale to compile MPI programs at home and get them working before going to the lab to make sure they work with multiple processes.
How to Compile Programs That Use MPI
Since the MPI assignment hasn't been given yet, this is left as an exercise for the reader. Look at the makefile in /mpich-1.2.2.2/examples/basic and modify it to compile your code.
Troubleshooting
Fortunately, I had very little trouble getting MPI to work, other than the multiple process problem. So if you have problems during the configure or make stage, you are on your own. Isn't programming fun?
A bit more on the multiple process problem. If you try to run multiple processes (e.g. -np 2 or more) MPI will try to use rsh to start the other processes. Cygwin does not come with the rsh daemon configured, and I haven't been able to figure out how to get it to work. So you're stuck with only one process. This means that you can execute your supervisor portion of the code, but the worker portion of the code will never execute (because with only one process, you'll never have any workers). So you can make sure your code compiles, and make sure that the supervisor portion seems to work, and then take the code to Franklin's lab to finish testing the worker portion of the code by running with more than one process.