finish mushroom example
This commit is contained in:
@@ -15,11 +15,16 @@ namespace sync {
|
||||
/*! \brief reduce operator supported */
|
||||
enum ReduceOp {
|
||||
kSum,
|
||||
kMax,
|
||||
kBitwiseOR
|
||||
};
|
||||
|
||||
/*! \brief get rank of current process */
|
||||
int GetRank(void);
|
||||
/*!
|
||||
* \brief this is used to check if sync module is a true distributed implementation, or simply a dummpy
|
||||
*/
|
||||
bool IsDistributed(void);
|
||||
/*! \brief intiialize the synchronization module */
|
||||
void Init(int argc, char *argv[]);
|
||||
/*! \brief finalize syncrhonization module */
|
||||
|
||||
@@ -6,18 +6,28 @@ namespace sync {
|
||||
int GetRank(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Init(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
void Finalize(void) {
|
||||
}
|
||||
|
||||
bool IsDistributed(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template<>
|
||||
void AllReduce<uint32_t>(uint32_t *sendrecvbuf, int count, ReduceOp op) {
|
||||
}
|
||||
|
||||
template<>
|
||||
void AllReduce<float>(float *sendrecvbuf, int count, ReduceOp op) {
|
||||
}
|
||||
|
||||
void Bcast(std::string *sendrecv_data, int root) {
|
||||
}
|
||||
|
||||
ReduceHandle::ReduceHandle(void) : handle(NULL) {}
|
||||
ReduceHandle::~ReduceHandle(void) {}
|
||||
void ReduceHandle::Init(ReduceFunction redfunc, bool commute) {}
|
||||
|
||||
@@ -12,6 +12,10 @@ void Init(int argc, char *argv[]) {
|
||||
MPI::Init(argc, argv);
|
||||
}
|
||||
|
||||
bool IsDistributed(void) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Finalize(void) {
|
||||
MPI::Finalize();
|
||||
}
|
||||
@@ -20,6 +24,7 @@ void AllReduce_(void *sendrecvbuf, int count, const MPI::Datatype &dtype, Reduce
|
||||
switch(op) {
|
||||
case kBitwiseOR: MPI::COMM_WORLD.Allreduce(MPI_IN_PLACE, sendrecvbuf, count, dtype, MPI::BOR); return;
|
||||
case kSum: MPI::COMM_WORLD.Allreduce(MPI_IN_PLACE, sendrecvbuf, count, dtype, MPI::SUM); return;
|
||||
case kMax: MPI::COMM_WORLD.Allreduce(MPI_IN_PLACE, sendrecvbuf, count, dtype, MPI::MAX); return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user