locked
How to output the result on the screen? RRS feed

  • Question

  • I am a beginner and using compute cluster server 2003 to submit my MPI code. I wonder if I could output some result on the screen when the code is running and how to do that.

    Thank you.

    Monday, November 29, 2010 9:19 AM

Answers

  • Hello,

    You can just use c/c++ printf to output to the screen. Note that With MSMPI, the stdout/error from the mpi programs are redirected to mpiexec console. So all the output from each rank will be displayed at mpiexec console. Taking the following simple helloworld mpi app as an example:

    #include <stdio.h>
    #include "mpi.h"
    int main( int argc, char *argv[] )
    {
      int rank;
      MPI_Init( &argc, &argv );
      MPI_Comm_rank(MPI_COMM_WORLD, &rank);
      printf( "Hello World from Rank %d\n", rank);
      MPI_Finalize();
      return 0;
    }
    


    After compile it, you can execute with the command line:

    mpiexec -n 4 HelloWorld.exe

    Hello World from Rank 3
    Hello World from Rank 1
    Hello World from Rank 2
    Hello World from Rank 0

     

    Thanks,

    James

    Thursday, December 16, 2010 9:28 PM