Showing posts with label Parallel Computing. Show all posts
Showing posts with label Parallel Computing. Show all posts

Monday, February 23, 2009

Complie an MPICH2 Application (C++)

Developer Visual Studio 6.0

Visual C++ 6.0 cannot handle multiple functions with the same type signature
that only differ in their return type. So you must define HAVE_NO_VARIABLE_RETURN _TYPE_SUPPORT in your project.
1. Create a project and add your source files.
2. Bring up the settings for the project by hitting Alt F7. Select the Preprocessor
Category from the C/C++ tab. Enter “HAVE_NO_VARIABLE_RETURN_TYPE_SUPPORT”
into the Preprocessor box. Enter “C:\Program Files\MPICH2\include” into the “Additional include directories” box.
3. Select the Input Category from the Link tab. Add cxx.lib and
mpi.lib to the Object/library modules box. Add C:\Program Files\MPICH2\lib
to the “Additional library path” box.
4. Compile your application.
[Source: mpich2-doc-windev.pdf, section 9.10.2]

Developer Studio .NET 2003

For Developer Studio .NET 2003 or newer you can use the example projects provided with the release as a guide to creating your own projects.
1. Create a project and add your source files.
2. Bring up the properties dialog for your project by right clicking the project name and selecting Properties.
3. Navigate to Configuration Properties::C/C++::General
4. Add C:\Program Files\MPICH2\include to the “Additional Include Directories” box.
5. Navigate to Configuration Properties::Linker::General
6. Add C:\Program Files\MPICH2\lib to the “Aditional Library Directories” box.
7. Navigate to Configuration Properties::Linker::Input
8. Add cxx.lib and mpi.lib and fmpich2.lib to the “Additional Dependencies” box.
If your application is a C application then it only needs mpi.lib. If it is a C++ application then it needs both cxx.lib and mpi.lib. If it is a Fortran application then it only needs one of the fmpich2[s,g].lib libraries. The fortran library comes in three flavors fmpich2.lib, fmpich2s.lib and fmpich2s.lib. fmpich2.lib contains all uppercase symbols and uses the C calling convention like this: MPI INIT. fmpich2s.lib contains all uppercase symbols and uses the 9 RUNTIME ENVIRONMENT 30 stdcall calling convention like this: MPI INIT@4. fmpich2g.lib contains all lowercase symbols with double underscores and the C calling convention like this: mpi init . Add the library that matches your Fortran compiler.
9. Compile your application.
[Source: mpich2-doc-windev.pdf, section 9.10.2]

1. Trouble Shooting

C++ and SEEK_SET
Some users may get error messages such as
SEEK_SET is #defined but must not be for the C++ binding of MPI

The problem is that both stdio.h and the MPI C++ interface use SEEK_SET, SEEK_CUR, and SEEK_END. This is really a bug in the MPI-2 standard. You can try adding
#undef SEEK_SET
#undef SEEK_END
#undef SEEK_CUR

before mpi.h is included, or add the definition
-DMPICH_IGNORE_CXX_SEEK

