Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Protected Attributes | List of all members
singa::Msg Class Reference

Msg used to transfer Param info (gradient or value), feature blob, etc between workers, stubs and servers. More...

#include <msg.h>

Public Member Functions

 Msg (int src, int dst)
 Construct the msg providing source and destination addr.
 
 Msg (const Msg &msg)
 Copy constructor.
 
void SwapAddr ()
 Swap the src/dst addr.
 
void AddFrame (const void *addr, int nBytes)
 Add a frame (a chunck of bytes) into the message.
 
int FrameSize ()
 
void * FrameData ()
 
char * FrameStr ()
 
void FirstFrame ()
 Move the cursor to the first frame.
 
void LastFrame ()
 Move the cursor to the last frame.
 
bool NextFrame ()
 Move the cursor to the next frame. More...
 
int AddFormatFrame (const char *format,...)
 Add a 'format' frame to the msg (like CZMQ's zsock_send). More...
 
int ParseFormatFrame (const char *format,...)
 Parse the current frame added using AddFormatFrame(const char*, ...). More...
 
void ParseFromZmsg (zmsg_t *msg)
 
zmsg_t * DumpToZmsg ()
 
int size () const
 
void set_src (int addr)
 Set source addr. More...
 
int src () const
 
void set_dst (int addr)
 Set destination addr. More...
 
int dst () const
 
void set_type (int type)
 Set msg type, e.g., kPut, kGet, kUpdate, kRequest.
 
int type () const
 
void set_trgt (int val, int version)
 Set msg target. More...
 
int trgt_val () const
 
int trgt_version () const
 

Protected Attributes

int src_ = 0
 
int dst_ = 0
 
int type_ = 0
 
int trgt_val_ = 0
 
int trgt_version_ = 0
 
zmsg_t * msg_ = nullptr
 
zframe_t * frame_ = nullptr
 

Detailed Description

Msg used to transfer Param info (gradient or value), feature blob, etc between workers, stubs and servers.

Each msg has a source addr and dest addr identified by a unique integer. It is also associated with a target field (value and version) for ease of getting some meta info (e.g., parameter id) from the msg.

Other data is added into the message as frames.

Member Function Documentation

int singa::Msg::AddFormatFrame ( const char *  format,
  ... 
)

Add a 'format' frame to the msg (like CZMQ's zsock_send).

The format is a string that defines the type of each field. The format can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t p = void * (sends the pointer value, only meaningful over inproc) s = char**

Returns size of the added content.

int singa::Msg::dst ( ) const
inline
Returns
dst addr.
void* singa::Msg::FrameData ( )
Returns
the pointer to the current frame data.
int singa::Msg::FrameSize ( )
Returns
num of bytes of the current frame.
char* singa::Msg::FrameStr ( )
Returns
the data of the current frame as c string
bool singa::Msg::NextFrame ( )

Move the cursor to the next frame.

Returns
true if the next frame is not NULL; otherwise false
int singa::Msg::ParseFormatFrame ( const char *  format,
  ... 
)

Parse the current frame added using AddFormatFrame(const char*, ...).

The format is a string that defines the type of each field. The format can contain any of these characters, each corresponding to one or two arguments: i = int (signed) 1 = uint8_t 2 = uint16_t 4 = uint32_t 8 = uint64_t p = void * (sends the pointer value, only meaningful over inproc) s = char**

Returns size of the parsed content.

void singa::Msg::set_dst ( int  addr)
inline

Set destination addr.

Parameters
addrunique identify one worker/server/stub in the current job
void singa::Msg::set_src ( int  addr)
inline

Set source addr.

Parameters
addrunique identify one worker/server/stub in the current job
void singa::Msg::set_trgt ( int  val,
int  version 
)
inline

Set msg target.

One msg has a target to identify some entity in worker/server/stub. The target is associated with a version, e.g., Param version.

int singa::Msg::size ( ) const
Returns
msg size in terms of bytes, ignore meta info.
int singa::Msg::src ( ) const
inline
Returns
source addr.
int singa::Msg::type ( ) const
inline
Returns
msg type.

The documentation for this class was generated from the following file: