c++ - MPI_Barrier and recursion -


i'm trying use mpi_barrier (openmpi) force process in same depth of recursive call.

this code

#include <iostream> #include <fstream> #include <stdio.h> #include <mpi.h>  using namespace std;  void recursive_function(int,int,int);  int main(int argc, char *argv[]) {     int rank, size;      mpi_init(&argc, &argv);     mpi_comm_rank(mpi_comm_world, &rank);     mpi_comm_size(mpi_comm_world, &size);      recursive_function(0,3,rank);      mpi_finalize(); }  void recursive_function(int depth, int limit, int rank) {     printf("depth: %d, processor %d\n", depth, rank);      mpi_barrier(mpi_comm_world);     if(depth == limit) return;     else recursive_function(depth+1,limit,rank); } 

what (running mpirun -np 2 barrier)

depth: 0, processor 0 depth: 1, processor 0 depth: 2, processor 0 depth: 3, processor 0 depth: 0, processor 1 depth: 1, processor 1 depth: 2, processor 1 depth: 3, processor 1   

while expect

depth: 0, processor 0 depth: 0, processor 1 depth: 1, processor 0 depth: 1, processor 1 depth: 2, processor 1 depth: 2, processor 0 depth: 3, processor 1 depth: 3, processor 0  

there no guarantee stdout among mpi processes ordered in way.

that is, need have processes communicate prove @ same recursion depth. e.g. after barrier each process != 0 sends message rank 0 prints something.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -