template<class ArithT, class RedOpT>
Definition at line 523 of file PxDistribution.h. Referenced by PxReduceValueToAll(). 00524 { 00525 /*** MPI-based global Allreduce NOT using any of the predefined ***/ 00526 /*** reduce operations supported by MPI. At all times, a handle ***/ 00527 /*** to a correctly instantiated (Horus) reduction operation is ***/ 00528 /*** passed as a parameter to MPI_Allreduce(...). ***/ 00529 00530 int commute = 1; 00531 ArithT result = RedOpT::NeutralElement(); 00532 MPI_Op operation; 00533 MPI_Datatype elem; 00534 MPI_Type_contiguous(sizeof(ArithT), MPI_BYTE, &elem); 00535 MPI_Type_commit(&elem); 00536 00537 /*** Make instantiation of PxReduce, bind to MPIop handle & run ***/ 00538 00539 void (*reduceOp)(ArithT*, ArithT*, int*, MPI_Datatype*) = 00540 PxReduce<ArithT, RedOpT>; 00541 MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))reduceOp, 00542 commute, &operation); 00543 MPI_Allreduce(&val, &result, 1, elem, operation, MPI_COMM_WORLD); 00544 MPI_Op_free(&operation); 00545 MPI_Type_free(&elem); 00546 return result; 00547 }
|