Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

template<class ArithT, class RedOpT>
static ArithT Impala::Core::Array::Pattern::PxReduceValueToRootOFT ( ArithT  val,
RedOpT  redOp,
int  root 
) [inline, static]

Definition at line 382 of file PxDistribution.h.

References _myCPU, _nrCPUs, and RDUCE_TAG.

Referenced by PxReduceValueToAllOFT(), and PxReduceValueToRoot().

00383 {
00384     /*** Reduce value to root using One-level Flat Tree ***/
00385 
00386     ArithT result = ArithT(val);
00387     MPI_Datatype elem;
00388     MPI_Status stat;
00389     MPI_Type_contiguous(sizeof(ArithT), MPI_BYTE, &elem);
00390     MPI_Type_commit(&elem);
00391 
00392     if (_myCPU == root) {           // receive value from all other CPUs
00393         for (int partner=0; partner<_nrCPUs; partner++) {
00394             if (partner != _myCPU) {
00395                 ArithT recvVal;
00396                 MPI_Recv(&recvVal, 1, elem,
00397                          partner, RDUCE_TAG, MPI_COMM_WORLD, &stat);
00398                 redOp.DoIt(result, recvVal);
00399             }
00400         }
00401     } else {                        // send value to root
00402         MPI_Send(&val, 1, elem, root, RDUCE_TAG, MPI_COMM_WORLD);
00403     }
00404     MPI_Type_free(&elem);
00405     return result;
00406 }


Generated on Fri Mar 19 11:02:36 2010 for ImpalaSrc by  doxygen 1.5.1