You are on page 1of 11

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

MPI configuration with Visual C (Visual Studio 2008)


Mumtazimah binti Mohamad & Md Yazid Mohd Saman Department Computer Science , Faculty of Science & Technology Universiti Malaysia Terengganu Email: mumtaz@udm.edu.my

1.0 Introduction to Message Passing Interface and MPICH2 Message Passing Interface(MPI) is a specification for a standard library for message passing that was defined by the MPI Forum, a broadly based group of parallel computer vendors, library, writers, and applications specialists(Gropp et al., 1996). MPI is combine interface, the protocol and semantic specifications for how its features must behave in any implementation (such as a message buffering and message delivery progress requirement). MPI includes point-to-point message passing and collective (global) operations, all scoped to a user-specified group of processes. MPICH is a freely available, complete implementation of the MPI specification, designed to be both portable and efficient. The CH in MPICH stands for Chameleon, symbol of adaptability to ones environment and thus of portability. Chameleons are fast, and from the beginning a secondary goal was to give up as little efficiency as possible for the portability. MPICH2 is extension of MPI1 with high performance and widely portable implementation of message passing interface (MPI) standard. It is developed by Argonne National Laboratory. The goal of MPICH2 are (1) to provide an MPI implementation that supports different computation and communication platforms including commodity clusters (desktop systems, shared-memory systems, multicore architectures), high-speed networks(e.g. infiniBand) and propriety high-end computing(e.g. Cray) (2) to enable cutting-edge research in MPI through an easy-to-extend modular framework for other derived implementations (ANL, 2005). MPICH2 should be used instead of MPICH1 except for the case of clusters with heterogeneous data representations (e.g., different lengths for integers or different byte ordering). MPICH2 is distributed as source (with an open-source, freely available license). It has been tested on several platforms, including Linux (on IA32 and x86-64), Mac OS/X (PowerPC and Intel), Solaris (32- and 64-bit), and Windows. MPICH2 support Multiple Program Multiple Data(MPMD) and clusters on

different platform and have C++ standard binding as previous MPICH1. 1.1 Other windows-based MPI implementations.

There are other windows-based implementations such as:


i. ii. iii. iv. v. vi. vii. viii.

WMPI1.3 works on Microsoft Windows95 and Windows NT. mp-mpich from RWTH: Scalable Computing, Aachen i. Contact: mp-mpich@lfbs.rwth-aachen.de MPI-FM from University of Illinois, Concurrent Systems Architecture Group i. Contact: fast-messages@red-herring.cs.uiuc.edu MPICH/NT from Mississippi State University i. Contact: shane@erc.msstate.edu and boris@cs.msstate.edu MSMPI from Microsoft i. Source : http://technet.microsoft.com/en-us/library/cc720120%28WS.10%29.aspx MPI/LAM - developed by Indiana, OSC, Notre Dame (freeware) MPI/Pro - commercial product Apple's X Grid 1

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010 ix.

OpenMPI - MPI-2 compliant, thread safe

The similarities in various implementations are:


Source code compatibility (except parallel I/O) Programs should compile and run as it is Most of them support for heterogeneous parallel architectures such as clusters, groups of workstations, SMP computers and grids.

The various MPI implementations as above list maybe differs in commands for compiling and linking, MPI program launching, parallel I/O (start from MPI-2) and also debugging. Approaches of programming in most MPI windows-based implementation can be Single Program Multiple Data(SPMD) where the same program is on all processors and Multiple Program Multiple Data ( MPMD) where the different programs is located on different processors. 2.0 Configuration of MPICH and Visual C++ in Visual Studio 2008 In order to support MPI programming for multiprocessor and parallel computing, we have to have the MPI implementation standard. Note that this configuration is done unto Windows Vista Home Premium 32 bit operating system. The installation should also applied to Windows XP. We need: Visual C++ from Visual Studio 2005 or visual Studio 2008 as a compiler. MPICH2 for MPI library component for MPI windows-based implementations 2.1 Visual Studio 2008 Both the express and professional editions can be used. The express edition can be downloaded from Internet at http://cplus.about.com/od/learnc/ss/vc2008_2.htm . The incoming configuration also can be applied on Visual Studio 2003 and Visual Studio 2005 where it has been tested to be similar. The use of Visual Studio 2010 is yet to be tested. 2.2 Configuring MPI with MPICH2 The MPICH2 setup can be downloaded at http://www.mcs.anl.gov/research/projects/mpich2/ . This version is 32bit edition. i. Double click on downloaded setup then it will automatically install on the machine. Figure 1.1 shows the setup wizard for installation.

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

Figure 1.1 : The installation windows There is a step that the process manager setup remind the user to remember the passphrase given. The default value of the passphrase is behappy as shown in figure 1.2. This passphrase will be used during SMPD service that capable to make processes from variety of platform.

Figure 1.2 : Step 2 of the installation: Passphrase ii. Edit the system path

After the mpich2 installation is done. Add the following to system path (in Vista: right click My Computer/Properties/Advanced System Settings/ Advanced/ Environment Variables) C:\Program Files\MPICH2\bin Edit the path variable for either the system or user variables. This also works on XP but the advanced setting does not exist. 3

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

Figure 1.3 : Editing the system path iii. Add the following exceptions to your firewall: C:\Program Files\MPICH2\bin\mpiexec.exe C:\Program Files\MPICH2\bin\smpd.exe

