/* DEFS: readonly CkChareID mainID;
 */
extern CkChareID mainID;

/* DEFS: readonly CkArrayID bgArrayID;
 */
extern CkArrayID bgArrayID;

/* DEFS: message CreateBgNodeMsg;
 */
#ifndef CK_TEMPLATES_ONLY
void *CMessage_CreateBgNodeMsg::operator new(size_t s){
  return CreateBgNodeMsg::alloc(__idx, s, 0, 0);
}
void *CMessage_CreateBgNodeMsg::operator new(size_t s,const int pb){
  return CreateBgNodeMsg::alloc(__idx, s, 0, pb);
}
void *CMessage_CreateBgNodeMsg::operator new(size_t s, int* sz){
  return CreateBgNodeMsg::alloc(__idx, s, sz, 0);
}
void *CMessage_CreateBgNodeMsg::operator new(size_t s, int* sz,const int pb){
  return CreateBgNodeMsg::alloc(__idx, s, sz, pb);
}
void* CMessage_CreateBgNodeMsg::alloc(int msgnum, size_t sz, int *sizes, int pb) {
  int offsets[1];
  offsets[0] = ALIGN8(sz);
  CreateBgNodeMsg *newmsg = (CreateBgNodeMsg *) CkAllocMsg(msgnum, offsets[0], pb);
  return (void *) newmsg;
}
void* CMessage_CreateBgNodeMsg::pack(CreateBgNodeMsg *msg) {
  return (void *) msg;
}
CreateBgNodeMsg* CMessage_CreateBgNodeMsg::unpack(void* buf) {
  CreateBgNodeMsg *msg = (CreateBgNodeMsg *) buf;
  return msg;
}
int CMessage_CreateBgNodeMsg::__idx=0;
#endif

/* DEFS: message PacketMsg;
 */
#ifndef CK_TEMPLATES_ONLY
void *CMessage_PacketMsg::operator new(size_t s){
  return PacketMsg::alloc(__idx, s, 0, 0);
}
void *CMessage_PacketMsg::operator new(size_t s,const int pb){
  return PacketMsg::alloc(__idx, s, 0, pb);
}
void *CMessage_PacketMsg::operator new(size_t s, int* sz){
  return PacketMsg::alloc(__idx, s, sz, 0);
}
void *CMessage_PacketMsg::operator new(size_t s, int* sz,const int pb){
  return PacketMsg::alloc(__idx, s, sz, pb);
}
void* CMessage_PacketMsg::alloc(int msgnum, size_t sz, int *sizes, int pb) {
  int offsets[1];
  offsets[0] = ALIGN8(sz);
  PacketMsg *newmsg = (PacketMsg *) CkAllocMsg(msgnum, offsets[0], pb);
  return (void *) newmsg;
}
void* CMessage_PacketMsg::pack(PacketMsg *msg) {
  return (void *) msg;
}
PacketMsg* CMessage_PacketMsg::unpack(void* buf) {
  PacketMsg *msg = (PacketMsg *) buf;
  return msg;
}
int CMessage_PacketMsg::__idx=0;
#endif

/* DEFS: mainchare Main{
Main();
void Finish(void);
};
 */
#ifndef CK_TEMPLATES_ONLY
int CProxy_Main::__idx=0;
#endif
#ifndef CK_TEMPLATES_ONLY
    void CProxy_Main::__register(const char *s, size_t size) {
      __idx = CkRegisterChare(s, size);
    /* REG: Main();
*/
      __idx_Main = CkRegisterEp("Main", (CkCallFnPtr)_call_Main, 0, __idx);
      CkRegisterMainChare(__idx, __idx_Main);

    /* REG: void Finish(void);
*/
      __idx_Finish_void = CkRegisterEp("Finish", (CkCallFnPtr)_call_Finish_void, 0, __idx);
    }
#endif
#ifndef CK_TEMPLATES_ONLY
/* DEFS: Main();
 */
int CProxy_Main::__idx_Main=0;
void CProxy_Main::ckNew(int onPE)
{
      void *msg = CkAllocSysMsg();
  CkCreateChare(__idx, __idx_Main, msg, 0, onPE);
}
void CProxy_Main::ckNew(CkChareID* pcid, int onPE)
{
      void *msg = CkAllocSysMsg();
  CkCreateChare(__idx, __idx_Main, msg, pcid, onPE);
}
  CProxy_Main::CProxy_Main(int onPE)
{
      void *msg = CkAllocSysMsg();
  CkCreateChare(__idx, __idx_Main, msg, &_ck_cid, onPE);
}
void CProxy_Main::_call_Main(CkArgMsg* msg, Main* obj)
{
  new (obj) Main((CkArgMsg*)msg);
}

/* DEFS: void Finish(void);
 */
