Medial Code Documentation
Loading...
Searching...
No Matches
Namespaces | Typedefs | Functions
rabit Namespace Reference

namespace of rabit More...

Namespaces

namespace  engine
 core interface of the engine
 
namespace  op
 reduction operators namespace
 
namespace  utils
 namespace for helper utils of the project
 

Typedefs

using Stream = dmlc::Stream
 defines stream used in rabit see definition of Stream in dmlc/io.h
 
using Serializable = dmlc::Serializable
 defines serializable objects used in rabit see definition of Serializable in dmlc/io.h
 

Functions

bool Init (int argc, char *argv[])
 initializes rabit, call this once at the beginning of your program
 
bool Finalize ()
 finalizes the rabit engine, call this function after you finished with all the jobs
 
int GetRingPrevRank ()
 
int GetRank ()
 gets rank of the current process
 
int GetWorldSize ()
 gets total number of processes
 
bool IsDistributed ()
 whether rabit env is in distributed mode
 
std::string GetProcessorName ()
 gets processor's name
 
void Broadcast (void *sendrecv_data, size_t size, int root)
 broadcasts a memory region to every node from the root
 
template<typename DType >
void Broadcast (std::vector< DType > *sendrecv_data, int root)
 broadcasts an std::vector<DType> to every node from root
 
void Broadcast (std::string *sendrecv_data, int root)
 broadcasts a std::string to every node from the root
 
template<typename OP , typename DType >
void Allreduce (DType *sendrecvbuf, size_t count, void(*prepare_fun)(void *arg), void *prepare_arg)
 
void TrackerPrint (const std::string &msg)
 prints the msg to the tracker, this function can be used to communicate progress information to the user who monitors the tracker
 
void TrackerPrintf (const char *fmt,...)
 prints the msg to the tracker, this function may not be available in very strict c++98 compilers, though it usually is. this function can be used to communicate progress information to the user who monitors the tracker
 
int LoadCheckPoint ()
 deprecated, planned for removal after checkpoing from JVM package is removed.
 
void CheckPoint ()
 deprecated, planned for removal after checkpoing from JVM package is removed.
 
int VersionNumber ()
 
template<typename T >
auto Min (T const &l, T const &r)
 
template<typename T >
auto Max (T const &l, T const &r)
 
template<typename T >
T * BeginPtr (std::vector< T > &vec)
 get the beginning address of a vector
 
char * BeginPtr (std::string &str)
 
const char * BeginPtr (const std::string &str)
 
template<typename OP , typename DType >
void Allreduce (DType *sendrecvbuf, size_t count, void(*prepare_fun)(void *)=nullptr, void *prepare_arg=nullptr)
 performs in-place Allreduce on sendrecvbuf this function is NOT thread-safe
 
template<typename DType >
void Allgather (DType *sendrecvbuf_, size_t total_size, size_t slice_begin, size_t slice_end, size_t size_prev_slice)
 Allgather function, each node have a segment of data in the ring of sendrecvbuf, the data provided by current node k is [slice_begin, slice_end), the next node's segment must start with slice_end after the call of Allgather, sendrecvbuf_ contains all the contents including all segments use a ring based algorithm.
 

Detailed Description

namespace of rabit

rabit namespace

Function Documentation

◆ Allgather()

template<typename DType >
void rabit::Allgather ( DType *  sendrecvbuf_,
size_t  total_size,
size_t  slice_begin,
size_t  slice_end,
size_t  size_prev_slice 
)
inline

Allgather function, each node have a segment of data in the ring of sendrecvbuf, the data provided by current node k is [slice_begin, slice_end), the next node's segment must start with slice_end after the call of Allgather, sendrecvbuf_ contains all the contents including all segments use a ring based algorithm.

Parameters
sendrecvbuf_buffer for both sending and receiving data, it is a ring conceptually
total_sizetotal size of data to be gathered
slice_beginbeginning of the current slice
slice_endend of the current slice
size_prev_slicesize of the previous slice i.e. slice of node (rank - 1) % world_size