Usually, you will receive a message to unblock these programs. But in case you don't, you have to add them manually. iv. Register a user account with MPI. Go to C:\Program Files\MPICH2\bin\wmpiregister and type in the user account and password that will be used to start MPI jobs. You should have the same user account and password on all your cluster machines Open port 8676. Go to C:\Program Files\MPICH2\bin\wmpiconfig and select "port" at the top of the list

v.

Note that if you install the 32 bit MPICH2 on a 64 bit windows, the MPICH installation directory will be under "Program Files (x86)".

2.3 Configuring Visual Studio 2005 or 2008 Now, to setup the environment in Visual Studio we have to tell the compiler where to find the MPI header files and libraries, do the following a. Start Visual Studio and go to menu Tools>Options>Projects and Solutions>Visual C++ Directories.

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

In the platform list, select win32. At Show directories for dropdown list, choose Include files. Add the following path to list by click new list icon. It can be done by directly type or by browsing the lib file location as follows: C:\Program Files\MPICH2\include

Figure 1.4 : Configuring the include file of MPICH2 b. Change directory to Library Files and add new path to the library files list as figure 1.5. add the following path: C:\Program Files\MPICH2\lib

Figure 1.4 : Configuring the library file of MPICH2 This setting is configured once after installation of MPICH2. 5

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

2.4 Configuring MPI project during coding To develop a new project, click menu File and choose New Project. There will be a menu for setting a new project as in figure 1.6. Choose Visual C++ project type and click Win32. On the right, there will templates for win32 project, click on the Win32 Console Application. Name the project name and the location to be saved. Then click OK.

Figure 1.6 : Creating a new project of win32 console application Figure 1.7 appear afterwards and choose empty project and click Finish button.

Figure 1.7: Setting the project Before start writing any codes, each MPI project should have the following setting manually.

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

Click on project Name, and select menu Project and choose Properties. Click Configuration Properties, then choose C/C++ and click on General. On Additional Include Directories, add (or browse) the following entry: C:\Program Files\MPICH2\include

Figure 1.8 : Setting the include file project As figure 1.7, Select "Linker" tree menu and choose Input. In Additional Library Directories add the following entry: C:\Program Files\MPICH2\lib

Figure 1.9 : Setting the library file project The last one is by selecting Linker> Input> on the left side. Choose Additional Dependencies by add mpi.lib and click OK button as shown in Figure 1.10. 7

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

Figure 1.10 : Setting the input library of project 2.5 MPI Debugging with Visual Studio Open your project properties, and go to Configuration Properties and choose Debugging. Set the the following properties:
1.

MPIRun Command is the path and filename of your mpirun application (usually mpiexec.exe or mpirun.exe), if the default path is "c:\Program Files\MPICH2\bin\mpiexec.exe" (do not forget the ). Make sure the mpiexec file in the located file.

Figure 1.11 : Setting the mpiexec 8

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010 2.

MPIRun Arguments are the arguments we want to pass to the mPIRun command, at very least we have to tell mpi the number processes to spawn, so we use n 2 (or np 2) for 2 processes (change 2 as you wish).

Figure 1.12 : Setting the MPI application command


3.

MPIShim Location is the path and filename of your mpishim.exe file. Mpishim.exe is different for every release of visual studio and platform you have. For example its location for Visual Studio 2008 and 2005 for 32bit platforms should be C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86

Figure 1.13 Setting Configuring MPI project during : coding the MPI properties 9

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

Debugging

Figure 1.14 : Setting the MPI properties MPI program should define their library header which is mpi.h among all other libraries. To start debugging the MPI program, write some mpi code or, copy MPI helloworld program and paste into source file .cpp. Compile and run on command prompt where, the executable file is located Example: C:\..\theProject\debug\mpiexec np 3 exefile.exe mpiexec - mpirun command np for number processor syntax 3 is for numbers of processor include master exefile is file executable file of compiled program.

Figure 1.15 : Running on command prompt 10

MPI configuration with Visual C (Visual Studio 2008) (C) Mumtazimah Mohamad UniSZA 2010

4.0 Conclusion Before programming make sure the following work was finished. 1. The windows cluster works well by configuration in 2.5. 2. The Visual Studio host computer (the one from which you are debugging) must has been setted up as in 2. 3. MPICH2 must be installed and configured on each node of the cluster 4. The Visual Studio Remote Debugging Monitor (msvsmon.exe) must be installed on each node in the cluster. 5. The MPIShim.exe file must be installed on each node in the cluster, and in the same location on each node. 5.0 References 1. M. Y. Saman ;D. J. Evans, Manual on System Setup for PC Cluster with WMPI and Microsoft Visual C++, 1994
2. 3.

http://www.tuncbahcecioglu.com/posts/mpi-debugging-with-visual-studio/ A L. (2005). MPICH2: High-Performance and Widely Portable MPI. USA: Argonne ational Laboratory. Gropp, W., Lusk, E., Doss, ., & Skjellum, A. (1996). A high-performance, portable implementation of the MPI message passing interface standard. Parallel Computing, 22(6), 789-828.

4.

For more information, please contact: Mumtazimah binti Mohamad1 & Md Yazid Mohd Saman2 1 Email: mumtaz@udm.edu.my 2 Department Computer Science , Faculty of Science & Technolog Universiti Malaysia Terengganu Date: October 2010-09-20

11

You might also like