locked
Switching single CPU to multi-cpu RRS feed

  • Question

  • Dear Experts,

    I am the super beginner of MPI programming. Actually I started learning it one week ago. Right now, I am modeling a dynamic problem and its inverse. The forward model in not very big, a single CPU could handle. However, there is one step for inversion, requires a very large computation as a rank-4 tenser product with a vector. And I need to compute it in every time step. So I would like to parallelize this step using MPI and to keep the rest of the steps running in series.

    Could anyone teach me a bit or give me some hints on how to hold the rest of CPUs when the parallel computations are finished at each time step?

     

    Many thanks in advance

    Wednesday, July 28, 2010 2:19 PM

Answers

  • Could you the rank to control your program flow? For example, you can use rank 0 to do all serialized job while let all CPUs do parallel computations.

    MPI_Comm_rank(MPI_COMM_WORLD,&rank);
    if (rank == 0)
      Serialized computations here
      ....
    else
      Parallel computations here
    ......

    Thanks,

    James

    • Proposed as answer by Don Pattee Wednesday, October 6, 2010 11:44 PM
    • Marked as answer by Don Pattee Wednesday, January 12, 2011 2:47 AM
    Wednesday, August 4, 2010 9:10 PM