to the command line (this will cause the MPI versions of SEEK_SET etc. to be skipped).
[Source: http://www.mcs.anl.gov/research/projects/mpich2/support/index.php?s=faqs#cxxseek]

Install MPICH2 on Windows XP

[Reference: http://www.mcs.anl.gov/research/projects/mpich2/documentation/index.php?s=docs]

STEP 1: INSTALLING MPICH2


1. Main MPICH homepage:

http://www.mcs.anl.gov/research/projects/mpich2/index.php

2. Download the Win32IA32 version of MPICH2 from:

http://www.mcs.anl.gov/research/projects/mpich2/downloads/index.php?s=downloads


3. Download Microsoft Visual C++ 2005 SP1 Redistributable Package (x86) and install the program.

http://www.microsoft.com/downloads/thankyou.aspx?familyId=200b2fd9-ae1a-4a14-984d-389c36f85647&displayLang=en#

4. Run the executable, mpich2-1.0.7-win32-ia32.msi (or a more recent version). Most likely it will result in the following error:

If you follow the link to download the .NET Framework it will download version 2.0.50727. To download version 2.0 use this link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=0856EACB-4362-4B0D-8EDD-AAB15C5E04F5&displaylang=en


5. Install the .NET Framework program

6. Install the MPICH2 executable. Write down the passphrase “behappy” for future reference. The passphrase must be consistent across a network.

7. NOTE: make sure that the MPICH2 versions are the same in all computers/machines. Otherwise, the following error massage may appear:

Aborting: unable to connect to ni, smpd version mismatch Aborting: unable to connect to ni, smpd version mismatch.



STEP 2: CHANGE COMPUTER SETTINGS

1. Copy the executable to the same directory in each machine (node). For example “C:\Program Files\MPICH2\examples\cpi.exe”

2. Set “ Network Connections”: Ensure that each machine can let its files shared by other computers by checking the option “Control PanelàNetwork and Internet ConnectionsàNetwork ConnectionsàLocal Area ConnectionàPropertiesàGeneral-File and Printer Sharing for Microsoft Networks”.

3. Set “Windows Firewall”:

    1. Ensure that Windows Firewall can allow files sharing by checking the option “Control PanelàSecurity CenteràWindows FirewallàExceptionsàFile and Printer Sharing”
    2. From the Exceptions Tab, select “Add Program” and make sure “C:\Program Files\MPICH2\bin\smpd.exe” and “C:\Program Files\MPICH2\bin\mpiexec.exe” are on the list.
    3. Form the Exception Tab, select “Add Program” and add the executable “C:\Program Files\MPICH2\examples\cpi.exe” into the exception list.

4. Add the MPICH2 path to Windows:

A. Right click “My Computer” and pick properties

B. Select the Advanced Tab

C. Select the Environment Variables button

D. Highlight the path variable under User Variables and click edit. Add “C:\Program Files\MPICH2\bin” to the end of the list; make sure to separate this from the prior path with a semicolon.

E. Highlight the path variable under System Variables and click edit. Add “C:\Program Files\MPICH2\bin” to the end of the list; make sure to separate this from the prior path with a semicolon.


STEP 3: RUN MPI


  1. Get Domain name, User name and Password for each machine (Node)
    1. Log on each machine you want to run on. This is not required, but prevents anyone else logging on and using the machine.
    2. Use Start MenuàRunà cmd.exe to opens command prompt window.
    3. Type in “ipconfig” to obtain the IP address of the machine. For example, “1.2.3.4
    4. In the machine, type in “ping –a 1.2.3.4” to resolve IP address to the host name, we can see: "Pinging hostname[1.2.3.4] with 32 bytes of data."
    5. However, “testmachine” is only a “host name” but not a “domain name”, which is required to find a computer in the network. To get the domain name, we have to ping the machine from another machine, then we will see: "Pinging domainname[1.2.3.4] with 32 bytes of data"
    6. Now we obtain the following informations:

Domain Name: domainname

It is required to find a computer in the network

Host Name: hostname

The host name can be used to identify a computer only when all the computers are in the same subnetwork.

IP Address: 1.2.3.4

User Name: username

The user name required to log in the machine

Password: **********

The corresponding password required to log in the machine

  1. Register each “user” in the master node so that a domain name, user name and password can be automatically retrieved by mpiexec to launch processes.

mpiexec –register user 1 domainname\username\**********

Mpiexec will ask you to enter the domain name, user name and password.

  1. Validate the saved user information:

mpiexec –validate user 1”

Mpiexec should return a message “SUCCESS”.

  1. Go to the working directory

C:\> cd C:\workingdirectory

C:\workingdirectory>

  1. In the working directory, run the example executable to insure correct installation.

mpiexec –n 2 c:\program files\mpich2\examples\cpi.exe

mpiexe c –hosts 2 domainnameA 1 domainnameB 1 c:\program files\mpich2\examples\cpi.exe