---------------------------------------------------------------
| 22 | |
| 23 | //--------------------------------------------------------------- |
| 24 | void WaitRegion() { |
| 25 | BL_PROFILE_REGION_START("R::Wait"); |
| 26 | BL_PROFILE("Wait"); |
| 27 | int nProcs(ParallelDescriptor::NProcs()); |
| 28 | int myProc(ParallelDescriptor::MyProc()); |
| 29 | |
| 30 | Vector<long> snds(nProcs,0); |
| 31 | Vector<MPI_Status> stats(nProcs-1); |
| 32 | Vector<MPI_Request> rreqs(nProcs-1); |
| 33 | const int SeqNum = ParallelDescriptor::SeqNum(); |
| 34 | Vector<int> data(nProcs, myProc); |
| 35 | int nSends = nProcs-1; |
| 36 | int j; |
| 37 | |
| 38 | j=0; |
| 39 | for (int i=0; i<nProcs; ++i) |
| 40 | { |
| 41 | if (i != myProc) |
| 42 | { |
| 43 | rreqs[j] = ParallelDescriptor::Arecv(&data[i], 1, i, SeqNum).req(); |
| 44 | j++; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | j=0; |
| 49 | for (int i=0; i<nProcs; ++i) |
| 50 | { |
| 51 | if (i != myProc) |
| 52 | { |
| 53 | ParallelDescriptor::Send(&data[j], 1, i, SeqNum); |
| 54 | j++; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | for (int i=0; i<nSends; ++i) |
| 59 | { |
| 60 | ParallelDescriptor::Wait(rreqs[i], stats[i]); |
| 61 | } |
| 62 | |
| 63 | amrex::Print() << "Wait: " << endl; |
| 64 | for (int i=0; i<nProcs; i++) |
| 65 | { amrex::Print() << "data[" << i << "] = " << data[i] << endl; } |
| 66 | |
| 67 | BL_PROFILE_REGION_STOP("R::Wait"); |
| 68 | } |
| 69 | |
| 70 | //--------------------------------------------------------------- |
| 71 | void WaitAllRegion() { |