[CMake] How to compile MPI code
Mª Dolores Villalobos Ortiz
lolalobos17 at yahoo.es
Wed Jun 22 08:25:02 EDT 2011
>What do you mean with "it doesn't run correctly"? Does it not even
start? How do you start your program?
------------------------------------------------------
My program's code is:
#include <iostream>
using namespace std;
#include "mpi.h"
int main( int argc, char * argv[] )
{
int node;
int num_nodes;
int i, buf;
MPI::Init(argc, argv);
node = MPI::COMM_WORLD.Get_rank();
num_nodes = MPI::COMM_WORLD.Get_size();
std::cout << "I am node " << node << std::endl;
if ( node == 0 ) {
std::cout << "I am node " << node << std::endl;
std::cout << "Num threads (Get_size) -> " << num_nodes << std::endl;
}
else
{
std::cout << "I am node " << node << std::endl;
}
MPI_Finalize();
return 0;
}
------------------------------------------------------
And, in order to run the program, I type in Ubuntu's terminal:
mpiexec -n 2 ./main_program
-------------------------------------------------------------
The program write in terminal:
I am node 0
I am node 0
Num threads (Get_size) -> 1
I am node 0
I am node 0
Num threads (Get_size) -> 1
instead of:
I am node 0
I am node 0
Num threads (Get_size) -> 2
I am node 1
I am node 1
Lola
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110622/4105d84d/attachment.htm>
More information about the CMake
mailing list