[CMake] How to compile MPI code

Jakob van Bethlehem j.s.van.bethlehem at astro.rug.nl
Wed Jun 22 10:57:54 EDT 2011


Hm... this is the CMake user list, not the MPI-user list..... You're 
posing your question on the wrong list.
(but.... how did you compile? Did you use mpicc?)

Sincerely,
Jakob

On 06/22/2011 02:25 PM, Mª Dolores Villalobos Ortiz wrote:
>  >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
>
>
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list