int CProxy_Main::__idx_Finish_void=0;
void CProxy_Main::Finish(void)
{
  void *msg = CkAllocSysMsg();
  CkSendMsg(__idx_Finish_void, msg, &_ck_cid);
}
void CProxy_Main::_call_Finish_void(void* msg, Main* obj)
{
  obj->Finish();
  CkFreeSysMsg(msg);
}
#endif /*CK_TEMPLATES_ONLY*/

/* DEFS: array BgNode: ArrayElement{
BgNode(CkMigrateMessage*);
BgNode(CreateBgNodeMsg*);
void putMessage(PacketMsg*);
};
 */
#ifndef CK_TEMPLATES_ONLY
int CProxy_BgNode::__idx=0;
#endif
#ifndef CK_TEMPLATES_ONLY
    void CProxy_BgNode::__register(const char *s, size_t size) {
      __idx = CkRegisterChare(s, size);
  _REGISTER_BASE(__idx, CProxy_ArrayElement::__idx);
    /* REG: BgNode(CkMigrateMessage*);
*/
      __idx_BgNode_CkMigrateMessage = CkRegisterEp("BgNode", (CkCallFnPtr)_call_BgNode_CkMigrateMessage, 0, __idx);

    /* REG: BgNode(CreateBgNodeMsg*);
*/
      __idx_BgNode_CreateBgNodeMsg = CkRegisterEp("BgNode", (CkCallFnPtr)_call_BgNode_CreateBgNodeMsg, CMessage_CreateBgNodeMsg::__idx, __idx);

    /* REG: void putMessage(PacketMsg*);
*/
      __idx_putMessage_PacketMsg = CkRegisterEp("putMessage", (CkCallFnPtr)_call_putMessage_PacketMsg, CMessage_PacketMsg::__idx, __idx);
      CkRegisterMigCtor(__idx, __idx_BgNode_CkMigrateMessage);
    }
#endif
#ifndef CK_TEMPLATES_ONLY
/* DEFS: BgNode(CkMigrateMessage*);
 */
int CProxy_BgNode::__idx_BgNode_CkMigrateMessage=0;
void CProxy_BgNode::_call_BgNode_CkMigrateMessage(void* msg, BgNode* obj)
{
  new (obj) BgNode((CkMigrateMessage*)msg);
}

/* DEFS: BgNode(CreateBgNodeMsg*);
 */
int CProxy_BgNode::__idx_BgNode_CreateBgNodeMsg=0;
void CProxy_BgNode::insert(CreateBgNodeMsg*msg, int onPE)
{ base_insert(__idx_BgNode_CreateBgNodeMsg,onPE,msg);}
void CProxy_BgNode::_call_BgNode_CreateBgNodeMsg(void* msg, BgNode* obj)
{
  new (obj) BgNode((CreateBgNodeMsg*)msg);
}

/* DEFS: void putMessage(PacketMsg*);
 */
int CProxy_BgNode::__idx_putMessage_PacketMsg=0;
void CProxy_BgNode::putMessage(PacketMsg*msg) const
{
      if(_idx.nInts==-1) 
        base_broadcast(msg, __idx_putMessage_PacketMsg);
      else
        base_send(msg, __idx_putMessage_PacketMsg);
}
void CProxy_BgNode::_call_putMessage_PacketMsg(void* msg, BgNode* obj)
{
  obj->putMessage((PacketMsg*)msg);
}
#endif /*CK_TEMPLATES_ONLY*/

#ifndef CK_TEMPLATES_ONLY
void _registerBlueGene(void)
{
  static int _done = 0; if(_done) return; _done = 1;
  CkRegisterReadonly(sizeof(CkChareID), (void *) &mainID);

  CkRegisterReadonly(sizeof(CkArrayID), (void *) &bgArrayID);

/* REG: message CreateBgNodeMsg;
*/
CMessage_CreateBgNodeMsg::__register("CreateBgNodeMsg", sizeof(CreateBgNodeMsg),(CkPackFnPtr) CreateBgNodeMsg::pack,(CkUnpackFnPtr) CreateBgNodeMsg::unpack);

/* REG: message PacketMsg;
*/
CMessage_PacketMsg::__register("PacketMsg", sizeof(PacketMsg),(CkPackFnPtr) PacketMsg::pack,(CkUnpackFnPtr) PacketMsg::unpack);

/* REG: mainchare Main{
Main();
void Finish(void);
};
*/
  CProxy_Main::__register("Main", sizeof(Main));

/* REG: array BgNode: ArrayElement{
BgNode(CkMigrateMessage*);
BgNode(CreateBgNodeMsg*);
void putMessage(PacketMsg*);
};
*/
  CProxy_BgNode::__register("BgNode", sizeof(BgNode));

}
extern "C" void CkRegisterMainModule(void) {
  _registerBlueGene();
  _REGISTER_DONE();
}
#endif
