From 61626aaf85a22c17ff02e103d271520855e8075e Mon Sep 17 00:00:00 2001 From: tqchen Date: Mon, 12 Jan 2015 20:45:07 -0800 Subject: [PATCH] add more data types --- include/rabit.h | 2 +- include/rabit/engine.h | 17 ++++++++++++----- include/rabit/rabit-inl.h | 16 ++++++++++++++++ src/engine_mpi.cc | 4 ++++ 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/include/rabit.h b/include/rabit.h index d3620d8d0..17ef5e616 100644 --- a/include/rabit.h +++ b/include/rabit.h @@ -51,7 +51,7 @@ struct Sum; struct BitOR; } // namespace op /*! - * \brief intialize the rabit module, call this once function before using anything + * \brief intialize the rabit module, call this once before using anything * \param argc number of arguments in argv * \param argv the array of input arguments */ diff --git a/include/rabit/engine.h b/include/rabit/engine.h index ce8fb6ee5..c06fbc6cc 100644 --- a/include/rabit/engine.h +++ b/include/rabit/engine.h @@ -146,14 +146,21 @@ IEngine *GetEngine(void); namespace mpi { /*!\brief enum of all operators */ enum OpType { - kMax, kMin, kSum, kBitwiseOR + kMax = 0, + kMin = 1, + kSum = 2, + kBitwiseOR = 3 }; /*!\brief enum of supported data types */ enum DataType { - kInt, - kUInt, - kDouble, - kFloat + kChar = 0, + kUChar = 1, + kInt = 2, + kUInt = 3, + kLong = 4, + kULong = 5, + kFloat = 6, + kDouble = 7 }; } // namespace mpi /*! diff --git a/include/rabit/rabit-inl.h b/include/rabit/rabit-inl.h index 55f60cf44..3ba3ec95e 100644 --- a/include/rabit/rabit-inl.h +++ b/include/rabit/rabit-inl.h @@ -18,6 +18,14 @@ namespace mpi { template inline DataType GetType(void); template<> +inline DataType GetType(void) { + return kChar; +} +template<> +inline DataType GetType(void) { + return kUChar; +} +template<> inline DataType GetType(void) { return kInt; } @@ -26,6 +34,14 @@ inline DataType GetType(void) { return kUInt; } template<> +inline DataType GetType(void) { + return kLong; +} +template<> +inline DataType GetType(void) { + return kULong; +} +template<> inline DataType GetType(void) { return kFloat; } diff --git a/src/engine_mpi.cc b/src/engine_mpi.cc index bdad5e2d1..c1b723572 100644 --- a/src/engine_mpi.cc +++ b/src/engine_mpi.cc @@ -95,8 +95,12 @@ IEngine *GetEngine(void) { inline MPI::Datatype GetType(mpi::DataType dtype) { using namespace mpi; switch (dtype) { + case kChar: return MPI::CHAR; + case kUChar: return MPI::BYTE; case kInt: return MPI::INT; case kUInt: return MPI::UNSIGNED; + case kLong: return MPI::LONG; + case kULong: return MPI::UNSIGNED_LONG; case kFloat: return MPI::FLOAT; case kDouble: return MPI::DOUBLE; }