22 #ifndef SINGA_COMMUNICATION_MSG_H_
23 #define SINGA_COMMUNICATION_MSG_H_
40 inline int Addr(
int grp,
int id_or_proc,
int type) {
41 return (grp << 16) | (id_or_proc << 8) | type;
59 static const int mask = (1 << 8) - 1;
60 return (addr >> 8) & mask;
77 static const int mask = (1 << 8) -1;
110 void AddFrame(
const void* addr,
int nBytes);
172 void ParseFromZmsg(zmsg_t* msg);
173 zmsg_t* DumpToZmsg();
184 inline void set_src(
int addr) { src_ = addr; }
188 inline int src()
const {
return src_; }
193 inline void set_dst(
int addr) { dst_ = addr; }
197 inline int dst()
const {
return dst_; }
205 inline int type()
const {
return type_; }
214 trgt_version_ = version;
216 inline int trgt_val()
const {
return trgt_val_; }
217 inline int trgt_version()
const {
return trgt_version_; }
224 int trgt_version_ = 0;
226 zmsg_t* msg_ =
nullptr;
227 zframe_t *frame_ =
nullptr;
231 inline void DeleteMsg(Msg** msg) {
238 #endif // SINGA_COMMUNICATION_MSG_H_
int AddrType(int addr)
Parse msg type from addr.
Definition: msg.h:76
void set_type(int type)
Set msg type, e.g., kPut, kGet, kUpdate, kRequest.
Definition: msg.h:201
void set_dst(int addr)
Set destination addr.
Definition: msg.h:193
void set_src(int addr)
Set source addr.
Definition: msg.h:184
void LastFrame()
Move the cursor to the last frame.
bool NextFrame()
Move the cursor to the next frame.
int type() const
Definition: msg.h:205
Msg used to transfer Param info (gradient or value), feature blob, etc between workers, stubs and servers.
Definition: msg.h:91
void FirstFrame()
Move the cursor to the first frame.
int dst() const
Definition: msg.h:197
int AddFormatFrame(const char *format,...)
Add a 'format' frame to the msg (like CZMQ's zsock_send).
int AddrID(int addr)
Parse worker/server id from addr.
Definition: msg.h:58
int AddrProc(int addr)
Parse worker/server procs from addr.
Definition: msg.h:68
int src() const
Definition: msg.h:188
int ParseFormatFrame(const char *format,...)
Parse the current frame added using AddFormatFrame(const char*, ...).
int Addr(int grp, int id_or_proc, int type)
Wrapper to generate message address.
Definition: msg.h:40
void set_trgt(int val, int version)
Set msg target.
Definition: msg.h:212
void AddFrame(const void *addr, int nBytes)
Add a frame (a chunck of bytes) into the message.
void SwapAddr()
Swap the src/dst addr.
int AddrGrp(int addr)
Parse group id from addr.
Definition: msg.h:49