00001 /* @HEADER@ */ 00002 // 00003 /* @HEADER@ */ 00004 00005 #ifndef PLAYA_VECTORFUNCTORDECL_HPP 00006 #define PLAYA_VECTORFUNCTORDECL_HPP 00007 00008 #include "PlayaDefs.hpp" 00009 #include "PlayaMPIComm.hpp" 00010 #include "Teuchos_RCP.hpp" 00011 #include "PlayaGeneralizedIndex.hpp" 00012 00013 namespace PlayaFunctors 00014 { 00015 00016 using Playa::GeneralizedIndex; 00017 using Teuchos::RCP; 00018 using Playa::MPIComm; 00019 using Playa::MPIOp; 00020 using Playa::MPIDataType; 00021 00022 /** 00023 * \brief This traits class specifies the return type of a reduction functor. 00024 * If not specialized, the default return type will be a Scalar. 00025 * 00026 * @author Kevin Long (kevin.long@ttu.edu) 00027 */ 00028 template <class Scalar, class FunctorType> 00029 class VectorFunctorTraits 00030 { 00031 public: 00032 typedef Scalar ReturnType; 00033 }; 00034 00035 00036 00037 /** 00038 * \brief Base class for reduction functors 00039 * 00040 * @author Kevin Long (kevin.long@ttu.edu) 00041 */ 00042 template <class Scalar> 00043 class ReductionFunctorBase 00044 { 00045 public: 00046 /** Construct with a communicator */ 00047 ReductionFunctorBase( 00048 const MPIComm& comm 00049 ) 00050 : comm_(comm) {} 00051 00052 /** Callback for any postprocessing step (for example, MPI all-reduce) */ 00053 virtual void postProc() const = 0 ; 00054 00055 protected: 00056 00057 /** Return the MPI communicator */ 00058 const MPIComm& comm() const {return comm_;} 00059 00060 private: 00061 MPIComm comm_; 00062 }; 00063 00064 00065 /** 00066 * \brief IndexedValue is the return type for reduction operations such 00067 * as MinLoc that return a location and a value. 00068 */ 00069 template <class Scalar> 00070 struct IndexedValue 00071 { 00072 /** Value */ 00073 Scalar what; 00074 /** Index */ 00075 int where; 00076 }; 00077 00078 } 00079 00080 #endif