Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11K views

MPICH2 Code::Blocks IDE

The document provides instructions for installing MPICH2 parallel computing library and configuring the Code::Blocks C++ IDE to use MPICH2. The steps include downloading and installing MPICH2, adding its path to the environment variables, configuring Code::Blocks compiler and linker settings to use MPICH2 libraries and includes, writing a sample MPI program to test it runs in parallel, and using mpiexec to launch the program across multiple processors.

Uploaded by

Denny Hermawanto
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11K views

MPICH2 Code::Blocks IDE

The document provides instructions for installing MPICH2 parallel computing library and configuring the Code::Blocks C++ IDE to use MPICH2. The steps include downloading and installing MPICH2, adding its path to the environment variables, configuring Code::Blocks compiler and linker settings to use MPICH2 libraries and includes, writing a sample MPI program to test it runs in parallel, and using mpiexec to launch the program across multiple processors.

Uploaded by

Denny Hermawanto
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Denny Hermawanto 2011

MPICH2 Parallel Computing using Code::Blocks C++ IDE


Here is the installation procedure of MPICH2 parallel computing library on CodeBlock
C++ IDE:

1. Download and install MPICH2 library from


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

2. Don’t forget to add MPICH2 PATH to your user environment variable.

2. Open your CodeBlock C++ IDE

3. Point to "Settings" menu and select "Compiler and debugger"

4. Go to "Linker settings" tab, in the Link Library box click "Add".


From the pop-up windows browse to MPICH lib directory and select mpi.lib
then click OK to return to compiler setting window.
Denny Hermawanto 2011

5. Go to "Search Directories" tab. In the "Compiler" option click Add and point to your
MPICH2 include folder path. Usually, it located in C:\Program Files\MPICH2\include
Denny Hermawanto 2011

6. Now you can test your MPICH based program.

7. Create new project (File->New->Project->Console Application)

8. In the main.cpp write this code:

#include <iostream>
#include "mpi.h"
#include <string>

using namespace std;

int main(int argc, char *argv[])


{
int my_rank;
int size;
MPI_Init(&argc, &argv); /*START MPI */

/*DETERMINE RANK OF THIS PROCESSOR*/


MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

/*DETERMINE TOTAL NUMBER OF PROCESSORS*/


MPI_Comm_size(MPI_COMM_WORLD, &size);

printf("Hello world! I'm rank (processor number) %d of %d processor \n",


my_rank, size);

MPI_Finalize(); /* EXIT MPI */

return 0;
}

9. Build the code (Ctrl-F9) and your executable program result will be in folder
bin/Debug of your project folder.

To run your parallel program, you must launch it using mpiexec.exe if you use Windows
Operating System. Follow these steps:

1. Open console and change directory to the executable file in your project path. For
example, my program is located in this folder:
E:\My Documents\C++ Project\MPI\bin\Debug
Denny Hermawanto 2011

2. Suppose you want to execute your parallel program named MPI.exe using 2 nodes
locally (in your computer only), the script to execute program will look like this:
E:\My Documents\C++ Project\MPI\bin\Debug>mpiexec -n 2 -localonly MPI

13. Then the correct output will be like this:


Hello world! I'm rank (processor number) 0 of 2 processor
Hello world! I'm rank (processor number) 1 of 2 processor

14. Then you are ready to code using MPICH2 using CodeBlocks C++ IDE...

Happy parallel computing!!! :)

You might also like