Pervasive Technology Labs logo

MPI.NET Tutorial: Installation

  |   Home   |   Download   |   Documentation   |  

In This Section

Prerequisites

To develop parallel programs using MPI.NET, you will need several other tools. Note that you do not need to have a Windows cluster or even a multi-core/multi-processor workstation to develop MPI programs: any desktop machine that can run Windows XP can be used to develop MPI programs with MPI.NET.

  • Microsoft Visual Studio 2005 (or newer), including Microsoft Visual C#: we will be writing all of our examples in C#, although MPI.NET can be used from any .NET language.
  • MS-MPI: MPI.NET is built on Microsoft's implementation of the Message Passing Interface. There are actually two different ways to get MS-MPI (you only need to do one of these):
  • Windows Installer: most Windows users will already have this program, which is used to install programs on Microsoft Windows.

Install MPI.NET SDK

To develop programs for MPI.NET, you will need the MPI.NET software development kit, which you can download from the MPI.NET download page. Execute the installer to install the MPI.NET Software Development Kit.

MPI.NET Installer

Ping? Pong! Running an MPI program

Once the MPI.NET SDK has been installed, it's time to run our first MPI program. Open up a Command Prompt and navigate to the location where you installed the MPI.NET SDK. You should type what is shown in red.

C:\>cd "C:\Program Files\MPI.NET"

Then, execute the program PingPong.exe:

C:\Program Files\MPI.NET>PingPong.exe
Rank 0 is alive and running on jeltz

Here, we have executed the MPI program PingPong with a single process, which will always be assigned rank 0. The process has displayed the name of the computer it is running on (our computer is named "jeltz") and returned. When you run this program, you might get a warning from Windows Firewall like the following, because PingPong is initiating network communications. Just select "Unblock" to let the program execute.

Windows Firewall Security Alert

To make PingPong more interesting, we will instruct MPI to execute 8 separate processes in the PingPong job, all coordinating via MPI. Each of the processes will execute the PingPong program, but because they have different MPI ranks (integers 0 through 7, inclusive), each will act slightly differently. To run MPI programs with multiple processes, we use the mpiexec program provided by the Microsoft Compute Cluster Pack or its SDK, as follows (all on a single command line):

C:\Program Files\MPI.NET>"C:\Program Files\Microsoft Compute Cluster Pack\Bin\mpiexec.exe" -n 8 PingPong.exe
Rank 0 is alive and running on jeltz
Pinging process with rank 1... Pong!
  Rank 1 is alive and running on jeltz
Pinging process with rank 2... Pong!
  Rank 2 is alive and running on jeltz
Pinging process with rank 3... Pong!
  Rank 3 is alive and running on jeltz
Pinging process with rank 4... Pong!
  Rank 4 is alive and running on jeltz
Pinging process with rank 5... Pong!
  Rank 5 is alive and running on jeltz
Pinging process with rank 6... Pong!
  Rank 6 is alive and running on jeltz
Pinging process with rank 7... Pong!
  Rank 7 is alive and running on jeltz

That's it! The mpiexec program launched 8 separate processes that are working together as a single MPI program. The -n 8 argument instructs mpiexec to start 8 processes that will all communicate via MPI (you can specify any number of processes here). In the PingPong program, the process with rank 0 will send a "ping" to each of the other processes, and report the name of the computer running that process back to the user. Since we haven't told mpiexec to run on different computers, all 8 processes are running on our workstation; however, the same program would work even if the 8 processes were running on different machines.

If PingPong ran correctly on your system, your installation of MPI.NET is complete and you're ready to move on the programming in MPI.NET. If you are going to be developing and running MPI programs, you will probably want to add the Compute Cluster Pack's Bin directory to your PATH environment variable, so that you can run mpiexec directly. From now on, we're going to assume that you have done so and will just use mpiexec in our examples without providing its path.

Previous: Introduction Next: Hello, World!