Parallel Computing: Eclipse and OpenMPI
Well, the first semester of SY 2007-2008 is nicely on its way. As usual, I will be getting teaching load this year. This particular semester I am once again teaching AMC 153: Introduction to Distributed and Parallel Computing. Due to advances in computing technology and the state of commodity parallel computing software, I have decided to re-format the course to teach students how to not just “use a commodity computing cluster” but to “build a commodity computing cluster“. The tools are getting much easier now.
So the first in this series in how to install, configure and use OpenMPI.
MPI stands for the Message Passing Interface. Written by the MPI Forum (a large committee comprising of a cross-section between industry and research representatives), MPI is a standardized API typically used for parallel and/or distributed computing. The MPI standard is comprised of 2 documents: MPI-1 (published in 1994) and MPI-2 (published in 1996). MPI-2 is, for the most part, additions and extensions to the original MPI-1 specification.
Open MPI is an open source, freely available implementation of both the MPI-1 and MPI-2 documents. The Open MPI software achieves high performance; the Open MPI project is quite receptive to community input.
Let’s get started. First, install Eclipse the usual way. Since, I am a big fan of doing things the “RedHat-way” here are the steps.
yum install eclipse eclipse-cdt
See. That was not very hard. Then let us install OpenMPI.
yum install openmpi openmpi-devel openmpi-libs
Huh? That is it? Now, it is time to try out our newly installed Eclipse-CDT with OpenMPI.
eclipse
Here are the steps to create a new project that would use OpenMPI inside Eclipse-CDT.
- Create a new project. File->New->Project. Select ‘Managed Make C Project’. Name the project and choose default for everything else. We are using a managed make configuration so we don’t have to worry about writing our own Makefiles.
- Right click on the Project Name in the Left (Project) Panel and change ‘Active Build Configuration’ to ‘Release’. This forces us to use the release properties as our default. The ‘Debug’ setting likes to run the debugger if you want that. But, it best you use PTP described below.
- Right click on the Project Name again and select ‘New’ and create a new file called ‘nodes.txt’. This file will contain the OpenMPI machine file. Here you define the nodes in your cluster. In this particular case, just put ‘localhost’.
- Right click on the Project Name again and select ‘Properties’. Select ‘C/C++ Build’ then select ‘GCC C Linker’. Change command to ‘mpicc’ from ‘gcc’. Do the same for ‘GCC C Compiler’. After that, select ‘Warnings’ and select ‘-Wall’ and ‘-Werror’. Next select ‘Optimization’ and select ‘None’.
- Go to Run->External Tools->External Tools. We cannot run this project like ordinary C/C++ projects in Eclipse because we have to run MPI programs with the mpirun wrapper. So now select ‘Program’ then add a new configuration. Name the configuration ‘AMC153-mpirun’. Select the ‘Working Directory’ by clicking on ‘Browse Workspace’ and selecting the root directory of the current project which I called AMC153. Finally, add ‘-np 4 -machinefile nodes.txt ${project_loc}/Release/${project_name}’ in the arguments line. 4 is the number of processes to spawn (set appropriately). nodes.txt is our newly created machine file above. The last argument is the directory of the executable. This formally is generally correct.
- Right click on the Project Name again and select ‘New’ then select ‘Source Folder’ and name it ’src’.
- Right click on the ’src’ and select ‘New’ source or header file and start coding!
- To run the project. Just select ‘Run’ then ‘External Tools’ then ‘AMC153-mpirun’.
You might want to try the following program.
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main ( int argc, char *argv[] )
{
int rank, size;
MPI_Init ( &argc, &argv );
MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
MPI_Comm_size ( MPI_COMM_WORLD, &size );
printf( "Hello, world! I am %d of %d\n", rank, size );
MPI_Finalize ();
return 0;
}
Another option is to use the Parallel Tools Platform (PTP) that comes as an Eclipse plug-in. These tools also use OpenMPI as the engine. I have not gotten to that yet because I am pretty pleased with plain Eclipse and OpenMPI. Maybe we can explore this next?

June 25th, 2007 at 4:02 am
[…] black berry unlocked « Parallel Computing: Eclipse and OpenMPI […]
September 8th, 2007 at 4:01 am
[…] Providing common shared storage is an important part of parallel computing. Being able to share files between compute nodes in a parallel cluster is key to getting a parallel job done. This is a follow-up article on configuring OpenMPI for Parallel Computing. You need to do this to get other nodes to play in your cluster. So, let’s get started. […]