Support bitwise allreduce operations in the communicator (#8623)
This commit is contained in:
@@ -133,7 +133,9 @@ enum OpType {
|
||||
kMax = 0,
|
||||
kMin = 1,
|
||||
kSum = 2,
|
||||
kBitwiseOR = 3
|
||||
kBitwiseAND = 3,
|
||||
kBitwiseOR = 4,
|
||||
kBitwiseXOR = 5,
|
||||
};
|
||||
/*!\brief enum of supported data types */
|
||||
enum DataType {
|
||||
|
||||
@@ -85,6 +85,13 @@ struct Sum {
|
||||
dst += src;
|
||||
}
|
||||
};
|
||||
struct BitAND {
|
||||
static const engine::mpi::OpType kType = engine::mpi::kBitwiseAND;
|
||||
template<typename DType>
|
||||
inline static void Reduce(DType &dst, const DType &src) { // NOLINT(*)
|
||||
dst &= src;
|
||||
}
|
||||
};
|
||||
struct BitOR {
|
||||
static const engine::mpi::OpType kType = engine::mpi::kBitwiseOR;
|
||||
template<typename DType>
|
||||
@@ -92,6 +99,13 @@ struct BitOR {
|
||||
dst |= src;
|
||||
}
|
||||
};
|
||||
struct BitXOR {
|
||||
static const engine::mpi::OpType kType = engine::mpi::kBitwiseXOR;
|
||||
template<typename DType>
|
||||
inline static void Reduce(DType &dst, const DType &src) { // NOLINT(*)
|
||||
dst ^= src;
|
||||
}
|
||||
};
|
||||
template <typename OP, typename DType>
|
||||
inline void Reducer(const void *src_, void *dst_, int len, const MPI::Datatype &) {
|
||||
const DType *src = static_cast<const DType *>(src_);
|
||||
|
||||
@@ -50,11 +50,21 @@ struct Min;
|
||||
* \brief sum reduction operator
|
||||
*/
|
||||
struct Sum;
|
||||
/*!
|
||||
* \class rabit::op::BitAND
|
||||
* \brief bitwise AND reduction operator
|
||||
*/
|
||||
struct BitAND;
|
||||
/*!
|
||||
* \class rabit::op::BitOR
|
||||
* \brief bitwise OR reduction operator
|
||||
*/
|
||||
struct BitOR;
|
||||
/*!
|
||||
* \class rabit::op::BitXOR
|
||||
* \brief bitwise XOR reduction operator
|
||||
*/
|
||||
struct BitXOR;
|
||||
} // namespace op
|
||||
/*!
|
||||
* \brief initializes rabit, call this once at the beginning of your program
|
||||
|
||||
Reference in New Issue
Block a user