◆ Allreduce()

template<typename OP , typename DType >
void rabit::Allreduce ( DType *  sendrecvbuf,
size_t  count,
void(*)(void *)  prepare_fun = nullptr,
void *  prepare_arg = nullptr 
)
inline

performs in-place Allreduce on sendrecvbuf this function is NOT thread-safe

Example Usage: the following code does an Allreduce and outputs the sum as the result

vector<int> data(10);
...
Allreduce<op::Sum>(&data[0], data.size());
...
sum reduction operator
Definition rabit-inl.h:81
Parameters
sendrecvbufbuffer for both sending and receiving data
countnumber of elements to be reduced
prepare_funLazy preprocessing function, if it is not NULL, prepare_fun(prepare_arg) will be called by the function before performing Allreduce in order to initialize the data in sendrecvbuf. If the result of Allreduce can be recovered directly, then prepare_func will NOT be called
prepare_argargument used to pass into the lazy preprocessing function
Template Parameters
OPsee namespace op, reduce operator
DTypedata type

◆ Broadcast() [1/3]

void rabit::Broadcast ( std::string *  sendrecv_data,
int  root 
)
inline

broadcasts a std::string to every node from the root

Parameters
sendrecv_datathe pointer to the send/receive buffer, for the receiver, the vector does not need to be pre-allocated
_filecaller file name used to generate unique cache key
_linecaller line number used to generate unique cache key
_callercaller function name used to generate unique cache key
rootthe process root

◆ Broadcast() [2/3]

template<typename DType >
void rabit::Broadcast ( std::vector< DType > *  sendrecv_data,
int  root 
)
inline

broadcasts an std::vector<DType> to every node from root

Parameters
sendrecv_datathe pointer to send/receive vector, for the receiver, the vector does not need to be pre-allocated
rootthe process root
Template Parameters
DTypethe data type stored in the vector, has to be a simple data type that can be directly transmitted by sending the sizeof(DType)

◆ Broadcast() [3/3]

void rabit::Broadcast ( void *  sendrecv_data,
size_t  size,
int  root 
)
inline

broadcasts a memory region to every node from the root

Example: int a = 1; Broadcast(&a, sizeof(a), root);
Parameters
sendrecv_datathe pointer to the send/receive buffer,
sizethe data size
rootthe process root

◆ Finalize()

bool rabit::Finalize ( )
inline

finalizes the rabit engine, call this function after you finished with all the jobs

Returns
true if finalized successfully, otherwise false

◆ GetProcessorName()

std::string rabit::GetProcessorName ( )
inline

gets processor's name

Returns
processor name

◆ GetRank()

int rabit::GetRank ( )
inline

gets rank of the current process

Returns
rank number of worker

◆ GetWorldSize()

int rabit::GetWorldSize ( )
inline

gets total number of processes

Returns
total world size

◆ Init()

bool rabit::Init ( int  argc,
char *  argv[] 
)
inline

initializes rabit, call this once at the beginning of your program

Parameters
argcnumber of arguments in argv
argvthe array of input arguments
Returns
true if initialized successfully, otherwise false

◆ IsDistributed()

bool rabit::IsDistributed ( )
inline

whether rabit env is in distributed mode

Returns
is distributed

◆ TrackerPrint()

void rabit::TrackerPrint ( const std::string &  msg)
inline

prints the msg to the tracker, this function can be used to communicate progress information to the user who monitors the tracker

Parameters
msgthe message to be printed

◆ TrackerPrintf()

void rabit::TrackerPrintf ( const char *  fmt,
  ... 
)
inline

prints the msg to the tracker, this function may not be available in very strict c++98 compilers, though it usually is. this function can be used to communicate progress information to the user who monitors the tracker

Parameters
fmtthe format string

◆ VersionNumber()

int rabit::VersionNumber ( )
inline
Returns
version number of the current stored model, which means how many calls to CheckPoint we made so far
See also
LoadCheckPoint, CheckPoint