template<class ArithT, class RedOpT>
Definition at line 451 of file PxDistribution.h. Referenced by PxReduceValueToRoot(). 00452 { 00453 /*** MPI-based global reduction NOT using any of the predefined ***/ 00454 /*** reduce operations supported by MPI. At all times, a handle ***/ 00455 /*** to a correctly instantiated (Horus) reduction operation is ***/ 00456 /*** passed as a parameter to MPI_Reduce(...). ***/ 00457 00458 int commute = 1; 00459 ArithT result = RedOpT::NeutralElement(); 00460 MPI_Op operation; 00461 MPI_Datatype elem; 00462 MPI_Type_contiguous(sizeof(ArithT), MPI_BYTE, &elem); 00463 MPI_Type_commit(&elem); 00464 00465 /*** Make instantiation of PxReduce, bind to MPIop handle & run ***/ 00466 00467 void (*reduceOp)(ArithT*, ArithT*, int*, MPI_Datatype*) = 00468 PxReduce<ArithT, RedOpT>; 00469 MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))reduceOp, 00470 commute, &operation); 00471 MPI_Reduce(&val, &result, 1, elem, operation, root, MPI_COMM_WORLD); 00472 MPI_Op_free(&operation); 00473 MPI_Type_free(&elem); 00474 return result; 00475 }
|