Rewrote the Charm++ runtime system, and the ITC++ translator.
authorMilind Bhandarkar <milind@cs.uiuc.edu>
Mon, 15 Feb 1999 20:56:33 +0000 (20:56 +0000)
committerMilind Bhandarkar <milind@cs.uiuc.edu>
Mon, 15 Feb 1999 20:56:33 +0000 (20:56 +0000)
82 files changed:
src/ck-core/acc.c [deleted file]
src/ck-core/boc.c [deleted file]
src/ck-core/charm++-inc.h [deleted file]
src/ck-core/charm++.h
src/ck-core/charm-inc.h [deleted file]
src/ck-core/charm.h
src/ck-core/ck.C [new file with mode: 0644]
src/ck-core/ck.c [deleted file]
src/ck-core/ck.h [new file with mode: 0644]
src/ck-core/ckfutures.C
src/ck-core/ckfutures.ci
src/ck-core/ckfutures.h [new file with mode: 0644]
src/ck-core/ckstream.h [new file with mode: 0644]
src/ck-core/common.c [deleted file]
src/ck-core/condsend.c [deleted file]
src/ck-core/cplus.C [deleted file]
src/ck-core/dagger.h [deleted file]
src/ck-core/debug-message.C [new file with mode: 0644]
src/ck-core/debug-object.C [moved from src/ck-core/objectData.C with 57% similarity]
src/ck-core/debug-object.h [moved from src/ck-core/objectData.h with 53% similarity]
src/ck-core/defmain-cpp.C [deleted file]
src/ck-core/defmain-std.c [deleted file]
src/ck-core/dummy.cplus.c [deleted file]
src/ck-core/envelope.h [new file with mode: 0644]
src/ck-core/globals.c [deleted file]
src/ck-core/info.C [new file with mode: 0644]
src/ck-core/info.c [deleted file]
src/ck-core/init.C [new file with mode: 0644]
src/ck-core/init.c [deleted file]
src/ck-core/init.h [new file with mode: 0644]
src/ck-core/main.C [new file with mode: 0644]
src/ck-core/main.c [deleted file]
src/ck-core/memstuff.c [deleted file]
src/ck-core/messageData.C [deleted file]
src/ck-core/mono.c [deleted file]
src/ck-core/msgalloc.C [new file with mode: 0644]
src/ck-core/qd.C [new file with mode: 0644]
src/ck-core/qd.c [deleted file]
src/ck-core/qd.h [new file with mode: 0644]
src/ck-core/rdonly.c [deleted file]
src/ck-core/register.C [new file with mode: 0644]
src/ck-core/register.c [deleted file]
src/ck-core/register.h [new file with mode: 0644]
src/ck-core/stat.c [deleted file]
src/ck-core/stats.h [new file with mode: 0644]
src/ck-core/tbl.c [deleted file]
src/ck-core/vid.c [deleted file]
src/ck-core/wrtone.c [deleted file]
src/ck-perf/charmreplay.c [deleted file]
src/ck-perf/trace-none.C [new file with mode: 0644]
src/ck-perf/trace-none.c [deleted file]
src/ck-perf/trace-projections.C [new file with mode: 0644]
src/ck-perf/trace-projections.c [deleted file]
src/ck-perf/trace-projections.h [new file with mode: 0644]
src/ck-perf/trace-record.c [deleted file]
src/ck-perf/trace-replay.c [deleted file]
src/ck-perf/trace-summary.c [deleted file]
src/ck-perf/trace.h
src/ck-perf/traceio.c [deleted file]
src/conv-core/conv-trace.h [new file with mode: 0644]
src/conv-core/convcore.c
src/conv-core/converse.h
src/conv-core/threads.c
src/scripts/Makefile
src/scripts/charmc
src/xlat-i/xi-generate.C [deleted file]
src/xlat-i/xi-grammar.tab.C [new file with mode: 0644]
src/xlat-i/xi-grammar.tab.h [new file with mode: 0644]
src/xlat-i/xi-grammar.y [new file with mode: 0644]
src/xlat-i/xi-main.C
src/xlat-i/xi-parse.bison [deleted file]
src/xlat-i/xi-parse.tab.C [deleted file]
src/xlat-i/xi-parse.tab.h [deleted file]
src/xlat-i/xi-scan.C
src/xlat-i/xi-scan.flex [deleted file]
src/xlat-i/xi-scan.l [new file with mode: 0644]
src/xlat-i/xi-symbol.C
src/xlat-i/xi-symbol.h
src/xlat-i/xi-util.C [new file with mode: 0644]
src/xlat-i/xi-util.h [new file with mode: 0644]
src/xlat-i/xi.makefile [new file with mode: 0644]
src/xlat-i/xlat.makefile [deleted file]

diff --git a/src/ck-core/acc.c b/src/ck-core/acc.c
deleted file mode 100644 (file)
index 08c2173..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-#include "charm.h"
-
-void *GetAccMsgPtr() ;
-extern void * CPlus_CallAccInit() ;
-extern void * CPlus_GetAccMsgPtr() ;
-extern void CPlus_CallCombineFn() ;
-extern void CPlus_SetAccId() ;
-
-
-
-/* internal functions */
-static void ACC_CollectFromNode_Fn();
-static void ACC_LeafNodeCollect_Fn();
-static void ACC_InteriorNodeCollect_Fn();
-static void ACC_BranchInit_Fn();
-
-
-void AccAddSysBocEps(void)
-{
-  CsvAccess(CkChare_ACC) =
-    registerChare("CkChare_ACC", sizeof(ACC_DATA), NULL);
-
-  CsvAccess(CkEp_ACC_CollectFromNode) =
-    registerBocEp("CkEp_ACC_CollectFromNode",
-                 ACC_CollectFromNode_Fn,
-                 CHARM, 0, CsvAccess(CkChare_ACC));
-  CsvAccess(CkEp_ACC_LeafNodeCollect) =
-    registerBocEp("CkEp_ACC_LeafNodeCollect",
-                 ACC_LeafNodeCollect_Fn,
-                 CHARM, 0, CsvAccess(CkChare_ACC));
-  CsvAccess(CkEp_ACC_InteriorNodeCollect) =
-    registerBocEp("CkEp_ACC_InteriorNodeCollect",
-                 ACC_InteriorNodeCollect_Fn,
-                 CHARM, 0, CsvAccess(CkChare_ACC));
-  CsvAccess(CkEp_ACC_BranchInit) =
-    registerBocEp("CkEp_ACC_BranchInit",
-                 ACC_BranchInit_Fn,
-                 CHARM, 0, CsvAccess(CkChare_ACC));
-}
-
-
-
-
-
-void CollectValue(bocnum, EP, CID)
-int bocnum;
-int EP;
-ChareIDType *CID;
-{
-       ACC_COLLECT_MSG *msg;
-
-       msg = (ACC_COLLECT_MSG *) CkAllocMsg(sizeof(ACC_COLLECT_MSG));
-       msg->EP = EP; 
-       msg->cid = *CID;
-       if (CmiMyPe() == 0)
-               ACC_CollectFromNode_Fn(msg, GetBocDataPtr(bocnum)); 
-       else
-               GeneralSendMsgBranch(CsvAccess(CkEp_ACC_CollectFromNode), msg,
-                       0, ImmBocMsg, bocnum);
-}
-
-
-static void ACC_CollectFromNode_Fn(msg, mydata)
-ACC_COLLECT_MSG *msg;
-ACC_DATA *mydata;
-{
-       int i;
-       DUMMY_MSG *tmsg;
-
-       if (mydata->AlreadyDone)
-               CmiPrintf("***ERROR*** Accumulation already done\n");   
-       else
-       {
-               mydata->EP = msg->EP;
-               mydata->CID = msg->cid;
-               tmsg = (DUMMY_MSG *) CkAllocMsg(sizeof(DUMMY_MSG));
-               mydata->AlreadyDone = 1;
-               GeneralBroadcastMsgBranch(CsvAccess(CkEp_ACC_LeafNodeCollect), tmsg,
-                       ImmBroadcastBocMsg,
-                        MyBocNum(mydata));
-       }
-}
-
-
-
-
-static void ACC_LeafNodeCollect_Fn(msg, mydata)
-DUMMY_MSG *msg;
-ACC_DATA *mydata;
-{
-
-       if (CmiNumSpanTreeChildren(mydata->Penum) == 0)
-       {
-               if (mydata->Penum == 0)
-                       SendMsg(mydata->EP,  GetAccMsgPtr(mydata),
-                               &(mydata->CID)); 
-               else
-               {
-TRACE(CmiPrintf("[%d] ACC_NodeCollect : Sent message to parent\n",
-       CmiMyPe()));
-                       mydata->Penum = CmiSpanTreeParent(mydata->Penum);
-                       GeneralSendMsgBranch(CsvAccess(CkEp_ACC_InteriorNodeCollect), 
-                                       GetAccMsgPtr(mydata), mydata->Penum,
-                                       ImmBocMsg,
-                                        MyBocNum(mydata));
-               }
-       }
-}
-
-
-
-static void ACC_InteriorNodeCollect_Fn(msg, mydata)
-char *msg;
-ACC_DATA *mydata;
-{
-
-       if ( IsCharmPlusPseudo(mydata->id) ) 
-               CPlus_CallCombineFn(mydata->dataptr,msg) ;
-       else 
-               (*(CsvAccess(PseudoTable)[mydata->id].pseudo_type.acc.combinefn))(mydata->dataptr, msg);
-       mydata->NumChildren--;
-       if (mydata->NumChildren <= 0)
-       {
-               if (mydata->Penum == 0)
-                       SendMsg(mydata->EP, GetAccMsgPtr(mydata),
-                               &(mydata->CID)); 
-               else
-               {
-TRACE(CmiPrintf("[%d] ACC_NodeCollect : Sent message to parent\n",
-               CmiMyPe()));
-                       mydata->Penum = CmiSpanTreeParent(mydata->Penum);
-                       GeneralSendMsgBranch(CsvAccess(CkEp_ACC_InteriorNodeCollect), 
-                                       GetAccMsgPtr(mydata), mydata->Penum,
-                                       ImmBocMsg,
-                                        MyBocNum(mydata));
-               }
-       }
-}
-
-
-AccIDType CreateAcc(id, initmsg, ReturnEP, ReturnID)
-int id;
-void *initmsg;
-EntryPointType ReturnEP;
-ChareIDType *ReturnID;
-{
-       ChareNumType boc;
-       ENVELOPE *envelope = (ENVELOPE *) ENVELOPE_UPTR(initmsg);
-
-       SetEnv_other_id(envelope, id);
-TRACE(CmiPrintf("[%d] CreateAcc: id=%d\n", CmiMyPe(), id));
-       boc = CreateBoc(CsvAccess(CkChare_ACC), CsvAccess(CkEp_ACC_BranchInit),
-                        initmsg, ReturnEP, ReturnID);
-TRACE(CmiPrintf("[%d] CreateAcc: boc = %d\n", CmiMyPe(), (AccIDType ) boc));
-       return((AccIDType) boc);
-}
-
-
-static void ACC_BranchInit_Fn(msg, mydata)
-void *msg;
-ACC_DATA *mydata; 
-{
-       ENVELOPE *env = (ENVELOPE *) ENVELOPE_UPTR(msg);
-       int id = GetEnv_other_id(env);
-
-TRACE(CmiPrintf("[%d] ACC_BranchInit : id = %d\n", CmiMyPe(), id));
-
-       mydata->id = id; 
-       mydata->AlreadyDone = 0;
-       mydata->Penum = CmiMyPe();
-       mydata->NumChildren = CmiNumSpanTreeChildren(mydata->Penum) ;   
-
-       if ( IsCharmPlusPseudo(id) ) {
-           mydata->dataptr = CPlus_CallAccInit(id, msg) ;
-           CPlus_SetAccId(mydata->dataptr,MyBocNum(mydata)) ;
-       }
-       else 
-           mydata->dataptr = (void *) (*(CsvAccess(PseudoTable)[id].initfn))(NULL, msg);
-
-TRACE(CmiPrintf("[%d] ACC_BranchInit : NumChildren = %d\n",
-       CmiMyPe(),  mydata->NumChildren));
-}
-
-
-void * _CK_9GetAccDataPtr(accdata)
-ACC_DATA * accdata; 
-{
-       return(accdata->dataptr);
-}
-
-
-FUNCTION_PTR _CK_9GetAccumulateFn(accdata)
-ACC_DATA * accdata; 
-{
-       return(CsvAccess(PseudoTable)[accdata->id].pseudo_type.acc.addfn);
-}
-
-
-void * GetAccMsgPtr(mydata)
-ACC_DATA *mydata ;
-{
-/* In Charm++, the dataptr points to the accumulator object, and the
-   actual data (in the form of a message as for Charm) is a field inside 
-   the object, which is accessed through the _CK_GetMsgPtr() generated
-   by the translator */
-       if ( IsCharmPlusPseudo(mydata->id) ) 
-               return(CPlus_GetAccMsgPtr(mydata->dataptr)) ;
-       else
-               return(mydata->dataptr) ;       
-}
-
diff --git a/src/ck-core/boc.c b/src/ck-core/boc.c
deleted file mode 100644 (file)
index 42529b6..0000000
+++ /dev/null
@@ -1,532 +0,0 @@
-#include "charm.h"
-
-#include "trace.h"
-
-#define MAXBOC 15
-
-typedef struct msg_element {
-        int ref;
-        void *msg;
-        ChareNumType ep;
-        struct msg_element *next;
-} MSG_ELEMENT;
-
-typedef struct bocdata_queue_element {
-       ChareNumType bocNum;
-       CHARE_BLOCK *dataptr;
-       struct bocdata_queue_element *next;
-} BOCDATA_QUEUE_ELEMENT;
-
-typedef struct bocid_message_count {
-       int count;
-       ChareNumType bocnum;
-       ChareIDType ReturnID;
-       EntryPointType ReturnEP;
-       struct bocid_message_count *next;
-} BOCID_MESSAGE_COUNT;
-
-
-
-typedef MSG_ELEMENT *MSG_ELEMENT_;
-typedef BOCDATA_QUEUE_ELEMENT *BOCDATA_QUEUE_ELEMENT_[MAXBOC];
-typedef BOCID_MESSAGE_COUNT *BOCID_MESSAGE_COUNT_[MAXBOC];
-
-CpvStaticDeclare(int, number_dynamic_boc);
-CpvStaticDeclare(MSG_ELEMENT_, DynamicBocMsgList); 
-CpvStaticDeclare(BOCDATA_QUEUE_ELEMENT_, BocDataTable);
-CpvStaticDeclare(BOCID_MESSAGE_COUNT_, BocIDMessageCountTable);
-
-CHARE_BLOCK *CreateChareBlock();
-
-void GeneralSendMsgBranch();
-
-
-void bocModuleInit(void)
-{
-   CpvInitialize(int, number_dynamic_boc);
-   CpvInitialize(MSG_ELEMENT_, DynamicBocMsgList);
-   CpvInitialize(BOCDATA_QUEUE_ELEMENT_, BocDataTable);
-   CpvInitialize(BOCID_MESSAGE_COUNT_, BocIDMessageCountTable);
-
-   CpvAccess(number_dynamic_boc)=1;
-}
-
-
-
-
-void InitializeDynamicBocMsgList(void)
-{
-       CpvAccess(DynamicBocMsgList) = (MSG_ELEMENT *) NULL;
-}
-
-void InitializeBocDataTable(void)
-{
-       int i;
-
-       for (i=0; i<MAXBOC; i++)
-           CpvAccess(BocDataTable)[i] = (BOCDATA_QUEUE_ELEMENT *) NULL;
-}
-
-void InitializeBocIDMessageCountTable(void)
-{
-       int i;
-
-       for (i=0; i<MAXBOC; i++)
-           CpvAccess(BocIDMessageCountTable)[i] = (BOCID_MESSAGE_COUNT *) NULL;
-}
-
-void GetDynamicBocMsg(ref, msg, ep)
-int ref;
-void **msg;
-ChareNumType *ep;
-{
-       MSG_ELEMENT * previous = NULL;
-       MSG_ELEMENT * temp; 
-
-        temp = CpvAccess(DynamicBocMsgList);
-       
-       while (temp != NULL)
-       {
-               if (temp->ref == ref)
-               {
-                       *msg = temp->msg;
-                       *ep = temp->ep;
-
-TRACE(CmiPrintf("[%d] GetDynamicBocMsg: ref=%d, ep=%d\n",
-               CmiMyPe(), ref, temp->ref)); 
-       
-                       if (previous == NULL)
-                               CpvAccess(DynamicBocMsgList) = temp->next; 
-                       else
-                               previous->next = temp->next;
-                       CmiFree(temp);
-                       return;
-               }
-               else
-               {
-                       previous = temp;
-                       temp = temp->next;
-               }
-       }
-       CmiPrintf("[%d] *** ERROR *** Could not locate return address for dynamic creation %d.\n", CmiMyPe(), ref);
-}
-
-
-CHARE_BLOCK *GetBocBlockPtr(bocNum)
-ChareNumType bocNum;
-{
-       int index;
-       BOCDATA_QUEUE_ELEMENT *element;
-
-
-       index = bocNum % MAXBOC;
-       element = CpvAccess(BocDataTable)[index];
-
-TRACE(CmiPrintf("[%d] GetBocBlockPtr: bocNum=%d, index=%d, element=0x%x\n",
-                CmiMyPe(), bocNum, index, element));
-
-       while (element != NULL)
-       {
-               if (element->bocNum == bocNum)
-                       return(element->dataptr);
-               else
-                       element = element->next;
-       }
-       CmiPrintf("[%d] *** ERROR *** Unable to locate BOC %d data ptr.\n",
-               CmiMyPe(),  bocNum);
-  return (CHARE_BLOCK *) 0;
-}
-
-
-void * GetBocDataPtr(ChareNumType bocNum)
-{
-    return GetBocBlockPtr(bocNum)->chareptr;
-}
-
-
-BOCID_MESSAGE_COUNT * GetBocIDMessageCount(bocnum)
-ChareNumType bocnum;
-{
-       int index;
-       BOCID_MESSAGE_COUNT *element;
-
-       index = bocnum % MAXBOC;
-       element = CpvAccess(BocIDMessageCountTable)[index];
-       while (element != NULL)
-       {
-               if (element->bocnum == bocnum)
-                       return(element);
-               else    
-                       element = element->next;
-       }
-       TRACE(CmiPrintf("[%d] *** ERROR *** Incorrect boc number %d in GetBocIDMessageCount\n", 
-                       CmiMyPe(), bocnum));
-       return(NULL);
-}
-
-SetDynamicBocMsg(msg,ep)
-void *msg;
-ChareNumType ep;
-{
-       MSG_ELEMENT * new; 
-       
-       new = (MSG_ELEMENT *) CmiAlloc(sizeof(MSG_ELEMENT));
-       new->ref = CpvAccess(number_dynamic_boc)++;
-       new->msg = msg;
-       new->ep = ep;
-       new->next = CpvAccess(DynamicBocMsgList); 
-       CpvAccess(DynamicBocMsgList) = new; 
-
-TRACE(CmiPrintf("[%d] SetDynamicBocMsg: ref=%d, ep=%d\n",
-       CmiMyPe(), new->ref, new->ep));
-
-       return (new->ref);
-}
-
-void SetBocBlockPtr(bocNum, ptr)
-ChareNumType bocNum;
-CHARE_BLOCK *ptr;
-{
-       int index;
-       BOCDATA_QUEUE_ELEMENT *new;
-       BOCDATA_QUEUE_ELEMENT *element;
-
-
-       index = bocNum % MAXBOC;
-       new = (BOCDATA_QUEUE_ELEMENT *) CmiAlloc(sizeof(BOCDATA_QUEUE_ELEMENT));
-       CkMemError(new);
-       new->bocNum = bocNum;
-       new->dataptr = ptr;
-       element = CpvAccess(BocDataTable)[index];
-       new->next = element;    
-       CpvAccess(BocDataTable)[index] = new;
-
-TRACE(CmiPrintf("[%d] SetBocBlockPtr: bocNum=%d, index=%d, new=0x%x\n",
-                CmiMyPe(), bocNum, index, new));
-}
-
-
-BOCID_MESSAGE_COUNT * SetBocIDMessageCount(bocnum, count, ReturnEP, ReturnID)
-ChareNumType bocnum;
-int count;
-EntryPointType ReturnEP;
-ChareIDType *ReturnID;
-{
-       int index;
-       BOCID_MESSAGE_COUNT *new, *element;
-
-       index = bocnum % MAXBOC;
-       new = (BOCID_MESSAGE_COUNT *) CmiAlloc(sizeof(BOCID_MESSAGE_COUNT));
-       CkMemError(new);
-       new->bocnum = bocnum;
-       new->count = count;
-       new->ReturnEP = ReturnEP;
-       if (ReturnID != NULL) 
-               new->ReturnID = *ReturnID;
-       element = CpvAccess(BocIDMessageCountTable)[index];
-       new->next = element;
-       CpvAccess(BocIDMessageCountTable)[index] = new;
-       return(new);
-}
-
-
-ChareNumType CreateBoc(id, Entry, Msg, ReturnEP, ReturnID)
-int id;
-EntryNumType Entry;
-void *Msg;
-EntryNumType ReturnEP;
-ChareIDType *ReturnID;
-{
-  ENVELOPE *env ;
-
-  if (id!=CsvAccess(EpInfoTable)[Entry].chareindex)
-    CmiPrintf("** ERROR ** Illegal combination of CHARENUM/EP in CreateBOC\n");
-
-  env = (ENVELOPE *) ENVELOPE_UPTR(Msg);
-
-  if (CpvAccess(InsideDataInit))
-    /* static boc creation */
-    {
-      int executing_boc_num; 
-      
-      SetEnv_boc_num(env, ++CpvAccess(currentBocNum));
-      SetEnv_EP(env, Entry);
-      SetEnv_msgType(env, BocInitMsg);
-      if(CpvAccess(traceOn))
-        trace_creation(GetEnv_msgType(env), Entry, env);
-      PACK(env);
-      CmiSetHandler(env,CsvAccess(HANDLE_INIT_MSG_Index));
-      CmiSyncBroadcast(GetEnv_TotalSize(env),env);
-      UNPACK(env);
-      
-      /* env becomes the usrMsg, hence should not be freed by us */
-      executing_boc_num = ProcessBocInitMsg(env);
-      if (ReturnEP >= 0)
-       {
-         ChareNumType *msg;
-         
-         msg = (ChareNumType *)
-           CkAllocMsg(sizeof(ChareNumType));
-         *msg = CpvAccess(currentBocNum);
-         SendMsg(ReturnEP, msg, ReturnID); 
-       }
-      return(executing_boc_num);
-    }
-  else
-    /* dynamic boc creation */
-    {
-      DYNAMIC_BOC_REQUEST_MSG *msg;
-      
-      msg = (DYNAMIC_BOC_REQUEST_MSG *) 
-       CkAllocMsg(sizeof(DYNAMIC_BOC_REQUEST_MSG));
-      msg->source = CmiMyPe();
-      msg->ep = ReturnEP;
-      msg->id = *ReturnID;
-      msg->ref = SetDynamicBocMsg(Msg, Entry);
-      
-      GeneralSendMsgBranch(CsvAccess(CkEp_DBOC_OtherCreateBoc), msg,
-                          0, ImmBocMsg, DynamicBocNum);
-    }
-    return 0;
-}
-
-void OtherCreateBoc(msg, mydata)
-DYNAMIC_BOC_REQUEST_MSG *msg;
-char *mydata;
-{
-  DYNAMIC_BOC_NUM_MSG *tmsg;
-  BOCID_MESSAGE_COUNT *element;
-  
-  element = SetBocIDMessageCount(++CpvAccess(currentBocNum),
-                                CmiNumSpanTreeChildren(CmiMyPe()),
-                                msg->ep, &(msg->id));
-  tmsg = (DYNAMIC_BOC_NUM_MSG *) CkAllocMsg(sizeof(DYNAMIC_BOC_NUM_MSG)); 
-  tmsg->boc = CpvAccess(currentBocNum);
-  tmsg->ref = msg->ref;
-  
-  TRACE(CmiPrintf("[%d] OtherCreateBoc: boc=%d, ref=%d\n",
-                 CmiMyPe(), tmsg->boc, tmsg->ref));
-  
-  GeneralSendMsgBranch(CsvAccess(CkEp_DBOC_InitiateDynamicBocBroadcast), tmsg,
-                      msg->source, ImmBocMsg, DynamicBocNum);
-}
-
-MyBocNum(mydata)
-void *mydata;
-{
-        CHARE_BLOCK *chare = ((CHARE_BLOCK *)mydata)-1;
-        return chare->x.boc_num;
-}
-
-void MyBranchID(pChareID, mydata)
-ChareIDType *pChareID;
-void *mydata;
-{
-        CHARE_BLOCK *chare = ((CHARE_BLOCK *)mydata)-1;
-        *pChareID = chare->selfID;
-}
-
-void GeneralMulticastMsgBranch(ep, msg, type, bocnum, grp)
-EntryPointType ep;
-void *msg;
-MsgTypes type;
-ChareNumType bocnum;
-CmiGroup grp;
-{
-  ENVELOPE *env;
-  int len, queueing, priobits; unsigned int *prioptr;
-  CldInfoFn ifn = (CldInfoFn)CmiHandlerToFunction(CpvAccess(CkInfo_Index));
-  CldPackFn pfn;
-  /* Charm++ translator puts type as -1 to avoid using the
-     BroadcastBocMsg macro. */
-  if ( type == -1 )
-    type = BroadcastBocMsg ;
-  env = ENVELOPE_UPTR(msg);
-  SetEnv_msgType(env, type);
-  SetEnv_boc_num(env, bocnum);
-  SetEnv_EP(env, ep);
-  TRACE(CmiPrintf("[%d] GeneralBroadcast: type=%d, msgType=%d\n",
-                  CmiMyPe(), type, GetEnv_msgType(env)));
-  /* if (bocnum >= NumSysBoc) */
-  CpvAccess(nodebocMsgsCreated)+=CmiNumPes();
-
-  if(CpvAccess(traceOn))
-    trace_creation(GetEnv_msgType(env), ep, env);
-
-  CmiSetHandler(env,CpvAccess(HANDLE_INCOMING_MSG_Index));
-  ifn((void *)env, &pfn, &len, &queueing, &priobits, &prioptr);
-  if (pfn) {
-      pfn(&env);
-      ifn((void *)env, &pfn, &len, &queueing, &priobits, &prioptr);
-  }
-  CmiFreeMulticastFn(grp, len, (void *)env);
-  /*CldEnqueue(destPE, env, CpvAccess(CkInfo_Index));*/
-
-  if((type!=QdBocMsg)&&(type!=QdBroadcastBocMsg)&&(type!=LdbMsg))
-  QDCountThisCreation(1);
-}
-
-
-void GeneralSendMsgBranch(ep, msg, destPE, type, bocnum)
-EntryPointType ep;
-void *msg;
-PeNumType destPE;
-MsgTypes type;
-ChareNumType bocnum;
-{
-  ENVELOPE *env;
-
-  /* Charm++ translator puts type as -1 to avoid using the 
-     BocMsg macro. */
-  if ( type == -1 ) 
-    type = BocMsg ;
-  
-  env  = ENVELOPE_UPTR(msg);
-  
-  SetEnv_msgType(env, type);
-  SetEnv_boc_num(env, bocnum);
-  SetEnv_EP(env, ep);
-  
-  TRACE(CmiPrintf("[%d] GeneralSend: type=%d, msgType=%d\n",
-                 CmiMyPe(), type, GetEnv_msgType(env)));
-  
-  /* if (bocnum >= NumSysBoc) */
-  CpvAccess(nodebocMsgsCreated)++;
-  
-  if(CpvAccess(traceOn))
-    trace_creation(GetEnv_msgType(env), ep, env);
-  
-  CmiSetHandler(env, CpvAccess(HANDLE_INCOMING_MSG_Index));
-  CldEnqueue(destPE, env, CpvAccess(CkInfo_Index));
-  if((type!=QdBocMsg)&&(type!=QdBroadcastBocMsg)&&(type!=LdbMsg))
-    QDCountThisCreation(1);
-}
-
-
-void GeneralBroadcastMsgBranch(ep, msg, type, bocnum)
-EntryPointType ep;
-void *msg;
-MsgTypes type;
-ChareNumType bocnum;
-{
-  ENVELOPE *env;
-  
-  /* Charm++ translator puts type as -1 to avoid using the 
-     BroadcastBocMsg macro. */
-  if ( type == -1 ) 
-    type = BroadcastBocMsg ;
-  
-  env = ENVELOPE_UPTR(msg);
-  
-  SetEnv_msgType(env, type);
-  SetEnv_boc_num(env, bocnum);
-  SetEnv_EP(env, ep);
-  
-  TRACE(CmiPrintf("[%d] GeneralBroadcast: type=%d, msgType=%d\n",
-                 CmiMyPe(), type, GetEnv_msgType(env)));
-  
-  /* if (bocnum >= NumSysBoc) */
-  CpvAccess(nodebocMsgsCreated)+=CmiNumPes();
-  
-  if(CpvAccess(traceOn))
-    trace_creation(GetEnv_msgType(env), ep, env);
-  CmiSetHandler(env,CpvAccess(HANDLE_INCOMING_MSG_Index));
-  CldEnqueue(CLD_BROADCAST_ALL, env, CpvAccess(CkInfo_Index));
-  if((type!=QdBocMsg)&&(type!=QdBroadcastBocMsg)&&(type!=LdbMsg))
-    QDCountThisCreation(CmiNumPes());
-}
-
-
-void RegisterDynamicBocInitMsg(bocnumptr, mydata)
-ChareNumType *bocnumptr;
-void *mydata;
-{
-       ChareNumType *msg;
-       int mype = CmiMyPe();
-       BOCID_MESSAGE_COUNT  * bocdata = GetBocIDMessageCount(*bocnumptr);
-
-TRACE(CmiPrintf("[%d] RegisterDynamicBoc: bocnum=%d, bocdata=0x%x\n",
-                CmiMyPe(), *bocnumptr, bocdata));
-       if (bocdata == NULL)
-               bocdata = SetBocIDMessageCount(*bocnumptr,
-                               CmiNumSpanTreeChildren(mype), -1, NULL);
-       bocdata->count--;
-
-       if (bocdata->count < 0)
-       {
-               msg = (ChareNumType *) CkAllocMsg(sizeof(ChareNumType));
-               *msg = *bocnumptr;
-
-               if (mype == 0)
-               {
-                       if (bocdata->ReturnEP >= 0)
-                               SendMsg(bocdata->ReturnEP, msg,
-                                       &bocdata->ReturnID);
-               }
-               else
-                       GeneralSendMsgBranch(CsvAccess(CkEp_DBOC_RegisterDynamicBocInitMsg), (void *) msg,
-                           CmiSpanTreeParent(mype), ImmBocMsg, DynamicBocNum);
-       }
-}
-
-
-void InitiateDynamicBocBroadcast(msg, mydata)
-DYNAMIC_BOC_NUM_MSG *msg;
-char *mydata;
-{
-  int dataSize;
-  void *tmsg;
-  ENVELOPE * env;
-  ChareNumType ep;
-  
-  GetDynamicBocMsg(msg->ref, &tmsg, &ep); 
-  
-  TRACE(CmiPrintf("[%d] InitiateDynamicBocBroadcast: ref=%d, boc=%d, ep=%d\n",
-                 CmiMyPe(), msg->ref, msg->boc, ep));
-  
-  env = (ENVELOPE *) ENVELOPE_UPTR(tmsg);
-  SetEnv_boc_num(env, msg->boc);
-  SetEnv_EP(env, ep);
-  SetEnv_msgType(env, DynamicBocInitMsg);
-  
-  if(CpvAccess(traceOn))
-    trace_creation(GetEnv_msgType(env), ep, env);
-  CmiSetHandler(env,CpvAccess(HANDLE_INCOMING_MSG_Index));
-  CldEnqueue(CLD_BROADCAST_ALL, env, CpvAccess(CkInfo_Index));
-  
-  QDCountThisCreation(CmiNumPes());
-}
-
-void DynamicBocInit(void)
-{
-       CHARE_BLOCK *bocBlock;
-
-       /* Create a dummy block */
-       bocBlock = CreateChareBlock(sizeof(int), CHAREKIND_BOCNODE, 0);
-        bocBlock->x.boc_num = DynamicBocNum;
-       SetBocBlockPtr(DynamicBocNum, bocBlock);
-}
-
-
-void DynamicAddSysBocEps(void)
-{
-  CsvAccess(CkEp_DBOC_RegisterDynamicBocInitMsg) =
-    registerBocEp("CkEp_DBOC_RegisterDynamicBocInitMsg",
-                 RegisterDynamicBocInitMsg,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_DBOC_OtherCreateBoc) =
-    registerBocEp("CkEp_DBOC_OtherCreateBoc",
-                 OtherCreateBoc,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_DBOC_InitiateDynamicBocBroadcast) =
-    registerBocEp("CkEp_DBOC_InitiateDynamicBocBroadcast",
-                 InitiateDynamicBocBroadcast,
-                 CHARM, 0, 0);
-}
-
-
diff --git a/src/ck-core/charm++-inc.h b/src/ck-core/charm++-inc.h
deleted file mode 100644 (file)
index bfdc839..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/***** quiescence.h : included in user CHARM++ files. *****/
-
-#ifndef _quiescence_h_
-#define _quiescence_h_
-
-message class QUIESCENCE_MSG {
-public:        int msgs_processed;
-} ;
-
-
-#define TBL_WAITFORDATA 1
-#define TBL_NOWAITFORDATA 2
-
-#define TBL_REPLY 1
-#define TBL_NOREPLY 2
-
-#define TBL_WAIT_AFTER_FIRST 1
-#define TBL_NEVER_WAIT 2
-#define TBL_ALWAYS_WAIT 3
-
-
-extern int _CK_NumTables ;
-extern "C" void TblInsert(int, int, int, void *, int, int, ChareIDType *, int);
-extern "C" void TblDelete(int, int, int, int, ChareIDType *, int) ;
-extern "C" void TblFind(int, int, int, int, ChareIDType *, int) ;
-
-
-class table { /* top level distributed table object */
-        int _CK_MyId ;
-public:
-        table()
-        {       _CK_MyId = _CK_NumTables++ ;
-                /* Table ids are assigned at run time unlike in CHARM.
-                   _CK_NumTables is a global, defined in cplus_node_main.c */
-        }
-        void Insert(int key, void *data, int size_data, int EPid, ChareIDType cid, int option)
-        {
-            if ( CK_PE_SPECIAL(GetID_onPE(cid)) )
-                ::TblInsert(_CK_MyId, -1, key, data, size_data, EPid, NULL, option) ;
-            else
-                ::TblInsert(_CK_MyId, -1, key, data, size_data, EPid, &cid, option) ;
-        }
-
-        void Delete(int key, int EPid, ChareIDType cid, int option)
-        {
-            if ( CK_PE_SPECIAL(GetID_onPE(cid)) )
-                ::TblDelete(_CK_MyId, -1, key, EPid, NULL, option) ;
-            else
-                ::TblDelete(_CK_MyId, -1, key, EPid, &cid, option) ;
-        }
-
-        void Find(int key, int EPid, ChareIDType cid, int option)
-        {
-            if ( CK_PE_SPECIAL(GetID_onPE(cid)) )
-                ::TblFind(_CK_MyId, -1, key, EPid, NULL, option) ;
-            else
-                ::TblFind(_CK_MyId, -1, key, EPid, &cid, option) ;
-        }
-
-       int GetId()
-       {       return _CK_MyId ; }
-
-       void SetId (int x) {
-            _CK_MyId = x;
-       }
-
-} ;
-
-#endif
index 52b80bd3ca173a28d2d8b0485b0a6f9dbeb34dba..9d8647956a88df0cbaa54ee14a224238105d65b6 100644 (file)
-#ifndef C_PLUS_INTERFACE_H
-#define C_PLUS_INTERFACE_H
+#ifndef _CHARMPP_H_
+#define _CHARMPP_H_
+
+#include <stdlib.h>
 
 extern "C" {
 #include "charm.h"
 }
 
-class _CK_Object ;
-class groupmember ;
-
-#define NULL_EP -1
-
-/* GroupIdType is the generic type usable for all BOC ids */
-typedef int GroupIdType ;
-
-/* EPFnType is a pointer to a _CK_call_Chare_EP() function */
-typedef void (*EPFnType)(void *, _CK_Object *) ;
-
-/* CHAREFNTYPE is a pointer to a _CK_create_ChareName() function */
-typedef _CK_Object * (*CHAREFNTYPE)(int) ;
-
-/* BOCFNTYPE is a pointer to a _CK_create_BocName() function */
-typedef groupmember * (*BOCFNTYPE)(void) ;
-
-/* ACCFNTYPE is a pointer to a _CK_create_AccName() function */
-typedef void * (*ACCFNTYPE)(void *) ;
-
-/* ALLOCFNTYPE is a pointer to a _CK_alloc_MsgName() function */
-typedef void * (*ALLOCFNPTR)(int, int, int*, int) ;
-
-/* this is the handle of the main chare, used in place of MainChareID */
-extern ChareIDType mainhandle;
-extern ChareIDType NULL_HANDLE;
-
-
-/* These are C++ functions in the runtime system */
-FUNCTION_PTR CFunctionRefToName(int index) ;
-
-
-/* These are C functions in the Charm runtime system */
-
-extern "C" int registerMsg(char *name, FUNCTION_PTR allocf, FUNCTION_PTR packf, FUNCTION_PTR unpackf, FUNCTION_PTR coerce, int size) ;
-
-extern "C" int registerBocEp(char *name, FUNCTION_PTR epFunc , int epType , int msgIndx, int chareIndx) ;
-
-extern "C" int registerEp(char *name, FUNCTION_PTR epFunc , int epType , int msgIndx, int chareIndx) ;
-
-extern "C" int registerChare(char *name, int dataSz, FUNCTION_PTR createfn) ;
-
-extern "C" int registerFunction(FUNCTION_PTR fn) ;
-
-extern "C" int registerMonotonic(char *name , FUNCTION_PTR initfn, FUNCTION_PTR updatefn , int language) ;
-
-extern "C" int registerTable(char *name , FUNCTION_PTR initfn, FUNCTION_PTR hashfn) ;
-
-extern "C" int registerAccumulator(char *name , FUNCTION_PTR initfn, FUNCTION_PTR addfn, FUNCTION_PTR combinefn , int language) ;
-
-extern "C" int registerReadOnlyMsg() ;
-
-extern "C" void registerReadOnly(int size , FUNCTION_PTR fnCopyFromBuffer, FUNCTION_PTR fnCopyToBuffer) ;
-
-extern "C" void registerMainChare(int m, int ep , int type) ;
-
-extern "C" void * VarSizeCkAlloc(int, int, int, int[]) ;
-extern "C" void * CkAllocPackBuffer(void *, int) ;
-extern "C" int CreateBoc(int, int, void *, int, ChareIDType *) ;
-extern "C" void CreateChare(int, int, void *, ChareIDType *, int) ;
-extern "C" int CreateAcc(int, void *, int, ChareIDType *) ;
-extern "C" int CreateMono(int, void *, int, ChareIDType *) ;
-extern "C" void CkExit() ;
-extern "C" void ChareExit() ;
-extern "C" void CkFreeMsg(void *) ;
-extern "C" void GeneralMulticastMsgBranch(int, void *, int, int, CmiGroup) ;
-extern "C" void GeneralSendMsgBranch(int, void *, int, int, int) ;
-extern "C" void GeneralBroadcastMsgBranch(int, void *, int, int) ;
-extern "C" void SendMsg(int, void *, ChareIDType *) ;
-extern "C" void *GetBocDataPtr(int) ;
-extern "C" void SetBocBlockPtr(int, CHARE_BLOCK *);
-
-extern "C" void VidRetrieveMessages(CHARE_BLOCK *, PeNumType, CHARE_BLOCK *) ;
-extern "C" void SendNodeStatistics() ;
-extern "C" void close_log() ;
-extern "C" void PrintStsFile(char *) ;
-extern "C" void trace_creation(int, int, ENVELOPE *) ;
-extern "C" void trace_begin_execute(ENVELOPE *) ;
-extern "C" void trace_end_execute(int, int, int) ;
-
-extern "C" int CPlus_GetMagicNumber(_CK_Object *) ;
-extern "C" void CPlus_StartQuiescence(int, ChareIDType) ;
-
-extern "C" void * _CK_9GetAccDataPtr(void *) ;
-extern "C" void * _CK_9GetMonoDataPtr(void *) ;
-extern "C" void _CK_BroadcastMono(void *, int) ;
-extern "C" void CollectValue(int, int, ChareIDType *) ;
-extern "C" void * MonoValue(int) ;
-
-extern "C" unsigned int *CkPrioPtrFn(void *);
-extern "C" int           CkPrioSizeBitsFn(void *);          
-extern "C" int           CkPrioSizeBytesFn(void *);          
-extern "C" int           CkPrioSizeWordsFn(void *);
-extern "C" void          CkPrioConcatFn(void *, void *, unsigned int);
-
-extern "C" void          CkSetQueueing(void *, int);
-
-extern "C" ENVELOPE *CkCopyEnv(ENVELOPE *) ;
-
-
-extern "C" void  SetRefNumber(void *m, int n);
-extern "C" int   GetRefNumber(void *m);
-
-extern "C" void      futuresModuleInit();
-extern "C" void      futuresCreateBOC();
-extern "C" void*     CRemoteCallBranchFn(int ep, void * m, int g, int p);
-extern "C" void*     CRemoteCallFn(int ep, void *m, ChareIDType *id);
-extern "C" void      CSendToFuture(void *m, int processor);
-
 #if CMK_DEBUG_MODE
-void putObject(_CK_Object *);
-void removeObject(_CK_Object *);
+class Chare;
+void putObject(Chare *);
+void removeObject(Chare *);
 #endif
 
-/* These are messages which are created in C code in the runtime 
-   and received by a Charm++ chare. So they cant inherit from 
-   comm_object, else the layout of the message changes. The translator
-   puts them in the symbol table at initialization time (in process.c),
-   so these definitions dont need to be seen by the translator (they are 
-   seen by the C++ compiler because this file is #included in the program. */
-
-class GroupIdMessage { // sizeof(GroupIdMessage) MUST be 4
-public:        GroupIdType groupid ;
-
-       void *operator new(CMK_SIZE_T size) {   // should never be called
-               size += 0 ;     // to prevent CC from generating "size unused"
-               return NULL ;
-       }
-
-        void operator delete(void *msg) {
-                CkFreeMsg(msg) ;
-        }
-} ;
-
-class TableMessage {   
-// used by distributed tables, must have exactly the
-// same size and format as TBL_MSG in tbl.h
-public: int key ;
-        char *data ;
-       void *operator new(CMK_SIZE_T size) {   // should never be called
-               size += 0 ;     // to prevent CC from generating "size unused"
-               return NULL ;
-       }
-
-        void operator delete(void *msg) {
-                CkFreeMsg(msg) ;
-        }
-} ;
-
-
-
-
-/****** This is the top level class from which all message types inherit *****/
-
-class comm_object {
-public:        void operator delete(void *msg) {
-               CkFreeMsg(msg) ;
-       }
-
-       void *operator new(CMK_SIZE_T size) ;
-
-       void *operator new(CMK_SIZE_T size, void *ptr) {
-          return ptr;
-        }
-
-       void *operator new(CMK_SIZE_T size, int id) {
-               return (void *)GenericCkAlloc(id, size, 0) ;
-       }
-
-       void *operator new(CMK_SIZE_T size, int id, int prio) {
-               return (void *)GenericCkAlloc(id, size, prio) ;
-       }
-
-       void *operator new(CMK_SIZE_T size, int id, int* sizes) {
-               return (void *)((ALLOCFNPTR)(CsvAccess(MsgToStructTable)[id].alloc))(id, size, sizes, 0) ;
-       }
-
-       void *operator new(CMK_SIZE_T size, int id, int prio, int* sizes) {
-               return (void *)((ALLOCFNPTR)(CsvAccess(MsgToStructTable)[id].alloc))(id, size, sizes, prio) ;
-       }
-} ;
-
-
-// size of this message has to be sizeof(int), which means that
-// comm_object cannot have virtual methods.
-
-class QuiescenceMessage : public comm_object {// used in quiescence module
+class Chare {
+  protected:
+    CkChareID thishandle;
   public:
-    int emptyfield ;
-} ;
-
-/******* Top level chare class at root of chare hierarchy ********/
-
-class _CK_Object {  
-public:
-       ChareIDType thishandle ;   
-
-       _CK_Object() ;
-       ~_CK_Object();
-
-        void * operator new(CMK_SIZE_T size) ;
-        void * operator new(CMK_SIZE_T size, void *buf) ;
-
-       void operator delete(void *obj) {
-               obj = obj ;     // to prevent CC from generating "obj unused"
-               ChareExit() ;
-       }
-       
-       virtual char* showHeader();
-       virtual char* showContents();
-} ;
-
-
-/* for use in the non-translator version */
-class chare_object : public _CK_Object {} ;
-
-
-class groupmember : public _CK_Object {  /* top level BOC object */
-public:
-       int thisgroup ;  /* stores BocNum */
-
-       groupmember() ;
-} ;
-
-
-class _CK_Accumulator { /* top level Accumulator object */
-
-public:
-       int _CK_MyId ;
-
-       virtual void * _CK_GetMsgPtr() = 0 ;
-
-       virtual void _CK_Combine(void *) = 0 ;
-
-       void CollectValue(int EpNum, ChareIDType cid)
-       {
-               ::CollectValue(_CK_MyId, EpNum, &cid) ; 
-               /* in node_acc.c */
-       }
-} ;
-
-class _CK_Monotonic { /* top level Monotonic object */
-
-public:
-       int _CK_MyId ;
-
-       virtual void * _CK_GetMsgPtr() = 0 ;
+    void *operator new(size_t, void *ptr) { return ptr; }
+#if CMK_DEBUG_MODE
+    Chare() { CkGetChareID(&thishandle); putObject(this); }
+    ~Chare() { removeObject(this); }
+    virtual char *showHeader(void) {
+      char *ret = (char *)malloc(strlen("Default Header")+1);
+      strcpy(ret,"Default Header");
+      return ret;
+    }
+    virtual char *showContents(void) {
+      char *ret = (char *)malloc(strlen("Default Content")+1);
+      strcpy(ret,"Default Content");
+      return ret;
+    }
+#else
+    Chare() { CkGetChareID(&thishandle); }
+#endif
+};
 
-       virtual void _CK_SysUpdate(void *) = 0 ;  /* called by system */
-} ;
+class Group : public Chare {
+  protected:
+    int thisgroup;
+  public:
+    Group() { thisgroup = CkGetGroupID(); }
+};
 
 class _CK_CID {
-  public:
-    ChareIDType _ck_cid;
+  protected:
+    CkChareID _ck_cid;
 };
 
+class _CK_GID : public _CK_CID {
+  protected:
+    int _ck_gid;
+};
 
-class _CK_GID {
+class CkQdMsg {
   public:
-    int _ck_bocid;
+    void operator delete(void* ptr) { CkFreeMsg(ptr); }
 };
 
+#include "ckstream.h"
+#include "CkFutures.decl.h"
+
 #endif
diff --git a/src/ck-core/charm-inc.h b/src/ck-core/charm-inc.h
deleted file mode 100644 (file)
index 5222d6d..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#define TBL_REPLY 1
-#define TBL_NOREPLY 2
-
-#define TBL_WAIT_AFTER_FIRST 1
-#define TBL_NEVER_WAIT 2
-#define TBL_ALWAYS_WAIT 3
-
-message {
-       int key;
-       char *data;
-} TBL_MSG;
-
-
-#define TblInsert(x1, x2, x3, x4, x5, x6) \
-               _CK_Insert(x1, -1, x2, x3, x4, x5, x6, -1)
-#define TblDelete(x1, x2, x3, x4, x5)  _CK_Delete(x1, -1, x2, x3, x4, x5)
-#define TblFind(x1, x2, x3, x4, x5) _CK_Find(x1, -1, x2, x3, x4, x5)
-
-message {
-       int msgs_processed;
-} QUIESCENCE_MSG;
index d4a7008149174c2fa9cd6ceedd2bde4104d0aa0b..dfbcf0ae5d9853a283e6c9dcf2a4a1ca48c67171 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef CHARM_H
 #define CHARM_H
 
-#include "stdio.h"
 #include "converse.h"
 
 /******************************************************************************
 #define CK_QUEUEING_BFIFO  CQS_QUEUEING_BFIFO
 #define CK_QUEUEING_BLIFO  CQS_QUEUEING_BLIFO
 
-#define CkTimer()      ((int)(CmiTimer() * 1000.0))
-#define CkWallTimer()          ((int)(CmiWallTimer() * 1000.0))
-#define CkUTimer()     ((int)(CmiWallTimer() * 1000000.0))
-#define CkHTimer()     ((int)(CmiWallTimer() / 3600.0))
+#define CkTimer        CmiTimer
+#define CkWallTimer    CmiWallTimer
 
-#define CTimer()       ((int)(CmiTimer() * 1000.0))
-#define CWallTimer()   ((int)(CmiWallTimer() * 1000.0))
-#define CUTimer()      ((int)(CmiWallTimer() * 1000000.0))
-#define CHTimer()      ((int)(CmiWallTimer() / 3600.0))
+#define CkMyPe         CmiMyPe
+#define CkMyRank       CmiMyRank
+#define CkMyNode       CmiMyNode
+#define CkNumPes       CmiNumPes
+#define CkNumNodes     CmiNumNodes
+#define CkNodeFirst    CmiNodeFirst
+#define CkNodeSize     CmiNodeSize
+#define CkNodeOf       CmiNodeOf
+#define CkRankOf       CmiRankOf
 
-/**************************************************
-  Parallel Debugger
-
-  **************************************************/            
-#if CMK_DEBUG_MODE
-//void handlerArrayRegister(int);
-#endif
-
-/******************************************************************************
- *
- * Unclassified / Miscellaneous
- *
- *****************************************************************************/
-
-#ifdef DEBUG
-#define TRACE(p) p
-#else
-#define TRACE(p)
-#endif
-
-#define CHARRED(x) ((char *) (x))
-
-#ifndef CINTBITS
-#define CINTBITS (sizeof(int)*8)
-#endif
+#define CkPrintf                CmiPrintf
+#define CkScanf                 CmiScanf
+#define CkError                        CmiError
 
 /******************************************************************************
  *
  *
  *****************************************************************************/
 
-#define NO_PACK                0
-#define UNPACKED       1
-#define PACKED         2
-
-#define CHARE          53
-#define BOC            35
-
-#define CHARM          0
-#define CHARMPLUSPLUS  1
-
-#define ACCUMULATOR    0
-#define MONOTONIC      1
-#define TABLE          2
-
-#define NULL_VID        NULL
-#define NULL_PE         CK_PE_ANY
-#define NULL_PACK_ID    0  
-
-#define CK_PE_SPECIAL(x) ((x)>=0xFFF0)
-#define CK_PE_ALL        (0xFFF0)
-#define CK_PE_ALL_BUT_ME (0xFFF1)
-#define CK_PE_ANY        (0xFFF2)
-#define CK_PE_INVALID    (0xFFF3)
-
-#define QDBocNum         1  /* Quiescecence Detection */
-#define WOVBocNum        2  /* write once variables   */
-#define TblBocNum        3  /* dynamic table boc      */
-#define DynamicBocNum    4  /* to manage dynamic boc  */
-#define StatisticBocNum  5  /* to manage statistics   */
-#define NumSysBoc        6  /* a sentinel for this list */
-
-#define MaxBocs                100
-#define PSEUDO_Max     20
-
-#define MainInitEp            0
-#define NumHostSysEps         0
-#define NumNodeSysEps         0
-
-#define CHAREKIND_CHARE    0   /* Plain old chare */
-#define CHAREKIND_BOCNODE  1   /* BOC node */
-#define CHAREKIND_UVID     2   /* Unfilled-VID */
-#define CHAREKIND_FVID     3   /* Filled-VID */
-
-#define _CK_VARSIZE_UNIT 8
-
-/******************************************************************************
- *
- * Unclassified / Miscellaneous
- *
- *****************************************************************************/
-
-typedef int            PeNumType;
-typedef int            EntryPointType;
-typedef int            EntryNumType;
-typedef int            ChareNumType;
-typedef int            ChareNameType;
-typedef int            MsgTypes;
-typedef int            MsgCategories;
-typedef int            START_LOOP;
-typedef void           FUNC();
-typedef int            (*FUNCTION_PTR)();
-typedef int            FunctionRefType;
-typedef int            WriteOnceID;    
-
-/******************************************************************************
- *
- * Message Categories and Types
- *
- *****************************************************************************/
-
-#define        IMMEDIATEcat    0
-#define USERcat        1
-
-/* USERcat */
-#define NewChareMsg            0
-#define NewChareNoBalanceMsg    1
-#define ForChareMsg            2
-#define BocInitMsg             3
-#define BocMsg                 4
-#define TerminateToZero        5   /* never used??? */
-#define TerminateSys           6   /* never used??? */
-#define InitCountMsg           7
-#define ReadVarMsg             8
-#define ReadMsgMsg             9
-#define BroadcastBocMsg        10
-#define DynamicBocInitMsg      11
-
-/* IMMEDIATEcat */
-#define LdbMsg                 12  /* never used??? */
-#define VidSendOverMsg          13
-#define QdBocMsg               14
-#define QdBroadcastBocMsg      15
-#define ImmBocMsg               16
-#define ImmBroadcastBocMsg      17
-#define InitBarrierPhase1       18
-#define InitBarrierPhase2       19
+#define CK_PE_ALL        CLD_BROADCAST_ALL
+#define CK_PE_ALL_BUT_ME CLD_BROADCAST
+#define CK_PE_ANY        CLD_ANYWHERE
 
 /******************************************************************************
  *
@@ -162,694 +49,107 @@ typedef int              WriteOnceID;
  *
  *****************************************************************************/
 
-typedef struct chare_id_type  {
-  unsigned short        onPE;
-  unsigned short        magic;
-  struct chare_block   *chareBlockPtr;
-} ChareIDType;
-
-typedef struct chare_block { 
-  char charekind;                   /* CHAREKIND: CHARE BOCNODE UVID FVID */
-  ChareIDType selfID;               /* My chare ID. */
-  union {
-    ChareNumType boc_num;         /* if a BOC node */
-    ChareIDType  realID;          /* if a Filled-VID */
-    struct fifo_queue *vid_queue; /* if an Unfilled-VID */
-  } x;
-  void *chareptr ;                /* Pointer to the data area of the chare */
-  double data[1];                   /* Pad it to 8 bytes */
-} CHARE_BLOCK ;  
-
-typedef struct ep_struct {
-  char *name;
-  FUNCTION_PTR function;
-  int language;
-  int messageindex;
-  int chareindex;
-  int chare_or_boc;
-  int threaded;
-} EP_STRUCT;
-
-typedef struct msg_struct {
-  int size;
-  FUNCTION_PTR packfn;
-  FUNCTION_PTR unpackfn;
-  FUNCTION_PTR alloc;
-  FUNCTION_PTR coerce;
-} MSG_STRUCT;
-
-typedef struct mono_struct {
-  FUNCTION_PTR updatefn;
-} MONO_STRUCT;
-
-typedef struct acc_struct {
-  FUNCTION_PTR addfn;
-  FUNCTION_PTR combinefn;
-} ACC_STRUCT;
 typedef struct {
-  int id;
-  int Penum;
-  char *dataptr;
-  int AlreadyDone;
-  struct chare_id_type CID;
-  int NumChildren;
-  EntryPointType EP;
-} ACC_DATA;
+  int argc;
+  char **argv;
+} CkArgMsg;
 
 typedef struct {
-  int id;
-  int time;
-  char *dataptr;
-  int ismodified;
-} MONO_DATA;
-
-typedef struct table_struct {
-  FUNCTION_PTR hashfn;
-} TABLE_STRUCT;
-typedef struct pseudo_struct {
-  int type;
-  int language ;
-  char *name;
-  FUNCTION_PTR initfn;
-  union {
-    MONO_STRUCT mono;
-    ACC_STRUCT acc;
-    TABLE_STRUCT tbl;
-  } pseudo_type;
-} PSEUDO_STRUCT;
-
-typedef struct bocinit_queue {
-  void **block;
-  short block_len;
-  short first;
-  short length;
-} BOCINIT_QUEUE;
-
-typedef struct DUMMY_MSG {
-  int x;
-} DUMMY_MSG;
+  int   onPE;
+  int   magic;
+  void* objPtr;
+} CkChareID;
 
 /******************************************************************************
  *
- * The Charm Envelope
- *
- * Current envelope size: 256 bits = 32 bytes = 4 doubles.
- *
- * Note: the user-data area is aligned to a 64-bit boundary.  Therefore,
- * there is no point to trimming the envelope unless you can save 64 bits.
- *
- * save 32 bits: remove 'event'.  Easy with ifdefs, doubles SUPER_INSTALL time.
- * save 16 bits: remove 'pe'.     Easy with ifdefs, doubles SUPER_INSTALL time.
- * save 16 bits: change TotalSize to a magnitude.  Inefficient.
- * save 16 bits: could eliminate priosize, by moving it into priority. Clumsy.
- * save  8 bits: remove msgType by replacing HANDLE_X_MSG.  Hard.
- * save 14 bits: turn isPACKED, msgType, queueing into bitfields.  Inefficient.
- * save  2 bits: coalesce isPACKED with packid. Hard.
+ * Function Pointer Types
  *
  *****************************************************************************/
 
-typedef struct envelope {
-  char     core[CmiExtHeaderSizeBytes];
-  
-  unsigned int   event;   /* unknown meaning. Used only for logging.*/
-
-  void *     i_tag2;  /* Count OR vidBlockPtr OR chareBlockPtr OR boc_num*/
-
-  unsigned int   TotalSize; /* total size of message, in bytes */
-
-  unsigned short s_tag1;  /* vidPE OR ref OR other_id */
-  unsigned short s_tag2;  /* chare_magic_number */
-
-  unsigned short EP;      /* entry point to call */
-  unsigned short priosize;/* priority length, measured in bits */
-
-  unsigned short pe;      /* unknown meaning. used only for logging. */
-  unsigned char  msgType;
-  unsigned char  isPACKED;
-
-  unsigned char  queueing;
-  unsigned char  packid;
-  char padding[6];
-
-
-} ENVELOPE;
-
+typedef void* (*CkPackFnPtr)(void *msg);
+typedef void* (*CkUnpackFnPtr)(void *buf);
+typedef void* (*CkCoerceFnPtr)(void *buf);
+typedef void  (*CkCallFnPtr) (void *msg, void *obj);
+typedef void  (*CkCopyFromFnPtr) (void *buf);
+typedef void  (*CkCopyToFnPtr) (void *buf);
 
 /******************************************************************************
  *
- * ChareID Accessors
+ * Registration Calls
  *
  *****************************************************************************/
 
-#define GetID_onPE(id)                         ((id).onPE)
-#define SetID_onPE(id,x)               ((id).onPE=(x))
-
-#define GetID_chare_magic_number(id)   ((id).magic)
-#define SetID_chare_magic_number(id,x) ((id).magic=(x))
-
-#define GetID_chareBlockPtr(id)                ((id).chareBlockPtr)
-#define SetID_chareBlockPtr(id,x)       ((id).chareBlockPtr=(x))
+extern int CkRegisterMsg(char *name, CkPackFnPtr pack, CkUnpackFnPtr unpack, 
+                         CkCoerceFnPtr coerce, int size);
+extern int CkRegisterEp(char *name, CkCallFnPtr call, int msgIdx, int chareIdx);
+extern int CkRegisterChare(char *name, int dataSz);
+extern int CkRegisterMainChare(int chareIndex, int epIndex);
+extern void CkRegisterReadonly(int size, void *ptr);
+extern void CkRegisterReadonlyMsg(void** pMsg);
 
 /******************************************************************************
  *
- * Charm Envelope Accessors
- *
- * About s_tag1:
- *
- *    other_id is used only for acc, mono, init, tbl msgs 
- *    vidPE is used only if msgType==VidSendOverMsg       
- *    ref is for user messages only.                      
+ * Object Creation Calls
  *
  *****************************************************************************/
 
-#define GetEnv_count(e)                   ((CMK_SIZE_T)(((ENVELOPE *)(e))->i_tag2))
-#define SetEnv_count(e,x)         (((ENVELOPE *)(e))->i_tag2=((void *)(x)))
-
-#define GetEnv_chareBlockPtr(e)           ((CHARE_BLOCK *)(((ENVELOPE *)(e))->i_tag2))
-#define SetEnv_chareBlockPtr(e,x)  (((ENVELOPE *)(e))->i_tag2=((void *)(x)))
-
-#define SetEnv_vidBlockPtr(e,x)           (((ENVELOPE *)(e))->i_tag2=(x))
-#define GetEnv_vidBlockPtr(e)     ((CHARE_BLOCK *)(((ENVELOPE *)(e))->i_tag2))
-
-#define GetEnv_boc_num(e)         ((CMK_SIZE_T)(((ENVELOPE *)(e))->i_tag2))
-#define SetEnv_boc_num(e,x)       (((ENVELOPE *)(e))->i_tag2=((void *)(x)))
-
-#define GetEnv_other_id(e)   (((ENVELOPE *)(e))->s_tag1)
-#define SetEnv_other_id(e,x) (((ENVELOPE *)(e))->s_tag1=(x))
-
-#define GetEnv_vidPE(e)      (((ENVELOPE *)(e))->s_tag1)
-#define SetEnv_vidPE(e,x)    (((ENVELOPE *)(e))->s_tag1=(x))
-
-#define GetEnv_ref(e)        (((ENVELOPE *)(e))->s_tag1)
-#define SetEnv_ref(e,x)      (((ENVELOPE *)(e))->s_tag1=(x))
-
-#define GetEnv_chare_magic_number(e)   (((ENVELOPE *)(e))->s_tag2)
-#define SetEnv_chare_magic_number(e,x)  (((ENVELOPE *)(e))->s_tag2=(x))
-
-#define GetEnv_isPACKED(e)      (((ENVELOPE *)(e))->isPACKED)
-#define SetEnv_isPACKED(e,x)    (((ENVELOPE *)(e))->isPACKED=(x))
-
-#define GetEnv_pe(e)           (((ENVELOPE *)(e))->pe)
-#define SetEnv_pe(e,x)          (((ENVELOPE *)(e))->pe=(x))
-
-#define GetEnv_event(e)                (((ENVELOPE *)(e))->event)
-#define SetEnv_event(e,x)      (((ENVELOPE *)(e))->event=(x))
-
-#define GetEnv_EP(e)           (((ENVELOPE *)(e))->EP)
-#define SetEnv_EP(e,x)                 (((ENVELOPE *)(e))->EP=(x))
-
-#define GetEnv_queueing(e)      (((ENVELOPE *)(e))->queueing)
-#define SetEnv_queueing(e,x)    (((ENVELOPE *)(e))->queueing=(x))
-
-#define GetEnv_priosize(e)      (((ENVELOPE *)(e))->priosize)
-#define SetEnv_priosize(e,x)    (((ENVELOPE *)(e))->priosize=(x))
-
-#define GetEnv_TotalSize(e)     (((ENVELOPE *)(e))->TotalSize)
-#define SetEnv_TotalSize(e,x)   (((ENVELOPE *)(e))->TotalSize=(x))
-
-#define GetEnv_packid(e)        (((ENVELOPE *)(e))->packid)
-#define SetEnv_packid(e,x)      (((ENVELOPE *)(e))->packid=(x))
-
-#define GetEnv_msgType(e)       (((ENVELOPE *)(e))->msgType)
-#define SetEnv_msgType(e,x)     (((ENVELOPE *)(e))->msgType=(x))
+extern void CkCreateChare(int chareIdx, int constructorIdx, void *msg,
+                          CkChareID *vid, int destPE);
+extern int CkCreateGroup(int chareIdx, int constructorIdx, void *msg,
+                         int returnEpIdx, CkChareID *returnChare);
 
 /******************************************************************************
  *
- * Priority Accessors
+ * Asynchronous Remote Method Invocation Calls
  *
  *****************************************************************************/
 
-typedef unsigned int PVECTOR;
-
-#define GetEnv_priowords(e) ((GetEnv_priosize(e)+CINTBITS-1)/CINTBITS)
-#define GetEnv_priobytes(e) (GetEnv_priowords(e)*sizeof(int))
-#define GetEnv_prioend(e) ((unsigned int *)(((char *)(e))+GetEnv_TotalSize(e)))
-#define GetEnv_priobgn(e) ((unsigned int *)(((char *)(e))+GetEnv_TotalSize(e)-GetEnv_priobytes(e)))
-
-extern unsigned int *CkPrioPtrFn(void *);
-extern int           CkPrioSizeBitsFn(void *);
-extern int           CkPrioSizeBytesFn(void *);
-extern int           CkPrioSizeWordsFn(void *);
-extern void          CkPrioConcatFn(void *,void *,unsigned int);
-
-#define CkPrioPtr(msg)       (CkPrioPtrFn((void *)(msg)))
-#define CkPrioSizeBits(msg)  (CkPrioSizeBitsFn((void *)(msg)))
-#define CkPrioSizeBytes(msg) (CkPrioSizeBytesFn((void *)(msg)))
-#define CkPrioSizeWords(msg) (CkPrioSizeWordsFn((void *)(msg)))
-#define CkPrioConcat(s,d,x)  (CkPrioConcatFn((void *)(s),(void *)(d),x))
-
+extern void CkSendMsg(int entryIndex, void *msg, CkChareID *chare);
+extern void CkSendMsgBranch(int entryIdx, void *msg, int destPE, int groupID);
+extern void CkBroadcastMsgBranch(int entryIdx, void *msg, int groupID);
 
 /******************************************************************************
  *
- * Unclassified / Miscellaneous
+ * Blocking Method Invocation Calls
  *
  *****************************************************************************/
 
-#define CkTraceOn() CpvAccess(traceOn)=1
-#define CkTraceOff() CpvAccess(traceOn)=0
-
-#define PACK(x)    CkPack(&x)
-#define UNPACK(x)  if (GetEnv_isPACKED((x)) == PACKED) {\
-                    CkUnpack(&x);\
-                   }
+extern void* CkRemoteCall(int entryIdx, void *msg, CkChareID *chare);
+extern void* CkRemoteBranchCall(int entryIdx, void *msg, int groupID, int pe);
+extern void  CkSendToFuture(int futNum, void *msg, int pe);
 
 /******************************************************************************
  *
- * THIS SECTION CONSTITUTES THE NEW FORMAT OF A Charm MESSAGE 
- * This file provides access macros for extracting the different
- * sections of a message. The organisation of a message is as follows 
- *
- *           -------------------------------
- *           | env + ldb | user | priority |
- *           -------------------------------
- * 
- *   The sizes of the fields are as follows:
- * 
- *       envelope      : sizeof(ENVELOPE)
- *                        (ENVELOPE is defined in env_macros.h)
- *                     First word in ENVELOPE is the core language field.
- * 
- *       ldb           : LDB_ELEM_SIZE is a global variable defined by the
- *                        load balancing module
- * 
- *       user          : the user message data.
- * 
- *       priority      : bit-vector (variable size)
- *
- *   all fields are padded to 8-byte boundaries except the priority,
- *   which is padded to an int-sized boundary.
+ * Quiescence Calls
  *
- * The following variables reflect the message format above. If any
- * change is made to the format, the initialization of the variables must
- * be altered. The variables are initialized in InitializeMessageMacros()
- * in main/common.c. Compile time constants are #defines. 
- * All variables reflect sizes in BYTES.                       
- *
- *************************************************************************/
-
-
-#define ENVELOPE_SIZE sizeof(ENVELOPE)
-
-#define TOTAL_MSG_SIZE(usrsize, priowords)\
-    (ENVELOPE_SIZE+((priowords)*sizeof(int))+(usrsize))
-
-#define USER_MSG_PTR(env)\
-    (CHARRED(env) + ENVELOPE_SIZE)
+ *****************************************************************************/
 
-#define ENVELOPE_UPTR(usrptr)\
-       (ENVELOPE *) (CHARRED(usrptr) - ENVELOPE_SIZE)
+extern void CkStartQD(int entryIdx, CkChareID *chare);
 
 /******************************************************************************
  *
- * BOC Creation Messages and Structures
+ * Message Allocation Calls
  *
  *****************************************************************************/
 
-typedef struct {
-        int ref;
-        int source;
-        ChareNumType ep;
-        ChareIDType id;
-} DYNAMIC_BOC_REQUEST_MSG;
-
-typedef struct {
-       ChareNumType boc;
-       int ref;
-} DYNAMIC_BOC_NUM_MSG;
+extern void* CkAllocSysMsg(void);
+extern void  CkFreeSysMsg(void *msg);
+extern void* CkAllocMsg(int msgIdx, int msgBytes, int prioBits);
+extern void* CkAllocBuffer(void *msg, int bufsize);
+extern void  CkFreeMsg(void *msg);
+extern void* CkCopyMsg(void **pMsg);
+extern void  CkSetQueueing(void *msg, int strategy);
+extern void* CkPriorityPtr(void *msg);
 
 /******************************************************************************
  *
- * Unclassified / Miscellaneous
+ * Miscellaneous Calls
  *
  *****************************************************************************/
 
-#define IsCharmPlus(Entry)\
-    (CsvAccess(EpInfoTable)[Entry].language==CHARMPLUSPLUS)
-
-#define IsCharmPlusPseudo(id) (CsvAccess(PseudoTable)[id].language==CHARMPLUSPLUS)
-
-
-#define CkMemError(ptr) if (ptr == NULL) \
-                CmiPrintf("*** ERROR *** Memory Allocation Failed --- consider +m command-line option.\n");
-
-#define QDCountThisProcessing() CpvAccess(msgs_processed)++
-
-#define QDCountThisCreation(x) CpvAccess(msgs_created) += (x)
-
-
-#define ReadValue(v)                   (v)
-#define ReadInit(v) 
-
-void *GetBocDataPtr(ChareNumType bocNum);
-
-#define new_packbuffer                 CkAllocPackBuffer
+extern void *CkLocalBranch(int groupID);
+extern void  CkGetChareID(CkChareID *pcid);
+extern int   CkGetGroupID(void);
+extern void  CkExit(void);
 
-#define _CK_4MonoDataAreaType          MONO_DATA 
-#define _CK_9LockMonoDataArea(x)
-#define _CK_9GetMonoDataArea           GetBocDataPtr
-#define _CK_9UnlockMonoDataArea(x)
-
-#define _CK_4AccDataAreaType           ACC_DATA
-#define _CK_9LockAccDataArea(x)
-#define _CK_9GetAccDataArea            GetBocDataPtr
-#define _CK_9UnlockAccDataArea(x)
-
-#ifdef STRIP
-#define _CK_BroadcastMsgBranch(ep,msg,boc)  GeneralBroadcastMsgBranch(ep,msg,\
-                                       ImmBroadcastBocMsg,boc)
-#define _CK_SendMsgBranch(ep,msg,boc,pe)       GeneralSendMsgBranch(ep,msg,pe,\
-                                       ImmBocMsg,boc)
-#else
-#define _CK_BroadcastMsgBranch(ep,msg,boc)  GeneralBroadcastMsgBranch(ep,msg,\
-                                       BroadcastBocMsg,boc)
-#define _CK_SendMsgBranch(ep,msg,boc,pe)       GeneralSendMsgBranch(ep,msg,pe,\
-                                       BocMsg,boc)
-#endif
-#define _CK_ImmSendMsgBranch(ep,msg,boc,pe)    GeneralSendMsgBranch(ep,msg,pe,\
-                                       ImmBocMsg,boc)
-
-extern void *GenericCkAlloc(int, unsigned int, unsigned int);
-
-CpvExtern(int, _CK_13PackOffset);
-CpvExtern(int, _CK_13PackMsgCount);
-CpvExtern(int, _CK_13ChareEPCount);
-CpvExtern(int, _CK_13TotalMsgCount);
-CsvExtern(FUNCTION_PTR*, _CK_9_GlobalFunctionTable);
-CsvExtern(MSG_STRUCT*, MsgToStructTable);
-
-typedef int AccIDType;
-
-typedef struct {
-  ChareIDType cid;
-  EntryPointType EP;   
-} ACC_COLLECT_MSG;
-
-FUNCTION_PTR _CK_9GetAccumulateFn();
-void * _CK_9_GetAccDataPtr();
-
-typedef int MonoIDType;
-
-#define UP_WAIT_TIME 200
-#define MAX_UP_WAIT_TIME 5*200
-
-FUNCTION_PTR _CK_9GetMonoCompareFn();
-
-
-#define BranchCall(x)          x
-#define PrivateCall(x)         x
-
-#if CMK_STATIC_PROTO_WORKS
-#define PROTO_PUB_PRIV static
-#endif
-
-#if CMK_STATIC_PROTO_FAILS
-#define PROTO_PUB_PRIV extern
 #endif
-
-#define _CK_Find               TblFind
-#define _CK_Delete             TblDelete
-#define _CK_Insert             TblInsert
-#define _CK_MyBocNum           MyBocNum
-#define _CK_CreateBoc          CreateBoc
-#define _CK_CreateAcc          CreateAcc
-#define _CK_CreateMono         CreateMono
-#define _CK_CPlus_CreateAcc    CPlus_CreateAcc
-#define _CK_CPlus_CreateMono   CPlus_CreateMono
-#define _CK_CreateChare                CreateChare
-#define _CK_MyBranchID         MyBranchID
-#define _CK_MonoValue          MonoValue
-
-/* charm and charm++ names for converse functions */
-
-#define CK_INT_BITS             (sizeof(int)*8)
-#define  C_INT_BITS             (sizeof(int)*8)
-
-#define CkMyPe                  CmiMyPe
-#define  CMyPe                  CmiMyPe
-
-#define CkNumPes                 CmiNumPes
-#define  CNumPes                 CmiNumPes
-
-#define CkPrintf                CmiPrintf
-#define  CPrintf                CmiPrintf
-
-#define CkScanf                 CmiScanf
-#define  CScanf                 CmiScanf
-
-#define CkAlloc                 CmiAlloc
-#define  CAlloc                 CmiAlloc
-
-#define CkFree                  CmiFree
-#define  CFree                  CmiFree
-
-#define CkSpanTreeParent        CmiSpanTreeParent
-#define  CSpanTreeParent        CmiSpanTreeParent
-
-#define CkSpanTreeRoot          0
-#define  CSpanTreeRoot          0
-
-#define CkSpanTreeChildren      CmiSpanTreeChildren
-#define  CSpanTreeChildren      CmiSpanTreeChildren
-
-#define CkSendToSpanTreeLeaves  CmiSendToSpanTreeLeaves
-#define  CSendToSpanTreeLeaves  CmiSendToSpanTreeLeaves
-
-#define CkNumSpanTreeChildren   CmiNumSpanTreeChildren
-#define  CNumSpanTreeChildren   CmiNumSpanTreeChildren
-
-#define CK_QUEUEING_FIFO  CQS_QUEUEING_FIFO
-#define  C_QUEUEING_FIFO  CQS_QUEUEING_FIFO
-
-#define CK_QUEUEING_LIFO  CQS_QUEUEING_LIFO
-#define  C_QUEUEING_LIFO  CQS_QUEUEING_LIFO
-
-#define CK_QUEUEING_IFIFO CQS_QUEUEING_IFIFO
-#define  C_QUEUEING_IFIFO CQS_QUEUEING_IFIFO
-
-#define CK_QUEUEING_ILIFO CQS_QUEUEING_ILIFO
-#define  C_QUEUEING_ILIFO CQS_QUEUEING_ILIFO
-
-#define CK_QUEUEING_BFIFO CQS_QUEUEING_BFIFO
-#define  C_QUEUEING_BFIFO CQS_QUEUEING_BFIFO
-
-#define CK_QUEUEING_BLIFO CQS_QUEUEING_BLIFO
-#define  C_QUEUEING_BLIFO CQS_QUEUEING_BLIFO
-
-/* Charm++ names for charm functions */
-
-#define CPriorityPtr                CkPrioPtr
-#define CPrioritySizeBits           CkPrioSizeBits
-#define CPrioritySizeBytes          CkPrioSizeBytes
-#define CPrioritySizeWords          CkPrioSizeWords
-#define CPriorityConcat             CkPrioConcat
-
-#define CStartQuiescence       CPlus_StartQuiescence
-#define CharmExit               CkExit
-#define CSetQueueing            CkSetQueueing
-
-/* obsolete names */
-
-#define CMyPeNum                CmiMyPe
-#define CMaxPeNum               CmiNumPes
-
-#define McMyPeNum() CmiMyPe()
-#define McMaxPeNum() CmiNumPes()
-#define McTotalNumPe() CmiNumPes()   
-#define McSpanTreeInit() CmiSpanTreeInit()
-#define McSpanTreeParent(node) CmiSpanTreeParent(node)
-#define McSpanTreeRoot() 0
-#define McSpanTreeChild(node, children) CmiSpanTreeChildren(node, children)
-#define McNumSpanTreeChildren(node) CmiNumSpanTreeChildren(node)
-#define McSendToSpanTreeLeaves(size, msg) CmiSendToSpanTreeLeaves(size, msg)
-
-
-
-
-/* These are macros for the non-translator version of Charm++.
-   They work only for preprocessors with ANSI concatenation, e.g. g++
-   So they wont work with cpp. */
-
-#define __ChareNum(ChareType) _CK_chare_##ChareType##::_CK_charenum_##ChareType
-
-#define GetEntryPtr(ChareType,EP, MsgType)     _CK_chare_##ChareType##::##EP##_##MsgType
-
-#define CkEstablishGroup(npes, pes)     CmiEstablishGroup(npes, pes)
-#define CMulticastMsgBranch(ChareType,EP,MsgType,msg,ChareId,grp) GeneralMulticastMsgBranch(GetEntryPtr(ChareType,EP,MsgType), msg, -1, ChareId, grp)
-
-#define CSendMsg(ChareType,EP,MsgType,msg,ChareId)     SendMsg(GetEntryPtr(ChareType,EP,MsgType), msg, ChareId)
-
-#define CSendMsgBranch(ChareType,EP,MsgType,msg,ChareId,Pe)    GeneralSendMsgBranch(GetEntryPtr(ChareType,EP,MsgType), msg, Pe, -1, ChareId)
-
-#define CBroadcastMsgBranch(ChareType,EP,MsgType,msg,ChareId)  GeneralBroadcastMsgBranch(GetEntryPtr(ChareType,EP,MsgType), msg, -1, ChareId)
-
-#define CLocalBranch(BocType, BocId)   ((BocType *)GetBocDataPtr(BocId))
-
-#define CRemoteCallBranch(BOC1, ep1 , mtype, m, g, p) CRemoteCallBranchFn(GetEntryPtr(BOC1,ep1,mtype), m, g, p)
-
-#define CRemoteCall(CH, ep, mtype, m, cid) CRemoteCallFn(GetEntryPtr(CH,ep,mtype),m,cid)
-
-#define MsgIndex(MessageType)  _CK_msg_##MessageType
-
-#define new_chare(ChareType, msgtype, msg)     CreateChare(__ChareNum(ChareType), GetEntryPtr(ChareType,ChareType,msgtype), msg, 0, (0xFFF2))
-
-#define new_chare2(ChareType, msgtype, msg, vid, pe)   CreateChare(__ChareNum(ChareType), GetEntryPtr(ChareType,ChareType,msgtype), msg, vid, pe)
-
-
-#define new_group(ChareType, msgtype, msg)     CreateBoc(__ChareNum(ChareType), GetEntryPtr(ChareType,ChareType,msgtype), msg, -1, 0)
-
-
-#define new_group2(ChareType, msgtype, msg, returnEP, returnID)        CreateBoc(__ChareNum(ChareType), GetEntryPtr(ChareType,ChareType,msgtype), msg, returnEP, returnID)
-
-#define newMessage(msgtype)  new (MsgIndex(msgtype)) msgtype
-
-CsvExtern(int, TotalEps);
-CpvExtern(int, TotalMsgs);
-CpvExtern(int, TotalPseudos);
-CpvExtern(int, NumReadMsg);
-CpvExtern(int, MsgCount);              
-
-CpvExtern(int, MainDataSize);          /* size of dataarea for main chare      */
-CpvExtern(int, currentBocNum);
-CpvExtern(int, InsideDataInit);
-CpvExtern(int, mainChare_magic_number);
-typedef struct chare_block *CHARE_BLOCK_;
-CpvExtern(CHARE_BLOCK_, mainChareBlock);
-CpvExtern(CHARE_BLOCK_, currentChareBlock);
-
-CsvExtern(FUNCTION_PTR*, ROCopyFromBufferTable);
-CsvExtern(FUNCTION_PTR*, ROCopyToBufferTable);
-CsvExtern(EP_STRUCT*, EpInfoTable);
-CsvExtern(MSG_STRUCT*, MsgToStructTable); 
-CsvExtern(int*,  ChareSizesTable);
-CsvExtern(PSEUDO_STRUCT*, PseudoTable);
-CsvExtern(char**, EventTable);
-
-CsvExtern(char**, ChareNamesTable);
-
-CpvExtern(int, msgs_processed);
-CpvExtern(int, msgs_created);
-
-CpvExtern(int, disable_sys_msgs);
-CpvExtern(int, nodecharesProcessed);
-CpvExtern(int, nodebocInitProcessed);
-CpvExtern(int, nodebocMsgsProcessed);
-CpvExtern(int, nodeforCharesProcessed);
-CpvExtern(int, nodecharesCreated);
-CpvExtern(int, nodeforCharesCreated);
-CpvExtern(int, nodebocMsgsCreated);
-
-
-CpvExtern(int, PrintQueStat); 
-CpvExtern(int, PrintMemStat); 
-CpvExtern(int, PrintChareStat);
-CpvExtern(int, PrintSummaryStat);
-CpvExtern(int, QueueingDefault);
-CpvExtern(int, CtrLogBufSize);
-
-CpvExtern(int, RecdStatMsg);
-CpvExtern(int, CtrRecdTraceMsg);
-
-CpvExtern(int, numHeapEntries);
-CpvExtern(int, numCondChkArryElts);
-
-CsvExtern(int, MainChareLanguage);
-
-CpvExtern(int, LDB_ELEM_SIZE);
-
-/* Handlers for various message-types */
-CpvExtern(int, HANDLE_INCOMING_MSG_Index);
-CsvExtern(int, BUFFER_INCOMING_MSG_Index);
-CsvExtern(int, MAIN_HANDLE_INCOMING_MSG_Index);
-CsvExtern(int, HANDLE_INIT_MSG_Index);
-CpvExtern(int, CkPack_Index);
-CpvExtern(int, CkInfo_Index);
-
-/* System-defined chare numbers */
-CsvExtern(int, CkChare_ACC);
-CsvExtern(int, CkChare_MONO);
-
-/* Entry points for Quiescence detection BOC   */
-CsvExtern(int, CkEp_QD_Init);
-CsvExtern(int, CkEp_QD_InsertQuiescenceList);
-CsvExtern(int, CkEp_QD_PhaseIBroadcast);
-CsvExtern(int, CkEp_QD_PhaseIMsg);
-CsvExtern(int, CkEp_QD_PhaseIIBroadcast);
-CsvExtern(int, CkEp_QD_PhaseIIMsg);
-
-/* Entry points for Write Once Variables       */
-CsvExtern(int, CkEp_WOV_AddWOV);
-CsvExtern(int, CkEp_WOV_RcvAck);
-CsvExtern(int, CkEp_WOV_HostAddWOV);
-CsvExtern(int, CkEp_WOV_HostRcvAck);
-
-
-/* Entry points for dynamic tables BOC         */
-CsvExtern(int, CkEp_Tbl_Unpack);
-
-/* Entry points for accumulator BOC            */
-CsvExtern(int, CkEp_ACC_CollectFromNode);
-CsvExtern(int, CkEp_ACC_LeafNodeCollect);
-CsvExtern(int, CkEp_ACC_InteriorNodeCollect);
-CsvExtern(int, CkEp_ACC_BranchInit);
-
-/* Entry points for monotonic BOC              */
-CsvExtern(int, CkEp_MONO_BranchInit);
-CsvExtern(int, CkEp_MONO_BranchUpdate);
-CsvExtern(int, CkEp_MONO_ChildrenUpdate);
-
-/* These are the entry points necessary for the dynamic BOC creation. */
-CsvExtern(int, CkEp_DBOC_RegisterDynamicBocInitMsg);
-CsvExtern(int, CkEp_DBOC_OtherCreateBoc);
-CsvExtern(int, CkEp_DBOC_InitiateDynamicBocBroadcast);
-
-/* These are the entry points for the statistics BOC */
-CsvExtern(int, CkEp_Stat_CollectNodes);
-CsvExtern(int, CkEp_Stat_Data);
-CsvExtern(int, CkEp_Stat_TraceCollectNodes);
-CsvExtern(int, CkEp_Stat_BroadcastExitMessage);
-CsvExtern(int, CkEp_Stat_ExitMessage);
-
-/* Entry points for LoadBalancing BOC          */
-CsvExtern(int, CkEp_Ldb_NbrStatus);
-CsvExtern(int, NumSysBocEps);
-
-/* Initialization phase count variables for synchronization */
-CpvExtern(int,CkInitCount);
-CpvExtern(int,CkCountArrived);
-
-
-/* Buffer for the non-init messages received during the initialization phase */
-CpvExtern(void*, CkBuffQueue);
-
-/* Initialization phase flag : 1 if in the initialization phase */
-CpvExtern(int, CkInitPhase);
-
-#define MAXMEMSTAT 10 
-
-CpvExtern(int, CstatsMaxChareQueueLength);
-CpvExtern(int, CstatsMaxForChareQueueLength);
-CpvExtern(int, CstatsMaxFixedChareQueueLength);
-
-typedef struct message3 {
-    int srcPE;
-    int chareQueueLength;
-    int forChareQueueLength;
-    int fixedChareQueueLength;
-    int charesCreated;
-    int charesProcessed;
-    int forCharesCreated;
-    int forCharesProcessed;
-    int bocMsgsCreated;
-    int bocMsgsProcessed;
-    int nodeMemStat[MAXMEMSTAT];
-} STAT_MSG;
-
-typedef FUNCTION_PTR   *FNPTRTYPE;
-
-#endif
-
-
-
-
diff --git a/src/ck-core/ck.C b/src/ck-core/ck.C
new file mode 100644 (file)
index 0000000..121d6bb
--- /dev/null
@@ -0,0 +1,361 @@
+#include "ck.h"
+
+extern "C"
+void CkGetChareID(CkChareID *pCid) {
+  pCid->onPE = CkMyPe();
+  pCid->objPtr = CpvAccess(_currentChare);
+}
+
+extern "C"
+int CkGetGroupID(void) {
+  return CpvAccess(_currentGroup);
+}
+
+static inline void *_allocNewChare(envelope *env)
+{
+  return malloc(_chareTable[_entryTable[env->getEpIdx()]->chareIdx]->size);
+}
+static void _processNewChareMsg(envelope *env)
+{
+  register void *obj = _allocNewChare(env);
+  register void *msg = EnvToUsr(env);
+  CpvAccess(_currentChare) = obj;
+  _entryTable[env->getEpIdx()]->call(msg, obj);
+}
+
+static void _processNewVChareMsg(envelope *env)
+{
+  register void *obj = _allocNewChare(env);
+  register CkChareID *pCid = (CkChareID *) 
+      _allocMsg(FillVidMsg, sizeof(CkChareID));
+  pCid->onPE = CkMyPe();
+  pCid->objPtr = obj;
+  register envelope *ret = UsrToEnv(pCid);
+  ret->setVidPtr(env->getVidPtr());
+  register int srcPe = env->getSrcPe();
+  ret->setSrcPe(CkMyPe());
+  CmiSetHandler(ret, _charmHandlerIdx);
+  CmiSyncSendAndFree(srcPe, ret->getTotalsize(), ret);
+  CpvAccess(_qd)->create();
+  CpvAccess(_currentChare) = obj;
+  register void *msg = EnvToUsr(env);
+  _entryTable[env->getEpIdx()]->call(msg, obj);
+}
+
+static inline void _processForChareMsg(envelope *env)
+{
+  register void *msg = EnvToUsr(env);
+  register int epIdx = env->getEpIdx();
+  register void *obj = env->getObjPtr();
+  CpvAccess(_currentChare) = obj;
+  _entryTable[epIdx]->call(msg, obj);
+}
+
+static inline void _processForBocMsg(envelope *env)
+{
+  register int groupID = env->getGroupNum();
+  register void *obj = CpvAccess(_groupTable)->find(groupID);
+  env->setMsgtype(ForChareMsg);
+  env->setObjPtr(obj);
+  CpvAccess(_currentGroup) = groupID;
+  _processForChareMsg(env);
+}
+
+static inline void _processFillVidMsg(envelope *env)
+{
+  register VidBlock *vptr = (VidBlock *) env->getVidPtr();
+  register CkChareID *pcid = (CkChareID *) EnvToUsr(env);
+  vptr->fill(pcid->onPE, pcid->objPtr);
+  CmiFree(env);
+}
+
+static inline void _processForVidMsg(envelope *env)
+{
+  VidBlock *vptr = (VidBlock *) env->getVidPtr();
+  vptr->send(env);
+}
+
+static inline void _processDBocReqMsg(envelope *env)
+{
+  assert(CkMyPe()==0);
+  register int groupNum = _numGroups++;
+  env->setMsgtype(DBocNumMsg);
+  register int srcPe = env->getSrcPe();
+  env->setSrcPe(CkMyPe());
+  env->setGroupNum(groupNum);
+  CmiSyncSendAndFree(srcPe, env->getTotalsize(), env);
+  CpvAccess(_qd)->create();
+}
+
+static inline void _processDBocNumMsg(envelope *env)
+{
+  register envelope *usrenv = (envelope *) env->getUsrMsg();
+  register int retEp = env->getRetEp();
+  register CkChareID *retChare = (CkChareID *) EnvToUsr(env);
+  register int groupID = env->getGroupNum();
+  _createGroup(groupID, usrenv, retEp, retChare);
+}
+
+void _processBocInitMsg(envelope *env)
+{
+  register int groupID = env->getGroupNum();
+  register int epIdx = env->getEpIdx();
+  _createGroupMember(groupID, epIdx, EnvToUsr(env));
+}
+
+void _processHandler(void *msg)
+{
+  CmiGrabBuffer(&msg);
+  register envelope *env = (envelope *) msg;
+  switch(env->getMsgtype()) {
+    case NewChareMsg :
+      CpvAccess(_qd)->process();
+      if(env->isPacked()) _unpackFn((void **)&env);
+      _processNewChareMsg(env);
+      CpvAccess(_myStats)->recordProcessChare();
+      break;
+    case NewVChareMsg :
+      CpvAccess(_qd)->process();
+      if(env->isPacked()) _unpackFn((void **)&env);
+      _processNewVChareMsg(env);
+      CpvAccess(_myStats)->recordProcessChare();
+      break;
+    case BocInitMsg :
+      CpvAccess(_qd)->process();
+      if(env->isPacked()) _unpackFn((void **)&env);
+      _processBocInitMsg(env);
+      break;
+    case DBocReqMsg:
+      CpvAccess(_qd)->process();
+      _processDBocReqMsg(env);
+      break;
+    case DBocNumMsg:
+      CpvAccess(_qd)->process();
+      _processDBocNumMsg(env);
+      break;
+    case ForChareMsg :
+      CpvAccess(_qd)->process();
+      if(env->isPacked()) _unpackFn((void **)&env);
+      _processForChareMsg(env);
+      CpvAccess(_myStats)->recordProcessMsg();
+      break;
+    case ForBocMsg :
+      CpvAccess(_qd)->process();
+      if(env->isPacked()) _unpackFn((void **)&env);
+      _processForBocMsg(env);
+      CpvAccess(_myStats)->recordProcessBranch();
+      break;
+    case ForVidMsg   :
+      CpvAccess(_qd)->process();
+      _processForVidMsg(env);
+      break;
+    case FillVidMsg  :
+      CpvAccess(_qd)->process();
+      _processFillVidMsg(env);
+      break;
+    default:
+      CmiAbort("Internal Error: Unknown-msg-type. Contact Developers.\n");
+  }
+}
+
+void _infoFn(void *msg, CldPackFn *pfn, int *len,
+             int *queueing, int *priobits, unsigned int **prioptr)
+{
+  register envelope *env = (envelope *)msg;
+  *pfn = (CldPackFn)_packFn;
+  *len = env->getTotalsize();
+  *queueing = env->getQueueing();
+  *priobits = env->getPriobits();
+  *prioptr = (unsigned int *) env->getPrioPtr();
+}
+
+void _packFn(void **pEnv)
+{
+  register envelope *env = *((envelope **)pEnv);
+  register int msgIdx = env->getMsgIdx();
+  if(!env->isPacked() && _msgTable[msgIdx]->pack) {
+    register void *msg = EnvToUsr(env);
+    msg = _msgTable[msgIdx]->pack(msg);
+    UsrToEnv(msg)->setPacked(1);
+    *((envelope **)pEnv) = UsrToEnv(msg);
+  }
+}
+
+void _unpackFn(void **pEnv)
+{
+  register envelope *env = *((envelope **)pEnv);
+  register int msgIdx = env->getMsgIdx();
+  if(_msgTable[msgIdx]->unpack) {
+    register void *msg = EnvToUsr(env);
+    msg = _msgTable[msgIdx]->unpack(msg);
+    UsrToEnv(msg)->setPacked(0);
+    *((envelope **)pEnv) = UsrToEnv(msg);
+  }
+}
+
+extern "C"
+void CkSendMsg(int entryIdx, void *msg, CkChareID *pCid)
+{
+  register envelope *env = UsrToEnv(msg);
+  env->setMsgtype(ForChareMsg);
+  env->setEpIdx(entryIdx);
+  CmiSetHandler(env, _charmHandlerIdx);
+  if(pCid->onPE < 0) {
+    register int pe = -(pCid->onPE+1);
+    if(pe==CkMyPe()) {
+      VidBlock *vblk = (VidBlock *) pCid->objPtr;
+      vblk->send(env);
+    } else {
+      env->setMsgtype(ForVidMsg);
+      env->setSrcPe(CkMyPe());
+      env->setVidPtr(pCid->objPtr);
+      CldEnqueue(pe, env, _infoIdx);
+      CpvAccess(_qd)->create();
+    }
+  } else {
+    env->setSrcPe(CkMyPe());
+    env->setObjPtr(pCid->objPtr);
+    CldEnqueue(pCid->onPE, env, _infoIdx);
+    CpvAccess(_qd)->create();
+  }
+  CpvAccess(_myStats)->recordSendMsg();
+}
+
+extern "C"
+void CkCreateChare(int cIdx, int eIdx, void *msg, CkChareID *pCid, int destPE)
+{
+  assert(cIdx == _entryTable[eIdx]->chareIdx);
+  envelope *env = UsrToEnv(msg);
+  if(pCid == 0) {
+    env->setMsgtype(NewChareMsg);
+  } else {
+    pCid->onPE = (-(CkMyPe()+1));
+    pCid->objPtr = (void *) new VidBlock();
+    env->setMsgtype(NewVChareMsg);
+    env->setVidPtr(pCid->objPtr);
+    env->setSrcPe(CkMyPe());
+  }
+  env->setEpIdx(eIdx);
+  env->setSrcPe(CkMyPe());
+  CmiSetHandler(env, _charmHandlerIdx);
+  CldEnqueue(destPE, env, _infoIdx);
+  CpvAccess(_qd)->create();
+  CpvAccess(_myStats)->recordCreateChare();
+}
+
+void _createGroupMember(int groupID, int eIdx, void *msg)
+{
+  register int gIdx = _entryTable[eIdx]->chareIdx;
+  register void *obj = malloc(_chareTable[gIdx]->size);
+  CpvAccess(_groupTable)->add(groupID, obj);
+  register void *prev = CpvAccess(_currentChare);
+  CpvAccess(_currentChare) = obj;
+  register int prevGrp = CpvAccess(_currentGroup);
+  CpvAccess(_currentGroup) = groupID;
+  _entryTable[eIdx]->call(msg, obj);
+  CpvAccess(_currentChare) = prev;
+  CpvAccess(_currentGroup) = prevGrp;
+  CpvAccess(_myStats)->recordProcessGroup();
+}
+
+void _createGroup(int groupID, envelope *env, int retEp, CkChareID *retChare)
+{
+  register int epIdx = env->getEpIdx();
+  register int msgIdx = env->getMsgIdx();
+  env->setGroupNum(groupID);
+  env->setSrcPe(CkMyPe());
+  register void *msg =  EnvToUsr(env);
+  if(CkNumPes()>1) {
+    if(!env->isPacked() && _msgTable[msgIdx]->pack) {
+      msg = _msgTable[msgIdx]->pack(msg);
+      UsrToEnv(msg)->setPacked(1);
+    }
+    env = UsrToEnv(msg);
+    CmiSetHandler(env, _bocHandlerIdx);
+    _numInitMsgs++;
+    CmiSyncBroadcast(env->getTotalsize(), env);
+    CpvAccess(_qd)->create(CkNumPes()-1);
+    if(env->isPacked() && _msgTable[msgIdx]->unpack) {
+      msg = _msgTable[msgIdx]->unpack(msg);
+      UsrToEnv(msg)->setPacked(0);
+    }
+  }
+  CpvAccess(_myStats)->recordCreateGroup();
+  _createGroupMember(groupID, epIdx, msg);
+  if(retChare) {
+    msg = CkAllocMsg(0, sizeof(int), 0); // 0 is a system msg of size int
+    *((int *)msg) = groupID;
+    CkSendMsg(retEp, msg, retChare);
+  }
+}
+
+static int _staticGroupCreate(envelope *env, int retEp, CkChareID *retChare)
+{
+  register int groupNum = _numGroups++;
+  _createGroup(groupNum, env, retEp, retChare);
+  return groupNum;
+}
+
+static void _dynamicGroupCreate(envelope *env, int retEp, CkChareID * retChare)
+{
+  register CkChareID *msg = 
+    (CkChareID*) _allocMsg(DBocReqMsg, sizeof(CkChareID));
+  *msg = *retChare;
+  register envelope *newenv = UsrToEnv((void *)msg);
+  newenv->setUsrMsg(env);
+  newenv->setSrcPe(CkMyPe());
+  newenv->setEpIdx(retEp);
+  CmiSetHandler(newenv, _charmHandlerIdx);
+  CmiSyncSendAndFree(0, newenv->getTotalsize(), newenv); 
+  CpvAccess(_qd)->create();
+}
+
+extern "C"
+int CkCreateGroup(int cIdx, int eIdx, void *msg, int retEp,CkChareID *retChare)
+{
+  assert(cIdx == _entryTable[eIdx]->chareIdx);
+  register envelope *env = UsrToEnv(msg);
+  env->setMsgtype(BocInitMsg);
+  env->setEpIdx(eIdx);
+  if(CkMyPe()==0) {
+    return _staticGroupCreate(env, retEp, retChare);
+  } else {
+    _dynamicGroupCreate(env, retEp, retChare);
+    return (-1);
+  }
+}
+
+extern "C"
+void *CkLocalBranch(int groupID)
+{
+  return CpvAccess(_groupTable)->find(groupID);
+}
+
+static inline void _sendMsgBranch(int eIdx, void *msg, int gID, 
+                           int pe=CLD_BROADCAST_ALL)
+{
+  register envelope *env = UsrToEnv(msg);
+  env->setMsgtype(ForBocMsg);
+  env->setEpIdx(eIdx);
+  env->setGroupNum(gID);
+  env->setSrcPe(CkMyPe());
+  CmiSetHandler(env, _charmHandlerIdx);
+  CldEnqueue(pe, env, _infoIdx);
+}
+
+extern "C"
+void CkSendMsgBranch(int eIdx, void *msg, int pe, int gID)
+{
+  _sendMsgBranch(eIdx, msg, gID, pe);
+  CpvAccess(_myStats)->recordSendBranch();
+  CpvAccess(_qd)->create();
+}
+
+extern "C"
+void CkBroadcastMsgBranch(int eIdx, void *msg, int gID)
+{
+  _sendMsgBranch(eIdx, msg, gID);
+  CpvAccess(_myStats)->recordSendBranch(CkNumPes());
+  CpvAccess(_qd)->create(CkNumPes());
+}
diff --git a/src/ck-core/ck.c b/src/ck-core/ck.c
deleted file mode 100644 (file)
index 23c0c3d..0000000
+++ /dev/null
@@ -1,485 +0,0 @@
-#include "charm.h"
-
-#include "trace.h"
-#include "converse.h"
-
-#include <varargs.h>
-
-void CkUnpack(ENVELOPE **msg);
-void CkPack(ENVELOPE **msg);
-void CkInfo(void *msg, CldPackFn *pfn, int *len, int *qs, int *pb, unsigned int **pp);
-
-extern void *FIFO_Create();
-extern CHARE_BLOCK *CreateChareBlock();
-
-CpvStaticDeclare(int, num_exits);
-CpvStaticDeclare(int, num_endcharms);
-CpvDeclare(int, CkInfo_Index);
-
-void ckModuleInit()
-{
-   CpvInitialize(int, num_exits);
-   CpvInitialize(int, num_endcharms);
-   CpvInitialize(int, CkInfo_Index);
-
-   CpvAccess(num_exits)=0;
-   CpvAccess(num_endcharms)=0;
-   CpvAccess(CkInfo_Index) = CldRegisterInfoFn(CkInfo);
-}
-
-
-/*************************************************************************
-  EXIT PROTOCOL FOR CHARM
-
-  How do the CkExit and CkEndCharm protocols work?
-
-  CkExits send a message with an iteration number whose value is num_exits
-  CkEndCharms send -1 in the message ..
-
-  To prevent the sending of two messages for a particular CkExit,
-    *  the seq number in the message should equal the value of num_exits for
-       a CkExit to be processed (thus no two CkExits with the same seq number
-       are processed).
-  Also, CkEndCharm has a synchronization : the broadcast for statistics
-  collection is done only after all processors have reported a CkEndCharm.
-
-  The scheme is necessitated by the possibility of use of more than one 
-  "DoCharm()" (now Scheduler()) and CkExits in each of them.
-
-  The control flow - Any processor calling CkExit or CkEndCharm sends a 
-  BroadcastExitMessage to node 0 which broadcasts to ExitMessage on all 
-  processors.
-
-  ExitMessage handles CkExit and CkEndCharm requests differently.
-
-**************************************************************************/
-
-
-CkExit()
-{
-       int *msg;
-
-       msg = (int *) CkAllocMsg(sizeof(int));
-       CkMemError(msg);
-       *msg = CpvAccess(num_exits);
-
-       GeneralSendMsgBranch(CsvAccess(CkEp_Stat_BroadcastExitMessage),
-                       msg, 0, BocMsg, StatisticBocNum);
-}
-
-
-CkEndCharm()
-{
-       int *msg;
-
-       msg = (int *) CkAllocMsg(sizeof(int));
-       CkMemError(msg);
-       *msg = -1;
-
-       GeneralSendMsgBranch(CsvAccess(CkEp_Stat_BroadcastExitMessage),
-                       msg, 0, BocMsg, StatisticBocNum);
-}
-
-BroadcastExitMessage(usr, data)
-void *usr, *data;
-{
-/* This function is executed only on node 0 - corresponds to 
-                 CsvAccess(CkEp_Stat_BroadcastExitMessage) */
-
-       int *msg;
-       
-       if (*((int *)usr) == -1) { /* For CkEndCharm */
-               CpvAccess(num_endcharms)++ ;
-               if( CpvAccess(num_endcharms) < CmiNumPes() ) 
-                       return;
-       }
-       else {  /* For CkExit */
-               if(*((int *)usr) < CpvAccess(num_exits))
-                        return;
-               CpvAccess(num_exits)++;
-       }
-       
-       msg = (int *) CkAllocMsg(sizeof(int));
-       CkMemError(msg);
-       *msg = *((int *)usr);
-       GeneralBroadcastMsgBranch(CsvAccess(CkEp_Stat_ExitMessage), msg, 
-                       BroadcastBocMsg, StatisticBocNum);
-       CpvAccess(disable_sys_msgs) = 1;
-}
-
-ExitMessage(usr, data)
-void *usr, *data;
-{
-        if(*((int *)usr) == -1) /* If the user called CkEndCharm */
-       {
-               SendNodeStatistics();
-               send_log();
-               if ( CmiMyPe() != 0 && CpvAccess(CtrRecdTraceMsg) 
-                                   && CpvAccess(RecdStatMsg) ) 
-                       ExitNode();
-       }
-       else /* If the user called CkExit */
-       {
-               CkEndCharm();
-               if(CmiMyPe())
-                       CpvAccess(num_exits)++;
-       }
-}
-
-
-SendNodeStatistics()
-{
-       (*(CsvAccess(EpInfoTable)[CsvAccess(CkEp_Stat_Data)].function)) 
-                                                               (NULL,NULL);
-}
-
-
-ExitNode()
-{
-       char *msg;
-       ENVELOPE *env;
-
-       /* close_log(); moved to convcore.c */
-       if (CmiMyPe() == 0)
-       {
-               /* First print out statistics. */
-               PrintOutStatistics();
-       }
-
-       /* Complete the loop */ 
-        CsdExitScheduler();
-}
-
-
-
-
-
-
-/**********************************************************************
- * These are utility routines for chares 
-***********************************************************************/
-
-ChareExit()
-{
-       SetID_chare_magic_number(CpvAccess(currentChareBlock)->selfID,-1);
-       CmiFree(CpvAccess(currentChareBlock));
-}
-
-
-CHARE_BLOCK *CreateChareBlock(sizeData, kind, magic)
-int sizeData, magic, kind;
-{
-  CHARE_BLOCK *p = (CHARE_BLOCK *)CmiAlloc(sizeof(CHARE_BLOCK) + sizeData);
-  CkMemError(p);
-  SetID_chare_magic_number(p->selfID, magic);
-  SetID_onPE(p->selfID, CmiMyPe());
-  SetID_chareBlockPtr(p->selfID, p);
-  p->charekind = kind;
-
-  /* the chare data area is just after the chare-block, by default */
-  p->chareptr = (void *)(p+1); 
-  return((void *) p);
-}
-
-IsChareLocal(chareid)
-ChareIDType * chareid;
-{
-       if (GetID_onPE((*chareid)) == CmiMyPe()) return 1;
-       return 0;
-}
-
-void *GetChareDataPtr(chareid)
-ChareIDType * chareid;
-{
-       return ((CHARE_BLOCK *) GetID_chareBlockPtr((*chareid))) + 1;
-}
-
-MyChareID(pChareID)
-ChareIDType * pChareID;
-{
-    *pChareID = CpvAccess(currentChareBlock)->selfID;
-}
-
-
-/* Deleted already commented out MyParentID function : SANJEEV May 24, 93 */
-
-MainChareID(pChareID)
-ChareIDType * pChareID;
-{
-       SetID_onPE((*pChareID), 0);
-       if (CmiMyPe() == 0)
-               SetID_chare_magic_number((*pChareID),
-                   GetID_chare_magic_number(CpvAccess(mainChareBlock)->selfID));
-       else
-               SetID_chare_magic_number((*pChareID), CpvAccess(mainChare_magic_number));
-       SetID_chareBlockPtr((*pChareID), CpvAccess(mainChareBlock));
-}
-
-
-
-/* this is the general CreateChare call: all the user level CreateChare
-   calls are mapped to this call: they include 
-
-       CreateChare(Charename, Entry, Msg, [vid [,destPE]]) 
-
-   If vid is NULL_VID it is a CreateChare call ("without ID"). 
-   if DestPe is CK_PE_ANY  then it may go to any destination node
-   if DestPe is not CK_PE_SPECIAL then the message is bound for a regular destination
-
-*/
-
-CreateChare(id, Entry, Msg, vid, destPE)
-int id;
-EntryNumType Entry;
-void *Msg;
-ChareIDType *vid;
-int destPE;
-{
-  ENVELOPE *env;
-  CHARE_BLOCK *vidblock;
-
-  if (id!=CsvAccess(EpInfoTable)[Entry].chareindex) 
-    CmiPrintf("** ERROR ** Illegal combination of CHAREINDEX/EP in CreateChare\n");
-
-  TRACE(CmiPrintf("[%d] CreateChare: Entry=%d\n", CmiMyPe(), Entry));
-  
-  CpvAccess(nodecharesCreated)++;
-  env = ENVELOPE_UPTR(Msg);
-  
-  SetEnv_EP(env, Entry);
-  
-  if (vid != NULL_VID) {
-    vidblock = (CHARE_BLOCK *)CreateChareBlock(0, CHAREKIND_UVID, rand());
-    vidblock->x.vid_queue = (void *)FIFO_Create();
-    (*vid) = vidblock->selfID;
-    SetEnv_vidPE(env, GetID_onPE(vidblock->selfID));
-    SetEnv_vidBlockPtr(env, GetID_chareBlockPtr(vidblock->selfID));
-  } else {
-    SetEnv_vidPE(env, -1);
-    SetEnv_vidBlockPtr(env, NULL);
-  }
-  
-  if(CpvAccess(traceOn))
-    trace_creation(NewChareMsg, Entry, env);
-  QDCountThisCreation(1);
-
-  SetEnv_msgType(env, NewChareMsg);
-  if (destPE == CK_PE_ANY) destPE = CLD_ANYWHERE;
-  CmiSetHandler(env, CpvAccess(HANDLE_INCOMING_MSG_Index));
-  CldEnqueue(destPE, env, CpvAccess(CkInfo_Index));
-}
-
-
-SendMsg(Entry, Msg, pChareID)
-int Entry;
-void * Msg;
-ChareIDType * pChareID;
-{
-  ENVELOPE * env;
-  int destPE = GetID_onPE((*pChareID));
-
-  CpvAccess(nodeforCharesCreated)++;
-  env = ENVELOPE_UPTR(Msg);
-  SetEnv_msgType(env, ForChareMsg);
-  SetEnv_EP(env, Entry);
-  SetEnv_chareBlockPtr(env, GetID_chareBlockPtr((*pChareID)));
-  SetEnv_chare_magic_number(env, GetID_chare_magic_number((*pChareID)));
-  QDCountThisCreation(1);
-  if(CpvAccess(traceOn))
-    trace_creation(GetEnv_msgType(env), Entry, env);
-  CmiSetHandler(env, CpvAccess(HANDLE_INCOMING_MSG_Index));
-  CldEnqueue(destPE, env, CpvAccess(CkInfo_Index));
-}
-
-/*****************************************************************/
-/** Gets reference number.                                     **/
-/*****************************************************************/
-GetRefNumber(msg)
-void *msg;
-{
-       ENVELOPE *env = (ENVELOPE *) ENVELOPE_UPTR(msg);
-
-       return GetEnv_ref(env);
-}
-
-
-/*****************************************************************/
-/** Sets reference number.                                     **/
-/*****************************************************************/
-SetRefNumber(msg, number)
-void *msg;
-int number;
-{
-       ENVELOPE *env = (ENVELOPE *) ENVELOPE_UPTR(msg);
-
-       SetEnv_ref(env, number);
-}
-
-
-void CkSetQueueing(usrptr, kind)
-void *usrptr;
-int kind;
-{
-  SetEnv_queueing(ENVELOPE_UPTR(usrptr), kind);
-}
-
-/*****************************************************************************
- * Load balancer needs.
- *****************************************************************************/
-
-void CkUnpack(ENVELOPE **henv)
-{
-  ENVELOPE *envelope = *henv;
-  void *unpackedUsrMsg; 
-  void *usrMsg = USER_MSG_PTR(envelope); 
-  if(CpvAccess(traceOn)) 
-    trace_begin_unpack(); 
-  (*(CsvAccess(MsgToStructTable)[GetEnv_packid(envelope)].unpackfn)) 
-    (usrMsg, &unpackedUsrMsg); 
-  if(CpvAccess(traceOn)) 
-    trace_end_unpack(); 
-  if (usrMsg != unpackedUsrMsg) 
-    /* else unpacked in place */ 
-  { 
-    int temp_i; 
-    int temp_size; 
-    char *temp1, *temp2; 
-    /* copy envelope */ 
-    temp1 = (char *) envelope; 
-    temp2 = (char *) ENVELOPE_UPTR(unpackedUsrMsg); 
-    temp_size = (char *) usrMsg - temp1; 
-    for (temp_i = 0; temp_i<temp_size; temp_i++) 
-    *temp2++ = *temp1++; 
-    CmiFree(envelope); 
-    envelope = ENVELOPE_UPTR(unpackedUsrMsg); 
-   } 
-   SetEnv_isPACKED(envelope, UNPACKED); 
-  *henv = envelope;
-}
-
-void CkPack(ENVELOPE **henv)
-{
-  ENVELOPE *env = *henv;
-  if (GetEnv_isPACKED(env) == UNPACKED) {
-    /* needs packing and not already packed */ 
-    int size; 
-    char *usermsg, *packedmsg; 
-    /* make it +ve to connote a packed msg */ 
-    SetEnv_isPACKED(env, PACKED); 
-    usermsg = USER_MSG_PTR(env); 
-    if(CpvAccess(traceOn)) 
-      trace_begin_pack(); 
-    (*(CsvAccess(MsgToStructTable)[GetEnv_packid(env)].packfn)) 
-      (usermsg, &packedmsg, &size); 
-    if(CpvAccess(traceOn)) 
-      trace_end_pack(); 
-    if (usermsg != packedmsg) { 
-      /* Free the usermsg here. */ 
-      CkFreeMsg(usermsg); 
-      env = ENVELOPE_UPTR(packedmsg); 
-    }
-  }
-  *henv = env;
-}
-
-
-void CkInfo(void *msg, CldPackFn *pfn, int *len,
-           int *queueing, int *priobits, unsigned int **prioptr)
-{
-  ENVELOPE *env = (ENVELOPE *)msg;
-  *pfn = (CldPackFn)CkPack;
-  *len = GetEnv_TotalSize(env);
-  *queueing = GetEnv_queueing(env);
-  *priobits = GetEnv_priosize(env);
-  *prioptr = GetEnv_priobgn(env);
-}
-
-
-CkEnqueue(env)
-void *env;
-{
-  CsdEnqueueGeneral(env,
-    GetEnv_queueing(env),
-    GetEnv_priosize(env),
-    GetEnv_priobgn(env));
-}
-
-/************************************************************************
- *
- * CkPrioConcat
- *
- * Copies all the priority bits from the bitvector in 'srcmsg' onto
- * the bitvector in 'dstmsg', then, if there is any space left in the
- * bitvector of 'dstmsg', that space is filled by bits taken from the
- * lsb of 'delta'.
- *
- * The code works as follows:
- *
- * step 1: Copy old bitvector onto new. Always copies a multiple of
- * 32 bits, therefore, may copy some "padding" bits.  The number of
- * padding bits copied can be found in 'padbits'.
- *
- * step 2: move bits in delta to msb-end.
- *
- * step 3: if any padding-bits were copied, overwrite them with a
- * piece of delta.
- *
- * step 4: if padding-bits were insufficient to hold all of delta,
- * store remainder of delta in next word.
- *
- ************************************************************************/
-
-#define CINTBITS (sizeof(int)*8)
-
-void CkPrioConcatFn(srcmsg, dstmsg, delta)
-void *srcmsg;
-void *dstmsg;
-unsigned int delta;
-{
-  int padbits, deltabits;
-  ENVELOPE *srcenv = ENVELOPE_UPTR(srcmsg);
-  ENVELOPE *dstenv = ENVELOPE_UPTR(dstmsg);
-  int srcbits = GetEnv_priosize(srcenv);
-  int dstbits = GetEnv_priosize(dstenv);
-  int srcwords = (srcbits+CINTBITS-1)/CINTBITS;
-  int dstwords = (dstbits+CINTBITS-1)/CINTBITS;
-  unsigned int *srcptr = GetEnv_prioend(srcenv) - srcwords;
-  unsigned int *dstptr = GetEnv_prioend(dstenv) - dstwords;
-  deltabits = dstbits - srcbits;
-  if (deltabits < 0) {
-    CmiPrintf("CkPrioConcat: prio-bits from source message don't fit in destination message.\n");
-    exit(1);
-  }
-  if (deltabits > CINTBITS) {
-    CmiPrintf("CkPrioConcat: prio-bits from source message plus bits of delta don't fill destination-message.\n");
-    exit(1);
-  }
-  while (srcbits>0) { *dstptr++ = *srcptr++; srcbits -= CINTBITS; }
-  padbits = -srcbits;
-  delta <<= (CINTBITS-deltabits);
-  if (padbits) {
-    dstptr[-1] &= (((unsigned int)(-1))<<padbits);
-    dstptr[-1] |= (delta>>(CINTBITS-padbits));
-  }
-  if (deltabits>padbits) dstptr[0] = (delta<<padbits);
-}
-
-int CkPrioSizeBitsFn(msg) void *msg;
-{
-    return GetEnv_priosize(ENVELOPE_UPTR(msg));
-}
-
-int CkPrioSizeBytesFn(msg) void *msg;
-{
-    return GetEnv_priobytes(ENVELOPE_UPTR(msg));
-}
-
-int CkPrioSizeWordsFn(msg) void *msg;
-{
-    return GetEnv_priowords(ENVELOPE_UPTR(msg));
-}
-
-unsigned int *CkPrioPtrFn(msg) void *msg;
-{
-    return GetEnv_priobgn(ENVELOPE_UPTR(msg));
-}
diff --git a/src/ck-core/ck.h b/src/ck-core/ck.h
new file mode 100644 (file)
index 0000000..d7147bf
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef _CK_H_
+#define _CK_H_
+
+#include <string.h>
+#include <stdlib.h>
+
+#define NDEBUG
+#include <assert.h>
+
+extern "C" {
+#include "charm.h"
+}
+
+#include "envelope.h"
+#include "init.h"
+#include "qd.h"
+#include "register.h"
+#include "stats.h"
+#include "ckfutures.h"
+#include "ckstream.h"
+
+class VidBlock {
+    enum VidState {FILLED, UNFILLED};
+    VidState state;
+    PtrQ *msgQ;
+    CkChareID actualID;
+  public:
+    VidBlock() { state = UNFILLED; msgQ = new PtrQ(); }
+    void send(envelope *env) {
+      if(state==UNFILLED) {
+        msgQ->enq((void *)env);
+      } else {
+        env->setSrcPe(CkMyPe());
+        env->setMsgtype(ForChareMsg);
+        env->setObjPtr(actualID.objPtr);
+        CldEnqueue(actualID.onPE, env, _infoIdx);
+        CpvAccess(_qd)->create();
+      }
+    }
+    void fill(int onPE, void *oPtr) {
+      state = FILLED;
+      actualID.onPE = onPE;
+      actualID.objPtr = oPtr;
+      envelope *env;
+      while(env=(envelope*)msgQ->deq()) {
+        env->setSrcPe(CkMyPe());
+        env->setMsgtype(ForChareMsg);
+        env->setObjPtr(actualID.objPtr);
+        CldEnqueue(actualID.onPE, env, _infoIdx);
+        CpvAccess(_qd)->create();
+      }
+      delete msgQ; msgQ=0;
+    }
+};
+
+extern void _processHandler(void *);
+extern void _infoFn(void *msg, CldPackFn *pfn, int *len,
+                    int *queueing, int *priobits, UInt **prioptr);
+extern void _packFn(void **msg);
+extern void _unpackFn(void **msg);
+extern void _createGroupMember(int groupID, int eIdx, void *env);
+extern void _createGroup(int groupID, envelope *env, int retEp, 
+                         CkChareID *retChare);
+
+/***********************/
+/* generated by charmc */
+/***********************/
+
+extern void CkRegisterMainModule(void);
+
+#endif
index 00b049002c26d9cada9b7c2009e7c3db52df44a5..7723b1262424aa0be750beed0c08a2ee23d6c66f 100644 (file)
@@ -1,6 +1,6 @@
-
 #include "charm++.h"
-#include "ckfutures.top.h"
+#include "ck.h"
+#include "ckfutures.h"
 #include <stdlib.h>
 
 /******************************************************************************
@@ -9,16 +9,14 @@
  *
  *****************************************************************************/
 
-typedef struct Future_s
-{
+typedef struct Future_s {
   int ready;
   void *value;
   CthThread waiters;
   int next; 
 } Future;
 
-typedef struct
-{
+typedef struct {
   Future *array;
   int max;
   int freelist;
@@ -97,7 +95,7 @@ static void setFuture(int handle, void *pointer)
   fut->waiters = 0;
 }
 
-extern "C" void futuresModuleInit()
+void _futuresModuleInit(void)
 {
   int i; Future *array;
   CpvInitialize(FutureState, futurestate);
@@ -113,63 +111,59 @@ extern "C" void futuresModuleInit()
  *
  *****************************************************************************/
 
-int futureBocNum;
+CProxy_FutureBOC fBOC(0);
 
-class FutureInitMsg : public comm_object
-{
+class FutureInitMsg : public CMessage_FutureInitMsg {
   public: int x ;
 };
 
-extern "C" void *CRemoteCallBranchFn( int ep, void *m, int group, int processor)
+class  FutureMain : public Chare {
+  public:
+    FutureMain(CkArgMsg *m) {
+      fBOC.ckSetGroupId(CProxy_FutureBOC::ckNew(new FutureInitMsg));
+      CkFreeMsg(m);
+    }
+};
+
+extern "C" 
+void *CkRemoteCallBranch(int ep, void *m, int group, int PE)
 { 
   void * result;
-  ENVELOPE *env = ENVELOPE_UPTR(m);
+  envelope *env = UsrToEnv(m);
   int i = createFuture();
-  SetRefNumber(m,i);
-  SetEnv_pe(env, CmiMyPe());
-  GeneralSendMsgBranch(ep, m, processor, -1, group);
+  env->setRef(i);
+  CkSendMsgBranch(ep, m, PE, group);
   result = waitFuture(i, 1);
   return (result);
 }
 
-extern "C" void *CRemoteCallFn(int ep, void *m, ChareIDType *ID)
+extern "C" 
+void *CkRemoteCall(int ep, void *m, CkChareID *ID)
 { 
   void * result;
-  ENVELOPE *env = ENVELOPE_UPTR(m);
+  envelope *env = UsrToEnv(m);
   int i = createFuture();
-  SetRefNumber(m,i);
-  SetEnv_pe(env, CmiMyPe());
-  SendMsg(ep, m, ID);
+  env->setRef(i);
+  CkSendMsg(ep, m, ID);
   result = waitFuture(i, 1);
   return (result);
 }
 
-class FutureBOC: public groupmember
-{
+class FutureBOC: public Group {
 public:
-
-  FutureBOC(FutureInitMsg *m) 
-  {
-    delete m;
-  }
-  void SetFuture(FutureInitMsg * m)
-  {
+  FutureBOC(FutureInitMsg *m) { delete m; }
+  void SetFuture(FutureInitMsg * m) { 
     int key;
-    key = GetRefNumber(m);
+    key = UsrToEnv((void *)m)->getRef();
     setFuture( key, m);
   }
 };
 
-extern "C" void futuresCreateBOC()
-{
-  FutureInitMsg *message2 = new (MsgIndex(FutureInitMsg)) FutureInitMsg ;
-  futureBocNum = new_group (FutureBOC, FutureInitMsg, message2);
-}
-
-extern "C" void CSendToFuture(void *m, int processor)
+extern "C" 
+void CkSendToFuture(int futNum, void *m, int PE)
 {
-  CSendMsgBranch(FutureBOC, SetFuture, FutureInitMsg, m, futureBocNum, processor);
+  UsrToEnv(m)->setRef(futNum);
+  fBOC.SetFuture((FutureInitMsg *)m,PE);
 }
 
-
-#include "ckfutures.bot.h"
+#include "CkFutures.def.h"
index 85bef557b7827ce8f9889fc5287fbd693767b2c6..d44fb41bf2ee12665492cc67aadc0ef9927265bf 100644 (file)
@@ -1,8 +1,16 @@
-readonly int futureBocNum;
-message FutureInitMsg;
+module CkFutures {
+  // temporarily All system messages are here
+  message CkQdMsg;
+  message FutureInitMsg;
 
-group FutureBOC {
-  entry FutureBOC(FutureInitMsg *);
-  entry SetFuture(FutureInitMsg *);
-};
+  group FutureBOC {
+    entry FutureBOC(FutureInitMsg *);
+    entry void SetFuture(FutureInitMsg *);
+  };
+
+  mainchare FutureMain {
+    entry FutureMain();
+  };
 
+  readonly CProxy_FutureBOC fBOC;
+};
diff --git a/src/ck-core/ckfutures.h b/src/ck-core/ckfutures.h
new file mode 100644 (file)
index 0000000..6709ea7
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _CKFUTURES_H_
+#define _CKFUTURES_H_
+
+#include "CkFutures.decl.h"
+
+extern void _futuresModuleInit(void);
+extern void _registerCkFutures(void);
+
+#endif
diff --git a/src/ck-core/ckstream.h b/src/ck-core/ckstream.h
new file mode 100644 (file)
index 0000000..9e9a4f2
--- /dev/null
@@ -0,0 +1,149 @@
+#ifndef _CKSTREAM_H
+#define _CKSTREAM_H
+
+#include <string.h>
+#include <stdio.h>
+
+class _CkOStream {
+  private:
+    int _isErr;
+    int _buflen, _actlen;
+    char _obuf[16384];
+    char _tbuf[1024];
+  public:
+    _CkOStream(int isErr=0) { 
+      _buflen=16384; 
+      _actlen=1;
+      _isErr = isErr; 
+      _obuf[0] = '\0'; 
+    }
+    void endl(void) {
+      strcat(_obuf, "\n");
+      if(_isErr)
+        CkError(_obuf);
+      else
+        CkPrintf(_obuf);
+    }
+
+#define _OPSHIFTLEFT(type, format) \
+    _CkOStream& operator << (type x) { \
+      sprintf(_tbuf, format, x); \
+      _actlen += strlen(_tbuf); \
+      if(_actlen > _buflen) \
+        CmiAbort("Print Buffer Overflow!!\n"); \
+      strcat(_obuf, _tbuf); \
+      return *this; \
+    }
+
+    _OPSHIFTLEFT(int, "%d");
+    _OPSHIFTLEFT(unsigned int, "%u");
+    _OPSHIFTLEFT(short, "%hd");
+    _OPSHIFTLEFT(unsigned short, "%hu");
+    _OPSHIFTLEFT(long, "%ld");
+    _OPSHIFTLEFT(unsigned long, "%lu");
+    _OPSHIFTLEFT(char, "%c");
+    _OPSHIFTLEFT(unsigned char, "%u");
+    _OPSHIFTLEFT(float, "%f");
+    _OPSHIFTLEFT(double, "%lf");
+    _OPSHIFTLEFT(const char*, "%s");
+    _OPSHIFTLEFT(void*, "%x");
+};
+
+static inline _CkOStream& endl(_CkOStream& s)  { s.endl(); return s; }
+
+class _CkOutStream : public _CkOStream {
+  public:
+    _CkOutStream() : _CkOStream(0) {}
+};
+
+class _CkErrStream : public _CkOStream {
+  public:
+    _CkErrStream() : _CkOStream(1) {}
+};
+
+CpvExtern(_CkOutStream*, _ckout);
+CpvExtern(_CkErrStream*, _ckerr);
+
+class CkOutStream {
+  public:
+#define OUTSHIFTLEFT(type) \
+  CkOutStream& operator << (type x) { \
+    *CpvAccess(_ckout) << x; \
+    return *this; \
+  }
+    OUTSHIFTLEFT(int);
+    OUTSHIFTLEFT(unsigned int);
+    OUTSHIFTLEFT(short);
+    OUTSHIFTLEFT(unsigned short);
+    OUTSHIFTLEFT(long);
+    OUTSHIFTLEFT(unsigned long);
+    OUTSHIFTLEFT(char);
+    OUTSHIFTLEFT(unsigned char);
+    OUTSHIFTLEFT(float);
+    OUTSHIFTLEFT(double);
+    OUTSHIFTLEFT(const char*);
+    OUTSHIFTLEFT(void*);
+};
+
+static inline CkOutStream& endl(CkOutStream& s)  
+{ 
+  CpvAccess(_ckout)->endl(); return s; 
+}
+
+class CkErrStream {
+  public:
+#define ERRSHIFTLEFT(type) \
+  CkErrStream& operator << (type x) { \
+    *CpvAccess(_ckerr) << x; \
+    return *this; \
+  }
+    ERRSHIFTLEFT(int);
+    ERRSHIFTLEFT(unsigned int);
+    ERRSHIFTLEFT(short);
+    ERRSHIFTLEFT(unsigned short);
+    ERRSHIFTLEFT(long);
+    ERRSHIFTLEFT(unsigned long);
+    ERRSHIFTLEFT(char);
+    ERRSHIFTLEFT(unsigned char);
+    ERRSHIFTLEFT(float);
+    ERRSHIFTLEFT(double);
+    ERRSHIFTLEFT(const char*);
+    ERRSHIFTLEFT(void*);
+};
+
+static inline CkErrStream& endl(CkErrStream& s)  
+{ 
+  CpvAccess(_ckerr)->endl(); return s; 
+}
+
+extern CkOutStream ckout;
+extern CkErrStream ckerr;
+
+class CkInStream {
+  public:
+#define OPSHIFTRIGHT(type, format) \
+    CkInStream& operator >> (type& x) { \
+      CkScanf(format, &x); \
+      return *this; \
+    }
+
+    OPSHIFTRIGHT(int, "%d");
+    OPSHIFTRIGHT(unsigned int, "%u");
+    OPSHIFTRIGHT(short, "%hd");
+    OPSHIFTRIGHT(unsigned short, "%hu");
+    OPSHIFTRIGHT(long, "%ld");
+    OPSHIFTRIGHT(unsigned long, "%lu");
+    OPSHIFTRIGHT(char, "%c");
+    OPSHIFTRIGHT(unsigned char, "%u");
+    OPSHIFTRIGHT(float, "%f");
+    OPSHIFTRIGHT(double, "%lf");
+
+    CkInStream& operator >> (char* x) {
+      CkScanf("%s", x);
+      return *this;
+    }
+};
+
+extern CkInStream ckin;
+
+#endif
diff --git a/src/ck-core/common.c b/src/ck-core/common.c
deleted file mode 100644 (file)
index 17e9071..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "charm.h"
-
-#include "trace.h"
-
-
-/**********************************************************************/
-/* This is perhaps the most crucial function in the entire system.    
-Everything that a message does depends on these. To avoid computing
-various offsets again and again, they have been made into variables,
-computed only once at initialization. Any changes made to the layout
-of the message must be reflected here. */
-/**********************************************************************/
-void InitializeMessageMacros(void)
-{
-}      
diff --git a/src/ck-core/condsend.c b/src/ck-core/condsend.c
deleted file mode 100644 (file)
index 96ccaf5..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-#include "charm.h"
-
-typedef struct {
-  int entry;
-  void *msg;
-  ChareIDType *cid;
-} SendMsgStuff;
-
-typedef struct {
-  FUNCTION_PTR fn_ptr;
-  int bocNum;
-} CallBocStuff;
-
-/* Function implemented but not to be used .. */
-static void SendMsgIfConditionArises(int condnum, int entry, void *msg, int size, ChareIDType *cid);
-
-void CallBocIfConditionArises(int condnum, FUNCTION_PTR fnp, int bocNum);
-
-void SendMsgAfter(unsigned int deltaT, int entry, void *msg, int size, ChareIDType *cid);
-
-void CallBocAfter(FUNCTION_PTR fnp, int bocNum, unsigned int deltaT);
-
-void CallBocOnCondition(FUNCTION_PTR fnp, int bocNum);
-
-int NoDelayedMsgs(void);
-
-
-CpvStaticDeclare(int, outstanding_sends);
-
-
-
-void condsendModuleInit()
-{
-    CpvInitialize(int, outstanding_sends);
-    CpvAccess(outstanding_sends) = 0;
-}
-
-
-
-
-/*****************************************************************************
-  This function sends out a message using fields that it extracts from its one
-  argument
- *****************************************************************************/
-static void SendMsgFn(arg)
-    void *arg;
-{
-  SendMsgStuff *sendstruct;
-
-  CpvAccess(outstanding_sends)--;
-
-  sendstruct = (SendMsgStuff *)arg;
-  SendMsg(sendstruct->entry, sendstruct->msg, sendstruct->cid);
-}
-
-/*****************************************************************************
-  This function makes a BOC call using fields that it extracts from its one
-  argument
- *****************************************************************************/
-static void CallBocFn(arg)
-    void *arg;
-{
-  CallBocStuff *cbocstruct;
-  
-  cbocstruct = (CallBocStuff *)arg;
-  if ( !((*(cbocstruct->fn_ptr))(cbocstruct->bocNum)) )
-      CcdPeriodicallyCall((CcdVoidFn)CallBocFn, (void *)arg);
-  else
-    CmiFree(arg);
-    
-
-}
-
-/*****************************************************************************
-  This function adds a call that will send a message if a particular condition
-  is raised
- *****************************************************************************/
-/* Function not to be used ..  */
-static void SendMsgIfConditionArises(condnum, entry, msgToSend, size, pChareID)
-int condnum; int entry; void *msgToSend; 
-int size; ChareIDType *pChareID;
-{
-  SendMsgStuff *newEntry;
-  if((newEntry = (SendMsgStuff *) CmiAlloc(sizeof(SendMsgStuff))) == NULL) {
-    CkMemError(newEntry);
-    return;
-  }
-  else {
-    newEntry->entry     = entry;
-    newEntry->msg       = msgToSend;
-    newEntry->cid   = pChareID;
-
-    CpvAccess(outstanding_sends)++;
-    
-    CcdCallOnCondition(condnum, (CcdVoidFn)SendMsgFn, (void *)newEntry);
-    }
-} 
-
-
-/*****************************************************************************
-  This function adds a call that will make a BOC call if a particular condition
-  is raised
- *****************************************************************************/
-void CallBocIfConditionArises(condnum, fn_ptr, bocNum)
-    int condnum; FUNCTION_PTR fn_ptr; int bocNum;
-{
-  CallBocStuff *newEntry;
-  
-  if((newEntry = (CallBocStuff *) CmiAlloc(sizeof(CallBocStuff))) == NULL) 
-    {
-      CkMemError(newEntry);
-      return;
-    }
-  else {
-    newEntry->bocNum   = bocNum;
-    newEntry->fn_ptr   = fn_ptr;;
-    CcdCallOnCondition(condnum, (CcdVoidFn)CallBocFn, (void *)newEntry);
-    }
-}
-
-/*****************************************************************************
-  This function adds a call that will send a message during a TimerChecks() 
-  call after a minimum delay of deltaT
- *****************************************************************************/
-void SendMsgAfter(deltaT, entry, msgToSend, size, pChareID)
-    unsigned int deltaT; int entry; void *msgToSend;
-    int size; ChareIDType *pChareID;
-{
-  SendMsgStuff *newEntry;
-
-  if((newEntry = (SendMsgStuff *) CmiAlloc(sizeof(SendMsgStuff))) == NULL) 
-    {
-      CkMemError(newEntry);
-      return;
-    }
-  else 
-    {
-      newEntry->entry     = entry;
-      newEntry->msg       = msgToSend;
-      newEntry->cid   = pChareID;        
-      
-      CpvAccess(outstanding_sends)++;
-      
-      CcdCallFnAfter((CcdVoidFn)SendMsgFn, (void *)newEntry, deltaT);
-    }
-} 
-
-/*****************************************************************************
-  This function adds a BOC call that will be made during a TimerChecks() call 
-  after a minimum delay of deltaT
- *****************************************************************************/
-void CallBocAfter(fn_ptr, bocNum, deltaT)
-    FUNCTION_PTR fn_ptr; int bocNum; unsigned int deltaT;
-{
-  CallBocStuff *newEntry;
-
-  if((newEntry = (CallBocStuff *) CmiAlloc(sizeof(CallBocStuff))) == NULL) 
-    {
-      CkMemError(newEntry);
-      return;
-    }
-  else 
-    {
-      newEntry->bocNum = bocNum;  
-      newEntry->fn_ptr = fn_ptr;  
-      CcdCallFnAfter((CcdVoidFn)CallBocFn, (void *)newEntry, deltaT);
-    } 
-} 
-
-/*****************************************************************************
-  In reality, this function adds a BOC call that will be made during each 
-  PeriodicChecks() call
- *****************************************************************************/
-void CallBocOnCondition(fn_ptr, bocNum)
-    FUNCTION_PTR fn_ptr; int bocNum;
-{
-  CallBocStuff *newEntry;
-
-  if((newEntry = (CallBocStuff *) CmiAlloc(sizeof(CallBocStuff))) == NULL) 
-    {
-      CkMemError(newEntry);
-      return;
-    }
-  else 
-    {
-      newEntry->bocNum = bocNum;  
-      newEntry->fn_ptr = fn_ptr;  
-      CcdPeriodicallyCall((CcdVoidFn)CallBocFn, (void *)newEntry);
-    } 
-} 
-
-/*****************************************************************************
-  Checks the static local variable outstanding_sends to see if all the 
-  delayed sends have been indeed sent off 
-  ****************************************************************************/
-int  NoDelayedMsgs()
-{
-  if(CpvAccess(outstanding_sends))
-    return 0;
-  else
-    return 1;
-}
-
-
diff --git a/src/ck-core/cplus.C b/src/ck-core/cplus.C
deleted file mode 100644 (file)
index 23175b3..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-#include "charm++.h"
-#include "trace.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#if CMK_STRINGS_USE_STRING_H
-#include <string.h>
-#endif
-#if CMK_STRINGS_USE_STRING_H
-#include <strings.h>
-#endif
-
-/* this is the handle of the main chare, used in place of MainChareID */
-/* If you make these Cpv or Csv, you have to change the charm++ xlator too */
-ChareIDType mainhandle;
-ChareIDType NULL_HANDLE;
-
-int _CK_NumTables = 0 ;
-/* distributed table ssv ids are assigned at run time with _CK_NumTables */
-
-
-/* These functions are exported from this file, and called from the core */
-extern "C" void StartQuiescence(int , ChareIDType *);
-extern "C" void CPlus_CallCharmInit(int, char **) ;
-extern "C" void CPlus_SetMainChareID() ;
-
-extern "C" void * CPlus_GetAccMsgPtr(_CK_Accumulator *) ;
-extern "C" void CPlus_CallCombineFn(_CK_Accumulator *acc, void *msg) ;
-extern "C" void CPlus_SetAccId(_CK_Accumulator *acc, int bocnum) ;
-extern "C" void *CPlus_CallAccInit(int id, void *msg) ;
-
-extern "C" void * CPlus_GetMonoMsgPtr(_CK_Monotonic *) ;
-extern "C" void CPlus_CallUpdateFn(_CK_Monotonic *mono, void *msg) ;
-extern "C" void CPlus_SetMonoId(_CK_Monotonic *mono, int bocnum) ;
-extern "C" void *CPlus_CallMonoInit(int id, void *msg) ;
-
-
-
-void *
-comm_object::operator new(CMK_SIZE_T size) 
-{
-       CmiPrintf("[%d] ERROR: wrong new operator for message allocation\n",CmiMyPe()) ;
-       return (void *)0;
-}
-
-void *
-_CK_Object::operator new(CMK_SIZE_T size) 
-{
-       CmiPrintf("[%d] ERROR: wrong new operator for chare object allocation\n",CmiMyPe()) ;
-       return (void *)0;
-}
-
-void * 
-_CK_Object::operator new(CMK_SIZE_T size, void *buf) 
-{
-        return buf ;
-}
-
-
-_CK_Object::_CK_Object() {
-        CHARE_BLOCK *chareblock = CpvAccess(currentChareBlock) ;
-        SetID_onPE(thishandle, CmiMyPe());
-        SetID_chare_magic_number(thishandle,GetID_chare_magic_number(chareblock->selfID)) ;
-        SetID_chareBlockPtr(thishandle, chareblock);
-#if CMK_DEBUG_MODE
-       putObject(this);
-#endif
-}
-
-_CK_Object::~_CK_Object() {
-#if CMK_DEBUG_MODE
-        removeObject(this);
-#endif
-}
-
-char *
-_CK_Object::showHeader(){
-  char *ret  = (char *)malloc(strlen("Default Header")+1);
-  strcpy(ret, "Default Header");
-  return(ret);  
-}
-
-char *
-_CK_Object::showContents(){
-  char *ret;
-
-  ret = (char *)malloc(sizeof(char) *50);
-  sprintf(ret, "Contents : %x", this);
-  return(ret);
-}
-
-groupmember::groupmember()
-{
-        CHARE_BLOCK *cblock = CpvAccess(currentChareBlock) ;
-        thisgroup = cblock->x.boc_num ;
-}
-
-
-
-
-
-
-
-
-void CPlus_StartQuiescence(int epnum, ChareIDType cid)
-{
-        StartQuiescence(epnum, &cid) ;
-}
-void CPlus_SetMainChareID()
-{
-  /* sets mainhandle, NULL_HANDLE etc */
-
-  SetID_onPE(mainhandle, 0);
-  if (CmiMyPe() == 0) 
-    SetID_chare_magic_number(mainhandle, 
-               GetID_chare_magic_number(CpvAccess(mainChareBlock)->selfID)) ;
-  else
-    SetID_chare_magic_number(mainhandle, 
-                               CpvAccess(mainChare_magic_number));
-  
-  SetID_chareBlockPtr(mainhandle, CpvAccess(mainChareBlock));
-
-  /* set the NULL_HANDLE field */
-  SetID_onPE(NULL_HANDLE, CK_PE_INVALID);
-}
-
-
-
-/**************************************************************************
-    FOLLOWING FUNCTIONS ARE FOR ACCS AND MONOS 
-**************************************************************************/
-
-void * CPlus_GetAccMsgPtr(_CK_Accumulator *acc)
-{
-       return(acc->_CK_GetMsgPtr()) ;
-}
-
-void CPlus_CallCombineFn(_CK_Accumulator *acc, void *msg)
-{
-       acc->_CK_Combine(msg) ;
-}
-
-void CPlus_SetAccId(_CK_Accumulator *acc, int bocnum)
-{
-       acc->_CK_MyId = bocnum ;
-}
-
-void *CPlus_CallAccInit(int id, void *msg)
-{
-/*     return( (CPlus_AccMonoFnTable[id-BASE_EP_NUM])(msg) ) ; */
-       return( ((ACCFNTYPE)(CsvAccess(PseudoTable)[id].initfn))(msg) ) ;
-}
-
-
-void * CPlus_GetMonoMsgPtr(_CK_Monotonic *mono)
-{
-       return(mono->_CK_GetMsgPtr()) ;
-}
-
-void CPlus_CallUpdateFn(_CK_Monotonic *mono, void *msg)
-{
-       mono->_CK_SysUpdate(msg) ;
-}
-
-void CPlus_SetMonoId(_CK_Monotonic *mono, int bocnum)
-{
-       mono->_CK_MyId = bocnum ;
-}
-
-void *CPlus_CallMonoInit(int id, void *msg)
-{
-       return( ((ACCFNTYPE)(CsvAccess(PseudoTable)[id].initfn))(msg) ) ;
-}
-
-FUNCTION_PTR CFunctionRefToName(int index)
-{
-       return (CsvAccess(_CK_9_GlobalFunctionTable)[index]) ;
-}
diff --git a/src/ck-core/dagger.h b/src/ck-core/dagger.h
deleted file mode 100644 (file)
index a505457..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#ifndef DAGGER_H
-#define DAGGER_H
-
-/* _dag3_WLIMIT is defined in dag.c dag.h also */
-#define _dag3_WLIMIT 8
-
-struct s_dag3_DAGVAR {
-    int index;
-    int init_value;
-    int counter;
-};
-
-struct s_dag3_RLNODE {
-    int    wno;
-    int    refnum;
-    struct s_dag3_RLNODE *next;
-};
-
-
-struct s_dag3_BUFFER {
-    int eno;
-    int refnum;
-    int expect;
-    int ecount;
-    int free_count;
-    void *msg;
-    struct s_dag3_BUFFER **prev;
-    struct s_dag3_BUFFER *next;
-};
-
-
-struct s_dag3_COUNT {
-    int refnum;
-    int value;
-    int bix;
-    struct s_dag3_BUFFER *bpa[_dag3_WLIMIT]; /* back pointer array */
-    struct s_dag3_COUNT  **prev;
-    struct s_dag3_COUNT  *next;
-};
-
-struct s_dag3_FREELIST {
-    int bcount;
-    int ccount;
-    struct s_dag3_BUFFER *b;
-    struct s_dag3_COUNT  *c;
-};
-
-struct s_dag3_RL {
-    int    dagexit;
-    struct s_dag3_COUNT *head;
-    struct s_dag3_COUNT *tail;
-};
-
-typedef struct s_dag3_COUNT _dag3_RLNODE;
-typedef struct s_dag3_RL     _dag3_RL;
-typedef struct s_dag3_BUFFER _dag3_BUFFER;
-typedef struct s_dag3_COUNT  _dag3_COUNT;
-typedef struct s_dag3_FREELIST _dag3_FREELIST;
-typedef struct s_dag3_DAGVAR _dag3_DAGVAR;
-typedef struct s_dag3_DAGVAR DAGVAR;
-typedef struct s_dag3_DAGVAR CONDVAR;
-
-extern _dag3_COUNT  *_dag4_mfc();
-extern _dag3_COUNT  *_dag4_nonmfc();
-extern _dag3_BUFFER *_dag4_mfb();
-extern _dag3_BUFFER *_dag4_nonmfb();
-extern _dag3_BUFFER *_dag4_fb();
-extern void         *_dag4_gb();
-
-/* DAG_NOREF define in dag.c also */
-#define DAG_NOREF 0
-#define expect(x,y) (*_CK_4mydata->_dag3_epf_fptr)(_CK_4mydata,x,y)
-#define dagExit()   (_CK_4mydata->_dag3_rl.dagexit = 1)
-#define eset(n,v)   (n=v)
-#define set(c,v)    (c.counter=v)
-#define inq(c)      (c.counter)
-#define decrement(c) (*_CK_4mydata->_dag3_cv_fptr)(_CK_4mydata,&(c),0,DAG_NOREF)
-#define ready(c,r) (*_CK_4mydata->_dag3_cv_fptr)(_CK_4mydata,&(c),(r==DAG_NOREF)?0:1,(r==DAG_NOREF)?((c.counter=1)-1):r)
-#define GetMyRefNumber() _CK_4mydata->_dag3_myrefnum
-message {int i;} _dag3_MSG;
-
-#ifdef STRACE
-/* trace function calls */
-extern _dag_s_sbranch1();
-extern _dag_s_sbranch2();
-extern _dag_s_broadcast();
-extern _dag_s_smsg();
-extern _dag_s_msetcond();
-extern _dag_s_endsend();
-
-
-#define dag_sendbranch1(e,m,p)    _dag_s_sbranch1(&_CK_4mydata->_dag3_cid,p,e,m)
-#define dag_sendbranch2(e,m,p,b)  _dag_s_sbranch2(b,p,e,m)
-#define dag_broadcast(e,m)        _dag_s_broadcast(&_CK_4mydata->_dag3_cid,e,m)
-#define dag_send(e,m,c)           _dag_s_smsg(c,e,m)
-#define dag_mwset()               (*_CK_4mydata->_dag3_mw_fptr)(_CK_4mydata)
-#define dag_mcset(c,v)            _dag_s_msetcond(c.index,v)
-#define dag_endsend()             _dag_s_endsend();
-
-#else
-
-#define dag_sendbranch1(e,m,p)
-#define dag_sendbranch2(e,m,p,b)  
-#define dag_broadcast(e,m)
-#define dag_send(e,m,c)
-#define dag_mwset()   
-#define dag_mcset(c,v) 
-#define dag_endsend()  
-
-#endif
-
-
-#endif
diff --git a/src/ck-core/debug-message.C b/src/ck-core/debug-message.C
new file mode 100644 (file)
index 0000000..49d6f2a
--- /dev/null
@@ -0,0 +1,261 @@
+#include "charm++.h"
+#include "ck.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "fifo.h"
+#include "queueing.h"
+
+#if CMK_DEBUG_MODE
+
+#define NUM_MESSAGES 100
+
+extern "C" void  CpdInitializeHandlerArray(void);
+extern void  handlerArrayRegister(int);
+extern char* genericViewMsgFunction(char *msg, int type);
+extern char* getMsgListSched(void);
+extern char* getMsgListPCQueue(void);
+extern char* getMsgListFIFO(void);
+extern char* getMsgListDebug(void);
+extern char* getMsgContentsSched(int index);
+extern char* getMsgContentsPCQueue(int index);
+extern char* getMsgContentsFIFO(int index);
+extern char* getMsgContentsDebug(int index);
+extern void  msgListCache(void);
+extern void  msgListCleanup(void);
+extern int   getCharmMsgHandlers(int *handleArray);
+extern char* getEnvInfo(envelope *env);
+extern char* getSymbolTableInfo(void);
+
+extern "C" void  CqsEnumerateQueue(Queue, void ***);
+extern "C" void  FIFO_Enumerate(FIFO_QUEUE*, void***);
+
+CpvDeclare(int*, handlerArray);
+CpvDeclare(int,  noOfHandlers);
+
+void **schedQueue=0;
+void **FIFOQueue=0;
+void **DQueue=0;
+
+int schedIndex;
+int debugIndex;
+int FIFOIndex;
+
+void msgListCleanup(void)
+{
+  if(schedQueue != 0) CmiFree(schedQueue);
+  if(FIFOQueue != 0) free(FIFOQueue);
+  if(DQueue != 0) free(DQueue);
+  schedIndex = 0;
+  FIFOIndex = 0;
+  debugIndex = 0;
+
+  schedQueue = 0;
+  FIFOQueue = 0;
+  DQueue = 0;
+}
+
+void msgListCache(void)
+{
+  CqsEnumerateQueue((Queue)CpvAccess(CsdSchedQueue), &schedQueue);
+  FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(CmiLocalQueue), &FIFOQueue);
+  schedIndex = 0;
+  FIFOIndex = 0;
+  debugIndex = 0;
+}
+
+extern "C"
+void CpdInitializeHandlerArray(void)
+{
+  CpvInitialize(int *, handlerArray);
+  CpvInitialize(int, noOfHandlers);
+  CpvAccess(handlerArray) = (int *)malloc(10 * sizeof(int));
+  CpvAccess(noOfHandlers) = 0;
+}
+
+void handlerArrayRegister(int hndlrID)
+{
+  CpvAccess(handlerArray)[CpvAccess(noOfHandlers)] = hndlrID;
+  CpvAccess(noOfHandlers)++;
+}
+
+static const char *ContentsNotKnown = 
+"Contents not known in this implementation."
+;
+
+static const char *HeaderUnknownFormat =
+"<HEADER>:Unknown # Format #"
+;
+
+// type = 0 header required
+//      = 1 contents required
+char* genericViewMsgFunction(char *msg, int type)
+{
+  int hndlrID;
+  char *unknownContentsMsg;
+  char *unknownFormatMsg;
+  char *temp;
+    
+  hndlrID = CmiGetHandler(msg);
+
+  //Look though the handlers in the handlerArray
+  //and perform the appropriate action
+  if((hndlrID == CpvAccess(handlerArray)[0]) || 
+     (hndlrID == CpvAccess(handlerArray)[1])){  // Charm handlers
+    //For now call the getEnvInfo function,
+    //Later, incorporate Milind's changes
+    if(type == 0){
+      return(getEnvInfo((envelope*) msg));
+    } else {
+      temp = (char *)malloc((strlen(ContentsNotKnown)+1) * sizeof(char));
+      strcpy(temp, ContentsNotKnown);
+      return(temp);
+    }
+  } else {
+    temp = (char *)malloc(strlen(HeaderUnknownFormat)+1);
+    strcpy(temp, HeaderUnknownFormat);
+    return(temp);
+  }
+}
+
+char* getMsgListSched(void)
+{
+  int ending;
+  int count = 0;
+  char *list;
+  char t[10];
+  int maxLength;
+
+  ending = NUM_MESSAGES;
+  if ( (ending + schedIndex) > ((Queue)(CpvAccess(CsdSchedQueue)))->length) {
+    ending = (((Queue)(CpvAccess(CsdSchedQueue)))->length) - schedIndex;
+  }
+  maxLength = ending * sizeof(char) * 20 + 1;
+  list = (char *)malloc(maxLength);
+  strcpy(list, "");
+
+  for(int i = schedIndex; i < ending + schedIndex; i++){
+    char *temp = genericViewMsgFunction((char *)schedQueue[i], 0);
+    if(strlen(list) + strlen(temp) + 10 > maxLength){ 
+      free(temp);
+      break;
+    }
+    strcat(list, temp);
+    strcat(list, "#");
+    sprintf(t, "%d", i);
+    strcat(list, t);
+    strcat(list, "#");
+    count++;
+    free(temp);
+  }
+  schedIndex += count;
+  return(list);
+}
+
+static const char *NotImpl = "Not Implemented";
+
+char* getMsgListPCQueue(void)
+{
+  char *list;
+
+  list = (char *)malloc(strlen(NotImpl)+1);
+  strcpy(list, NotImpl);
+  return(list);
+}
+
+char* getMsgListFIFO(void)
+{
+  int ending;
+  char *temp;
+  int count = 0;
+  char *list;
+  char t[10];
+  int maxLength;
+
+  ending = NUM_MESSAGES;
+  if ( (ending+FIFOIndex) > ((FIFO_QUEUE *)(CpvAccess(CmiLocalQueue)))->fill) {
+    ending = (((FIFO_QUEUE *)(CpvAccess(CmiLocalQueue)))->fill) - FIFOIndex;
+  }
+  maxLength = ending * sizeof(char) * 20 + 1;
+  list = (char *)malloc(maxLength);
+  strcpy(list, "");
+
+  for(int i=FIFOIndex; i < FIFOIndex+ending; i++){
+    temp = genericViewMsgFunction((char *)FIFOQueue[i], 0);
+    if(strlen(list) + strlen(temp) + 10 > maxLength){
+      free(temp); 
+      break;
+    }
+    strcat(list, temp);
+    strcat(list, "#");
+    sprintf(t, "%d", i);
+    strcat(list, t);
+    strcat(list, "#");
+    count++;
+    free(temp);
+  }
+  FIFOIndex += count;
+  return(list);
+}
+
+char* getMsgListDebug(void)
+{
+  int ending;
+  int count = 0;
+  char *list;
+  char t[10];
+  int maxLength;
+  char *temp;
+
+  ending = NUM_MESSAGES;
+  if ( (ending+debugIndex) > ((FIFO_QUEUE *)(CpvAccess(debugQueue)))->fill) {
+      ending = (((FIFO_QUEUE *)(CpvAccess(debugQueue)))->fill) - debugIndex;
+  }
+  maxLength = ending * sizeof(char) * 20 + 1;
+  list = (char *)malloc(maxLength);
+  strcpy(list, "");
+
+  FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(debugQueue), &DQueue);
+
+  for(int i=debugIndex; i < ending+debugIndex; i++){
+    temp = genericViewMsgFunction((char *)DQueue[i], 0);
+    if(strlen(list) + strlen(temp) + 10 > maxLength){ 
+      free(temp);
+      break;
+    }
+    strcat(list, temp);
+    strcat(list, "#");
+    sprintf(t, "%d", i);
+    strcat(list, t);
+    strcat(list, "#");
+    count++;
+    free(temp);
+  }
+  debugIndex += count;
+  return(list);
+}
+
+char* getMsgContentsSched(int index)
+{
+  return genericViewMsgFunction((char *)schedQueue[index], 1);
+}
+
+char* getMsgContentsPCQueue(int index)
+{
+  char *temp;
+  temp = (char *)malloc(strlen(NotImpl)+1);
+  strcpy(temp, NotImpl);
+  return(temp);
+}
+
+char* getMsgContentsFIFO(int index)
+{
+  return genericViewMsgFunction((char *)FIFOQueue[index], 1);
+}
+
+char* getMsgContentsDebug(int index)
+{
+  return genericViewMsgFunction((char *)DQueue[index], 1);
+}
+
+#endif
similarity index 57%
rename from src/ck-core/objectData.C
rename to src/ck-core/debug-object.C
index fb12bf3a3f7150d082a58a075831c1272d684c77..bba1ee93240bf122c85c6fbe5a61104b16040385 100644 (file)
@@ -1,45 +1,49 @@
-
-#include <iostream.h>
-#include <strstream.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
-#include <charm++.h>
+#include "charm++.h"
+#include "ck.h"
 
-#if CMK_DEBUG_MODE
+#include "debug-object.h"
 
-#include "objectData.h"
+#if CMK_DEBUG_MODE
 
 HashTable* objectTable;
 
-void putObject(_CK_Object* charePtr){
-  objectTable -> putObject(charePtr);
+void putObject(Chare* charePtr)
+{
+  objectTable->putObject(charePtr);
 }
 
-void removeObject(_CK_Object* charePtr){
-  objectTable -> removeObject(charePtr);
+void removeObject(Chare* charePtr)
+{
+  objectTable->removeObject(charePtr);
 }
 
-char* getObjectList(){
-  return(objectTable -> getObjectList());
+char* getObjectList(void)
+{
+  return(objectTable->getObjectList());
 }
 
-char* getObjectContents(int chareIndex){
-  return(objectTable -> getObjectContents(chareIndex));
+char* getObjectContents(int chareIndex)
+{
+  return(objectTable->getObjectContents(chareIndex));
 }
 
-HashTable::HashTable(){
+HashTable::HashTable()
+{
   chareIndex = 0;
   for(int i = 0; i < PRIME; i++)
     array[i] = 0;
 }
 
-HashTable::~HashTable(){
+HashTable::~HashTable()
+{
   struct HashTableElement *node, *temp;
 
   for(int i = 0; i < PRIME; i++){
     node = array[i];
-    while(node != NULL){
+    while(node != 0){
       temp = node;
       node = node -> next;
       free(temp);
@@ -47,32 +51,31 @@ HashTable::~HashTable(){
   }
 }
 
-void HashTable::putObject(_CK_Object* charePtr){
+void HashTable::putObject(Chare* charePtr)
+{
   struct HashTableElement *node;
   int pigeonHole;
   
   chareIndex = (int)charePtr;
   node = (struct HashTableElement *)malloc(sizeof(struct HashTableElement));
-  if(node == NULL){
-    CmiAbort("Memory overflow\n");
-  }
-  node -> charePtr = charePtr;
-  node -> chareIndex = chareIndex;
+  node->charePtr = charePtr;
+  node->chareIndex = chareIndex;
   pigeonHole = chareIndex % PRIME;
-  node -> next = array[pigeonHole];
+  node->next = array[pigeonHole];
   array[pigeonHole] = node;
 }
 
-void HashTable::removeObject(_CK_Object* charePtr){
+void HashTable::removeObject(Chare* charePtr)
+{
   int pigeonHole;
   struct HashTableElement *node, *prev;
   
   pigeonHole = (int)charePtr % PRIME;
-  prev = NULL;
+  prev = 0;
   node = array[pigeonHole];
-  while(node != NULL){
+  while(node != 0){
     if(node -> chareIndex == chareIndex){
-      if(prev == NULL){
+      if(prev == 0){
        array[pigeonHole] = node->next;
       } else {
        prev -> next = node -> next;
@@ -83,11 +86,11 @@ void HashTable::removeObject(_CK_Object* charePtr){
     prev = node;
     node = node -> next;
   }
-  cerr << "Erroneous chareIndex supplied in getObjectCOntents()" << endl
+  CkError("Erroneous chareIndex supplied in getObjectCOntents()\n")
 }
 
-char* HashTable::getObjectList(void){
-  strstream str;
+char* HashTable::getObjectList(void)
+{
   struct HashTableElement *node; 
   char *temp;
   char *list, *oldlist;
@@ -98,9 +101,8 @@ char* HashTable::getObjectList(void){
   strcpy(list, "");
   for(int i = 0; i < PRIME; i++){
     node = array[i];
-    while(node != NULL){
-      if ((node -> chareIndex != 0) && (node -> charePtr != NULL)){
-       //str << (node -> charePtr) -> showHeader() << "#" << (node -> chareIndex) << "#";
+    while(node != 0){
+      if ((node -> chareIndex != 0) && (node -> charePtr != 0)){
        temp = (node -> charePtr) -> showHeader();
        if((strlen(list) + strlen(temp) + 10) > maxLength){
          maxLength *= 2;
@@ -119,26 +121,26 @@ char* HashTable::getObjectList(void){
       node = node -> next;
     }
   }
-
-  //str << '\0';
-  //return str.str();
   return(list);
 }
 
-char* HashTable::getObjectContents(int chareIndex){
+char* HashTable::getObjectContents(int chareIndex)
+{
   struct HashTableElement *node;
   
   node = array[chareIndex % PRIME];
-  while(node != NULL){
+  while(node != 0){
     if(node -> chareIndex == chareIndex)
       return((node -> charePtr) -> showContents());
     node = node -> next;
   }
   
-  cerr << "Erroneous chareIndex supplied in getObjectCOntents()" << endl;
+  CkError("Erroneous chareIndex supplied in getObjectCOntents()\n");
 }
 
-void CpdInitializeObjectTable(){
+extern "C"
+void CpdInitializeObjectTable(void)
+{
   objectTable = new HashTable();
 }
 
similarity index 53%
rename from src/ck-core/objectData.h
rename to src/ck-core/debug-object.h
index dcc1a217bfe96087ad05243bb56020e609321c56..71517a8def14cbd3d2046d3bd19ed8abd8e7c882 100644 (file)
@@ -1,17 +1,19 @@
-#ifndef PROGRAM_DATA_H
-#define PROGRAM_DATA_H
+#ifndef _OBJECTDATA_H
+#define _OBJECTDATA_H
 
-#include <charm++.h>
+#include "charm++.h"
+
+#if CMK_DEBUG_MODE
 
 #define PRIME 17  // prime number for hash table
 
-char* getObjectList();
-char* getObjectContents();
-void putObject(_CK_Object* charePtr);
-void CpdInitializeObjectTable();
+extern char* getObjectList(void);
+extern char* getObjectContents(void);
+
+extern "C" void  CpdInitializeObjectTable(void);
 
 typedef struct HashTableElement {
-  _CK_Object* charePtr;
+  Chare* charePtr;
   int chareIndex;
   struct HashTableElement *next;
 };
@@ -20,14 +22,14 @@ class HashTable{
  public:
   HashTable();
   ~HashTable();
-  void putObject(_CK_Object* charePtr);
-  void removeObject(_CK_Object *charePtr);
+  void putObject(Chare* charePtr);
+  void removeObject(Chare* charePtr);
   char* getObjectList(void);
   char* getObjectContents(int chareIndex);
-
  private:
   HashTableElement *array[PRIME];
   int chareIndex;
 };
 
 #endif
+#endif
diff --git a/src/ck-core/defmain-cpp.C b/src/ck-core/defmain-cpp.C
deleted file mode 100644 (file)
index 096e41e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-extern "C" {
-#include "converse.h"
-void InitializeCharm(int argc, char **argv);
-void StartCharm(int argc, char **argv, void *whoknows);
-}
-
-void charm_init(int argc, char **argv)
-{
-  InitializeCharm(argc, argv);
-  StartCharm(argc, argv, (void *)0);
-}
-
-main(int argc, char **argv)
-{
-  ConverseInit(argc, argv, charm_init,0,0);
-}
diff --git a/src/ck-core/defmain-std.c b/src/ck-core/defmain-std.c
deleted file mode 100644 (file)
index 65e10dc..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#include "converse.h"
-
-void charm_init(argc, argv)
-int argc;
-char **argv;
-{
-  InitializeCharm(argc, argv);
-  StartCharm(argc, argv, (void *)0);
-}
-
-main(argc, argv)
-int argc;
-char *argv[];
-{
-  ConverseInit(argc, argv, charm_init,0,0);
-}
diff --git a/src/ck-core/dummy.cplus.c b/src/ck-core/dummy.cplus.c
deleted file mode 100644 (file)
index 02e83b1..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "converse.h"
-
-#if CMK_USE_HP_MAIN_FIX
-void _main(argc,argv)
-int argc;
-char *argv[];
-{
-}
-#endif
-
-void CPlus_ChareExit()
-{
-}
-
-
-void CPlus_GetAccMsgPtr()
-{}
-
-void CPlus_CallMonoInit()
-{}
-
-void CPlus_SetAccId()
-{}
-
-void CPlus_SetMonoId()
-{}
-
-void CPlus_CallCombineFn()
-{}
-
-void CPlus_CallAccInit()
-{}
-
-void CPlus_GetMonoMsgPtr()
-{}
-
-void CPlus_CallUpdateFn()
-{}
-
-
-void CPlus_SetMainChareID()
-{}
-
-/* projections.c calls this. For Charm++ files it is generated by translator*/
-void _CKmain_DumpNames() 
-{}
-
-void futuresModuleInit()
-{}
-
-void futuresCreateBOC()
-{}
diff --git a/src/ck-core/envelope.h b/src/ck-core/envelope.h
new file mode 100644 (file)
index 0000000..b3336ef
--- /dev/null
@@ -0,0 +1,194 @@
+#ifndef _ENVELOPE_H
+#define _ENVELOPE_H
+
+#define CINTBITS (sizeof(int)*8)
+
+typedef unsigned int   UInt;
+typedef unsigned short UShort;
+typedef unsigned char  UChar;
+
+#define SVM1     (sizeof(void*)-1)
+#define ALIGN(x) (((x)+SVM1)&(~(SVM1)))
+#define A(x)     ALIGN(x)
+#define D(x)     (A(x)-(x))
+#define PW(x)    ((x+CINTBITS-1)/CINTBITS)
+
+#define NewChareMsg  1
+#define NewVChareMsg 2
+#define BocInitMsg   3
+#define ForChareMsg  4
+#define ForBocMsg    5
+#define ForVidMsg    6
+#define FillVidMsg   7
+#define DBocReqMsg   8
+#define DBocNumMsg   9
+#define RODataMsg    10
+#define ROMsgMsg     11
+#define ExitMsg      12
+#define ReqStatMsg   13
+#define StatMsg      14
+
+// NewChareMsg : s1=epIdx
+// NewVChareMsg: ptr=vidPtr, s1=epIdx
+// ForChareMsg : ptr=objPtr, s1=epIdx
+// ForVidMsg   : ptr=vidPtr, s1=epIdx
+// FillVidMsg  : ptr=vidPtr
+// BocInitMsg  : i1=groupnum, s1=epIdx
+// DBocReqMsg  : ptr=usrmsg, s1=retEp
+// DBocNumMsg  : ptr=usrmsg, i1=groupnum, s1=retEp
+// RODataMsg   : i1=count
+// ROMsgMsg    : i1=roIdx
+// ForBocMsg   : i1=groupnum, s1=epidx
+
+class envelope {
+  private:
+    char   core[CmiExtHeaderSizeBytes];
+    void*  ptr;
+    UInt   event; // used by projections
+    UInt   pe;    // source processor
+    UInt   totalsize;
+    UInt   i1;
+    UShort s1;
+    UShort s2;
+    UShort priobits;
+    UChar  msgtype;
+    UChar  msgIdx;
+    UChar  queueing;
+    UChar  packed;
+    // to make envelope void* aligned
+    UChar padding[D(3*sizeof(UShort)+4*sizeof(UChar))];
+  public:
+    UInt   getEvent(void) { return event; }
+    void   setEvent(UInt e) { event = e; }
+    UInt   getRef(void) { return s2; }
+    void   setRef(UShort r) { s2 = r; }
+    UChar  getQueueing(void) { return queueing; }
+    void   setQueueing(UChar q) { queueing = q; }
+    UChar  getMsgtype(void) { return msgtype; }
+    void   setMsgtype(UChar m) { msgtype = m; }
+    UChar  getMsgIdx(void) { return msgIdx; }
+    void   setMsgIdx(UChar idx) { msgIdx = idx; }
+    UInt   getTotalsize(void) { return totalsize; }
+    void   setTotalsize(UInt s) { totalsize = s; }
+    UChar  isPacked(void) { return packed; }
+    void   setPacked(UChar p) { packed = p; }
+    UShort getPriobits(void) { return priobits; }
+    void   setPriobits(UShort p) { priobits = p; }
+    UShort getPrioWords(void) { return (priobits+CINTBITS-1)/CINTBITS; }
+    UShort getPrioBytes(void) { return getPrioWords()*sizeof(int); }
+    void*  getPrioPtr(void) { 
+      return (void *)((char *)this + totalsize - getPrioBytes());
+    }
+    UInt   getCount(void) { assert(msgtype==RODataMsg); return i1; }
+    void   setCount(UInt c) { assert(msgtype==RODataMsg); i1 = c; }
+    UInt   getRoIdx(void) { assert(msgtype==ROMsgMsg); return i1; }
+    void   setRoIdx(UInt r) { assert(msgtype==ROMsgMsg); i1 = r; }
+    static envelope *alloc(UChar type, UInt size=0, UShort prio=0)
+    {
+      assert(type>=NewChareMsg && type<=StatMsg);
+      register UInt tsize = sizeof(envelope)+ALIGN(size)+sizeof(int)*PW(prio);
+      register envelope *env = (envelope *)CmiAlloc(tsize);
+      env->msgtype = type;
+      env->totalsize = tsize;
+      env->priobits = prio;
+      env->packed = 0;
+      return env;
+    }
+    UShort getEpIdx(void) {
+      assert(msgtype==NewChareMsg || msgtype==NewVChareMsg
+          || msgtype==ForChareMsg || msgtype==ForVidMsg
+          || msgtype==BocInitMsg || msgtype==ForBocMsg);
+      return s1;
+    }
+    void   setEpIdx(UShort idx) {
+      assert(msgtype==NewChareMsg || msgtype==NewVChareMsg
+          || msgtype==ForChareMsg || msgtype==ForVidMsg
+          || msgtype==BocInitMsg || msgtype==ForBocMsg);
+      s1 = idx;
+    }
+    void*  getVidPtr(void) {
+      assert(msgtype==NewVChareMsg || msgtype==ForVidMsg
+          || msgtype==FillVidMsg);
+      return ptr;
+    }
+    void   setVidPtr(void *p) {
+      assert(msgtype==NewVChareMsg || msgtype==ForVidMsg
+          || msgtype==FillVidMsg);
+      ptr = p;
+    }
+    UInt   getSrcPe(void) { return pe; }
+    void   setSrcPe(UInt s) { pe = s; }
+    void*  getObjPtr(void) { assert(msgtype==ForChareMsg); return ptr; }
+    void   setObjPtr(void *p) { assert(msgtype==ForChareMsg); ptr = p; }
+    UShort getRetEp(void) { assert(msgtype==DBocReqMsg); return s1; }
+    void   setRetEp(UShort e) { assert(msgtype==DBocReqMsg); s1 = e; }
+    void*  getUsrMsg(void) { 
+      assert(msgtype==DBocReqMsg || msgtype==DBocNumMsg); 
+      return ptr; 
+    }
+    void   setUsrMsg(void *p) { 
+      assert(msgtype==DBocReqMsg || msgtype==DBocNumMsg); 
+      ptr = p; 
+    }
+    UInt   getGroupNum(void) {
+      assert(msgtype==BocInitMsg || msgtype==ForBocMsg
+          || msgtype==DBocNumMsg);
+      return i1;
+    }
+    void   setGroupNum(UInt g) {
+      assert(msgtype==BocInitMsg || msgtype==ForBocMsg
+          || msgtype==DBocNumMsg);
+      i1 = g;
+    }
+};
+
+static inline envelope *UsrToEnv(void *msg) {
+  return (((envelope *) msg)-1);
+}
+
+static inline void *EnvToUsr(envelope *env) {
+  return ((void *)(env+1));
+}
+
+static inline envelope *_allocEnv(int msgtype, int size=0, int prio=0) {
+  return envelope::alloc(msgtype,size,prio);
+}
+
+static inline void *_allocMsg(int msgtype, int size, int prio=0) {
+  return EnvToUsr(envelope::alloc(msgtype,size,prio));
+}
+
+extern UChar   _defaultQueueing;
+
+#define MAXMSGS 32
+
+class MsgPool {
+  private:
+    int num;
+    void *msgs[MAXMSGS];
+    void *_alloc(void) {
+      register envelope *env = _allocEnv(ForChareMsg,0,0);
+      env->setQueueing(_defaultQueueing);
+      env->setMsgIdx(0);
+      return EnvToUsr(env);
+    }
+  public:
+    MsgPool() { 
+      for(int i=0;i<MAXMSGS;i++)
+        msgs[i] = _alloc();
+      num = MAXMSGS;
+    }
+    void *get(void) {
+      return (num ? msgs[--num] : _alloc());
+    }
+    void put(void *m) {
+      if (num==MAXMSGS)
+        CkFreeMsg(m);
+      else
+        msgs[num++] = m;
+    }
+};
+
+CpvExtern(MsgPool*, _msgPool);
+
+#endif
diff --git a/src/ck-core/globals.c b/src/ck-core/globals.c
deleted file mode 100644 (file)
index 01febe5..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-#include "charm.h"
-#include <stdio.h>
-
-/**********************************************************************/
-/* Other global variables. */
-/**********************************************************************/
-CsvDeclare(int, TotalEps);
-CpvDeclare(int, NumReadMsg);
-CpvDeclare(int, MsgCount);     /* for the initial, pre-loop phase.
-                               to count up all the messages
-                               being sent out to nodes                 */
-CpvDeclare(int, InsideDataInit);
-CpvDeclare(int, mainChare_magic_number);
-CpvDeclare(CHARE_BLOCK_,  mainChareBlock);
-CpvDeclare(CHARE_BLOCK_, currentChareBlock);
-CpvDeclare(int, currentBocNum);
-CpvDeclare(int, MainDataSize);  /* size of dataarea for main chare     */
-
-
-CsvDeclare(FUNCTION_PTR*, ROCopyFromBufferTable);
-CsvDeclare(FUNCTION_PTR*, ROCopyToBufferTable);
-CsvDeclare(EP_STRUCT*, EpInfoTable);
-CsvDeclare(MSG_STRUCT*, MsgToStructTable);
-CsvDeclare(PSEUDO_STRUCT*, PseudoTable);
-CsvDeclare(char**, EventTable);
-CsvDeclare(int*, ChareSizesTable);
-CsvDeclare(char**, ChareNamesTable);
-
-CpvDeclare(int, msgs_processed);
-CpvDeclare(int, msgs_created);
-
-CpvDeclare(int, nodecharesCreated);
-CpvDeclare(int, nodeforCharesCreated);
-CpvDeclare(int, nodebocMsgsCreated);
-CpvDeclare(int, nodecharesProcessed);
-CpvDeclare(int, nodebocInitProcessed);
-CpvDeclare(int, nodebocMsgsProcessed);
-CpvDeclare(int, nodeforCharesProcessed);
-
-
-CpvDeclare(int, PrintChareStat); 
-CpvDeclare(int, PrintSummaryStat);
-CpvDeclare(int, QueueingDefault);
-
-CpvDeclare(int, RecdStatMsg);
-
-CpvDeclare(int, numHeapEntries);      /* heap of tme-dep calls   */
-CpvDeclare(int, numCondChkArryElts);  /* arry hldng conditon check info */
-
-
-CpvDeclare(int, _CK_13PackOffset);
-CpvDeclare(int, _CK_13PackMsgCount);
-CpvDeclare(int, _CK_13ChareEPCount);
-CpvDeclare(int, _CK_13TotalMsgCount);
-
-CsvDeclare(FUNCTION_PTR*,  _CK_9_GlobalFunctionTable);
-
-CsvDeclare(int, MainChareLanguage);
-
-/* Handlers for various message-types */
-CpvDeclare(int, HANDLE_INCOMING_MSG_Index);
-CsvDeclare(int, BUFFER_INCOMING_MSG_Index);
-CsvDeclare(int, MAIN_HANDLE_INCOMING_MSG_Index);
-CsvDeclare(int, HANDLE_INIT_MSG_Index);
-
-/* System-defined chare numbers */
-CsvDeclare(int, CkChare_ACC);
-CsvDeclare(int, CkChare_MONO);
-
-/* Entry points for Quiescence detection BOC   */
-CsvDeclare(int, CkEp_QD_Init);
-CsvDeclare(int, CkEp_QD_InsertQuiescenceList);
-CsvDeclare(int, CkEp_QD_PhaseIBroadcast);
-CsvDeclare(int, CkEp_QD_PhaseIMsg);
-CsvDeclare(int, CkEp_QD_PhaseIIBroadcast);
-CsvDeclare(int, CkEp_QD_PhaseIIMsg);
-
-/* Entry points for Write Once Variables       */
-CsvDeclare(int, CkEp_WOV_AddWOV);
-CsvDeclare(int, CkEp_WOV_RcvAck);
-CsvDeclare(int, CkEp_WOV_HostAddWOV);
-CsvDeclare(int, CkEp_WOV_HostRcvAck);
-
-/* Entry points for dynamic tables BOC         */
-CsvDeclare(int, CkEp_Tbl_Unpack);
-
-/* Entry points for accumulator BOC            */
-CsvDeclare(int, CkEp_ACC_CollectFromNode);
-CsvDeclare(int, CkEp_ACC_LeafNodeCollect);
-CsvDeclare(int, CkEp_ACC_InteriorNodeCollect);
-CsvDeclare(int, CkEp_ACC_BranchInit);
-
-/* Entry points for monotonic BOC              */
-CsvDeclare(int, CkEp_MONO_BranchInit);
-CsvDeclare(int, CkEp_MONO_BranchUpdate);
-CsvDeclare(int, CkEp_MONO_ChildrenUpdate);
-
-/* These are the entry points necessary for the dynamic BOC creation. */
-CsvDeclare(int, CkEp_DBOC_RegisterDynamicBocInitMsg);
-CsvDeclare(int, CkEp_DBOC_OtherCreateBoc);
-CsvDeclare(int, CkEp_DBOC_InitiateDynamicBocBroadcast);
-
-/* These are the entry points for the statistics BOC */
-CsvDeclare(int, CkEp_Stat_CollectNodes);
-CsvDeclare(int, CkEp_Stat_Data);
-CsvDeclare(int, CkEp_Stat_TraceCollectNodes);
-CsvDeclare(int, CkEp_Stat_BroadcastExitMessage);
-CsvDeclare(int, CkEp_Stat_ExitMessage);
-
-/* Entry points for LoadBalancing BOC          */
-CsvDeclare(int, CkEp_Ldb_NbrStatus);
-
-CsvDeclare(int, NumSysBocEps);
-
-
-/* Initialization phase count variables for synchronization */
-CpvDeclare(int,CkInitCount);
-CpvDeclare(int,CkCountArrived);
-
-
-/* Buffer for the non-init messages received during the initialization phase */
-CpvDeclare(void*, CkBuffQueue);
-
-
-/* Initialization phase flag : 1 if in the initialization phase */
-CpvDeclare(int, CkInitPhase);
-
-
-
-
-
-
-
-
-
-
-void globalsModuleInit()
-{
-   CpvInitialize(int, NumReadMsg);
-   CpvInitialize(int, MsgCount); 
-   CpvInitialize(int, InsideDataInit);
-   CpvInitialize(int, mainChare_magic_number);
-   CpvInitialize(CHARE_BLOCK_,  mainChareBlock);
-   CpvInitialize(CHARE_BLOCK_, currentChareBlock);
-   CpvInitialize(int, currentBocNum);
-   CpvInitialize(int, MainDataSize); 
-   CpvInitialize(int, msgs_processed);
-   CpvInitialize(int, msgs_created);
-   CpvInitialize(int, nodecharesCreated);
-   CpvInitialize(int, nodeforCharesCreated);
-   CpvInitialize(int, nodebocMsgsCreated);
-   CpvInitialize(int, nodecharesProcessed);
-   CpvInitialize(int, nodebocInitProcessed);
-   CpvInitialize(int, nodebocMsgsProcessed);
-   CpvInitialize(int, nodeforCharesProcessed);
-   CpvInitialize(int, PrintChareStat);
-   CpvInitialize(int, PrintSummaryStat);
-   CpvInitialize(int, QueueingDefault);
-   CpvInitialize(int, RecdStatMsg);
-   CpvInitialize(int, numHeapEntries);      
-   CpvInitialize(int, numCondChkArryElts); 
-   CpvInitialize(int, _CK_13PackOffset);
-   CpvInitialize(int, _CK_13PackMsgCount);
-   CpvInitialize(int, _CK_13ChareEPCount);
-   CpvInitialize(int, _CK_13TotalMsgCount);
-   CpvInitialize(int, CkInitPhase);
-   CpvInitialize(int, CkInitCount);
-   CpvInitialize(int, CkCountArrived);
-   CpvInitialize(void*, CkBuffQueue); 
-   CpvInitialize(int, HANDLE_INCOMING_MSG_Index);
-
-   CpvAccess(NumReadMsg)             = 0; 
-   CpvAccess(InsideDataInit)         = 0;
-   CpvAccess(currentBocNum)          = (NumSysBoc - 1); /* was set to  -1 */
-   CpvAccess(nodecharesCreated)      = 0;
-   CpvAccess(nodeforCharesCreated)   = 0;
-   CpvAccess(nodebocMsgsCreated)     = 0;
-   CpvAccess(nodecharesProcessed)    = 0;
-   CpvAccess(nodebocInitProcessed)   = 0;
-   CpvAccess(nodebocMsgsProcessed)   = 0;
-   CpvAccess(nodeforCharesProcessed) = 0;
-   CpvAccess(PrintChareStat)         = 0;
-   CpvAccess(PrintSummaryStat)       = 0;
-   CpvAccess(numHeapEntries)         = 0;  
-   CpvAccess(numCondChkArryElts)     = 0; 
-   CpvAccess(CkInitPhase)            = 1;
-   CpvAccess(CkInitCount)            = 0;
-   CpvAccess(CkCountArrived)         = 0; 
-   CpvAccess(CkBuffQueue)            = NULL;   
-
-   if (CmiMyRank() == 0) CsvAccess(MainChareLanguage)  = -1;
-}
diff --git a/src/ck-core/info.C b/src/ck-core/info.C
new file mode 100644 (file)
index 0000000..647627a
--- /dev/null
@@ -0,0 +1,145 @@
+#include "ck.h"
+#include "stdio.h"
+
+#if CMK_DEBUG_MODE
+
+int getCharmMsgHandlers(int *handleArray)
+{
+  *(handleArray) = _charmHandlerIdx;
+  *(handleArray+1) = _initHandlerIdx;
+  return(2);
+}
+
+CsvDeclare(int*,  BreakPoints);
+CsvDeclare(char*, SymbolTableInfo);
+
+CpvExtern(int*, handlerArray);
+CpvExtern(int,  noOfHandlers);
+
+char* getEnvInfo(envelope *env)
+{
+  char *returnInfo;
+  int size;
+  int chareIndex;
+  int epIndex = env->getEpIdx();
+  size = strlen(_entryTable[epIndex]->name)+1;
+  chareIndex = _entryTable[epIndex]->chareIdx;
+  size += strlen(_chareTable[chareIndex]->name)+1;
+  
+  returnInfo = (char *)malloc((size + 2) * sizeof(char));
+  strcpy(returnInfo, _entryTable[epIndex]->name);
+  strcat(returnInfo, "#");
+  strcat(returnInfo, _chareTable[chareIndex]->name);
+  strcat(returnInfo, "#");
+  return(returnInfo);
+}
+
+char* makeSymbolTableInfo(void)
+{
+  int i, chareIndex;
+  int size;
+  char *returnInfo;
+  char temp[10];
+  
+  size = _numEntries * 100;
+  returnInfo = (char *)malloc(size * sizeof(char));
+  strcpy(returnInfo, "");
+  for(i = 0; i < _numEntries; i++){
+    strcat(returnInfo, _entryTable[i]->name);
+    strcat(returnInfo, "#");
+    chareIndex = _entryTable[i]->chareIdx;
+    strcat(returnInfo, _chareTable[chareIndex]->name);
+    strcat(returnInfo, "#");
+    sprintf(temp, "%d", i);
+    strcat(returnInfo, temp);
+    strcat(returnInfo, "#");
+  }
+
+  return(returnInfo);
+}
+
+extern "C"
+void CpdInitializeBreakPoints(void)
+{
+  int i;
+
+  CsvInitialize(int *, BreakPoints);
+  CsvInitialize(char *, SymbolTableInfo);
+  CsvAccess(BreakPoints) = 0;
+  CsvAccess(SymbolTableInfo) = 0;
+}
+
+char *getSymbolTableInfo(void)
+{
+  if(CsvAccess(SymbolTableInfo) == 0) 
+    CsvAccess(SymbolTableInfo) = makeSymbolTableInfo();
+  return(CsvAccess(SymbolTableInfo));
+}
+
+void setBreakPoints(char *newBreakPoints)
+{
+  int i;
+  char *temp;
+
+  for(i = 0; i < _numEntries; i++)
+    CsvAccess(BreakPoints)[i] = (newBreakPoints[i] - '0');
+}
+
+char *getBreakPoints(void)
+{
+  char *temp;
+  int i;
+
+  if(CsvAccess(BreakPoints) == 0){
+    CsvAccess(BreakPoints) = (int *)malloc(_numEntries * sizeof(int));
+    for(i = 0; i < _numEntries; i++)
+      CsvAccess(BreakPoints)[i] = 0;
+  }
+
+  temp = (char *)malloc(_numEntries*2*sizeof(char)+6);
+  strcpy(temp, "");
+  sprintf(temp, "%d#", _numEntries);
+  for(i = 0; i < _numEntries; i++){
+    char t[3];
+    sprintf(t, "%d#", CsvAccess(BreakPoints)[i]);
+    strcat(temp, t);
+  }
+  return(temp);
+}
+
+int isBreakPoint(char *msg)
+{
+  envelope *env;
+  int epIndex;
+  int hndlrID;
+  int i;
+
+  if(CsvAccess(BreakPoints) == 0){
+    CsvAccess(BreakPoints) = (int *)malloc(_numEntries*sizeof(int));
+    for(i = 0; i < _numEntries; i++)
+      CsvAccess(BreakPoints)[i] = 0;
+  }
+  hndlrID = CmiGetHandler(msg);
+  if((hndlrID == CpvAccess(handlerArray)[0]) || 
+     (hndlrID == CpvAccess(handlerArray)[1])){
+    env = (envelope *)msg;
+    return(CsvAccess(BreakPoints)[env->getEpIdx()]);
+  } else {
+    return 0;
+  }
+}
+
+int isEntryPoint(char *msg)
+{
+  int hndlrID;
+
+  hndlrID = CmiGetHandler(msg);
+  if((hndlrID == CpvAccess(handlerArray)[0]) || 
+     (hndlrID == CpvAccess(handlerArray)[1])){
+    return 1;
+  } else {
+    return 0;
+  }
+} 
+
+#endif
diff --git a/src/ck-core/info.c b/src/ck-core/info.c
deleted file mode 100644 (file)
index a30ea17..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-#include <charm.h>
-
-#if CMK_DEBUG_MODE
-
-int getCharmMsgHandlers(int *handleArray){
-  *(handleArray) = CsvAccess(BUFFER_INCOMING_MSG_Index);
-  *(handleArray + 1) = CsvAccess(MAIN_HANDLE_INCOMING_MSG_Index);
-  return(2);
-}
-
-CsvDeclare(int *, BreakPoints);
-CsvDeclare(char *, SymbolTableInfo);
-
-CpvExtern(int *, handlerArray);
-CpvExtern(int, noOfHandlers);
-
-char* getEnvInfo(ENVELOPE *env){
-  char *returnInfo;
-  int size;
-  int chareIndex;
-  int epIndex = env -> EP;
-  size = strlen((CsvAccess(EpInfoTable) + epIndex) -> name)+1;
-  chareIndex = (CsvAccess(EpInfoTable) + epIndex) -> chareindex;
-  size += strlen((CsvAccess(ChareNamesTable))[chareIndex])+1;
-  
-  returnInfo = (char *)malloc((size + 2) * sizeof(char));
-  strcpy(returnInfo, (CsvAccess(EpInfoTable) + epIndex) -> name);
-  strcat(returnInfo, "#");
-  strcat(returnInfo, (CsvAccess(ChareNamesTable))[chareIndex]);
-  strcat(returnInfo, "#");
-  return(returnInfo);
-}
-
-char* makeSymbolTableInfo(){
-  int i, chareIndex;
-  int size;
-  char *returnInfo;
-  char temp[10];
-  
-  size = CsvAccess(TotalEps) * 100;
-  returnInfo = (char *)malloc(size * sizeof(char));
-  strcpy(returnInfo, "");
-  for(i = 0; i < CsvAccess(TotalEps); i++){
-    strcat(returnInfo, CsvAccess(EpInfoTable)[i].name);
-    strcat(returnInfo, "#");
-    chareIndex = CsvAccess(EpInfoTable)[i].chareindex;
-    strcat(returnInfo, CsvAccess(ChareNamesTable)[chareIndex]);
-    strcat(returnInfo, "#");
-    sprintf(temp, "%d", i);
-    strcat(returnInfo, temp);
-    strcat(returnInfo, "#");
-  }
-
-  return(returnInfo);
-}
-
-void CpdInitializeBreakPoints()
-{
-  int i;
-
-  CsvInitialize(int *, BreakPoints);
-  CsvInitialize(char *, SymbolTableInfo);
-  CsvAccess(BreakPoints) = 0;
-  CsvAccess(SymbolTableInfo) = 0;
-}
-
-char *getSymbolTableInfo()
-{
-  if(CsvAccess(SymbolTableInfo) == 0) 
-    CsvAccess(SymbolTableInfo) = makeSymbolTableInfo();
-  return(CsvAccess(SymbolTableInfo));
-}
-
-void setBreakPoints(char *newBreakPoints)
-{
-  int i;
-  char *temp;
-
-  for(i = 0; i < CsvAccess(TotalEps); i++)
-    CsvAccess(BreakPoints)[i] = (newBreakPoints[i] - '0');
-}
-
-char *getBreakPoints()
-{
-  char *temp;
-  int i;
-
-  if(CsvAccess(BreakPoints) == 0){
-    CsvAccess(BreakPoints) = (int *)malloc(CsvAccess(TotalEps) * sizeof(int));
-    for(i = 0; i < CsvAccess(TotalEps); i++)
-      CsvAccess(BreakPoints)[i] = 0;
-  }
-
-  temp = (char *)malloc(CsvAccess(TotalEps)*2*sizeof(char)+6);
-  strcpy(temp, "");
-  sprintf(temp, "%d#", CsvAccess(TotalEps));
-  for(i = 0; i < CsvAccess(TotalEps); i++){
-    char t[3];
-    sprintf(t, "%d#", CsvAccess(BreakPoints)[i]);
-    strcat(temp, t);
-  }
-  return(temp);
-}
-
-int isBreakPoint(char *msg)
-{
-  ENVELOPE *env;
-  int epIndex;
-  int hndlrID;
-  int i;
-
-  if(CsvAccess(BreakPoints) == 0){
-    CsvAccess(BreakPoints) = (int *)malloc(CsvAccess(TotalEps) * sizeof(int));
-    for(i = 0; i < CsvAccess(TotalEps); i++)
-      CsvAccess(BreakPoints)[i] = 0;
-  }
-  
-  hndlrID = CmiGetHandler(msg);
-
-  if((hndlrID == CpvAccess(handlerArray)[0]) || (hndlrID == CpvAccess(handlerArray)[1])){
-    env = (ENVELOPE *)msg;
-    return(CsvAccess(BreakPoints)[env->EP]);
-  }
-  else{
-    return 0;
-  }
-}
-
-int isEntryPoint(char *msg)
-{
-  int hndlrID;
-
-  hndlrID = CmiGetHandler(msg);
-
-  if((hndlrID == CpvAccess(handlerArray)[0]) || (hndlrID == CpvAccess(handlerArray)[1])){
-    return 1;
-  }
-  else{
-    return 0;
-  }
-} 
-
-#endif
diff --git a/src/ck-core/init.C b/src/ck-core/init.C
new file mode 100644 (file)
index 0000000..6d3da02
--- /dev/null
@@ -0,0 +1,345 @@
+#include "ck.h"
+
+UChar _defaultQueueing = CK_QUEUEING_FIFO;
+UInt  _printCS = 0;
+UInt  _printSS = 0;
+UInt  _numGroups = 0;
+UInt  _numInitMsgs = 0;
+int   _infoIdx;
+int   _charmHandlerIdx;
+int   _initHandlerIdx;
+int   _bocHandlerIdx;
+int   _qdHandlerIdx;
+
+CkOutStream ckout;
+CkErrStream ckerr;
+CkInStream  ckin;
+
+CpvDeclare(void*,       _currentChare);
+CpvDeclare(int,         _currentGroup);
+CpvDeclare(GroupTable*, _groupTable);
+CpvDeclare(Stats*, _myStats);
+CpvDeclare(MsgPool*, _msgPool);
+
+CpvDeclare(_CkOutStream*, _ckout);
+CpvDeclare(_CkErrStream*, _ckerr);
+
+CpvStaticDeclare(UInt,  _numInitsRecd);
+CpvStaticDeclare(PtrQ*, _buffQ);
+CpvStaticDeclare(PtrQ*, _bocInitQ);
+
+static int    _exitHandlerIdx;
+static Stats** _allStats = 0;
+static UInt   _numStatsRecd = 0;
+static int    _exitStarted = 0;
+
+static inline int _parseCommandLineOpts(int argc, char **argv)
+{
+  int found;
+  while(*argv) {
+    found = 0;
+    if(strcmp(*argv, "+cs")==0) {
+      _printCS = 1; found = 1;
+    } else if(strcmp(*argv, "+ss")==0) {
+      _printSS = 1; found = 1;
+    } else if(strcmp(*argv, "+fifo")==0) {
+      _defaultQueueing = CK_QUEUEING_FIFO; found = 1;
+    } else if(strcmp(*argv, "+lifo")==0) {
+      _defaultQueueing = CK_QUEUEING_LIFO; found = 1;
+    } else if(strcmp(*argv, "+ififo")==0) {
+      _defaultQueueing = CK_QUEUEING_IFIFO; found = 1;
+    } else if(strcmp(*argv, "+ilifo")==0) {
+      _defaultQueueing = CK_QUEUEING_ILIFO; found = 1;
+    } else if(strcmp(*argv, "+bfifo")==0) {
+      _defaultQueueing = CK_QUEUEING_BFIFO; found = 1;
+    } else if(strcmp(*argv, "+blifo")==0) {
+      _defaultQueueing = CK_QUEUEING_BLIFO; found = 1;
+    }
+    if(found) {
+      argc--;
+      char **next = argv;
+      while(*next) {
+        *next = *(next+1);
+        next++;
+      }
+    } else
+      argv++;
+  }
+  return argc;
+}
+
+static void _bufferHandler(void *msg)
+{
+  CmiGrabBuffer(&msg);
+  CpvAccess(_buffQ)->enq(msg);
+}
+
+static void _discardHandler(envelope *env)
+{
+  CmiGrabBuffer((void **)&env);
+  CmiFree(env);
+}
+
+
+static inline void _printStats(void)
+{
+  if(_printSS || _printCS) {
+    Stats *total = new Stats();
+    for(int i=0;i<CkNumPes();i++)
+      total->combine(_allStats[i]);
+    CkPrintf("Charm Kernel Summary Statistics:\n");
+    for(i=0;i<CkNumPes();i++) {
+      CkPrintf("Proc %d: [%d created, %d processed]\n", i, 
+               _allStats[i]->getCharesCreated(),
+               _allStats[i]->getCharesProcessed());
+    }
+    CkPrintf("Total Chares: [%d created, %d processed]\n",
+             total->getCharesCreated(), total->getCharesProcessed());
+  }
+  if(_printCS) {
+    CkPrintf("Charm Kernel Detailed Statistics:\n");
+    CkPrintf("PE\tCC\tCP\tFCC\tFCP\tGC\tGP\tFGC\tFGP\n");
+    for(int i=0;i<CkNumPes();i++) {
+      CkPrintf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",i,
+               _allStats[i]->getCharesCreated(),
+               _allStats[i]->getCharesProcessed(),
+               _allStats[i]->getForCharesCreated(),
+               _allStats[i]->getForCharesProcessed(),
+               _allStats[i]->getGroupsCreated(),
+               _allStats[i]->getGroupsProcessed(),
+               _allStats[i]->getGroupMsgsCreated(),
+               _allStats[i]->getGroupMsgsProcessed());
+    }
+  }
+}
+
+static inline void _sendStats(void)
+{
+  envelope *env = UsrToEnv(CpvAccess(_myStats));
+  env->setSrcPe(CkMyPe());
+  CmiSetHandler(env, _exitHandlerIdx);
+  CmiSyncSendAndFree(0, env->getTotalsize(), env);
+}
+
+static void _exitHandler(envelope *env)
+{
+  CmiGrabBuffer((void **)&env);
+  switch(env->getMsgtype()) {
+    case ExitMsg:
+      assert(CkMyPe()==0);
+      if(_exitStarted) {
+        CmiFree(env);
+        return;
+      }
+      _exitStarted = 1; 
+      CmiNumberHandler(_charmHandlerIdx,(CmiHandler)_discardHandler);
+      CmiNumberHandler(_bocHandlerIdx, (CmiHandler)_discardHandler);
+      env->setMsgtype(ReqStatMsg);
+      env->setSrcPe(CkMyPe());
+      CmiSyncBroadcastAllAndFree(env->getTotalsize(), env);
+      break;
+    case ReqStatMsg:
+      CmiNumberHandler(_charmHandlerIdx,(CmiHandler)_discardHandler);
+      CmiNumberHandler(_bocHandlerIdx, (CmiHandler)_discardHandler);
+      CmiFree(env);
+      _sendStats();
+      if(CkMyPe())
+        CsdExitScheduler();
+      break;
+    case StatMsg:
+      assert(CkMyPe()==0);
+      _allStats[env->getSrcPe()] = (Stats*) EnvToUsr(env);
+      _numStatsRecd++;
+      if(_numStatsRecd==CkNumPes()) {
+        _printStats();
+        CsdExitScheduler();
+      }
+      break;
+    default:
+      CmiAbort("Internal Error: Unknown-msg-type. Contact Developers.\n");
+  }
+}
+
+static inline void _processBufferedBocInits(void)
+{
+  register envelope *env;
+  CmiNumberHandler(_bocHandlerIdx, (CmiHandler)_processHandler);
+  while(env=(envelope *)CpvAccess(_bocInitQ)->deq()) {
+    if(env->isPacked() && _msgTable[env->getMsgIdx()]->unpack)
+      env = UsrToEnv(_msgTable[env->getMsgIdx()]->unpack(EnvToUsr(env)));
+    _processBocInitMsg(env);
+  }
+}
+
+static inline void _processBufferedMsgs(void)
+{
+  CmiNumberHandler(_charmHandlerIdx,(CmiHandler)_processHandler);
+  envelope *env;
+  while(env=(envelope*)CpvAccess(_buffQ)->deq()) {
+    CmiSyncSendAndFree(CkMyPe(), env->getTotalsize(), env);
+  }
+}
+
+static inline void _initDone(void)
+{
+  CmiNumberHandler(_exitHandlerIdx, (CmiHandler)_exitHandler);
+  _processBufferedBocInits();
+  _processBufferedMsgs();
+}
+
+static inline void _processROMsgMsg(envelope *env)
+{
+  *((char **)(_readonlyMsgs[env->getRoIdx()]->pMsg))=(char *)EnvToUsr(env);
+}
+
+static inline void _processRODataMsg(envelope *env)
+{
+  register int i;
+  register char *msg = (char *)EnvToUsr(env);
+  for(i=0;i<_numReadonlies;i++) {
+    memcpy(_readonlyTable[i]->ptr, msg, _readonlyTable[i]->size);
+    msg += _readonlyTable[i]->size;
+  }
+  CmiFree(env);
+}
+
+static void _initHandler(void *msg)
+{
+  assert(CkMyPe()!=0);
+  CpvAccess(_numInitsRecd)++;
+  CmiGrabBuffer(&msg);
+  register envelope *env = (envelope *) msg;
+  switch (env->getMsgtype()) {
+    case BocInitMsg:
+      CpvAccess(_qd)->process();
+      CpvAccess(_bocInitQ)->enq(msg);
+      break;
+    case ROMsgMsg:
+      CpvAccess(_qd)->process();
+      if(env->isPacked()) _unpackFn((void **)&env);
+      _processROMsgMsg(env);
+      break;
+    case RODataMsg:
+      CpvAccess(_qd)->process();
+      _numInitMsgs = env->getCount();
+      _processRODataMsg(env);
+      break;
+    default:
+      CmiAbort("Internal Error: Unknown-msg-type. Contact Developers.\n");
+  }
+  if(_numInitMsgs&&(CpvAccess(_numInitsRecd)==_numInitMsgs))
+    _initDone();
+}
+
+extern "C"
+void CkExit(void) 
+{
+  CmiNumberHandler(_charmHandlerIdx,(CmiHandler)_discardHandler);
+  CmiNumberHandler(_bocHandlerIdx, (CmiHandler)_discardHandler);
+  if(CkMyPe()==0) {
+    if(_exitStarted)
+      return;
+    envelope *env = _allocEnv(ReqStatMsg);
+    env->setSrcPe(CkMyPe());
+    CmiSetHandler(env, _exitHandlerIdx);
+    CmiSyncBroadcastAllAndFree(env->getTotalsize(), env);
+  } else {
+    envelope *env = _allocEnv(ExitMsg);
+    env->setSrcPe(CkMyPe());
+    CmiSetHandler(env, _exitHandlerIdx);
+    CmiSyncSendAndFree(0, env->getTotalsize(), env);
+  }
+}
+
+void _initCharm(int argc, char **argv)
+{
+  CpvInitialize(PtrQ*,_buffQ);
+  CpvInitialize(PtrQ*,_bocInitQ);
+  CpvInitialize(void*, _currentChare);
+  CpvInitialize(int, _currentGroup);
+  CpvInitialize(GroupTable*, _groupTable);
+  CpvInitialize(UInt, _numInitsRecd);
+  CpvInitialize(QdState*, _qd);
+  CpvInitialize(MsgPool*, _msgPool);
+
+  CpvInitialize(_CkOutStream*, _ckout);
+  CpvInitialize(_CkErrStream*, _ckerr);
+
+  CpvInitialize(Stats*, _myStats);
+
+  CpvAccess(_buffQ) = new PtrQ();
+  CpvAccess(_bocInitQ) = new PtrQ();
+  CpvAccess(_groupTable) = new GroupTable();
+  CpvAccess(_qd) = new QdState();
+  CpvAccess(_numInitsRecd) = 0;
+
+  CpvAccess(_ckout) = new _CkOutStream();
+  CpvAccess(_ckerr) = new _CkErrStream();
+
+  _charmHandlerIdx = CmiRegisterHandler((CmiHandler)_bufferHandler);
+  _initHandlerIdx = CmiRegisterHandler((CmiHandler)_initHandler);
+  _exitHandlerIdx = CmiRegisterHandler((CmiHandler)_bufferHandler);
+  _bocHandlerIdx = CmiRegisterHandler((CmiHandler)_initHandler);
+  _qdHandlerIdx = CmiRegisterHandler((CmiHandler)_qdHandler);
+  _infoIdx = CldRegisterInfoFn(_infoFn);
+
+#if CMK_DEBUG_MODE
+  handlerArrayRegister(_charmHandlerIdx);
+  handlerArrayRegister(_initHandlerIdx);
+#endif
+
+  _futuresModuleInit(); // part of futures implementation is a converse module
+  if(CmiMyRank()==0) {
+    argc = _parseCommandLineOpts(argc, argv);
+    _registerInit();
+    CkRegisterMsg("System", 0, 0, 0, sizeof(int));
+    _registerCkFutures();
+    CkRegisterMainModule();
+  }
+  CpvAccess(_msgPool) = new MsgPool();
+  CpvAccess(_myStats) = new Stats();
+  CmiNodeBarrier();
+  if(CmiMyPe()==0) {
+    _allStats = new Stats*[CkNumPes()];
+    register int i;
+    for(i=0;i<_numMains;i++) {
+      register int size = _chareTable[_mainTable[i]->chareIdx]->size;
+      register void *obj = malloc(size);
+      CpvAccess(_currentChare) = obj;
+      register CkArgMsg *msg = (CkArgMsg *)CkAllocMsg(0, sizeof(CkArgMsg), 0);
+      msg->argc = argc;
+      msg->argv = argv;
+      _entryTable[_mainTable[i]->entryIdx]->call(msg, obj);
+    }
+    CpvAccess(_myStats)->recordCreateChare(_numMains);
+    CpvAccess(_myStats)->recordProcessChare(_numMains);
+    for(i=0;i<_numReadonlyMsgs;i++) {
+      register void *roMsg = (void *) *((char **)(_readonlyMsgs[i]->pMsg));
+      if(roMsg==0)
+        continue;
+      register envelope *env = UsrToEnv(roMsg);
+      env->setSrcPe(CkMyPe());
+      env->setMsgtype(ROMsgMsg);
+      env->setRoIdx(i);
+      CmiSetHandler(env, _initHandlerIdx);
+      CldEnqueue(CLD_BROADCAST, env, _infoIdx);
+      CpvAccess(_qd)->create(CkNumPes()-1);
+      _numInitMsgs++;
+    }
+    register int roSize = 0;
+    for(i=0;i<_numReadonlies;i++)
+      roSize += _readonlyTable[i]->size;
+    register envelope *env = _allocEnv(RODataMsg, roSize);
+    register char *tmp;
+    for(tmp=(char *)EnvToUsr(env), i=0;i<_numReadonlies;i++) {
+      memcpy(tmp, _readonlyTable[i]->ptr, _readonlyTable[i]->size);
+      tmp += _readonlyTable[i]->size;
+    }
+    env->setCount(++_numInitMsgs);
+    env->setSrcPe(CkMyPe());
+    CmiSetHandler(env, _initHandlerIdx);
+    CmiSyncBroadcastAndFree(env->getTotalsize(), env);
+    CpvAccess(_qd)->create(CkNumPes()-1);
+    _initDone();
+  }
+}
diff --git a/src/ck-core/init.c b/src/ck-core/init.c
deleted file mode 100644 (file)
index 98dab6a..0000000
+++ /dev/null
@@ -1,771 +0,0 @@
-#include "charm.h"
-
-#include "trace.h"
-
-
-/* these two variables are set in registerMainChare() */
-CsvDeclare(int, _CK_MainChareIndex);
-CsvDeclare(int, _CK_MainEpIndex);
-
-CsvDeclare(int, ReadBuffSize); /* this is set in registerReadOnly() */
-CsvStaticDeclare(void **, _CK_9_ReadMsgTable); /* was previously global */
-
-CpvDeclare(char*, ReadBufIndex);
-CpvDeclare(char*, ReadFromBuffer);
-
-#define BLK_LEN 512
-CpvStaticDeclare(BOCINIT_QUEUE*, BocInitQueueHead);
-CpvStaticDeclare(ENVELOPE*, readvarmsg);
-
-static int EmptyBocInitMsgs();
-static void *BocInitQueueCreate();
-static void BocInitQueueDestroy();
-static void EnQueueBocInitMsgs();
-static ENVELOPE *DeQueueBocInitMsgs() ;
-
-/* these store argc, argv for use by CharmInit */
-CpvStaticDeclare(int,   userArgc);
-CpvStaticDeclare(char**,  userArgv);
-
-CpvStaticDeclare(int, NumChildrenDoneWithStartCharm);
-CpvStaticDeclare(FUNCTION_PTR, UserStartCharmDoneHandler);
-
-/* all these counts are incremented in register.c */
-CpvExtern(int,      fnCount);
-CpvExtern(int,      msgCount);
-CpvExtern(int,      chareCount);
-CpvExtern(int,      chareEpsCount);    /* count of chare AND boc eps */
-CpvExtern(int,      pseudoCount);
-CpvExtern(int,      readMsgCount);
-CpvExtern(int,      readCount);        /* count of read-only functions. Should be
-                                * same as total number of modules */
-CsvStaticDeclare(int, sharedReadCount); /* it holds the value of readCount, */
-                                        /* and it is  shared within node    */
-
-extern void CPlus_ProcessBocInitMsg(); /* in cplus_node_init.c */
-extern void CPlus_CallCharmInit();     /* in cplus_node_init.c */
-extern void CPlus_SetMainChareID();    /* in cplus_node_init.c */
-extern CHARE_BLOCK *CreateChareBlock();
-
-
-extern void BUFFER_INCOMING_MSG() ;
-extern void HANDLE_INCOMING_MSG() ;
-extern void HANDLE_INIT_MSG();
-
-void SysPeriodicCheckInit(void);
-void CharmRegisterHandlers();
-void InitializeEPTables();
-void AddSysBocEps(void);
-void BroadcastCount(void);
-void SysBocInit(void);
-
-void initModuleInit()
-{
-    CpvInitialize(char*, ReadBufIndex);
-    CpvInitialize(char*, ReadFromBuffer);
-    CpvInitialize(BOCINIT_QUEUE*, BocInitQueueHead);
-    CpvInitialize(int, userArgc);
-    CpvInitialize(char**, userArgv);
-    CpvInitialize(ENVELOPE*, readvarmsg);
-    CpvInitialize(int, NumChildrenDoneWithStartCharm);
-    CpvInitialize(FUNCTION_PTR, UserStartCharmDoneHandler);
-
-    CpvAccess(NumChildrenDoneWithStartCharm) = 0;
-    CpvAccess(BocInitQueueHead) = NULL;
-    if (CmiMyRank() == 0) CsvAccess(ReadBuffSize) = 0;
-}
-
-
-/*Added By Milind 05/02/95 */
-
-void _CkNullFunc()
-{
-       CmiPrintf("[%d] In Null Function: Module Uninitialized\n", CmiMyPe());
-}
-
-
-void InitializeCharm(argc, argv)
-int argc;
-char **argv;
-{
-/* these lines were in user_main */
-  if (CmiMyRank() != 0) CmiNodeBarrier();
-
-  bocModuleInit();
-  ckModuleInit();
-  condsendModuleInit();
-  globalsModuleInit();
-  initModuleInit();
-  mainModuleInit();
-  quiesModuleInit();
-  registerModuleInit();
-  statModuleInit();
-  tblModuleInit(); 
-  futuresModuleInit();
-
-  if (CmiMyRank() == 0) CmiNodeBarrier();
-}
-
-
-static void EndInitPhase()
-{
-  int i;
-  void  *buffMsg;
-  ENVELOPE *bocMsg;
-
-  CpvAccess(CkInitPhase) = 0;
-
-  
-  /* call all the CopyFromBuffer functions for ReadOnly variables.
-   * _CK_9_ReadMsgTable is passed as an arg because it is no longer
-   * global */
-  
-  if (CmiMyPe() != 0) {
-    if (CmiMyRank() == 0) {
-      for (i = 0; i < CsvAccess(sharedReadCount); i++)
-       (CsvAccess(ROCopyFromBufferTable)[i]) (CsvAccess(_CK_9_ReadMsgTable));
-    }
-    CmiFree(CpvAccess(readvarmsg));
-  
-    while ( (bocMsg=DeQueueBocInitMsgs()) != NULL )
-      ProcessBocInitMsg(bocMsg);
-    BocInitQueueDestroy();
-  }
-  
-  /* Charm is finally done Initializing */
-
-  if (CpvAccess(UserStartCharmDoneHandler))
-    CpvAccess(UserStartCharmDoneHandler)();
-  
-  /* process all the non-init messages arrived during the 
-     initialization */
-  while (!FIFO_Empty(CpvAccess(CkBuffQueue))  ) {
-    FIFO_DeQueue(CpvAccess(CkBuffQueue), &buffMsg);
-    CmiSetHandler(buffMsg, CpvAccess(HANDLE_INCOMING_MSG_Index));
-    CmiSyncSendAndFree(CmiMyPe(), GetEnv_TotalSize(buffMsg), buffMsg);
-  }
-}
-
-
-static void PropagateInitBarrier()
-{
-  if (CpvAccess(CkInitPhase) == 0) return;
-
-  if (CpvAccess(CkCountArrived) && CpvAccess(CkInitCount)==0) {
-    /* initialization phase is done, set the flag to 0 */
-    if (CpvAccess(NumChildrenDoneWithStartCharm)==
-        CmiNumSpanTreeChildren(CmiMyPe())) {
-      int parent = CmiSpanTreeParent(CmiMyPe());
-      void *msg = (void *)CkAllocMsg(0);
-      ENVELOPE *henv = ENVELOPE_UPTR(msg);
-      EndInitPhase();
-      if (parent == -1) {
-       SetEnv_msgType(henv, InitBarrierPhase2);
-       CmiSetHandler(henv, CsvAccess(HANDLE_INIT_MSG_Index));
-       CmiSyncBroadcastAllAndFree(GetEnv_TotalSize(henv), henv); 
-      } else {
-       SetEnv_msgType(henv, InitBarrierPhase1);
-        CmiSetHandler(henv, CsvAccess(HANDLE_INIT_MSG_Index));
-        CmiSyncSendAndFree(parent,GetEnv_TotalSize(henv), henv);
-      }
-    }
-  }
-}
-
-
-void StartCharm(argc, argv, donehandler)
-int argc;
-char **argv;
-FUNCTION_PTR donehandler;
-{
-       int             i;
-       char           *ReadBufMsg;
-
-        CpvAccess(UserStartCharmDoneHandler) = donehandler;
-        CpvAccess(userArgc) = ParseCommandOptions(argc, argv);
-        CpvAccess(userArgv) = argv;
-
-       InitializeMessageMacros();
-
-       /* CmiSpanTreeInit();  already done in CmiInitMc  -- Sanjeev 3/5/96 */
-
-        /* OtherQsInit(); this was combined with CsdInitialize */
-        StatInit();
-        InitializeDynamicBocMsgList();
-        InitializeBocDataTable();
-        InitializeBocIDMessageCountTable();
-        
-        CharmRegisterHandlers();
-
-#if CMK_DEBUG_MODE
-       handlerArrayRegister(CsvAccess(BUFFER_INCOMING_MSG_Index));
-       handlerArrayRegister(CsvAccess(MAIN_HANDLE_INCOMING_MSG_Index));
-#endif
-
-       /* set the main message handler to buffering handler */
-       /* after initialization phase, it will be assigned to regular handler */
-       CpvAccess(HANDLE_INCOMING_MSG_Index)
-             = CsvAccess(BUFFER_INCOMING_MSG_Index);
-
-        if (CmiMyRank() == 0) InitializeEPTables();
-        CmiNodeBarrier();          
-  
-        /* log_init(); Moved to convcore.c */
-        if(CpvAccess(traceOn))
-          trace_begin_computation();
-        SysBocInit();
-        CpvAccess(msgs_created) = CpvAccess(msgs_processed) = 0;
-
-       /* create the queue for non-init messages arrived
-          during initialization */
-        CpvAccess(CkBuffQueue) = (void *) FIFO_Create();
-
-
-       if (CmiMyPe() == 0)
-       {
-               CpvAccess(CkCountArrived)=1;
-
-               CpvAccess(MsgCount) = 0; 
-                                 /* count # of messages being sent to each
-                                * node. assume an equal number gets sent to
-                                * every one. if there is a difference, have
-                                * to modify this somewhat */
-               CpvAccess(InsideDataInit) = 1;
-
-               futuresCreateBOC();
-
-               CpvAccess(InsideDataInit) = 0;
-
-                if(CpvAccess(traceOn))
-                 trace_begin_charminit();
-                
-               CpvAccess(MainDataSize) = CsvAccess(ChareSizesTable)
-                                             [CsvAccess(_CK_MainChareIndex)];
-               CpvAccess(mainChareBlock) =
-                    CpvAccess(currentChareBlock) = 
-                       CreateChareBlock(CpvAccess(MainDataSize),
-                                        CHAREKIND_CHARE, 
-                                        CpvAccess(nodecharesProcessed)++);
-
-               if (CsvAccess(MainChareLanguage) == CHARMPLUSPLUS) 
-                       CPlus_SetMainChareID() ;  /* set mainhandle */
-
-
-               /* Calling CharmInit entry point */
-               CpvAccess(NumReadMsg) = 0;
-               CpvAccess(InsideDataInit) = 1;
-
-               (CsvAccess(EpInfoTable)[CsvAccess(_CK_MainEpIndex)].function)
-                               (NULL, CpvAccess(currentChareBlock)->chareptr,
-                                  CpvAccess(userArgc), CpvAccess(userArgv));
-               
-               CpvAccess(InsideDataInit) = 0;
-                if(CpvAccess(traceOn))
-                 trace_end_charminit();
-
-               /* create the buffer for the read only variables */
-               ReadBufMsg = (char *) CkAllocMsg(CsvAccess(ReadBuffSize));
-               CpvAccess(ReadBufIndex) = ReadBufMsg;
-               if (CsvAccess(ReadBuffSize) > 0)
-                       CkMemError(ReadBufMsg);
-
-               /*
-                * in Charm++ the CopyToBuffer fns also send out the
-                * ReadonlyMsgs by calling ReadMsgInit()
-                */
-               for (i = 0; i < CsvAccess(sharedReadCount); i++)
-                       (CsvAccess(ROCopyToBufferTable)[i]) ();
-
-               /*
-                * we are sending the id of the main chare along with the
-                * read only message. in future versions, we might eliminate
-                * this because the functionality can be expressed using
-                * readonly variables and MyChareID inside the main chare
-                */
-
-               BroadcastReadBuffer(ReadBufMsg, CsvAccess(ReadBuffSize), CpvAccess(mainChareBlock));
-
-               /*
-                * send a message with the count of initial messages sent so
-                * far, to all nodes; includes messages for read-buffer and
-                * bocs
-                */
-               BroadcastCount();
-               
-               PropagateInitBarrier();
-       }
-       else
-       {
-                       /* This is so that all PEs have consistent magic numbers for 
-                  BOCs. 0 is the magic # of main chare on proc 0, 
-                  all other procs have magic numbers from 1 */
-               CpvAccess(nodecharesProcessed) = 1 ;
-
-                /* create the boc init message queue */
-                CpvAccess(BocInitQueueHead) = (BOCINIT_QUEUE *) BocInitQueueCreate();
-       }
-
-       SysPeriodicCheckInit();
-}
-
-
-
-/*
- * This is the handler for initialization messages 
- * Start Boc's by allocating and filling the NodeBocTbl. 
- * When (a) the  "count" message is received and (b) "count" number of initial
- * messages are received, switch to the regular phase 
- */
-
-void HANDLE_INIT_MSG(env)
-ENVELOPE *env;
-{
-  int          i;
-  int          id;
-  int          type;
-  void         *usrMsg;
-  
-  CmiGrabBuffer((void **)&env);
-  if ((GetEnv_msgType(env) == BocInitMsg) ||
-      (GetEnv_msgType(env) == ReadMsgMsg))
-    UNPACK(env);
-  usrMsg = USER_MSG_PTR(env);
-  /* Have a valid message now. */
-  type = GetEnv_msgType(env);
-  
-  switch (type)
-    {
-    case BocInitMsg:
-      EnQueueBocInitMsgs(env);
-      CpvAccess(CkInitCount)++;
-      break;
-      
-    case InitCountMsg:
-      CpvAccess(CkCountArrived) = 1;
-      CpvAccess(CkInitCount) -= GetEnv_count(env);
-      CmiFree(env);
-      break;
-      
-    case ReadMsgMsg:
-      id = GetEnv_other_id(env);
-      CsvAccess(_CK_9_ReadMsgTable)[id] = (void *) usrMsg;
-      CpvAccess(CkInitCount)++; 
-      break;
-      
-    case ReadVarMsg:
-      CpvAccess(ReadFromBuffer) = usrMsg;
-      CpvAccess(CkInitCount)++; 
-      
-      /* get the information about the main chare */
-      CpvAccess(mainChareBlock) = (struct chare_block *)
-       GetEnv_chareBlockPtr(env);
-      CpvAccess(mainChare_magic_number) =
-       GetEnv_chare_magic_number(env);
-      if (CsvAccess(MainChareLanguage) == CHARMPLUSPLUS)
-       CPlus_SetMainChareID();
-      CpvAccess(readvarmsg) = env;
-      break;
-      
-    case InitBarrierPhase1:
-      CpvAccess(NumChildrenDoneWithStartCharm)++;
-      CmiFree(env);
-      break;
-      
-    case InitBarrierPhase2:
-      /* set the main handler to the unbuffering one */
-      CpvAccess(HANDLE_INCOMING_MSG_Index) = 
-          CsvAccess(MAIN_HANDLE_INCOMING_MSG_Index);
-      CmiFree(env);
-      break;
-      
-    default:
-      CmiPrintf("** ERROR ** Unknown message type in initialization phase%d\n",type);
-      
-    }
-  PropagateInitBarrier();
-}
-
-
-
-
-
-ProcessBocInitMsg(envelope)
-ENVELOPE       *envelope;
-{
-  CHARE_BLOCK    *bocBlock;
-  void           *usrMsg = USER_MSG_PTR(envelope);
-  int             current_ep = GetEnv_EP(envelope);
-  EP_STRUCT      *current_epinfo = CsvAccess(EpInfoTable) + current_ep;
-  int             current_bocnum = GetEnv_boc_num(envelope);
-  int             current_msgType = GetEnv_msgType(envelope);
-  int             current_chare = current_epinfo->chareindex;
-  int             current_magic = CpvAccess(nodecharesProcessed)++;
-  CHARE_BLOCK    *prev_chare_block;
-
-  CpvAccess(nodebocInitProcessed)++ ;
-
-  prev_chare_block = CpvAccess(currentChareBlock);
-  CpvAccess(currentChareBlock) = bocBlock = 
-               CreateChareBlock(CsvAccess(ChareSizesTable)[current_chare], 
-                                       CHAREKIND_BOCNODE, current_magic);
-  bocBlock->x.boc_num = current_bocnum;
-
-  SetBocBlockPtr(current_bocnum, bocBlock);
-  if(CpvAccess(traceOn))
-    trace_begin_execute(envelope);
-  (current_epinfo->function)(usrMsg, bocBlock->chareptr);
-  if(CpvAccess(traceOn))
-    trace_end_execute(current_magic, current_msgType, current_ep);
-  CpvAccess(currentChareBlock) = prev_chare_block;
-
-  /* for dynamic BOC creation, used in node_main.c */
-  return current_bocnum ;
-}
-
-
-/* this call can only be made after the clock has been initialized */
-
-void SysPeriodicCheckInit(void)
-{
-}
-
-
-int 
-ParseCommandOptions(argc, argv)
-int             argc;
-char          **argv;
-{
-  /* Removed Converse options into ConverseParseCommandOptions. - Sanjeev */
-  /*
-   * configure the chare kernel according to command line parameters.
-   * by convention, chare kernel parameters begin with '+'.
-   */
-  int             i, j, numSysOpts = 0, foundSysOpt = 0, end;
-  int             mainflag = 0, memflag = 0;
-  int             NumPes;
-  if (argc < 1)
-    {
-      CmiPrintf("Too few arguments. Usage> host_prog node_prog [...]\n");
-      exit(1);
-    }
-
-  end = argc;
-  if (CmiMyPe() == 0)
-    mainflag = 1;
-  
-  CpvAccess(QueueingDefault) = CK_QUEUEING_FIFO;
-  for (i = 1; i < end; i++) {
-    foundSysOpt = 0;
-    if (strcmp(argv[i], "+cs") == 0) {
-      CpvAccess(PrintChareStat) = 1;
-      /*
-       * if (mainflag) CmiPrintf("Chare Statistics Turned
-       * On\n");
-       */
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i], "+ss") == 0) {
-      CpvAccess(PrintSummaryStat) = 1;
-      /*
-       * if(mainflag)CmiPrintf("Summary Statistics Turned
-       * On\n");
-       */
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i],"+fifo")==0) {
-      CpvAccess(QueueingDefault) = CK_QUEUEING_FIFO;
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i],"+lifo")==0) {
-      CpvAccess(QueueingDefault) = CK_QUEUEING_LIFO;
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i],"+ififo")==0) {
-      CpvAccess(QueueingDefault) = CK_QUEUEING_IFIFO;
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i],"+ilifo")==0) {
-      CpvAccess(QueueingDefault) = CK_QUEUEING_ILIFO;
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i],"+bfifo")==0) {
-      CpvAccess(QueueingDefault) = CK_QUEUEING_BFIFO;
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i],"+blifo")==0) {
-      CpvAccess(QueueingDefault) = CK_QUEUEING_BLIFO;
-      foundSysOpt = 1;
-    } else if (strcmp(argv[i], "+p") == 0 && i + 1 < argc) {
-      sscanf(argv[i + 1], "%d", &NumPes);
-      foundSysOpt = 2;
-    } else if (sscanf(argv[i], "+p%d", &NumPes) == 1) {
-      foundSysOpt = 1;
-    }
-    if (foundSysOpt) {
-      /* if system option, remove it. */
-      numSysOpts += foundSysOpt;
-      end -= foundSysOpt;
-      for (j = i; j < argc - foundSysOpt; j++) {
-       argv[j] = argv[j + foundSysOpt];
-      }
-      /* reset i because we shuffled everything down one */
-      i--;
-    }
-  }
-  return (argc - numSysOpts);
-}
-
-
-
-#define TABLE_SIZE 256
-
-void CharmRegisterHandlers()
-{
-  /* Register the Charm handlers with Converse */
-  CsvAccess(BUFFER_INCOMING_MSG_Index)
-    = CmiRegisterHandler(BUFFER_INCOMING_MSG) ;
-  CsvAccess(MAIN_HANDLE_INCOMING_MSG_Index)
-    = CmiRegisterHandler(HANDLE_INCOMING_MSG) ;
-  CsvAccess(HANDLE_INIT_MSG_Index)
-    = CmiRegisterHandler(HANDLE_INIT_MSG);
-}
-
-void InitializeEPTables(void)
-{
-  int             i;
-  int             TotalFns;
-  int             TotalMsgs;
-  int             TotalChares;
-  int             TotalModules;
-  int             TotalReadMsgs;
-  int             TotalPseudos;
-  int             TotalEvents;
-  EP_STRUCT      *epinfo;
-  
-  /*
-   * TotalEps  =  _CK_5mainChareEPCount(); TotalFns    =
-   * _CK_5mainFunctionCount(); TotalMsgs       =  _CK_5mainMessageCount();
-   * TotalChares       =  _CK_5mainChareCount(); TotalBocEps   =
-   * NumSysBocEps + _CK_5mainBranchEPCount();
-   */
-  CsvAccess(TotalEps) = TABLE_SIZE;
-  TotalFns = TABLE_SIZE;
-  TotalMsgs = TABLE_SIZE;
-  TotalChares = TABLE_SIZE;
-  TotalModules = TABLE_SIZE;
-  TotalReadMsgs = TABLE_SIZE;
-  TotalPseudos = TABLE_SIZE;
-  TotalEvents = TABLE_SIZE;
-  
-  /*
-   * this table is used to store all ReadOnly Messages on processors
-   * other than proc 0. After they are received, they are put in the
-   * actual variables in the user program in the ...CopyFromBuffer
-   * functions
-   */
-  CsvAccess(_CK_9_ReadMsgTable) = (void **) 
-    CmiSvAlloc((TotalReadMsgs + 1) * sizeof(void *));
-  if (TotalReadMsgs > 0)
-    CkMemError(CsvAccess(_CK_9_ReadMsgTable));
-  
-  CsvAccess(ROCopyFromBufferTable) = (FUNCTION_PTR *) 
-    CmiSvAlloc((TotalModules + 1) * sizeof(FUNCTION_PTR));
-  
-  CsvAccess(ROCopyToBufferTable) = (FUNCTION_PTR *) 
-    CmiSvAlloc((TotalModules + 1) * sizeof(FUNCTION_PTR));
-  
-  if (TotalModules > 0)
-    {
-      CkMemError(CsvAccess(ROCopyFromBufferTable));
-      CkMemError(CsvAccess(ROCopyToBufferTable));
-    }
-  
-  epinfo=(EP_STRUCT*)CmiSvAlloc((CsvAccess(TotalEps)+1)*sizeof(EP_STRUCT));
-  CsvAccess(EpInfoTable)=epinfo;
-  if (CsvAccess(TotalEps) > 0) {
-    CkMemError(epinfo);
-    memset((char *)epinfo, 0, (CsvAccess(TotalEps)+1)*sizeof(EP_STRUCT));
-    for (i = 0; i < CpvAccess(chareEpsCount); i++)
-      epinfo[i].language = -1;
-  }
-  
-  CsvAccess(_CK_9_GlobalFunctionTable) = (FUNCTION_PTR *) 
-    CmiSvAlloc((TotalFns + 1) * sizeof(FUNCTION_PTR));
-  
-  if (TotalFns > 0)
-    CkMemError(CsvAccess(_CK_9_GlobalFunctionTable));
-  
-  
-  CsvAccess(MsgToStructTable) = (MSG_STRUCT *) 
-    CmiSvAlloc((TotalMsgs + 1) * sizeof(MSG_STRUCT));
-  
-  if (TotalMsgs > 0)
-    CkMemError(CsvAccess(MsgToStructTable));
-  
-  
-  CsvAccess(ChareSizesTable) = (int *) 
-    CmiSvAlloc((TotalChares + 1) * sizeof(int));
-  
-  CsvAccess(ChareNamesTable) = (char **) CmiSvAlloc(TotalChares * sizeof(char *));
-  
-  if (TotalChares > 0)
-    {
-      CkMemError(CsvAccess(ChareSizesTable));
-      CkMemError(CsvAccess(ChareNamesTable));
-    }
-  
-  CsvAccess(EventTable) = (char **) CmiSvAlloc(TotalEvents * sizeof(char *));
-
-  CsvAccess(PseudoTable) = (PSEUDO_STRUCT *) 
-    CmiSvAlloc((TotalPseudos + 1) * sizeof(PSEUDO_STRUCT));
-  
-  if (TotalPseudos > 0)
-    CkMemError(CsvAccess(PseudoTable));
-  
-  
-  
-  /** end of table allocation **/
-  
-  /* Register the NullFunction to detect uninitialized modules */
-  registerMsg("NULLMSG",_CkNullFunc,_CkNullFunc,_CkNullFunc,0) ;
-  registerEp("NULLEP",_CkNullFunc,0,0,0) ;
-  registerChare("NULLCHARE",0,_CkNullFunc) ;
-  registerFunction(_CkNullFunc) ;
-  registerMonotonic("NULLMONO",_CkNullFunc,_CkNullFunc,CHARM) ;
-  registerTable("NULLTABLE",_CkNullFunc,_CkNullFunc) ;
-  registerAccumulator("NULLACC",_CkNullFunc,_CkNullFunc,_CkNullFunc,CHARM) ;
-  
-  /* Register all the built-in BOC's */
-  AddSysBocEps();
-  CsvAccess(NumSysBocEps) = CpvAccess(chareEpsCount);
-
-  /*
-   * This is the top level call to all modules for initialization. It
-   * is generated at link time by charmc, in module_init_fn.c
-   */
-  _CK_module_init_fn();
-  
-  if ( CsvAccess(MainChareLanguage) == -1 ) {
-    CmiPrintf("[%d] ERROR: registerMainChare() not called : uninitialized module exists\n",CmiMyPe()) ;
-  }
-  
-
-
-  
-  /* set all the "Total" variables so that the rest of the modules work */
-  CsvAccess(TotalEps) = CpvAccess(chareEpsCount);
-  TotalFns = CpvAccess(fnCount);
-  TotalMsgs = CpvAccess(msgCount);
-  TotalChares = CpvAccess(chareCount);
-  TotalModules = CpvAccess(readCount);
-  TotalReadMsgs = CpvAccess(readMsgCount);
-  TotalPseudos = CpvAccess(pseudoCount);
-  
-  CsvAccess(sharedReadCount) = CpvAccess(readCount);
-}
-
-/* Adding entry points for system branch office chares. */
-void AddSysBocEps(void)
-{
-       QDAddSysBocEps();
-       WOVAddSysBocEps();
-       TblAddSysBocEps();
-       AccAddSysBocEps();
-       MonoAddSysBocEps();
-       DynamicAddSysBocEps();
-       StatAddSysBocEps();
-}
-
-
-/* Broadcast the count of messages that are received during initialization. */
-void BroadcastCount(void)
-{
-       ENVELOPE       *env;
-       void           *dummy_msg;
-       dummy_msg = (int *) CkAllocMsg(sizeof(int));
-       CkMemError(dummy_msg);
-       env = ENVELOPE_UPTR(dummy_msg);
-       SetEnv_msgType(env, InitCountMsg);
-
-       SetEnv_count(env, CpvAccess(currentBocNum) - NumSysBoc + 2 + CpvAccess(NumReadMsg));
-       CmiSetHandler(env,CsvAccess(HANDLE_INIT_MSG_Index));
-       CmiSyncBroadcastAndFree(GetEnv_TotalSize(env),env);
-}
-
-static int 
-EmptyBocInitMsgs()
-{
-       return (CpvAccess(BocInitQueueHead)->length == 0);
-}
-
-
-static void           *
-BocInitQueueCreate()
-{
-       BOCINIT_QUEUE  *queue;
-       queue = (BOCINIT_QUEUE *) CmiAlloc(sizeof(BOCINIT_QUEUE));
-       queue->block = (void **) CmiAlloc(sizeof(void *) * BLK_LEN);
-       queue->block_len = BLK_LEN;
-       queue->first = queue->block_len;
-       queue->length = 0;
-       return (void *) queue;
-}
-
-
-static void BocInitQueueDestroy()
-{
-    if (CpvAccess(BocInitQueueHead))
-    { 
-       if (CpvAccess(BocInitQueueHead)->block)
-          CmiFree(CpvAccess(BocInitQueueHead)->block);
-       CmiFree(CpvAccess(BocInitQueueHead));
-    } 
-}
-
-
-static void EnQueueBocInitMsgs(envelope)
-ENVELOPE       *envelope;
-{
-       int             num = GetEnv_boc_num(envelope);
-       int i ;
-
-       if (num > CpvAccess(BocInitQueueHead)->block_len)
-       {
-               void          **blk = CpvAccess(BocInitQueueHead)->block;
-               int             last;
-               CpvAccess(BocInitQueueHead)->block = (void **) CmiAlloc(sizeof(void *) * (num + BLK_LEN));
-               last = CpvAccess(BocInitQueueHead)->first + CpvAccess(BocInitQueueHead)->length;
-               for (i = CpvAccess(BocInitQueueHead)->first; i < last; i++)
-                       CpvAccess(BocInitQueueHead)->block[i] = blk[i];
-               CpvAccess(BocInitQueueHead)->block[num] = envelope;
-               CpvAccess(BocInitQueueHead)->length++;
-               CmiFree(blk);
-       }
-       else
-       {
-               CpvAccess(BocInitQueueHead)->block[num] = envelope;
-               CpvAccess(BocInitQueueHead)->length++;
-               if (CpvAccess(BocInitQueueHead)->first > num)
-                       CpvAccess(BocInitQueueHead)->first = num;
-       }
-}
-
-
-static ENVELOPE *DeQueueBocInitMsgs()
-{
-       ENVELOPE      *envelope;
-       if (CpvAccess(BocInitQueueHead)->length)
-       {
-               envelope = CpvAccess(BocInitQueueHead)->block[CpvAccess(BocInitQueueHead)->first++];
-               CpvAccess(BocInitQueueHead)->length--;
-       /*      if (!CpvAccess(BocInitQueueHead)->length)
-                       CpvAccess(BocInitQueueHead)->first = CpvAccess(BocInitQueueHead)->block_len;
-       */
-               return envelope ;
-       }
-       else
-               return NULL ;
-}
-
-void SysBocInit(void)
-{
-       QDBocInit();
-       TblBocInit();
-       WOVBocInit();
-       DynamicBocInit();
-       StatisticBocInit();
-}
diff --git a/src/ck-core/init.h b/src/ck-core/init.h
new file mode 100644 (file)
index 0000000..ef7b7b6
--- /dev/null
@@ -0,0 +1,87 @@
+#ifndef _INIT_H
+#define _INIT_H
+
+#define BLKSZ 32
+class PtrQ {
+    void **block;
+    int blklen;
+    int first;
+    int len;
+  public:
+    PtrQ() :len(0), first(0) {
+      block = new void*[blklen=BLKSZ];
+    }
+    ~PtrQ() { delete[] block; }
+    void *deq(void) {
+      void *ret=0;
+      if(len>0) {
+        len--;
+        ret = block[first];
+        first = (first+1)%blklen;
+      }
+      return ret;
+    }
+    void enq(void *elt) {
+      if(len==blklen) {
+        void **newblk = new void*[blklen+BLKSZ];
+        memcpy(newblk, block+first, sizeof(void*)*(blklen-first));
+        memcpy(newblk+blklen-first, block, sizeof(void*)*first);
+        delete[] block; block = newblk;
+        blklen += BLKSZ; first = 0;
+      }
+      block[(first+len)%blklen] = elt;
+      len++;
+      return;
+    }
+};
+
+// const inst MAXBINS = 32; in GroupTable is not allowed on solaris CC
+
+#define MAXBINS 32
+
+class GroupTable {
+  class TableEntry {
+    public:
+      int num;
+      void *obj;
+      TableEntry *next;
+      TableEntry(int _num, void *_obj, TableEntry* _next=0) :
+        num(_num), obj(_obj), next(_next) {}
+  };
+  TableEntry *bins[MAXBINS];
+  public:
+    GroupTable() { for(int i=0;i<MAXBINS;i++) bins[i] = 0;}
+    void add(int n, void *obj) {
+      int slot = n%MAXBINS;
+      bins[slot] = new TableEntry(n, obj, bins[slot]);
+    }
+    void *find(int n) {
+      TableEntry *next = bins[n%MAXBINS];
+      while(next!=0) {
+        if(next->num == n)
+          return next->obj;
+        next = next->next;
+      }
+      return 0;
+    }
+};
+
+extern UInt    _printCS;
+extern UInt    _printSS;
+
+extern UInt    _numGroups;
+extern int     _infoIdx;
+extern UInt    _numInitMsgs;
+extern int     _charmHandlerIdx;
+extern int     _initHandlerIdx;
+extern int     _bocHandlerIdx;
+extern int     _qdHandlerIdx;
+
+CpvExtern(void*,       _currentChare);
+CpvExtern(int,         _currentGroup);
+CpvExtern(GroupTable*, _groupTable);
+
+extern void _initCharm(int argc, char **argv);
+extern void _processBocInitMsg(envelope *);
+
+#endif
diff --git a/src/ck-core/main.C b/src/ck-core/main.C
new file mode 100644 (file)
index 0000000..40e70d8
--- /dev/null
@@ -0,0 +1,7 @@
+#include "ck.h"
+
+int main(int argc, char **argv)
+{
+  ConverseInit(argc, argv, _initCharm, 0, 0);
+  return 0;
+}
diff --git a/src/ck-core/main.c b/src/ck-core/main.c
deleted file mode 100644 (file)
index 367ce0d..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/*************************************************************************/
-/** This file now contains only the Charm/Charm++ part of the run-time.
-    The core (scheduler/Converse) part is in converse.c                 */
-/*************************************************************************/
-
-#include "charm.h"
-
-#include "trace.h"
-
-CHARE_BLOCK *GetBocBlockPtr();
-
-extern void CkLdbSend();
-void HANDLE_INCOMING_MSG();
-
-void mainModuleInit()
-{
-}
-
-void CheckMagicNumber(chare, env)
-    CHARE_BLOCK *chare; ENVELOPE *env;
-{
-  if (GetID_chare_magic_number(chare->selfID) !=
-      GetEnv_chare_magic_number(env)) {
-    CmiPrintf("[%d] *** ERROR *** dead chare or bad chareID used at entry point %s.\n", 
-             CmiMyPe(), CsvAccess(EpInfoTable)[GetEnv_EP(env)].name);
-    exit(1);
-  }
-}
-
-void CkProcess_ForChareMsg_to_UVID(env)
-ENVELOPE *env;
-{
-  if(CpvAccess(traceOn))
-    trace_begin_execute(env);
-  VidEnqueueMsg(env);
-  if(CpvAccess(traceOn))
-    trace_end_execute(0, ForChareMsg, 0);
-  QDCountThisProcessing();
-}
-
-void CkProcess_ForChareMsg_to_FVID(env)
-ENVELOPE *env;
-{
-  if(CpvAccess(traceOn))
-    trace_begin_execute(env);
-  VidForwardMsg(env);
-  if(CpvAccess(traceOn))
-    trace_end_execute(0, ForChareMsg, 0);
-  QDCountThisProcessing();
-}
-
-void CkProcess_ForChareMsg_to_Chare(env)
-ENVELOPE *env;
-{
-  CHARE_BLOCK *chareblock;
-  int          current_ep;
-  EP_STRUCT   *current_epinfo;
-  void        *current_usr;
-  int          current_magic;
-  int          current_msgType;
-
-  chareblock      = GetEnv_chareBlockPtr(env);
-  current_ep      = GetEnv_EP(env);
-  current_epinfo  = CsvAccess(EpInfoTable) + current_ep;
-  current_usr     = USER_MSG_PTR(env);
-  current_msgType = GetEnv_msgType(env);
-
-  CpvAccess(currentChareBlock) = (void *)chareblock;
-  CpvAccess(nodeforCharesProcessed)++;
-  if(CpvAccess(traceOn)) {
-    current_magic   = chareblock->selfID.magic;
-    trace_begin_execute(env);
-    (current_epinfo->function)(current_usr,chareblock->chareptr);
-    trace_end_execute(current_magic, current_msgType, current_ep);
-  } else {
-    (current_epinfo->function)(current_usr,chareblock->chareptr);
-  }
-  if((current_msgType!=QdBocMsg)&&(current_msgType!=QdBroadcastBocMsg)&&
-     (current_msgType!=LdbMsg))
-    QDCountThisProcessing();
-}
-
-void CkProcess_ForChareMsg(env)
-ENVELOPE *env;
-{
-  CHARE_BLOCK *chare = GetEnv_chareBlockPtr(env);
-  CheckMagicNumber(chare, env);
-  switch (chare->charekind) {
-    case CHAREKIND_UVID: CkProcess_ForChareMsg_to_UVID(env); break;
-    case CHAREKIND_FVID: CkProcess_ForChareMsg_to_FVID(env); break;
-    case CHAREKIND_CHARE: CkProcess_ForChareMsg_to_Chare(env); break;
-    case CHAREKIND_BOCNODE: CkProcess_ForChareMsg_to_Chare(env); break;
-  }
-}
-
-void CkProcess_BocMsg(env)
-ENVELOPE *env;
-{
-  CHARE_BLOCK *chare;
-  chare = GetBocBlockPtr(GetEnv_boc_num(env));
-  SetEnv_chareBlockPtr(env, chare);
-  CkProcess_ForChareMsg_to_Chare(env);
-}
-
-void CkProcess_DynamicBocInitMsg(env)
-ENVELOPE *env;
-{
-  /* ProcessBocInitMsg handles Charm++ bocs properly */
-  /* This process of registering the new boc using the */
-  /* spanning tree is exactly the same for Charm++ */
-  int current_msgType, executing_boc_num;
-
-  current_msgType = GetEnv_msgType(env);
-  executing_boc_num = ProcessBocInitMsg(env);
-  RegisterDynamicBocInitMsg(&executing_boc_num, NULL);
-  if((current_msgType!=QdBocMsg)&&(current_msgType!=QdBroadcastBocMsg)&&
-     (current_msgType!=LdbMsg))
-    QDCountThisProcessing();
-}
-
-void CkProcess_NewChareMsg(env)
-ENVELOPE *env;
-{
-  int current_ep, current_msgType, current_magic, current_chare;
-  void *current_usr;
-  CHARE_BLOCK *current_block;
-  EP_STRUCT *current_epinfo;
-  CHARE_BLOCK *CreateChareBlock();
-
-  current_ep = GetEnv_EP(env);
-  current_epinfo = CsvAccess(EpInfoTable) + current_ep;
-  current_chare = current_epinfo->chareindex;
-  current_usr = USER_MSG_PTR(env);
-  current_msgType = GetEnv_msgType(env);
-  current_magic = CpvAccess(nodecharesProcessed)++;
-  CpvAccess(currentChareBlock) = current_block = CreateChareBlock(
-                                   CsvAccess(ChareSizesTable)[current_chare],
-                                   CHAREKIND_CHARE, current_magic);
-
-  /* If virtual block exists, get all messages for this chare  */
-  if (GetEnv_vidBlockPtr(env))
-    VidRetrieveMessages(current_block,
-           GetEnv_vidPE(env),
-           GetEnv_vidBlockPtr(env));
-
-  /* Now call the entry point : For Charm, this is the actual call to the 
-     EP function. For Charm++, this is a call to the translator-generated
-     stub function which does "new ChareType(msg)". 
-     NOTE: CreateChareBlock sets current_block->chareptr to (current_block + 1)
-     because ChareSizesTable[] holds the correct size of the chare for both 
-     Charm and Charm++, so it allocates the correct amount of space.
-     - Sanjeev 10/10/95 */
-
-  if(CpvAccess(traceOn))
-    trace_begin_execute(env);
-  (current_epinfo->function)(current_usr, current_block->chareptr);
-  if(CpvAccess(traceOn))
-    trace_end_execute(current_magic, current_msgType, current_ep);
-  if((current_msgType!=QdBocMsg)&&(current_msgType!=QdBroadcastBocMsg)&&
-     (current_msgType!=LdbMsg))
-    QDCountThisProcessing();
-}
-
-void CkProcess_VidSendOverMsg(env)
-ENVELOPE *env;
-{
-  int current_msgType; void *current_usr;
-  
-  current_msgType = GetEnv_msgType(env);
-  current_usr = USER_MSG_PTR(env);
-  if(CpvAccess(traceOn))
-    trace_begin_execute(env);
-  VidSendOverMessages(current_usr, NULL);
-  if(CpvAccess(traceOn))
-    trace_end_execute(0, current_msgType, 0);
-  if((current_msgType!=QdBocMsg)&&(current_msgType!=QdBroadcastBocMsg)&&
-     (current_msgType!=LdbMsg))
-  QDCountThisProcessing();
-}
-
-
-
-
-/* This is the message handler for non-init messages during the
-   initialization phase. It simply buffers the messafe */
-void BUFFER_INCOMING_MSG(env)
-ENVELOPE *env;
-{
-  if (CpvAccess(CkInitPhase)) {
-    CmiGrabBuffer((void **)&env);
-    FIFO_EnQueue(CpvAccess(CkBuffQueue),(void *)env);
-  } else {
-    HANDLE_INCOMING_MSG(env);
-  }
-}
-
-
-/* This is the handler function for Charm and Charm++, which is called
-   immediately when a message is received (from self or network) */
-
-void HANDLE_INCOMING_MSG(env)
-ENVELOPE *env;
-{
-  CmiGrabBuffer((void **)&env);
-  UNPACK(env);
-  if(CpvAccess(traceOn))
-    trace_enqueue(env);
-  switch (GetEnv_msgType(env)) {
-  case NewChareMsg:          CkProcess_NewChareMsg(env); break;
-  case ForChareMsg:          CkProcess_ForChareMsg(env); break;
-  case LdbMsg:               CkProcess_BocMsg(env); break;
-  case QdBocMsg:             CkProcess_BocMsg(env); break;
-  case QdBroadcastBocMsg:    CkProcess_BocMsg(env); break;
-  case ImmBocMsg:            CkProcess_BocMsg(env); break;
-  case ImmBroadcastBocMsg:   CkProcess_BocMsg(env); break;
-  case BocMsg:               CkProcess_BocMsg(env); break;
-  case BroadcastBocMsg:      CkProcess_BocMsg(env); break;
-  case VidSendOverMsg:       CkProcess_VidSendOverMsg(env); break;
-  case DynamicBocInitMsg:    CkProcess_DynamicBocInitMsg(env); break;
-  case NewChareNoBalanceMsg:
-    CmiAbort("** ERROR ** obsolete message type.\n");
-  default:
-    CmiAbort("** ERROR ** bad message type.\n");
-  }
-}
-
-
diff --git a/src/ck-core/memstuff.c b/src/ck-core/memstuff.c
deleted file mode 100644 (file)
index 466c84d..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-#include <stdio.h>
-
-#define _CK_MEMORY_MANAGER
-#include "charm.h"
-#undef _CK_MEMORY_MANAGER
-
-#define align(var) ((var+sizeof(void *)-1)&(~(sizeof(void *)-1)))
-
-#include "trace.h" 
-void *CkAllocPackBuffer(msg, bytespacked)
-char *msg;
-unsigned int bytespacked;
-{
-  int i;
-  unsigned int priowords;
-  unsigned int headersize;
-  unsigned int totalsize;
-  unsigned int *ptr1, *ptr2;
-  ENVELOPE *envelope, *pack_envelope;
-  
-  bytespacked = align(bytespacked);
-  priowords = GetEnv_priowords(ENVELOPE_UPTR(msg));
-  totalsize = TOTAL_MSG_SIZE(bytespacked, priowords);
-  pack_envelope = (ENVELOPE *)CmiAlloc(totalsize);
-  
-  /*** Now we need to copy the envelope, then adjust totalsize  ***/
-  envelope = ENVELOPE_UPTR(msg); 
-  headersize = (msg - (char *) envelope);
-  memcpy( ((char *) pack_envelope), ((char *) envelope), headersize);
-  SetEnv_TotalSize(pack_envelope,totalsize);
-  SetEnv_packid(pack_envelope,GetEnv_packid(envelope));
-  
-  /*** Now we copy the priority field ***/
-  ptr1 = GetEnv_prioend(envelope);
-  ptr2 = GetEnv_prioend(pack_envelope);
-  while (priowords) { *(--ptr2) = *(--ptr1); priowords--; }
-  return((void *)USER_MSG_PTR(pack_envelope));
-}
-
-
-ENVELOPE *badmsg;
-
-void *CkAllocMsg(msgbytes)
-unsigned int msgbytes;
-{
-  unsigned int totalsize;
-  ENVELOPE *envptr;
-  
-  msgbytes = align(msgbytes);
-  totalsize = TOTAL_MSG_SIZE(msgbytes, 0);
-  envptr = (ENVELOPE *)CmiAlloc(totalsize);
-  if (envptr == badmsg) {
-    CmiPrintf("Bad Message.\n");
-  }
-  CkMemError(envptr);
-  SetEnv_isPACKED(envptr, NO_PACK);
-  SetEnv_TotalSize(envptr, totalsize);
-  SetEnv_packid(envptr, 0);
-  SetEnv_queueing(envptr, CpvAccess(QueueingDefault));
-  SetEnv_priosize(envptr, 0);
-  return((void *)USER_MSG_PTR(envptr));
-}
-
-
-
-
-void CkFreeMsg(ptr)
-char *ptr;
-{
-    ENVELOPE *envptr;
-
-    envptr = ENVELOPE_UPTR(ptr);
-    CmiFree(envptr);
-}
-
-
-/* Makes a copy of the envelope and the priority fields of the message passed
-   to it and returns the envelope */
-
-ENVELOPE *CkCopyEnv(env)
-ENVELOPE *env ;
-{
-  int size = GetEnv_TotalSize(env) ;   /* size of env in bytes */
-  ENVELOPE *newenv ;
-  
-  newenv = (ENVELOPE *) CmiAlloc(size) ;
-  memcpy(newenv, env, size) ;
-  
-  return(newenv) ;
-}
-
-/* Makes a copy of the entire system message (Envelope, priorities, user 
-   message et al.) and returns a pointer to the user message */
-
-void *CkCopyMsg(sourceUptr)
-char *sourceUptr ;
-{
-  int size ;
-  ENVELOPE *env, *newenv;
-  
-  env = ENVELOPE_UPTR(sourceUptr) ;
-  
-  PACK(env);
-  size = GetEnv_TotalSize(env) ;   /* size of env in bytes */
-  newenv = (ENVELOPE *) CmiAlloc(size) ;
-  memcpy(newenv, env, size) ;
-  UNPACK(env);
-  UNPACK(newenv);
-  return((void *)USER_MSG_PTR(newenv)) ;
-}
-
-
-
-/*****************************************************************
-The message allocation calls CkAllocMsg and CkAllocPrioMsg     
-inside the user program are translated to the GenericCkAlloc
-call in the following manner :
-
-CkAllocMsg(Type) -->  GenericCkAlloc(TypeId, sizeof(Type), 0) ;
-CkAllocPrioMsg(Type,prio) -->  GenericCkAlloc(TypeId, sizeof(Type), prio) ;
-
-For varsize msgs :
-CkAllocMsg(Type,sizearray) -->  
-       (CsvAccess(MsgToStructTable)[TypeId].allocfn)(TypeId,sizeof(Type),sizearray,0) ;
-CkAllocPrioMsg(Type,prio,sizearray) -->  
-       (CsvAccess(MsgToStructTable)[TypeId].allocfn)(TypeId,sizeof(Type),sizearray,prio);
-where the translator-generated allocfn template is :
-allocfn(id, msgsize, sizearray, prio)
-{
-       ... determine total message size (including varsize arrays) ...
-       GenericCkAlloc(id, total_msg_size, prio) ;
-       ... set varsize array pointers ...
-}
-
-- Sanjeev
-
-*****************************************************************/
-
-void *GenericCkAlloc(int msgno, unsigned int msgbytes, unsigned int priobits)
-{
-    unsigned int msgwords;
-    unsigned int priowords;
-    unsigned int totalsize;
-    ENVELOPE *env;
-
-    msgbytes = align(msgbytes);
-    priowords = (priobits+(sizeof(int)*8)-1)/(sizeof(int)*8);
-    totalsize = TOTAL_MSG_SIZE(msgbytes, priowords);
-    env = (ENVELOPE *)CmiAlloc(totalsize);
-    CkMemError(env);
-
-    SetEnv_priosize(env, priobits);
-    SetEnv_queueing(env, CpvAccess(QueueingDefault));
-
-    if (CsvAccess(MsgToStructTable)[msgno].packfn != NULL)
-    {
-        SetEnv_isPACKED(env, UNPACKED);
-        SetEnv_TotalSize(env, totalsize);
-        SetEnv_packid(env, msgno);
-    }
-    else
-    {
-        SetEnv_isPACKED(env, NO_PACK);
-        SetEnv_TotalSize(env, totalsize);
-        SetEnv_packid(env, 0);
-    }
-    return ((void *)USER_MSG_PTR(env));
-}
-
diff --git a/src/ck-core/messageData.C b/src/ck-core/messageData.C
deleted file mode 100644 (file)
index e946970..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-
-#include <charm++.h>
-#include <iostream.h>
-#include <strstream.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fifo.h>
-#include <queueing.h>
-
-#if CMK_DEBUG_MODE
-
-#define NUM_MESSAGES 100
-
-//function declarations
-void CpdInitializeHandlerArray();
-void handlerArrayRegister(int);
-char* genericViewMsgFunction(char *msg, int type);
-char* getMsgListSched();
-char* getMsgListPCQueue();
-char* getMsgListFIFO();
-char* getMsgListDebug();
-char* getMsgContentsSched(int index);
-char* getMsgContentsPCQueue(int index);
-char* getMsgContentsFIFO(int index);
-char* getMsgContentsDebug(int index);
-void msgListCache();
-void msgListCleanup();
-
-extern "C" void CqsEnumerateQueue(Queue, void ***);
-extern "C" void FIFO_Enumerate(FIFO_QUEUE*, void***);
-extern "C" int getCharmMsgHandlers(int *handleArray);
-extern "C" char* getEnvInfo(ENVELOPE *env);
-extern "C" char* getSymbolTableInfo();
-
-CpvDeclare(int *, handlerArray);
-CpvDeclare(int, noOfHandlers);
-
-void **schedQueue=0;
-void **FIFOQueue=0;
-void **DQueue=0;
-
-int schedIndex;
-int debugIndex;
-int FIFOIndex;
-
-void msgListCleanup(){
-  if(schedQueue != 0) CmiFree(schedQueue);
-  if(FIFOQueue != 0) free(FIFOQueue);
-  if(DQueue != 0) free(DQueue);
-  schedIndex = 0;
-  FIFOIndex = 0;
-  debugIndex = 0;
-
-  schedQueue = 0;
-  FIFOQueue = 0;
-  DQueue = 0;
-}
-
-void msgListCache(){
-  CqsEnumerateQueue((Queue)CpvAccess(CsdSchedQueue), &schedQueue);
-  FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(CmiLocalQueue), &FIFOQueue);
-  schedIndex = 0;
-  FIFOIndex = 0;
-  debugIndex = 0;
-}
-
-void CpdInitializeHandlerArray(){
-    CpvInitialize(int *, handlerArray);
-    CpvInitialize(int, noOfHandlers);
-    
-    // Allocate memory to store the array of handlers
-    CpvAccess(handlerArray) = (int *)malloc(10 * sizeof(int));
-    CpvAccess(noOfHandlers) = 0;
-}
-
-void handlerArrayRegister(int hndlrID){
-    CpvAccess(handlerArray)[CpvAccess(noOfHandlers)] = hndlrID;
-    CpvAccess(noOfHandlers)++;
-}
-
-// type = 0 header required
-//      = 1 contents required
-char* genericViewMsgFunction(char *msg, int type){
-    int hndlrID;
-    char *unknownContentsMsg;
-    char *unknownFormatMsg;
-    char *temp;
-    strstream str;
-    
-    hndlrID = CmiGetHandler(msg);
-
-    //Look though the handlers in the handlerArray
-    //and perform the appropriate action
-    if((hndlrID == CpvAccess(handlerArray)[0]) || (hndlrID == CpvAccess(handlerArray)[1])){// Charm handlers
-       
-       //For now call the getEnvInfo function,
-       //Later, incorporate Milind's changes
-       if(type == 0){
-           return(getEnvInfo((ENVELOPE *)msg));
-       }
-       else{
-           //str << "Contents not known in this implementation" << '\0';
-           temp = (char *)malloc((strlen("Contents not known in this implementation") + 1) * sizeof(char));
-           strcpy(temp, "Contents not known in this implementation");
-           //return(str.str());
-           return(temp);
-       }
-    }
-    else {
-        //str << "<HEADER>:Unknown # Format #" << '\0';
-        temp = (char *)malloc((strlen("<HEADER>:Unknown # Format #") + 1) * sizeof(char));
-       strcpy(temp, "<HEADER>:Unknown # Format #");
-       return(temp);
-        //return(str.str());
-    }
-}
-
-char* getMsgListSched(){
-    strstream str;
-    int ending;
-    int count = 0;
-    char *list;
-    char t[10];
-    int maxLength;
-    /** debugging **/
-    char *temp, *p;
-    /*** ***/
-
-    ending = NUM_MESSAGES;
-    if ( (ending + schedIndex) >
-         ((Queue)(CpvAccess(CsdSchedQueue)))->length) {
-      ending = (((Queue)(CpvAccess(CsdSchedQueue)))->length) 
-               - schedIndex;
-    }
-    maxLength = ending * sizeof(char) * 20 + 1;
-    list = (char *)malloc(maxLength);
-    strcpy(list, "");
-
-    //CqsEnumerateQueue((Queue)CpvAccess(CsdSchedQueue), &schedQueue);
-    for(int i = schedIndex; i < ending + schedIndex; i++){
-        temp = genericViewMsgFunction((char *)schedQueue[i], 0);
-       //str << temp << "#" << i << "#";
-       if(strlen(list) + strlen(temp) + 10 > maxLength){ 
-         free(temp);
-         break;
-       }
-       strcat(list, temp);
-       strcat(list, "#");
-       sprintf(t, "%d", i);
-       strcat(list, t);
-       strcat(list, "#");
-       count++;
-       free(temp);
-    }
-    //str << '\0';
-    schedIndex += count;
-  
-    //p = str.str();
-    
-    /*** debugging ****/
-    if(list == NULL) CmiPrintf("list is NULL\n");
-    else CmiPrintf("list length = %d\n", strlen(list));
-    /**** *****/
-    
-    //return(p);
-    
-    //Debugging
-    CmiPrintf("schedIndex = %d\n", schedIndex);
-
-
-    return(list);
-}
-
-char* getMsgListPCQueue(){
-    strstream str;
-    char *list;
-
-    list = (char *)malloc((strlen("Not implemented") + 1) * sizeof(char));
-    strcpy(list, "Not implemented");
-    //str << "Not implemented" << '\0';
-    //return(str.str());
-    return(list);
-}
-
-char* getMsgListFIFO(){
-    strstream str;
-    int ending;
-    char *temp;
-    int count = 0;
-    char *list;
-    char t[10];
-    int maxLength;
-
-    ending = NUM_MESSAGES;
-    if ( (ending + FIFOIndex) >
-         ((FIFO_QUEUE *)(CpvAccess(CmiLocalQueue)))->fill) {
-      ending = (((FIFO_QUEUE *)(CpvAccess(CmiLocalQueue)))->fill) 
-               - FIFOIndex;
-    }
-    maxLength = ending * sizeof(char) * 20 + 1;
-    list = (char *)malloc(maxLength);
-    strcpy(list, "");
-
-    //FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(CmiLocalQueue), &FIFOQueue);
-    for(int i = FIFOIndex; i < FIFOIndex + ending; i++){
-        temp = genericViewMsgFunction((char *)FIFOQueue[i], 0);
-        //str << temp << "#" << i << "#";
-       if(strlen(list) + strlen(temp) + 10 > maxLength){
-         free(temp); 
-         break;
-       }
-       strcat(list, temp);
-       strcat(list, "#");
-       sprintf(t, "%d", i);
-       strcat(list, t);
-       strcat(list, "#");
-       count++;
-       free(temp);
-    }
-    //str << '\0';
-    FIFOIndex += count;
-    
-    //return(str.str());
-    return(list);
-}
-
-char* getMsgListDebug(){
-    strstream str;
-    int ending;
-    int count = 0;
-    char *list;
-    char t[10];
-    int maxLength;
-    char *temp;
-
-    ending = NUM_MESSAGES;
-    if ( (ending + debugIndex) >
-         ((FIFO_QUEUE *)(CpvAccess(debugQueue)))->fill) {
-      ending = (((FIFO_QUEUE *)(CpvAccess(debugQueue)))->fill) 
-               - debugIndex;
-    }
-    maxLength = ending * sizeof(char) * 20 + 1;
-    list = (char *)malloc(maxLength);
-    strcpy(list, "");
-
-    //Debugging
-    CmiPrintf("ending in msgListDebug = %d %d\n", ending, debugIndex);
-
-    FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(debugQueue), &DQueue);
-
-    for(int i = debugIndex; i < ending + debugIndex; i++){
-        temp = genericViewMsgFunction((char *)DQueue[i], 0);
-        //str << genericViewMsgFunction((char *)DQueue[i], 0) << "#" << i << "#";
-       if(strlen(list) + strlen(temp) + 10 > maxLength){ 
-         free(temp);
-         break;
-       }
-       strcat(list, temp);
-       strcat(list, "#");
-       sprintf(t, "%d", i);
-       strcat(list, t);
-       strcat(list, "#");
-       count++;
-       free(temp);
-    }
-    //str << '\0';
-    debugIndex += count;
-    
-    //return (str.str());
-    return(list);
-}
-
-char* getMsgContentsSched(int index){
-    strstream str;
-    char *temp;
-    //CqsEnumerateQueue((Queue)CpvAccess(CsdSchedQueue), &schedQueue);
-    //str << genericViewMsgFunction((char *)schedQueue[index], 1);
-    //str << '\0';
-    temp = genericViewMsgFunction((char *)schedQueue[index], 1);
-    //return (str.str());
-    return(temp);
-}
-
-char* getMsgContentsPCQueue(int index){
-    strstream str;
-    char *temp;
-    //str << "Not implemented";
-    //str << '\0';
-    //return(str.str());
-    temp = (char *)malloc((strlen("Not implemented") + 1) * sizeof(char));
-    strcpy(temp, "Not implemented");
-    return(temp);
-}
-
-char* getMsgContentsFIFO(int index){
-    strstream str;
-    char *temp;
-    //FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(CmiLocalQueue), &FIFOQueue);
-    //str << genericViewMsgFunction((char *)FIFOQueue[index], 1);
-    //str << '\0';     
-    temp = genericViewMsgFunction((char *)FIFOQueue[index], 1);
-    //return (str.str());
-    return(temp);
-}
-
-char* getMsgContentsDebug(int index){
-    strstream str;
-    char *temp;
-    //FIFO_Enumerate((FIFO_QUEUE *)CpvAccess(debugQueue), &DQueue);
-    //str << genericViewMsgFunction((char *)DQueue[index], 1);
-    //str << '\0';     
-    temp = genericViewMsgFunction((char *)DQueue[index], 1);
-    //return (str.str());
-    return(temp);
-}
-
-#endif
diff --git a/src/ck-core/mono.c b/src/ck-core/mono.c
deleted file mode 100644 (file)
index 4c0ad06..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-#include "charm.h"
-
-void * GetMonoMsgPtr() ;
-
-extern void * CPlus_CallMonoInit() ;
-extern void * CPlus_GetMonoMsgPtr() ;
-extern void CPlus_CallUpdateFn() ;
-extern void CPlus_SetMonoId() ;
-
-void _CK_BroadcastMono();
-
-
-void * MonoValue(bocnum)
-int bocnum;
-{
-        return( GetMonoMsgPtr((MONO_DATA *) GetBocDataPtr(bocnum)) );
-}
-
-MonoIDType CreateMono(id, initmsg, ReturnEP, ReturnID)
-int id;
-char *initmsg;
-EntryPointType ReturnEP;
-ChareIDType *ReturnID;
-{
-  int boc;
-  ENVELOPE *env = (ENVELOPE  *) ENVELOPE_UPTR(initmsg);
-  
-  SetEnv_other_id(env, id);
-  boc=CreateBoc(CsvAccess(CkChare_MONO), CsvAccess(CkEp_MONO_BranchInit),
-               initmsg,  ReturnEP, ReturnID);
-  TRACE(CmiPrintf("[%d] CreateMono: boc = %d\n", CmiMyPe(), boc));
-  return(boc);
-}
-
-
-void MONO_BranchInit_Fn(msg, mydata)
-void *msg;
-MONO_DATA *mydata;
-{
-       ENVELOPE * env = (ENVELOPE *) ENVELOPE_UPTR(msg);
-
-       mydata->id = GetEnv_other_id(env);
-       mydata->time = 0;
-
-        if ( IsCharmPlusPseudo(mydata->id) ) {
-            mydata->dataptr = CPlus_CallMonoInit(mydata->id, msg) ;
-            CPlus_SetMonoId(mydata->dataptr,MyBocNum(mydata)) ;
-        }
-        else
-            mydata->dataptr = (void *) (*(CsvAccess(PseudoTable)[mydata->id].initfn))
-                                       (NULL, msg);
-}
-
-
-
-void _CK_9MONO_BranchNewValue(mydata, x)
-MONO_DATA *mydata; 
-char *x;
-{
-       if ((*(CsvAccess(PseudoTable)[mydata->id].pseudo_type.mono.updatefn))
-               (mydata->dataptr, x))
-       {
-               _CK_BroadcastMono(GetMonoMsgPtr(mydata), MyBocNum(mydata));
-       }
-}
-
-
-void MONO_BranchUpdate_Fn(msg, mydata)
-char *msg;
-MONO_DATA *mydata;
-{
-        if ( IsCharmPlusPseudo(mydata->id) )
-                CPlus_CallUpdateFn(mydata->dataptr,msg) ;
-        else
-               (*(CsvAccess(PseudoTable)[mydata->id].pseudo_type.mono.updatefn))
-               (mydata->dataptr, msg);
-}
-
-
-
-void * _CK_9GetMonoDataPtr(monodata)
-MONO_DATA *monodata;
-{
-       return(monodata->dataptr);
-}
-
-FUNCTION_PTR _CK_9GetMonoCompareFn(monodata)
-MONO_DATA *monodata;
-{
-       return(CsvAccess(PseudoTable)[monodata->id].pseudo_type.mono.updatefn);
-}
-
-void * GetMonoMsgPtr(mydata)
-MONO_DATA *mydata ;
-{
-       if ( IsCharmPlusPseudo(mydata->id) ) 
-               return(CPlus_GetMonoMsgPtr(mydata->dataptr)) ;
-       else
-               return(mydata->dataptr) ;
-}
-
-void _CK_BroadcastMono(msg, bocnum)
-void *msg ; 
-int bocnum ;
-{
-       char *tmsg;
-
-       tmsg = (char *) CkCopyMsg(msg);
-       GeneralBroadcastMsgBranch(CsvAccess(CkEp_MONO_BranchUpdate),
-                       tmsg,   ImmBroadcastBocMsg, bocnum) ;
-}
-
-
-void MonoAddSysBocEps(void)
-{
-  CsvAccess(CkChare_MONO) =
-    registerChare("CkChare_MONO",sizeof(MONO_DATA),NULL);
-
-  CsvAccess(CkEp_MONO_BranchInit) =
-    registerBocEp("CkEp_MONO_BranchInit",
-                 MONO_BranchInit_Fn,
-                 CHARM, 0, CsvAccess(CkChare_MONO));
-  CsvAccess(CkEp_MONO_BranchUpdate) =
-    registerBocEp("CkEp_MONO_BranchUpdate",
-                 MONO_BranchUpdate_Fn,
-                 CHARM, 0, CsvAccess(CkChare_MONO));
-}
-
-
diff --git a/src/ck-core/msgalloc.C b/src/ck-core/msgalloc.C
new file mode 100644 (file)
index 0000000..2e859e6
--- /dev/null
@@ -0,0 +1,84 @@
+#include "ck.h"
+
+extern "C"
+void *CkAllocSysMsg(void)
+{
+  return CpvAccess(_msgPool)->get();
+}
+
+extern "C"
+void CkFreeSysMsg(void *m)
+{
+  CpvAccess(_msgPool)->put(m);
+}
+
+extern "C"
+void* CkAllocMsg(int msgIdx, int msgBytes, int prioBits)
+{
+  register envelope *env = _allocEnv(ForChareMsg, msgBytes, prioBits);
+  env->setQueueing(_defaultQueueing);
+  env->setMsgIdx(msgIdx);
+  return EnvToUsr(env);
+}
+
+extern "C"
+void* CkAllocBuffer(void *msg, int bufsize)
+{
+  bufsize = ALIGN(bufsize);
+  register envelope *env = UsrToEnv(msg);
+  register envelope *packbuf = _allocEnv(env->getMsgtype(), bufsize, 
+                                         env->getPriobits());
+  register int size = packbuf->getTotalsize();
+  memcpy(packbuf, env, sizeof(envelope));
+  packbuf->setTotalsize(size);
+  packbuf->setPacked(!env->isPacked());
+  memcpy(packbuf->getPrioPtr(), env->getPrioPtr(), packbuf->getPrioBytes());
+  return EnvToUsr(packbuf);;
+}
+
+extern "C"
+void  CkFreeMsg(void *msg)
+{
+  CmiFree(UsrToEnv(msg));
+}
+
+// cannot simply copy all fields because srcMsg could be varsize msg
+
+extern "C"
+void* CkCopyMsg(void **pMsg)
+{
+  register void *srcMsg = *pMsg;
+  register envelope *env = UsrToEnv(srcMsg);
+  register unsigned char msgidx = env->getMsgIdx();
+  if(!env->isPacked() && _msgTable[msgidx]->pack) {
+    srcMsg = _msgTable[msgidx]->pack(srcMsg);
+    UsrToEnv(srcMsg)->setPacked(1);
+  }
+  register int size = UsrToEnv(srcMsg)->getTotalsize();
+  register envelope *newenv = (envelope *) CmiAlloc(size);
+  memcpy(newenv, UsrToEnv(srcMsg), size);
+  if(UsrToEnv(srcMsg)->isPacked() && _msgTable[msgidx]->unpack) {
+    srcMsg = _msgTable[msgidx]->unpack(srcMsg);
+    UsrToEnv(srcMsg)->setPacked(0);
+  }
+  *pMsg = srcMsg;
+  if(newenv->isPacked() && _msgTable[msgidx]->unpack) {
+    srcMsg = _msgTable[msgidx]->unpack(EnvToUsr(newenv));
+    UsrToEnv(srcMsg)->setPacked(0);
+  }
+  return srcMsg;
+}
+
+extern "C"
+void  CkSetQueueing(void *msg, int strategy)
+{
+  UsrToEnv(msg)->setQueueing((unsigned char) strategy);
+}
+
+
+extern "C"
+void* CkPriorityPtr(void *msg)
+{
+  return UsrToEnv(msg)->getPrioPtr();
+}
+
diff --git a/src/ck-core/qd.C b/src/ck-core/qd.C
new file mode 100644 (file)
index 0000000..707da7a
--- /dev/null
@@ -0,0 +1,134 @@
+#include "ck.h"
+
+CpvDeclare(QdState*, _qd);
+
+static inline void _bcastQD1(QdState* state, QdMsg *msg)
+{
+  msg->setPhase(0);
+  state->propagate(msg);
+  msg->setPhase(1);
+  msg->setCreated(state->getCreated());
+  msg->setProcessed(state->getProcessed());
+  envelope *env = UsrToEnv((void*)msg);
+  CmiSyncSendAndFree(CkMyPe(), env->getTotalsize(), env);
+  state->markProcessed();
+  state->reset();
+  state->setStage(1);
+}
+
+static inline void _bcastQD2(QdState* state, QdMsg *msg)
+{
+  msg->setPhase(1);
+  state->propagate(msg);
+  msg->setPhase(2);
+  msg->setDirty(state->isDirty());
+  envelope *env = UsrToEnv((void*)msg);
+  CmiSyncSendAndFree(CkMyPe(), env->getTotalsize(), env);
+  state->reset();
+  state->setStage(2);
+}
+
+static inline void _handlePhase0(QdState *state, QdMsg *msg)
+{
+  assert(CkMyPe()==0 || state->getStage()==0);
+  if(CkMyPe()==0)
+    state->enq(new QdCallback(msg->getEp(), msg->getCid()));
+  if(state->getStage()==0)
+    _bcastQD1(state, msg);
+  else
+    CkFreeMsg(msg);
+}
+
+static inline void _handlePhase1(QdState *state, QdMsg *msg)
+{
+  switch(state->getStage()) {
+    case 0 :
+      assert(CkMyPe()!=0);
+      _bcastQD2(state, msg);
+      break;
+    case 1 :
+      state->subtreeCreate(msg->getCreated());
+      state->subtreeProcess(msg->getProcessed());
+      state->reported();
+      if(state->allReported()) {
+        if(CkMyPe()==0) {
+          if(state->getCCreated()==state->getCProcessed()) {
+            _bcastQD2(state, msg);
+          } else {
+            _bcastQD1(state, msg);
+          }
+        } else {
+          msg->setCreated(state->getCCreated());
+          msg->setProcessed(state->getCProcessed());
+          envelope *env = UsrToEnv((void*)msg);
+          CmiSyncSendAndFree(state->getParent(), 
+                             env->getTotalsize(), env);
+          state->reset();
+          state->setStage(0);
+        }
+      } else
+          CkFreeMsg(msg);
+      break;
+    default: CmiAbort("Internal QD Error. Contact Developers.!\n");
+  }
+}
+
+static inline void _handlePhase2(QdState *state, QdMsg *msg)
+{
+  assert(state->getStage()==2);
+  state->subtreeSetDirty(msg->getDirty());
+  state->reported();
+  if(state->allReported()) {
+    if(CkMyPe()==0) {
+      if(state->isDirty()) {
+        _bcastQD1(state, msg);
+      } else {
+        QdCallback* cb;
+        while(cb=state->deq()) {
+          cb->send();
+          delete cb;
+        }
+        state->reset();
+        state->setStage(0);
+        CkFreeMsg(msg);
+      }
+    } else {
+      msg->setDirty(state->isDirty());
+      envelope *env = UsrToEnv((void*)msg);
+      CmiSyncSendAndFree(state->getParent(), env->getTotalsize(), env);
+      state->reset();
+      state->setStage(0);
+    }
+  } else
+    CkFreeMsg(msg);
+}
+
+static void _callWhenIdle(QdMsg *msg)
+{
+  QdState *state = CpvAccess(_qd);
+  switch(msg->getPhase()) {
+    case 0 : _handlePhase0(state, msg); break;
+    case 1 : _handlePhase1(state, msg); break;
+    case 2 : _handlePhase2(state, msg); break;
+    default: CmiAbort("Internal QD Error. Contact Developers.!\n");
+  }
+}
+
+void _qdHandler(envelope *env)
+{
+  CmiGrabBuffer((void **)&env);
+  register QdMsg *msg = (QdMsg*) EnvToUsr(env);
+  CcdCallOnCondition(CcdPROCESSORIDLE, (CcdVoidFn)_callWhenIdle, (void*) msg);
+}
+
+extern "C"
+void CkStartQD(int eIdx, CkChareID *cid)
+{
+  register QdMsg *msg = (QdMsg*) CkAllocMsg(0,sizeof(QdMsg),0);
+  msg->setPhase(0);
+  msg->setEp(eIdx);
+  msg->setCid(*cid);
+  register envelope *env = UsrToEnv((void *)msg);
+  CmiSetHandler(env, _qdHandlerIdx);
+  CldEnqueue(0, env, _infoIdx);
+}
diff --git a/src/ck-core/qd.c b/src/ck-core/qd.c
deleted file mode 100644 (file)
index afff8e9..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-/**********************************************************************
-qd.c
-
-This file deals with quiescence detection. It is implemented as
-a branch- office-chare. These are the routines that deal with
-the node part of the boc.
-***********************************************************************/
-
-#include "charm.h"
-
-#include "converse.h"
-#include <stdio.h>
-#include <string.h>
-
-/*** MACROS ***/
-#define isLeaf(peNum) (CmiNumSpanTreeChildren(peNum) == 0)
-
-typedef struct quiescence_msg {
-       int msgs_processed;
-} QUIESCENCE_MSG;
-
-
-typedef struct {
-    int msgs_processed;
-    int msgs_created;
-} PhaseIMSG;
-
-typedef struct {
-    int wasDirty;       /* indicates whether anything happened since */
-                    /*  last phase */
-} PhaseIIMSG;
-
-typedef struct quiescence_entry {
-    EntryPointType ep;
-    ChareIDType chareid;
-    struct quiescence_entry *next;
-} QUIESCENCE_ENTRY;
-
-typedef struct start_quiescence_msg {
-    EntryPointType ep;
-    ChareIDType chareid;
-} START_QUIESCENCE_MSG;
-
-
-
-
-CHARE_BLOCK *CreateChareBlock();
-
-
-
-
-typedef int LIST_[1000];
-
-CpvStaticDeclare(LIST_, creation_list);
-CpvStaticDeclare(LIST_, process_list);
-
-
-/* globals used for messages since we don't need to     */
-/* re-alloc each time                                   */
-
-
-CpvStaticDeclare(EntryPointType, userEntry);
-CpvStaticDeclare(ChareIDType, userChareID);
-CpvStaticDeclare(int, quiescenceStarted);
-CpvStaticDeclare(int, myPe);
-CpvStaticDeclare(int, mainPe);
-CpvStaticDeclare(int, rootPe);
-CpvStaticDeclare(int, numKids);
-CpvStaticDeclare(int, parentPe);
-CpvStaticDeclare(QUIESCENCE_ENTRY*, quiescence_list);
-
-
-/* we use this variable to indicate when we are checking in the queue */
-/* for messages. We need it because we might come through again and   */
-/* we don't want to make another call to CallBocOnCondition if one is */
-/* already pending. */
-
-CpvStaticDeclare(int, subtree_msgs_processed);
-CpvStaticDeclare(int, subtree_msgs_created);
-CpvStaticDeclare(int, msgs_previously_processed);
-CpvStaticDeclare(int, root_msgs_created);
-CpvStaticDeclare(int, root_msgs_processed);
-CpvStaticDeclare(int, HostQDdirty);
-CpvStaticDeclare(int, QDdirty);   
-                   /* QDdirty = 1 :some msg was enqueued since the last
-                   time this bit was reset. OR one of child sent a
-                   message in phaseII, with the wasDirty bit set 0. */
-
-CpvStaticDeclare(int, countResponses); /* # of rspnses received from children in this phase. */
-
-void InsertQuiescenceList();
-
-
-void quiesModuleInit(void)
-{
-   CpvInitialize(LIST_, creation_list);
-   CpvInitialize(LIST_, process_list);
-   CpvInitialize(EntryPointType, userEntry);
-   CpvInitialize(ChareIDType, userChareID);
-   CpvInitialize(int, quiescenceStarted);
-   CpvInitialize(int, myPe);
-   CpvInitialize(int, mainPe);
-   CpvInitialize(int, rootPe);
-   CpvInitialize(int, numKids);
-   CpvInitialize(int, parentPe);
-   CpvInitialize(QUIESCENCE_ENTRY*, quiescence_list);
-   CpvInitialize(int, subtree_msgs_processed);
-   CpvInitialize(int, subtree_msgs_created);
-   CpvInitialize(int, msgs_previously_processed);
-   CpvInitialize(int, root_msgs_created);
-   CpvInitialize(int, root_msgs_processed);
-   CpvInitialize(int, HostQDdirty);
-   CpvInitialize(int, QDdirty);   
-   CpvInitialize(int, countResponses);
-
-   CpvAccess(quiescence_list) = NULL;
-}
-
-
-
-
-/********************** FUNCTION PROTOTYPES *****************/
-void QDBocInit();
-/************************ phase I routines  *****************/
-void StartPhaseI();
-int  EndPhaseI();
-void PhaseIBroadcast();
-void HandlePhaseIMsg();
-int  sendUpI();
-/************************ phase II routines *****************/
-void StartPhaseII();
-int  EndPhaseII();
-void PhaseIIBroadcast();
-void HandlePhaseIIMsg();
-int  sendUpII();
-/************************ utility routine   *****************/
-void QDAddSysBocEps();
-
-
-
-
-
-/***************************************************************************
- this routine initiaizes the node part of the QD boc's. It is called by the 
- SysBocInit routine from the nodeBocinitLoop which is called from main.
-****************************************************************************/
-void QDBocInit()
-{
-    CHARE_BLOCK *bocblock;
-
-    /* Create a dummy BOC node */
-    bocblock = CreateChareBlock(0, CHAREKIND_BOCNODE, 0);
-    bocblock->x.boc_num = QDBocNum;
-    SetBocBlockPtr(QDBocNum, bocblock);
-
-    CpvAccess(countResponses)         = 0;
-    CpvAccess(msgs_previously_processed) = 0;
-    CpvAccess(root_msgs_created) = CpvAccess(root_msgs_processed) = 0;
-    
-    CpvAccess(myPe)        = CmiMyPe();
-    CpvAccess(mainPe)      = 0;
-    CpvAccess(rootPe)      = 0;
-    CpvAccess(numKids)     = CmiNumSpanTreeChildren(CpvAccess(myPe));
-    CpvAccess(parentPe)    = (CpvAccess(myPe) == CpvAccess(rootPe)) ? CpvAccess(mainPe) : CmiSpanTreeParent(CpvAccess(myPe));
-    CpvAccess(quiescenceStarted) = 0;
-}
-
-/***************************************************************************
-The next two procedures start quiescence and insert every request into
-quiescence list, so that when quiescence is detected a message can be 
-sent back to the user at every requested entry point.
-***************************************************************************/
-void StartQuiescence(ep, chareid)
-EntryPointType ep;
-ChareIDType *chareid;
-{
-       START_QUIESCENCE_MSG *msg ;     
-       msg = (START_QUIESCENCE_MSG *) CkAllocMsg(sizeof(START_QUIESCENCE_MSG));
-       msg->ep = ep;
-       msg->chareid = *chareid;
-       if (CmiMyPe() == 0)
-               InsertQuiescenceList(msg, NULL);
-       else
-                GeneralSendMsgBranch(CsvAccess(CkEp_QD_InsertQuiescenceList),
-                                msg, 0,
-                                QdBocMsg, QDBocNum);
-
-}
-
-
-void InsertQuiescenceList(msgptr, localdataptr)
-START_QUIESCENCE_MSG *msgptr;
-void *localdataptr;
-{
-       QUIESCENCE_ENTRY *new = (QUIESCENCE_ENTRY *)
-                                        CmiAlloc(sizeof(QUIESCENCE_ENTRY));
-       new->ep = msgptr->ep;
-       new->chareid = msgptr->chareid;
-       CkFreeMsg(msgptr);      
-       new->next = CpvAccess(quiescence_list);
-       CpvAccess(quiescence_list) = new;
-       if (!CpvAccess(quiescenceStarted)) {
-            StartPhaseI();
-                       CpvAccess(quiescenceStarted) = 1;
-       }
-}
-
-/***************************************************************************
-***************************************************************************/
-void PhaseIBroadcast(msgptr_,localdataptr_)
-void *msgptr_, *localdataptr_;
-{
-       PhaseIMSG * msg = (PhaseIMSG *) msgptr_;
-
-TRACE(CmiPrintf("Inside PhaseIBroadcast\n"));
-
-       if (CpvAccess(countResponses) == 0)
-               CpvAccess(subtree_msgs_created) = CpvAccess(subtree_msgs_processed) = 0;
-
-       if (isLeaf(CpvAccess(myPe))) {
-               TRACE(CmiPrintf("PhaseIBroadcast: lf[%d],cllng CallBocOnCnd\n",CpvAccess(myPe)));
-
-               CallBocOnCondition(sendUpI, QDBocNum);
-       }
-       else {
-               TRACE(CmiPrintf("PhaseIBroadcast: interior  node[%d], \n",CpvAccess(myPe)));
-       }
-       CkFreeMsg(msg);
-}
-
-
-/*************************************************************************** 
-wait for responses from all children, and then set a
-call-on-condition to call sendUpI when the queue is empty 
-****************************************************************************/
-void HandlePhaseIMsg(msgptr_,localdataptr_)
-void *msgptr_, *localdataptr_;
-{
-       PhaseIMSG *msg = (PhaseIMSG *) msgptr_;
-
-       if (CpvAccess(countResponses) == 0)
-               CpvAccess(subtree_msgs_created) = CpvAccess(subtree_msgs_processed) = 0;
-       CpvAccess(countResponses)++;
-       CpvAccess(subtree_msgs_created) += msg->msgs_created;
-       CpvAccess(subtree_msgs_processed) += msg->msgs_processed;
-
-       TRACE(CmiPrintf("HandlePhaseIMsg nd[%d]  children[%d]  responses so far[%d]\n", 
-           CpvAccess(myPe), CpvAccess(numKids), CpvAccess(countResponses)));
-       if (CpvAccess(countResponses) == CpvAccess(numKids)){
-               TRACE(CmiPrintf("HandlePhaseIMsg nd[%d] have all resps, cllng CallBocOn..\n",
-                   CpvAccess(myPe)));
-               CallBocOnCondition(sendUpI, QDBocNum);
-       }
-       CkFreeMsg(msg);
-}
-
-
-/**************************************************************************
-This is a boc access function, hence the unused reference to the bocNum. 
-The logic is as follows:
-
-if queue is empty
-    if I am root
-        start phase II after deltaT
-    else
-        send Msg to spanning tree parent
-    return 1
-else
-    return 0
-**************************************************************************/
-int sendUpI(bocNum)
-int bocNum;
-{
-       PhaseIMSG     *msg1;
-
-TRACE(CmiPrintf("Inside sendUpI\n"));
-
-/* SANJEEV, ATTILA Jun 8 : made AllAsyncMsgsSent an Mc function */
-
-       if (CsdEmpty() && NoDelayedMsgs() ) {
-               msg1 = (PhaseIMSG *)  CkAllocMsg(sizeof(PhaseIMSG));
-               CkMemError(msg1);
-               msg1->msgs_created = CpvAccess(subtree_msgs_created) + CpvAccess(msgs_created);
-               msg1->msgs_processed = CpvAccess(subtree_msgs_processed) + CpvAccess(msgs_processed);
-               CpvAccess(msgs_previously_processed) = CpvAccess(msgs_processed);
-
-               TRACE(CmiPrintf("sendUpI : created = %d, processed = %d\n", 
-                   msg1->msgs_created, msg1->msgs_processed));
-               CpvAccess(countResponses) = 0;   /* reset here for next phase (timing reasons) */
-               CpvAccess(QDdirty) = 0;      /* flag, 0 if we've seen no messages */
-               if (CpvAccess(myPe) == CpvAccess(rootPe)) {
-                       CpvAccess(root_msgs_created) = msg1->msgs_created;
-                       CpvAccess(root_msgs_processed) = msg1->msgs_processed;
-                       CallBocOnCondition(EndPhaseI,QDBocNum);
-                       CkFreeMsg(msg1);
-               }
-               else {
-                       TRACE(CmiPrintf("Nd[%d] sendUpI() sndng endPhaseI msg up to nd[%d]\n",
-                           CpvAccess(myPe),CpvAccess(parentPe)));
-                       GeneralSendMsgBranch(CsvAccess(CkEp_QD_PhaseIMsg),
-                               msg1, CpvAccess(parentPe),
-                               QdBocMsg, QDBocNum);
-               }
-               return(1); /* inform the conditional-wait manager that the cond.
-                                                    is satisfied, (and so should be removed from the Q) */
-       }
-       return(0);    /* not done yet, tell conditional wait mnger to try again */
-}
-
-
-
-/****************************************************************************
-if you are a leaf, send up a phase II message to your parent.
-otherwise, reset counts to 0 
-****************************************************************************/
-void PhaseIIBroadcast(msgptr_,localdataptr_)
-void *msgptr_, *localdataptr_;
-{
-       PhaseIIMSG * msg = (PhaseIIMSG *) msgptr_;
-
-       if (isLeaf(CpvAccess(myPe))) {
-               TRACE(CmiPrintf("PhaseIIBroadcast lf nd[%d],dirty[%d] CallBoc..SendUpII\n",
-                   CpvAccess(myPe),msg->wasDirty));
-               CallBocOnCondition(sendUpII,QDBocNum);
-       }
-       else {
-               TRACE(CmiPrintf("PhaseIIBroadcast interior nd[%d],dirty[%d]\n",
-                   CpvAccess(myPe),msg->wasDirty));
-               /* countResponses was reset in sendUpI, so don't do it here */
-               /* just wait to receive messages from the kids */
-       }
-       CkFreeMsg(msg);
-}
-
-
-/**************************************************************************
-wait for responses from all children, and then set a
-call-on-condition to call sendUpII when the queue is empty 
-**************************************************************************/
-void HandlePhaseIIMsg(msgptr_,localdataptr_)
-void *msgptr_, *localdataptr_;
-{
-       PhaseIIMSG *msg = (PhaseIIMSG *)  msgptr_;
-
-       TRACE(CmiPrintf("HandlePhaseIIMsg() nd[%d], dirty[%d] kds[%d] resp[%d]\n",
-           CpvAccess(myPe),msg->wasDirty,CpvAccess(numKids),CpvAccess(countResponses)+1));
-       CpvAccess(countResponses)++;
-       CpvAccess(QDdirty) = (CpvAccess(QDdirty) || msg->wasDirty);
-       if (CpvAccess(countResponses) == CpvAccess(numKids))
-               CallBocOnCondition(sendUpII,QDBocNum);
-       CkFreeMsg(msg);
-}
-
-
-/**************************************************************************
-Returns 1 when our queue is empty
-**************************************************************************/
-int sendUpII(bocNum)
-int bocNum;
-{
-       PhaseIIMSG     *msg2;
-
-       if (CsdEmpty() && NoDelayedMsgs() ) {
-               msg2 = (PhaseIIMSG *) CkAllocMsg(sizeof(PhaseIIMSG));
-               CkMemError(msg2);
-               /* flag to indicate activity until this pass */
-               msg2->wasDirty = CpvAccess(QDdirty) || 
-                   (CpvAccess(msgs_previously_processed) < CpvAccess(msgs_processed)) ;
-               CpvAccess(QDdirty)        = 0;
-               CpvAccess(countResponses )= 0;          /* reset for next iteration of program */
-               TRACE(CmiPrintf("sendUPII :: QDdirty = %d\n", msg2->wasDirty));
-               if (CpvAccess(myPe) == CpvAccess(rootPe)) {        /* root, pass to host */
-                       CpvAccess(HostQDdirty) = CpvAccess(HostQDdirty) || msg2->wasDirty;
-                       CallBocOnCondition(EndPhaseII,QDBocNum);
-                       CkFreeMsg(msg2);
-               }
-               else {                       /* not the root, pass it up */
-                       TRACE(CmiPrintf("sendUpII node[%d]sending endPhaseII msg up to nd[%d]\n",
-                           CpvAccess(myPe),CmiSpanTreeParent(CpvAccess(myPe))));
-                       GeneralSendMsgBranch(CsvAccess(CkEp_QD_PhaseIIMsg),
-                               msg2, CpvAccess(parentPe),
-                               QdBocMsg, QDBocNum);
-               }
-               return(1); /* inform the cond.-wait manager that the cond. stsfd */
-       }
-       return(0);    /* not done yet, tell cond. wait mngr to try again later */
-}
-
-
-
-/***************************************************************************
-*****************************************************************************/
-void StartPhaseI()
-{
-       int ep;
-       PhaseIMSG     *msg1;
-
-
-       TRACE(CmiPrintf("Host: Starting PhaseI at [%d]\n",CkTimer()));
-
-       msg1 = (PhaseIMSG *)  CkAllocMsg(sizeof(PhaseIMSG));
-       CkMemError(msg1);
-       ep   = CsvAccess(CkEp_QD_PhaseIBroadcast);
-
-       GeneralBroadcastMsgBranch(ep, msg1,
-                       QdBroadcastBocMsg, QDBocNum);
-}
-
-
-
-/*****************************************************************************
-*****************************************************************************/
-int EndPhaseI(bocNum)
-int bocNum;
-{
-       if(CsdEmpty() && NoDelayedMsgs() ) {
-
-TRACE(CmiPrintf("EndPhaseI: root_created=%d, root_processed=%d\n",
-CpvAccess(root_msgs_created), CpvAccess(root_msgs_processed)));
-
-               if (CpvAccess(root_msgs_created) == CpvAccess(root_msgs_processed))
-                       StartPhaseII();
-               else
-                       StartPhaseI();
-               return(1);
-       }
-       else
-               return(0);
-}
-
-
-
-/*****************************************************************************
-*****************************************************************************/
-void StartPhaseII(bocNum)
-int bocNum;
-{
-       int ep;
-       PhaseIIMSG     *msg2;
-
-       TRACE(CmiPrintf("Host: starting PhaseII at T=[%d]\n",CkTimer()));
-       CpvAccess(HostQDdirty) = 0;
-
-       ep   = CsvAccess(CkEp_QD_PhaseIIBroadcast);
-       msg2 = (PhaseIIMSG *) CkAllocMsg(sizeof(PhaseIIMSG));
-       CkMemError(msg2);
-
-       GeneralBroadcastMsgBranch(ep, msg2, 
-               QdBroadcastBocMsg, QDBocNum);
-}
-
-
-/*****************************************************************************
-*****************************************************************************/
-int EndPhaseII(bocNum)
-{
-       PhaseIIMSG  *msg ;
-
-/*     PumpMsgs();     removed 3/17/95 : Sanjeev */
-
-       if( CsdEmpty() && NoDelayedMsgs()) {
-               TRACE(CmiPrintf("Host: EndPhaseII(), nodesaredone, q empty, no msgs\n"));
-               if(!CpvAccess(HostQDdirty)) {
-                       QUIESCENCE_ENTRY *new;
-                       new = CpvAccess(quiescence_list);
-                       while (CpvAccess(quiescence_list) != NULL) {
-                               msg  = (PhaseIIMSG *)
-                                        CkAllocMsg(sizeof(PhaseIIMSG));
-                               CkMemError(msg);
-                               SendMsg(CpvAccess(quiescence_list)->ep, msg, 
-                                               &CpvAccess(quiescence_list)->chareid);
-                               CpvAccess(quiescence_list) = CpvAccess(quiescence_list)->next;
-                               CmiFree(new);   
-                               new = CpvAccess(quiescence_list);
-                       }
-                       CpvAccess(quiescenceStarted) = 0;
-               }
-               else 
-                       StartPhaseI();
-               return (1);
-       }
-       return(0);
-}
-
-
-/***************************************************************************
-here we set up the entry points so we can call our boc ep functions
-****************************************************************************/
-void QDAddSysBocEps()
-{
-    CsvAccess(CkEp_QD_Init) =
-      registerBocEp("CkEp_QD_Init", 
-                QDBocInit,
-                CHARM, 0, 0);
-    CsvAccess(CkEp_QD_InsertQuiescenceList) =
-      registerBocEp("CkEp_QD_InsertQuiescenceList",
-                InsertQuiescenceList,
-                CHARM, 0, 0);
-    CsvAccess(CkEp_QD_PhaseIBroadcast) =
-      registerBocEp("CkEp_QD_PhaseIBroadcast",
-                PhaseIBroadcast, 
-                CHARM, 0, 0);
-    CsvAccess(CkEp_QD_PhaseIMsg) =
-      registerBocEp("CkEp_QD_PhaseIMsg",
-                HandlePhaseIMsg, 
-                CHARM, 0, 0);
-    CsvAccess(CkEp_QD_PhaseIIBroadcast) =
-      registerBocEp("CkEp_QD_PhaseIIBroadcast",
-                PhaseIIBroadcast, 
-                CHARM, 0, 0);
-    CsvAccess(CkEp_QD_PhaseIIMsg) =
-      registerBocEp("CkEp_QD_PhaseIIMsg",
-                HandlePhaseIIMsg, 
-                CHARM, 0, 0);
-}
diff --git a/src/ck-core/qd.h b/src/ck-core/qd.h
new file mode 100644 (file)
index 0000000..374d577
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef _QD_H
+#define _QD_H
+
+class QdMsg {
+  private:
+    int phase; // 0..2
+    union {
+      struct { int ep; CkChareID cid; } p0;
+      struct { /* none */ } p1;
+      struct { int created; int processed; } p2;
+      struct { /* none */ } p3;
+      struct { int dirty; } p4;
+    } u;
+  public:
+    int getPhase(void) { return phase; }
+    void setPhase(int p) { phase = p; }
+    int getEp(void) { assert(phase==0); return u.p0.ep; }
+    void setEp(int e) { assert(phase==0); u.p0.ep = e; }
+    CkChareID getCid(void) { assert(phase==0); return u.p0.cid; }
+    void setCid(CkChareID c) { assert(phase==0); u.p0.cid = c; }
+    int getCreated(void) { assert(phase==1); return u.p2.created; }
+    void setCreated(int c) { assert(phase==1); u.p2.created = c; }
+    int getProcessed(void) { assert(phase==1); return u.p2.processed; }
+    void setProcessed(int p) { assert(phase==1); u.p2.processed = p; }
+    int getDirty(void) { assert(phase==2); return u.p4.dirty; }
+    void setDirty(int d) { assert(phase==2); u.p4.dirty = d; }
+};
+
+class QdCallback {
+  public:
+    int ep;
+    CkChareID cid;
+  public:
+    QdCallback(int e, CkChareID c) : ep(e), cid(c) {}
+    void send(void) { CkSendMsg(ep,CkAllocMsg(0,0,0),&cid); }
+};
+
+class QdState {
+  private:
+    int stage; // 0..2
+    int oProcessed;
+    int mCreated, mProcessed;
+    int cCreated, cProcessed;
+    int cDirty;
+    int nReported;
+    PtrQ *callbacks;
+    int nChildren;
+    int parent;
+    int *children;
+  public:
+    QdState():mCreated(0),mProcessed(0),stage(0),nReported(0) {
+      cCreated = 0; cProcessed = 0; cDirty = 0;
+      oProcessed = 0;
+      callbacks = new PtrQ();
+      nChildren = CmiNumSpanTreeChildren(CkMyPe());
+      parent = CmiSpanTreeParent(CkMyPe());
+      children = new int[nChildren];
+      CmiSpanTreeChildren(CkMyPe(), children);
+    }
+    void propagate(QdMsg *msg) {
+      envelope *env = UsrToEnv((void *)msg);
+      CmiSetHandler(env, _qdHandlerIdx);
+      for(int i=0; i<nChildren; i++)
+        CmiSyncSend(children[i], env->getTotalsize(), env);
+    }
+    int getParent(void) { return parent; }
+    QdCallback *deq(void) { return (QdCallback*) callbacks->deq(); }
+    void enq(QdCallback *c) { callbacks->enq((void *) c); }
+    void create(int n=1) { mCreated += n; }
+    void process(int n=1) { mProcessed += n; }
+    int getCreated(void) { return mCreated; }
+    int getProcessed(void) { return mProcessed; }
+    int getCCreated(void) { return cCreated; }
+    int getCProcessed(void) { return cProcessed; }
+    void subtreeCreate(int c) { cCreated += c; }
+    void subtreeProcess(int p) { cProcessed += p; }
+    int getStage(void) { return stage; }
+    void setStage(int p) { stage = p; }
+    void reported(void) { nReported++; }
+    int allReported(void) {return nReported==(nChildren+1);}
+    void reset(void) { nReported=0; cCreated=0; cProcessed=0; cDirty=0; }
+    void markProcessed(void) { oProcessed = mProcessed; }
+    int isDirty(void) { return ((mProcessed > oProcessed) || cDirty); }
+    void subtreeSetDirty(int d) { cDirty = cDirty || d; }
+};
+
+extern void _qdHandler(envelope *);
+CpvExtern(QdState*, _qd);
+
+#endif
diff --git a/src/ck-core/rdonly.c b/src/ck-core/rdonly.c
deleted file mode 100644 (file)
index 421578a..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "charm.h"
-
-#include "trace.h"
-
-
-CpvExtern(char *, ReadBufIndex);
-CpvExtern(char *, ReadFromBuffer);
-
-/************************************************************************/
-/* The following functions are used to copy the read-buffer out of and         */
-/* into the read only variables.                                       */
-/************************************************************************/
-void _CK_13CopyToBuffer(srcptr, var_size) 
-char *srcptr;
-int var_size;
-{
-  int i;
-
-  for (i=0; i<var_size; i++) 
-    *CpvAccess(ReadBufIndex)++ = *srcptr++;
-}
-
-void _CK_13CopyFromBuffer(destptr, var_size) 
-char *destptr;
-int var_size;
-{
-  int i;
-
-  for (i=0; i<var_size; i++) 
-    *destptr++ = *CpvAccess(ReadFromBuffer)++;
-}
-
-
-void BroadcastReadBuffer(ReadBuffer, size, mainChareBlock)
-char *ReadBuffer;
-int size;
-struct chare_block * mainChareBlock;
-{
-       ENVELOPE * env;
-
-       env = ENVELOPE_UPTR(ReadBuffer);
-       SetEnv_msgType(env, ReadVarMsg);
-       
-       /* this is where we add the information for the main chare
-       block */
-       SetEnv_chareBlockPtr(env, mainChareBlock);
-       SetEnv_chare_magic_number(env, 
-                       GetID_chare_magic_number(mainChareBlock->selfID));
-       CmiSetHandler(env,CsvAccess(HANDLE_INIT_MSG_Index));
-       CmiSyncBroadcastAndFree(GetEnv_TotalSize(env), env);
-}
-
-
-void ReadMsgInit(msg, id)
-char *msg;
-int id;
-{
-       int packed;
-       ENVELOPE *env ;
-
-       env = ENVELOPE_UPTR(msg);
-       CpvAccess(NumReadMsg)++;
-       SetEnv_msgType(env, ReadMsgMsg);
-       SetEnv_other_id(env, id);
-       if (GetEnv_isPACKED(env) == UNPACKED)
-               packed = 1;
-       else
-                packed = 0;
-        PACK(env);
-        CmiSetHandler(env,CsvAccess(HANDLE_INIT_MSG_Index));
-       CmiSyncBroadcast(GetEnv_TotalSize(env), env);
-       UNPACK(env);
-}
-
diff --git a/src/ck-core/register.C b/src/ck-core/register.C
new file mode 100644 (file)
index 0000000..0367fcf
--- /dev/null
@@ -0,0 +1,81 @@
+#include "ck.h"
+
+EntryInfo**        _entryTable;
+MsgInfo**          _msgTable;
+ChareInfo**        _chareTable;
+MainInfo**         _mainTable;
+ReadonlyInfo**     _readonlyTable;
+ReadonlyMsgInfo**  _readonlyMsgs;
+
+int _numEntries;
+int _numMsgs;
+int _numChares;
+int _numMains;
+int _numReadonlies;
+int _numReadonlyMsgs;
+
+void _registerInit(void)
+{
+  _numEntries =0;
+  _numMsgs = 0;
+  _numChares = 0;
+  _numMains = 0;
+  _numReadonlies = 0;
+  _numReadonlyMsgs = 0;
+  _entryTable = new EntryInfo*[_ENTRY_TABLE_SIZE];
+  _msgTable = new MsgInfo*[_MSG_TABLE_SIZE];
+  _chareTable = new ChareInfo*[_CHARE_TABLE_SIZE];
+  _mainTable = new MainInfo*[_MAIN_TABLE_SIZE];
+  _readonlyTable = new ReadonlyInfo*[_READONLY_TABLE_SIZE];
+  _readonlyMsgs = new ReadonlyMsgInfo*[_READONLY_TABLE_SIZE];;
+}
+
+extern "C"
+int CkRegisterMsg(char *name, CkPackFnPtr pack, CkUnpackFnPtr unpack, 
+                  CkCoerceFnPtr coerce, int size)
+{
+  _msgTable[_numMsgs] = new MsgInfo(name, pack, unpack, coerce, size);
+  return _numMsgs++;
+}
+
+extern "C"
+int CkRegisterEp(char *name, CkCallFnPtr call, int msgIdx, int chareIdx)
+{
+  _entryTable[_numEntries] = new EntryInfo(name, call, msgIdx, chareIdx);
+  return _numEntries++;
+}
+
+extern "C"
+int CkRegisterChare(char *name, int dataSz)
+{
+  _chareTable[_numChares] = new ChareInfo(name, dataSz);
+  return _numChares++;
+}
+
+extern "C"
+int CkRegisterMainChare(int chareIdx, int entryIdx)
+{
+  _mainTable[_numMains] = new MainInfo(chareIdx, entryIdx);
+  return _numMains++;
+}
+
+extern "C"
+void CkRegisterReadonly(int size, void *ptr)
+{
+  _readonlyTable[_numReadonlies++] = new ReadonlyInfo(size, ptr);
+  return;
+}
+
+extern "C"
+void CkRegisterReadonlyMsg(void **pMsg)
+{
+  _readonlyMsgs[_numReadonlyMsgs++] = new ReadonlyMsgInfo(pMsg);
+}
+
+// temporarily here for satisfying NAMD, it should go to tracing module
+
+extern "C"
+int registerEvent(char *name)
+{
+  return 0;
+}
diff --git a/src/ck-core/register.c b/src/ck-core/register.c
deleted file mode 100644 (file)
index bc13346..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-#include "charm.h"
-
-
-
-/* indexes */
-CsvExtern(int, _CK_MainChareIndex);
-CsvExtern(int, _CK_MainEpIndex);
-CsvExtern(int, ReadBuffSize);
-
-CpvDeclare(int, fnCount); 
-CpvDeclare(int, chareEpsCount);
-CpvDeclare(int, msgCount);
-CpvDeclare(int, chareCount);
-CpvDeclare(int, pseudoCount);
-CpvDeclare(int, readCount);
-CpvDeclare(int, readMsgCount);
-CpvDeclare(int, eventCount);
-
-
-void registerModuleInit()
-{
-     CpvInitialize(int, fnCount);
-     CpvInitialize(int, chareEpsCount);
-     CpvInitialize(int, msgCount);
-     CpvInitialize(int, chareCount);
-     CpvInitialize(int, pseudoCount);
-     CpvInitialize(int, readCount);
-     CpvInitialize(int, readMsgCount);
-     CpvInitialize(int, eventCount);
-
-     CpvAccess(fnCount) = 0;
-     CpvAccess(chareEpsCount) = 0;
-     CpvAccess(msgCount) = 0;
-     CpvAccess(chareCount) = 0;
-     CpvAccess(pseudoCount) = 0;
-     CpvAccess(readCount) = 0;
-     CpvAccess(readMsgCount) = 0;
-     CpvAccess(eventCount) = 0;
-}
-
-
-int registerEvent(name)
-char *name;
-{
-  CsvAccess(EventTable)[CpvAccess(eventCount)] = name;
-  CpvAccess(eventCount) ++ ;
-  return(CpvAccess(eventCount)-1) ;
-}
-
-int registerMsg(name,allocf,packf,unpackf,coerce,size)
-char *name;
-FUNCTION_PTR allocf, packf, unpackf, coerce;
-int size ;
-{
-/* fills in MsgToStructTable */
-       CsvAccess(MsgToStructTable)[CpvAccess(msgCount)].alloc = allocf ;
-       CsvAccess(MsgToStructTable)[CpvAccess(msgCount)].packfn = packf ;
-       CsvAccess(MsgToStructTable)[CpvAccess(msgCount)].unpackfn = unpackf ;
-       CsvAccess(MsgToStructTable)[CpvAccess(msgCount)].coerce = coerce ;
-       CsvAccess(MsgToStructTable)[CpvAccess(msgCount)].size = size ;
-       CpvAccess(msgCount) ++ ;
-       return(CpvAccess(msgCount)-1) ;
-}
-
-void setThreadedEp( int entry) {
-  (CsvAccess(EpInfoTable)+ entry)->threaded = 1;
-}
-
-void SetEp(ep,name,function,language,messageindex,chareindex,chare_or_boc)
-char *name;
-FUNCTION_PTR function ;
-int ep, language, messageindex, chareindex, chare_or_boc;
-{
-  EP_STRUCT *epinfo = CsvAccess(EpInfoTable)+ep;
-  char *nname = (char *)CmiSvAlloc(strlen(name)+1);
-  strcpy(nname, name);
-
-  epinfo->name        = nname;
-  epinfo->function    = function;
-  epinfo->language    = language;
-  epinfo->messageindex= messageindex;
-  epinfo->chareindex  = chareindex;
-  epinfo->chare_or_boc= chare_or_boc;
-  epinfo->threaded = 0; 
-}
-
-int registerEp(name,function,language,messageindex,chareindex)
-char *name;
-FUNCTION_PTR function ;
-int language ;
-int messageindex, chareindex;
-{
-  int index=CpvAccess(chareEpsCount)++;
-  SetEp(index, name, function, language, messageindex, chareindex, CHARE);
-  return index;
-}
-
-int registerBocEp(name,function,language,messageindex,chareindex)
-char *name;
-FUNCTION_PTR function ;
-int language ;
-int messageindex, chareindex;
-{
-  int index=CpvAccess(chareEpsCount)++;
-  SetEp(index, name, function, language, messageindex, chareindex, BOC);
-  return index;
-}
-
-int registerChare(name,dataSz,createfn)
-char *name;
-int dataSz;
-FUNCTION_PTR createfn ;
-{
-/* fills in ChareSizesTable, ChareNamesTable */
-       CsvAccess(ChareSizesTable)[CpvAccess(chareCount)] = dataSz ;
-       CsvAccess(ChareNamesTable)[CpvAccess(chareCount)] = 
-                             (char *)CmiSvAlloc(strlen(name)*sizeof(char)+1);
-
-        strcpy(CsvAccess(ChareNamesTable)[CpvAccess(chareCount)], name) ;
-       CpvAccess(chareCount)++ ;
-       return(CpvAccess(chareCount)-1) ;
-}
-
-
-int registerFunction(fn)
-FUNCTION_PTR fn ;
-{
-/* fills in _CK_9_GlobalFunctionTable */
-       CsvAccess(_CK_9_GlobalFunctionTable)[CpvAccess(fnCount)] = fn ;
-       CpvAccess(fnCount)++;   
-       return(CpvAccess(fnCount)-1) ;
-}
-
-
-int registerMonotonic(name, initfn, updatefn,language)
-char *name ;
-FUNCTION_PTR initfn, updatefn ;
-int language ;
-{
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].name = 
-                         (char *)CmiSvAlloc(strlen(name)*sizeof(char)+1);
-       strcpy(CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].name,name) ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].type = MONOTONIC ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].initfn = initfn ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].language = language ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].pseudo_type.mono.updatefn=updatefn;
-       CpvAccess(pseudoCount)++ ;
-
-       return(CpvAccess(pseudoCount)-1) ;
-}
-
-int registerTable(name, initfn, hashfn)
-char *name ;
-FUNCTION_PTR initfn, hashfn ;
-{
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].name = 
-                            (char *)CmiSvAlloc(strlen(name)*sizeof(char)+1);
-       strcpy(CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].name,name) ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].type = TABLE ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].initfn = initfn ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].pseudo_type.tbl.hashfn = hashfn ;
-       CpvAccess(pseudoCount)++ ;
-
-       return(CpvAccess(pseudoCount)-1) ;
-}
-
-int registerAccumulator(name, initfn, addfn, combinefn,language)
-char *name ;
-FUNCTION_PTR initfn, addfn, combinefn ;
-int language ;
-{
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].name = 
-                             (char *)CmiSvAlloc(strlen(name)*sizeof(char)+1);
-       strcpy(CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].name,name) ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].type = ACCUMULATOR ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].initfn = initfn ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].language = language ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].pseudo_type.acc.addfn = addfn ;
-       CsvAccess(PseudoTable)[CpvAccess(pseudoCount)].pseudo_type.acc.combinefn=combinefn;
-       CpvAccess(pseudoCount)++ ;
-
-       return(CpvAccess(pseudoCount)-1) ;
-}
-
-
-int registerReadOnlyMsg()
-{
-/* this is only needed to give a unique index to all all readonly msgs */
-       CpvAccess(readMsgCount)++ ;
-       return(CpvAccess(readMsgCount)-1) ;
-}
-
-
-void registerReadOnly(size, fnCopyFromBuffer, fnCopyToBuffer)
-int size ;
-FUNCTION_PTR fnCopyFromBuffer, fnCopyToBuffer ;
-{
-/* this is called only once per module */
-       CsvAccess(ROCopyFromBufferTable)[CpvAccess(readCount)] = fnCopyFromBuffer ;
-       CsvAccess(ROCopyToBufferTable)[CpvAccess(readCount)] = fnCopyToBuffer ;
-       CsvAccess(ReadBuffSize) += size ;
-       CpvAccess(readCount)++ ;
-}
-
-
-
-void registerMainChare(m, ep, type)
-int m, ep ;
-int type ;
-{
-       CsvAccess(_CK_MainChareIndex) = m ;
-       CsvAccess(_CK_MainEpIndex) = ep ;
-       CsvAccess(MainChareLanguage) = type ;
-}
diff --git a/src/ck-core/register.h b/src/ck-core/register.h
new file mode 100644 (file)
index 0000000..ad3edec
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef _REGISTER_H
+#define _REGISTER_H
+
+class EntryInfo {
+  public:
+    char *name;
+    CkCallFnPtr call;
+    int msgIdx;
+    int chareIdx;
+
+    EntryInfo(char *n, CkCallFnPtr c, int m, int ci) : 
+      name(n), call(c), msgIdx(m), chareIdx(ci)
+    {}
+};
+
+class MsgInfo {
+  public:
+    char *name;
+    CkPackFnPtr pack;
+    CkUnpackFnPtr unpack;
+    CkCoerceFnPtr coerce;
+    int size;
+
+    MsgInfo(char *n, CkPackFnPtr p, CkUnpackFnPtr u, CkCoerceFnPtr c, int s) : 
+      name(n), size(s), pack(p), unpack(u), coerce(c) 
+    {}
+};
+
+class ChareInfo {
+  public:
+    char *name;
+    int size;
+    ChareInfo(char *n, int s) : name(n), size(s) {}
+};
+
+class MainInfo {
+  public:
+    int chareIdx;
+    int entryIdx;
+    MainInfo(int c, int e) : chareIdx(c), entryIdx(e) {}
+};
+
+class ReadonlyInfo {
+  public:
+    int size;
+    void *ptr;
+    ReadonlyInfo(int s, void *p) : size(s), ptr(p) {}
+};
+
+class ReadonlyMsgInfo {
+  public:
+    void **pMsg;
+    ReadonlyMsgInfo(void **p) : pMsg(p) {}
+};
+
+extern EntryInfo**        _entryTable;
+extern MsgInfo**          _msgTable;
+extern ChareInfo**        _chareTable;
+extern MainInfo**         _mainTable;
+extern ReadonlyInfo**     _readonlyTable;
+extern ReadonlyMsgInfo**  _readonlyMsgs;
+
+extern int _numEntries;
+extern int _numMsgs;
+extern int _numChares;
+extern int _numMains;
+extern int _numReadonlies;
+extern int _numReadonlyMsgs;
+
+#define _ENTRY_TABLE_SIZE     1024
+#define _MSG_TABLE_SIZE       256
+#define _CHARE_TABLE_SIZE     1024
+#define _MAIN_TABLE_SIZE      128
+#define _READONLY_TABLE_SIZE  128
+
+extern void _registerInit(void);
+
+#endif
diff --git a/src/ck-core/stat.c b/src/ck-core/stat.c
deleted file mode 100644 (file)
index 9a504a9..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-#define NODESTAT
-
-#include "charm.h"
-#include "trace.h"
-
-typedef int **ARRAY_;
-CpvStaticDeclare(ARRAY_, HostStat);
-CpvStaticDeclare(ARRAY_, HostMemStatistics);
-CpvStaticDeclare(int, NumPes);
-
-extern CollectTraceFromNodes();
-extern CHARE_BLOCK *CreateChareBlock();
-
-
-void statModuleInit()
-{
-    CpvInitialize(ARRAY_, HostStat);
-    CpvInitialize(ARRAY_, HostMemStatistics);
-    CpvInitialize(int, NumPes);
-}
-
-
-
-
-
-void StatInit(void)
-{
-       CHARE_BLOCK *bocBlock;
-       int i;
-
-       CpvAccess(NumPes) = CmiNumPes();
-       CpvAccess(RecdStatMsg) = 1;
-       if (CmiMyPe() == 0)
-               CpvAccess(RecdStatMsg) = 0;
-}
-
-void StatisticBocInit(void)
-{
-       CHARE_BLOCK *bocBlock;
-
-       bocBlock = CreateChareBlock(0, CHAREKIND_BOCNODE, 0);
-        bocBlock->x.boc_num = StatisticBocNum;
-       SetBocBlockPtr(StatisticBocNum, bocBlock);
-}
-
-
-void NodeCollectStatistics(msgPtr, localdataPtr)
-void *msgPtr;
-void *localdataPtr;
-{
-       STAT_MSG *sPtr;
-       int i;
-
-TRACE(CmiPrintf("Node %d: Enter NodeCollectStatistics() \n", CmiMyPe()));
-
-       sPtr = (STAT_MSG *) CkAllocMsg(sizeof(STAT_MSG)); 
-       CkMemError(sPtr);
-
-       sPtr->srcPE = CmiMyPe();
-       sPtr->chareQueueLength = CpvAccess(CstatsMaxChareQueueLength);
-       sPtr->forChareQueueLength = CpvAccess(CstatsMaxForChareQueueLength);
-       sPtr->fixedChareQueueLength = CpvAccess(CstatsMaxFixedChareQueueLength);
-       sPtr->charesCreated = CpvAccess(nodecharesCreated);
-       sPtr->charesProcessed = CpvAccess(nodecharesProcessed)
-                                       - CpvAccess(nodebocInitProcessed) - 1 ;
-       /* The -1 above is because counting for user-created chares starts
-          from 1. The main-chare on proc 0 is hence not counted. */
-
-       sPtr->forCharesCreated = CpvAccess(nodeforCharesCreated) 
-                                       + CpvAccess(nodebocMsgsCreated) ;
-       /* This count includes both messages to chares and messages to BOCs,
-          because it is incremented in CkProcess_ForChareMsg() */
-       sPtr->forCharesProcessed = CpvAccess(nodeforCharesProcessed);
-
-       /* Messages to BOCs are not counted separately for now 
-       sPtr->bocMsgsCreated = CpvAccess(nodebocMsgsCreated);
-       sPtr->bocMsgsProcessed = CpvAccess(nodebocMsgsProcessed);
-       */
-
-       for (i=0; i < MAXMEMSTAT; i++)
-               sPtr->nodeMemStat[i] = CstatMemory(i);
-
-       GeneralSendMsgBranch(CsvAccess(CkEp_Stat_CollectNodes), sPtr, 
-               0, BocMsg, StatisticBocNum);
-}
-
-
-
-
-void CollectStatistics(void)
-{
-       DUMMY_MSG *mPtr;
-
-       TRACE(CmiPrintf("Host: Enter CollectStatistics(): and Call BroadcastMsgBranch()\n"));
-       mPtr = (DUMMY_MSG *) CkAllocMsg(sizeof(DUMMY_MSG));
-       CkMemError(mPtr);
-       GeneralBroadcastMsgBranch(CsvAccess(CkEp_Stat_Data), mPtr,
-                                ImmBroadcastBocMsg,
-                                 StatisticBocNum);
-}
-
-
-void CollectFromNodes(msgPtr, localdataptr)
-void *msgPtr, *localdataptr;
-{
-       int i,j,k;
-       STAT_MSG *mPtr = (STAT_MSG *) msgPtr;
-
-TRACE(CmiPrintf("Host %d: Enter CollectFromNodes(): NumPes %d\n",
-        CmiMyPe(), CpvAccess(NumPes)));
-       if (CpvAccess(NumPes) == CmiNumPes())
-       {
-              CpvAccess(HostMemStatistics)=
-                              (int **) CmiAlloc(sizeof(int *)*CpvAccess(NumPes));
-              CkMemError(CpvAccess(HostMemStatistics));
-               for (i=0; i<CpvAccess(NumPes); i++)
-               {
-                       CpvAccess(HostMemStatistics)[i] = 
-                           (int *) CmiAlloc(sizeof(int)*MAXMEMSTAT);
-                       CkMemError(CpvAccess(HostMemStatistics)[i]);
-               }
-               CpvAccess(HostStat) = 
-                           (int **) CmiAlloc(sizeof(int *)*CpvAccess(NumPes));
-               CkMemError(CpvAccess(HostStat));
-               for (i=0; i<CpvAccess(NumPes); i++)
-               {
-                       CpvAccess(HostStat)[i]=(int *)CmiAlloc(sizeof(int)*10);
-                       CkMemError(CpvAccess(HostStat)[i]);
-               }
-               for (i=0; i<CpvAccess(NumPes); i++)
-               {
-                       for (j=0; j<MAXMEMSTAT; j++)
-                               CpvAccess(HostMemStatistics)[i][j] = 0;
-                       for (j=0; j<10; j++)
-                               CpvAccess(HostStat)[i][j] = 0;
-               }
-       }
-       CpvAccess(NumPes)--;
-
-       CpvAccess(HostStat)[mPtr->srcPE][0] = mPtr->chareQueueLength;
-       CpvAccess(HostStat)[mPtr->srcPE][1] = mPtr->forChareQueueLength;
-       CpvAccess(HostStat)[mPtr->srcPE][2] = mPtr->fixedChareQueueLength;
-       CpvAccess(HostStat)[mPtr->srcPE][3] = mPtr->charesCreated;
-       CpvAccess(HostStat)[mPtr->srcPE][4] = mPtr->charesProcessed;
-       CpvAccess(HostStat)[mPtr->srcPE][5] = mPtr->forCharesCreated;
-       CpvAccess(HostStat)[mPtr->srcPE][6] = mPtr->forCharesProcessed;
-       CpvAccess(HostStat)[mPtr->srcPE][7] = mPtr->bocMsgsCreated;
-       CpvAccess(HostStat)[mPtr->srcPE][8] = mPtr->bocMsgsProcessed;
-
-       for (k=0; k < MAXMEMSTAT; k++)
-         CpvAccess(HostMemStatistics)[mPtr->srcPE][k] = mPtr->nodeMemStat[k];
-       
-       /* Exit when statistics from all the nodes have been received */
-       if (CpvAccess(NumPes) == 0)
-       {
-               CpvAccess(RecdStatMsg) = 1;
-               if (CpvAccess(CtrRecdTraceMsg)) ExitNode();
-       }
-}
-
-
-
-void PrintOutStatistics(void)
-{
-       int i,j,k;
-       int col = 0;
-       int totalHops = 0;
-       int  totalChares = 0;
-       int  totalCharesCrea = 0;
-       int  totalCharesProc = 0;
-       int totalChareQ = 0, totalForChareQ = 0, totalMemoryUsage = 0;
-       int totalMemoryOverflow = 0;
-       ENVELOPE * env;
-       char *msg;
-
-       if (CstatPrintQueueStats())
-       {
-               CmiPrintf("Queue Statistics: (NODE)[MaxChareQ, MaxForChareQ, MaxFixedChareQ]\n");
-               for (k=0; k < CmiNumPes(); k++)
-               {
-                       totalChareQ += CpvAccess(HostStat)[k][0];
-                       totalForChareQ += CpvAccess(HostStat)[k][1];
-               }
-               CmiPrintf("Average Queue Sizes: [AvgMaxChareQ %d, AvgMaxForChareQ %d]\n",
-                   totalChareQ/CmiNumPes(), totalForChareQ/CmiNumPes());
-
-               for (k=0; k < CmiNumPes(); k++)
-                       CmiPrintf("(%d)[%d, %d, %d], ", k, 
-                                   CpvAccess(HostStat)[k][0], 
-                                   CpvAccess(HostStat)[k][1], 
-                                   CpvAccess(HostStat)[k][2]);
-               CmiPrintf("\n\n");
-       }
-
-
-        if (CpvAccess(PrintChareStat) || CpvAccess(PrintSummaryStat))
-               for (k=0; k < CmiNumPes(); k++)
-               {
-                       totalCharesCrea += CpvAccess(HostStat)[k][3];
-                       totalCharesProc += CpvAccess(HostStat)[k][4];
-               }
-
-
-       if (CpvAccess(PrintSummaryStat))
-       {
-               CmiPrintf("\nPrinting Chare Summary Statistics:\n");
-               CmiPrintf("Total Chares: [Created %d, Processed %d]\n",
-                   totalCharesCrea, totalCharesProc);
-       }
-
-
-       if (CpvAccess(PrintChareStat))
-       {
-               CmiPrintf("----------------------------------------------\n");
-               CmiPrintf("Printing Chare Statistics:\n");
-               CmiPrintf("PE  Chares-Created Chares-Processed Messages-Created Messages-Processed\n");
-               for (k=0; k < CmiNumPes(); k++) {
-                       CmiPrintf("%-3d",k) ; 
-
-                       CmiPrintf(" %14d %16d", CpvAccess(HostStat)[k][3], 
-                                           CpvAccess(HostStat)[k][4]);
-                       CmiPrintf(" %16d %18d", CpvAccess(HostStat)[k][5],
-                                           CpvAccess(HostStat)[k][6]);
-                       CmiPrintf("\n") ;
-               }
-
-               CmiPrintf("\nNumber of Branch-Office Chares : %d\n",
-                                       CpvAccess(nodebocInitProcessed));
-
-
-               /* Boc msgs not counted separately for now 
-               CmiPrintf("For Boc Messages: ");
-               for (k=0; k < CmiNumPes(); k++)
-                       CmiPrintf("(%d)[%d, %d], ", k, 
-                          CpvAccess(HostStat)[k][7], CpvAccess(HostStat)[k][8]);
-               */
-               
-               CmiPrintf("\n\n");
-
-       }
-        
-       if (CstatPrintMemStats())
-       {
-               CmiPrintf("Printing Memory Statistics:\n\n");
-                CmiPrintf("Available Memory: %d (words)\n",
-                         CpvAccess(HostMemStatistics)[0][0]);
-                CmiPrintf(" Node     Unused         Allocated                   Freed\n");
-                CmiPrintf(" Node     (words)     (no.req, words)            (no.req, words)\n");
-                CmiPrintf("------   --------    ---------------------      ---------------------\n");
-               for (k=0; k < CmiNumPes(); k++)
-                        CmiPrintf("%4d    %8d     [%8d,%10d]      [%8d,%10d]\n",
-                        k,CpvAccess(HostMemStatistics)[k][1],
-                        CpvAccess(HostMemStatistics)[k][2],
-                        CpvAccess(HostMemStatistics)[k][3]*2,
-                        CpvAccess(HostMemStatistics)[k][4],
-                        CpvAccess(HostMemStatistics)[k][5]*2);
-                CmiPrintf("\n");
-       }
-}
-
-void StatAddSysBocEps(void)
-{
-  extern BroadcastExitMessage(), ExitMessage();
-
-  CsvAccess(CkEp_Stat_CollectNodes)=
-    registerBocEp("CkEp_Stat_CollectNodes",
-                 CollectFromNodes,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_Stat_Data)=
-    registerBocEp("CkEp_Stat_Data",
-                 NodeCollectStatistics,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_Stat_TraceCollectNodes)=
-    registerBocEp("CkEp_Stat_TraceCollectNodes",
-                 CollectTraceFromNodes,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_Stat_BroadcastExitMessage)=
-    registerBocEp("CkEp_Stat_BroadcastExitMessage",
-                 BroadcastExitMessage,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_Stat_ExitMessage)=
-    registerBocEp("CkEp_Stat_ExitMessage",
-                 ExitMessage,
-                 CHARM, 0, 0);
-}
diff --git a/src/ck-core/stats.h b/src/ck-core/stats.h
new file mode 100644 (file)
index 0000000..e6776a9
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef _STATS_H
+#define _STATS_H
+
+class Stats {
+  private:
+    UInt charesCreated; // # of new chare msgs sent
+    UInt charesProcessed; // # of new chare msgs processed
+    UInt forCharesCreated; // # of for chare msgs created
+    UInt forCharesProcessed; // # of for chare msgs processed
+    UInt groupInitsCreated; // # of group init msgs created
+    UInt groupInitsProcessed; // # of groupinits processed
+    UInt groupMsgsCreated; // # of for group msgs created
+    UInt groupMsgsProcessed; // # of for group msgs processed
+  public:
+    void *operator new(size_t size) { return _allocMsg(StatMsg, size); }
+    void operator delete(void *ptr) { CkFreeMsg(ptr); }
+    Stats() {
+      charesCreated = 0; 
+      charesProcessed = 0; 
+      forCharesCreated = 0; 
+      forCharesProcessed = 0; 
+      groupInitsCreated = 0; 
+      groupInitsProcessed = 0; 
+      groupMsgsCreated = 0; 
+      groupMsgsProcessed = 0; 
+    }
+    void combine(Stats* other) {
+      charesCreated += other->charesCreated; 
+      charesProcessed += other->charesProcessed; 
+      forCharesCreated += other->forCharesCreated; 
+      forCharesProcessed += other->forCharesProcessed; 
+      groupInitsCreated += other->groupInitsCreated; 
+      groupInitsProcessed += other->groupInitsProcessed; 
+      groupMsgsCreated += other->groupMsgsCreated; 
+      groupMsgsProcessed += other->groupMsgsProcessed; 
+    }
+    void recordCreateChare(int x=1) { charesCreated += x; }
+    void recordProcessChare(int x=1) { charesProcessed += x; }
+    void recordSendMsg(int x=1) { forCharesCreated += x; }
+    void recordProcessMsg(int x=1) { forCharesProcessed += x; }
+    void recordCreateGroup(int x=1) { groupInitsCreated += x; }
+    void recordProcessGroup(int x=1) { groupInitsProcessed += x; }
+    void recordSendBranch(int x=1) { groupMsgsCreated += x; }
+    void recordProcessBranch(int x=1) { groupMsgsProcessed += x; }
+    UInt getCharesCreated(void) { return charesCreated; }
+    UInt getCharesProcessed(void) { return charesProcessed; }
+    UInt getForCharesCreated(void) { return forCharesCreated; }
+    UInt getForCharesProcessed(void) { return forCharesProcessed; }
+    UInt getGroupsCreated(void) { return groupInitsCreated; }
+    UInt getGroupsProcessed(void) { return groupInitsProcessed; }
+    UInt getGroupMsgsCreated(void) { return groupMsgsCreated; }
+    UInt getGroupMsgsProcessed(void) { return groupMsgsProcessed; }
+};
+
+CpvExtern(Stats*, _myStats);
+
+#endif
diff --git a/src/ck-core/tbl.c b/src/ck-core/tbl.c
deleted file mode 100644 (file)
index 255bbac..0000000
+++ /dev/null
@@ -1,634 +0,0 @@
-#include "charm.h"
-#include "trace.h"
-
-#define TBL_WAITFORDATA 1
-#define TBL_NOWAITFORDATA 2
-
-#define TBL_REPLY 1
-#define TBL_NOREPLY 2
-
-#define TBL_WAIT_AFTER_FIRST 1
-#define TBL_NEVER_WAIT 2
-#define TBL_ALWAYS_WAIT 3
-
-#define MAX_TBL_SIZE 211
-
-typedef struct {
-       int penum;
-       int index;
-} map;
-
-typedef struct {
-       int key;
-       char *data;
-} TBL_MSG;
-
-
-typedef struct address {
-       int entry;
-       ChareIDType  chareid;
-       struct address *next;
-} ADDRESS;
-
-typedef struct tbl_element {
-       int isDefined;
-       int tbl;
-       int key;
-       char *data;
-       int size_data;
-       struct address *reply;
-       struct tbl_element *next;
-}      TBL_ELEMENT;
-
-typedef struct {
-       int i;
-} DATA_BR_TBL;
-
-typedef struct {
-       int i;
-} DATA_MNGR_TBL;
-
-#define SIZE_CHARE_ID sizeof(ChareIDType)
-extern CHARE_BLOCK *CreateChareBlock();
-
-typedef struct tbl_element *TBL_ELEMENT_[MAX_TBL_SIZE];
-CpvStaticDeclare(TBL_ELEMENT_, table);
-
-void TblInsert();
-void TblDelete();
-void TblFind();
-
-
-void tblModuleInit()
-{
-    CpvInitialize(TBL_ELEMENT_, table);
-}
-
-
-
-void TblBocInit(void)
-{
-       CHARE_BLOCK *bocBlock;
-       int i;
-
-       bocBlock = CreateChareBlock(sizeof(DATA_BR_TBL), CHAREKIND_BOCNODE, 0);
-        bocBlock->x.boc_num = TblBocNum;
-       SetBocBlockPtr(TblBocNum, bocBlock);
-
-       for (i=0; i<MAX_TBL_SIZE; i++)
-               CpvAccess(table)[i] = (TBL_ELEMENT *) NULL;
-       TRACE(CmiPrintf("Node %d: TblBocInit: BocDataTbl entry filled.\n",CmiMyPe()));
-}
-
-#define align(var) ((var+sizeof(void *)-1)&(~(sizeof(void *)-1)))
-
-/************************************************************************/
-/*     This entry point unpacks the packed stuff and does the required */
-/*     operation.                                                      */
-/************************************************************************/
-
-void Unpack(ptr, dataptr)
-char *ptr;
-void *dataptr;
-{
-       int size;
-       int *operation, *tbl, *entry, *option;
-       int *index;
-       char  *data;
-       int *key;
-       int  *size_data;
-       ChareIDType *chareid;
-       TBL_MSG *msg;
-       int *size_chareid;
-
-
-TRACE(CmiPrintf("[%d] Unpack:: ptr=0x%x\n", CmiMyPe(), ptr));
-
-       size = sizeof(int);
-       operation  = (int *) ptr;
-       ptr += size;
-       tbl  = (int *)ptr;
-       ptr += size;
-       index = (int *)ptr;
-       ptr += size;
-       key = (int *) ptr;
-       ptr += size;
-       size_data = (int *) ptr;
-       ptr += size;
-       if (*size_data == 0)
-               data = (char *) NULL;
-       else
-       {
-               data = (char *)  ptr;
-               ptr += align(*size_data);
-       }
-       entry  =(int *) ptr;
-       ptr += size;
-
-TRACE(CmiPrintf("[%d] Unpack:: index=%d, key=%d, size_data=%d, entry=%d\n",
-               CmiMyPe(), *index, *key, *size_data, *entry));
-
-       size_chareid = (int *) ptr;
-       ptr += size;
-       option = (int *) ptr;
-       ptr += size;
-
-TRACE(CmiPrintf("[%d] Unpack:: size_chareid=%d\n",
-               CmiMyPe(), *size_chareid));
-
-       if (*size_chareid == 0)
-               chareid = (ChareIDType *) NULL;
-       else
-       {
-               chareid = (ChareIDType *) ptr;  
-               ptr += *size_chareid;
-       }
-
-TRACE(CmiPrintf("[%d] Unpack:: option=%d\n",
-               CmiMyPe(), *option));
-
-       switch (*operation){
-       case 0 :
-               TblInsert(*tbl, *index, *key, data, *size_data,
-                        *entry, chareid, *option);
-               break;
-       case 1:
-               TblDelete(*tbl, *index, *key, *entry, chareid, *option);
-               break;
-       case 2:
-               TblFind(*tbl, *index, *key,  *entry, chareid, *option);
-               break;
-       case 3:
-               msg = (TBL_MSG *) CkAllocMsg(sizeof(TBL_MSG));
-               CkMemError(msg);
-               msg->key = *((int *) key);
-               msg->data = data;
-               SendMsg(*entry, msg, chareid);
-               break;
-       default:
-               CmiPrintf("We are in trouble here\n");
-       }
-}
-
-
-absolute(i)
-int i;
-{
-       if (i<0)
-               return(-i);
-       else
-               return(i);
-}
-
-
-/************************************************************************/
-/*     This function copies structures.                                */
-/************************************************************************/
-
-void structure_copy(x, y, size)
-char *x, *y;
-int size;
-{
-       int i;
-
-       for (i=0; i<size; i++)
-               *x++ = *y++;
-}
-
-
-/************************************************************************/
-/*     This function takes a key and its size, and computes a mapping  */
-/*     (p,i), where p is the processor on which the key resides/will   */
-/*     reside, and i is the index in the table.                        */
-/************************************************************************/
-
-map * Hash(tbl, key)
-int tbl, key;
-{
-       int p, i;
-       map *value;
-       
-       if (CsvAccess(PseudoTable)[tbl].pseudo_type.tbl.hashfn)
-               p = (*CsvAccess(PseudoTable)[tbl].pseudo_type.tbl.hashfn)(key);
-       else
-               p = 13*key % MAX_TBL_SIZE; 
-               
-       i = 83*key;
-       value = (map *) CmiAlloc(sizeof(map));
-       CkMemError(value);
-       value->penum = absolute(p % CmiNumPes());
-       value->index = absolute(i % MAX_TBL_SIZE);
-       return(value);
-}
-
-
-/************************************************************************/
-/*     This function takes the key and table index and matches it with */
-/*     the entries in the table . It returns a pointer to the matched  */
-/*     element.                                                        */
-/************************************************************************/
-
-TBL_ELEMENT * match(key, tbl, ptr)
-int key;
-int tbl;
-TBL_ELEMENT * ptr;
-{
-       while (ptr != NULL)
-       {
-               if ( (ptr->tbl == tbl) && (key == ptr->key))
-                               return(ptr);
-               else
-                       ptr = ptr->next;
-       }
-       return(NULL);
-}
-
-
-
-/************************************************************************/
-/*     This function packs the key, data etc for an entry              */
-/************************************************************************/
-void
-pack(operation, tbl, index, penum, key, data, size_data, entry,chareid, option)
-char *operation, *tbl, *index;
-int  penum;
-char  *key;
-char  *data;
-char *size_data;
-char *entry, *chareid;
-char *option;
-{
-       int size, sized;
-       int total_size;
-       char *original, *ptr;
-       TBL_MSG *msg;
-       int size_chareid;
-
-TRACE(CmiPrintf("[%d] Pack :: operation=%d, penum=%d, key=%d, entry=%d\n",
-                CmiMyPe(),
-                *((int *) operation), penum,
-                *((int *)key), *((int *)entry)));
-
-       if (penum == CmiMyPe())
-       {
-
-TRACE(CmiPrintf("[%d] Pack :: operation=%d, penum=%d, key=%d, entry=%d\n",
-                CmiMyPe(),
-                *((int *) operation), penum,
-                *((int *)key), *((int *)entry)));
-
-               msg = (TBL_MSG *) CkAllocMsg(sizeof(TBL_MSG));
-               CkMemError(msg);
-               msg->key = *((int *) key);
-               msg->data = data;
-               SendMsg(*((int *) entry), msg, (ChareIDType *) chareid);
-       }
-       else
-       {
-
-               size = sizeof(int);
-               sized = *((int *) size_data);
-               if (chareid == NULL)
-                       size_chareid = 0;
-               else 
-                       size_chareid = SIZE_CHARE_ID;
-               total_size = 9*size + align(sized) + size_chareid;
-
-TRACE(CmiPrintf("[%d] Pack:: size_chareid=%d, total_size=%d\n",
-               CmiMyPe(), size_chareid, total_size));
-
-               ptr = (char *) CkAllocMsg(total_size);
-               CkMemError(ptr);
-               original = ptr;
-               structure_copy(ptr, operation, size);
-               ptr += size;
-               structure_copy(ptr, tbl, size);
-               ptr += size;
-               structure_copy(ptr, index, size);
-               ptr += size;
-               structure_copy(ptr, key, size);
-               ptr += size;
-               structure_copy(ptr, size_data, size);
-               ptr += size;
-               if (sized != 0)
-               {
-                       structure_copy(ptr, data, sized);
-                       ptr += align(sized);
-               }
-               structure_copy(ptr, entry, size);
-               ptr += size;
-               structure_copy(ptr, (char *) &size_chareid, size);
-               ptr += size;
-               structure_copy(ptr, option, size);
-               ptr += size;
-               if (size_chareid != 0)
-               {
-                       structure_copy(ptr, chareid, size_chareid);
-                       ptr += size_chareid;
-               }
-       TRACE(CmiPrintf("Pack :: sending key %d to penum %d\n", 
-                       *((int *) key), penum));
-               GeneralSendMsgBranch(CsvAccess(CkEp_Tbl_Unpack), original,
-                               penum, ImmBocMsg, TblBocNum);
-       }
-}
-
-
-/************************************************************************/
-/*     This function intercepts local Insert calls, and then sends a   */
-/*     message to the entry point BR_TblInsert on the processor on     */
-/*     which the element is to be stored with details about the element*/
-/*     to be inserted.                                                 */
-/************************************************************************/
-
-void TblInsert(tbl, index, key, data, size_data, entry, chareid, option)
-int tbl;
-int index;
-int key;
-char *data;
-int size_data;
-int entry;
-ChareIDType *chareid;
-int option;
-{
-       map *place;
-       int operation = 0;
-       ADDRESS *temp;
-       TBL_ELEMENT *ptr;
-
-       option = -1;
-       if (index == -1)
-               place = Hash(tbl, key);
-       
-        if(CpvAccess(traceOn)) {
-         if (index == -1)
-                   trace_table(INSERT, tbl, key, place->penum);
-         else 
-                   trace_table(INSERT, tbl, key, CmiMyPe());
-        }
-
-       if (!data)  {
-               CmiPrintf("*** ERROR *** Insert on processor %d has null data.\n",
-                                       CmiMyPe());
-               return;
-       }
-       if ( (index == -1) && (place->penum != CmiMyPe()))
-               pack((char *) &operation, (char *) &tbl, (char *) &(place->index), place->penum,
-                        (char *) &key,  data, (char *) &size_data, (char *) &entry, (char *) chareid, (char *) &option);
-       else
-       {
-               if (index == -1) index = place->index;
-TRACE(CmiPrintf("TblInsert :: key = %d, index = %d\n", key, index));
-               ptr = match(key, tbl, CpvAccess(table)[index]);
-               operation = 3;
-               if ( (ptr == NULL) ||  (! ptr->isDefined) )
-               {
-                       if (ptr == NULL)
-                       {
-                               ptr = (TBL_ELEMENT *) CmiAlloc(sizeof(TBL_ELEMENT));
-                               CkMemError(ptr);
-                               ptr->tbl = tbl;
-                               ptr->key = key;
-                               ptr->reply = (ADDRESS *) NULL;
-                               ptr->next = CpvAccess(table)[index];
-                               CpvAccess(table)[index] = ptr;
-TRACE(CmiPrintf("TblInsert :: table entry created with key %d\n", key));
-                       }               
-                       ptr->data = (char *) CmiAlloc(size_data);
-                       CkMemError(ptr->data);
-                       structure_copy(ptr->data, data, size_data);
-                       ptr->size_data = size_data;
-                       ptr->isDefined = 1;
-                       temp = ptr->reply;
-                       while (temp != NULL)
-                       {
-TRACE(CmiPrintf("TblInsert :: Pending request key is %d  - data is %d\n",
-               ptr->key, *((int *) data)));
-                               pack((char *) &operation, (char *) &tbl, (char *) &index, GetID_onPE(temp->chareid),
-                                               (char *) &ptr->key, ptr->data, (char *) &size_data,
-                                               (char *) &temp->entry, (char *) &temp->chareid, (char *) &option);
-                               temp = temp->next;
-                       };
-                       if ((entry != -1) && (chareid != NULL))
-                               pack((char *) &operation, (char *) &tbl, (char *) &index, GetID_onPE((*chareid)),
-                                               (char *) &ptr->key, ptr->data, (char *) &size_data,  
-                                               (char *) &entry, (char *) chareid, (char *) &option);
-               }
-               else
-               {
-                       if ((entry != -1) && (chareid != NULL))
-                       {
-                               pack((char *) &operation, (char *) &tbl, (char *) &index,
-                                       GetID_onPE((*chareid)),
-                                        (char *) &ptr->key, ptr->data, (char *)&ptr->size_data,
-                                        (char *)&entry, (char *) chareid, (char *)&option);
-                       } 
-               }
-       }
-}
-
-
-/************************************************************************/
-/*     This function intercepts local Delete calls, and then sends a   */
-/*     message to the entry point BR_TblDelete on the processor on     */
-/*     which the element is to be stored with details about the element*/
-/*     to be deleted.                                                  */
-/************************************************************************/
-
-void TblDelete(tbl, index, key, entry, chareid, option)
-int tbl;
-int index;
-int key;
-int entry;
-ChareIDType *chareid;
-int option;
-{
-       int size = 0;
-       char *data = (char  *) NULL;
-       map *place;
-       int operation = 1;
-       TBL_ELEMENT *ptr1, *ptr2;
-
-       if ((option !=  TBL_REPLY) && (option != TBL_NOREPLY))
-               CmiPrintf("***error*** TblDelete :: Unknown option chosen\n");
-       if (index == -1)
-               place = Hash(tbl, key); 
-
-        if(CpvAccess(traceOn)) {
-         if (index == -1)
-                   trace_table(DELETE, tbl, key, place->penum);
-         else 
-                   trace_table(DELETE, tbl, key, CmiMyPe());
-        }
-
-       if ( (index == -1) && ( place->penum != CmiMyPe()))
-               pack((char *) &operation, (char *) &tbl, (char *) &(place->index), place->penum,
-                        (char *) &key, data, (char *) &size,  (char *) &entry, (char *) chareid, (char *) &option);
-       else
-       {
-               if (index == -1) index  = place->index;
-               ptr1 = CpvAccess(table)[index];
-               ptr2 = (TBL_ELEMENT *) NULL;
-               while ( (ptr1 != NULL) &&
-                       (  (ptr1->tbl != tbl) || 
-                          (key != ptr1->key)))
-               {
-                       ptr2 = ptr1;
-                       ptr1 = ptr1->next;
-               }
-               operation = 3;
-               if ( (ptr1 != NULL) && (entry != -1) && (chareid != NULL)) 
-                       pack((char *) &operation, (char *) &tbl, (char *) &index, 
-                               GetID_onPE((*chareid)),
-                               (char *) &ptr1->key, ptr1->data, (char *) &ptr1->size_data,
-                               (char *) &entry, (char *) chareid, (char *) &option);
-               if ( (ptr1 == NULL) && (entry != -1) && (chareid != NULL) 
-                                   && (option == TBL_REPLY))
-                       pack((char *) &operation, (char *) &tbl, (char *) &index, GetID_onPE((*chareid)),
-                                (char *) &key, data, (char *) &size, (char *) &entry, (char *) chareid, (char *) &option);
-               if (ptr2 == NULL) 
-                       if (ptr1 != NULL)
-                       {
-                               CpvAccess(table)[index] =  ptr1->next;
-                               CmiFree(ptr1);
-                       }
-                       else
-                               CpvAccess(table)[index] = (TBL_ELEMENT *) NULL;
-               else
-                       if (ptr1 != NULL)
-                       {
-                               ptr2->next = ptr1->next;
-                               CmiFree(ptr1);
-                       }
-                       else
-                               ptr2->next =(TBL_ELEMENT *) NULL;
-       }       
-}
-
-
-/************************************************************************/
-/*     This function intercepts local Find calls, and then sends a     */
-/*     message to the entry point BR_Tbl_Find on the processor on which*/
-/*     the element may exist with information about element to be found*/
-/************************************************************************/
-
-void TblFind( tbl, index, key, entry, chareid, option)
-int tbl;
-int index;
-int key;
-int entry;
-ChareIDType *chareid;
-int option;
-{
-       char * data = (char *) NULL;
-       int size =  0;
-       map *place;
-       int operation = 2;
-       TBL_ELEMENT *ptr;
-       ADDRESS *temp;
-
-       if ((option != TBL_NEVER_WAIT) && (option != TBL_ALWAYS_WAIT)
-               && (option != TBL_WAIT_AFTER_FIRST))
-                       CmiPrintf("***error*** TblFind :: Unknown option chosen\n");
-       place = Hash(tbl, key); 
-
-        if(CpvAccess(traceOn)) {
-         if (index == -1)
-                   trace_table(FIND, tbl, key, place->penum);
-         else 
-                   trace_table(FIND, tbl, key, CmiMyPe());
-        }
-
-
-       if ( (index == -1) && (place->penum != CmiMyPe()))
-               pack((char *) &operation, (char *) &tbl, (char *) &(place->index), place->penum,
-                        (char *) &key, data, (char *) &size, (char *) &entry, (char *) chareid, (char *) &option);
-       else
-       {
-               if (index == -1) index = place->index;
-               ptr = match(key, tbl, CpvAccess(table)[index]); 
-
-TRACE(CmiPrintf("[%d] TblFind: ptr=0x%x, entry=%d, option=%d, index=%d\n",
-               CmiMyPe(), ptr, entry, option, index));
-
-               operation = 3;
-               if (ptr != NULL)
-                       if (ptr->isDefined)
-                               {
-                               if ((entry != -1) && (chareid != NULL))
-                                       pack((char *) &operation, (char *) &tbl, (char *) &index, 
-                                               GetID_onPE((*chareid)), (char *) &key, 
-                                               ptr->data, (char *) &ptr->size_data,
-                                               (char *) &entry, (char *) chareid, (char *) &option);
-                               }
-                       else
-                       {
-                          if (option == TBL_NEVER_WAIT)
-                          {
-                               if ((entry != -1) && (chareid != NULL))
-                                       pack((char *) &operation, (char *) &tbl, (char *) &index, 
-                                               GetID_onPE((*chareid)), (char *) &key,
-                                               data, (char *) &size,
-                                               (char *) &entry, (char *) chareid, (char *) &option);
-                          }
-                          else
-                          {
-                               if ((entry != -1) && (chareid != NULL))
-                               {
-                                  temp = (ADDRESS *) CmiAlloc(sizeof(ADDRESS));
-                                  CkMemError(temp);
-                                  temp->entry = entry;
-                                  temp->chareid = *chareid;
-                                  temp->next = ptr->reply;
-                                  ptr->reply = temp;
-                               }
-                          }
-                       }
-               else
-               {
-TRACE(CmiPrintf("[%d TblFind: ptr is NULL, tbl=%d, key=%d\n",
-       CmiMyPe(), tbl, key));
-
-                       ptr = (TBL_ELEMENT *) CmiAlloc(sizeof(TBL_ELEMENT));
-TRACE(CmiPrintf("[%d] TblFind: Going to send message.\n"));
-                       CkMemError(ptr);
-                       ptr->tbl = tbl;
-                       ptr->key = key;
-                       ptr->reply = (ADDRESS *) NULL;
-                       ptr->next = CpvAccess(table)[index];
-                       CpvAccess(table)[index] = ptr;
-                       ptr->isDefined = 0;
-                       ptr->data = (char *) NULL;
-                       ptr->size_data = 0;
-
-                       if (option == TBL_ALWAYS_WAIT)
-                       {
-                          if ((entry != -1) && (chareid != NULL)) 
-                          {
-                               temp = (ADDRESS *) CmiAlloc(sizeof(ADDRESS));
-                               CkMemError(temp);
-                               temp->entry = entry;
-                               temp->chareid = *chareid;
-                               temp->next = ptr->reply;
-                               ptr->reply = temp;
-                          }
-                       }
-                       else
-                          if ((entry != -1) && (chareid != NULL)) 
-                               pack((char *) &operation, (char *) &tbl, (char *) &index, 
-                                       GetID_onPE((*chareid)),
-                                       (char *) &key, data, (char *) &size, (char *) &entry, (char *) chareid,
-                                       (char *) &option);
-TRACE(CmiPrintf("[%d] TblFind: Sent message.\n"));
-
-               }
-       }
-}
-
-void TblAddSysBocEps(void)
-{
-  CsvAccess(CkEp_Tbl_Unpack) =
-    registerBocEp("CkEp_Tbl_Unpack",
-                 Unpack,
-                 CHARM, 0, 0);
-}
diff --git a/src/ck-core/vid.c b/src/ck-core/vid.c
deleted file mode 100644 (file)
index d9ac122..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "charm.h"
-#include "trace.h"
-
-typedef struct data_brnch_vid {
-       int dummy;
-} DATA_BR_VID;
-
-typedef struct chare_id_msg{
-        ChareIDType ID;
-} CHARE_ID_MSG;
-
-void VidEnqueueMsg(env)
-ENVELOPE *env;
-{
-  CHARE_BLOCK *vid = GetEnv_chareBlockPtr(env);
-  void *vidqueue = vid->x.vid_queue;
-  FIFO_EnQueue(vidqueue, env);
-}
-
-void VidForwardMsg(env)
-ENVELOPE *env;
-{
-  CHARE_BLOCK *vid = GetEnv_chareBlockPtr(env);
-  SetEnv_chareBlockPtr(env, GetID_chareBlockPtr(vid->x.realID));
-  SetEnv_chare_magic_number(env, GetID_chare_magic_number(vid->x.realID));
-  if(CpvAccess(traceOn))
-    trace_creation(GetEnv_msgType(env), GetEnv_EP(env), env);
-  CldEnqueue(GetID_onPE(vid->x.realID), env, CpvAccess(CkInfo_Index));
-  QDCountThisCreation(1);
-}
-
-/************************************************************************/
-/*                     VidSendOverMessage                              */
-/*     Once the charm.ha been created it needs to get the messages     */
-/*     that were sent to it while it hadn't been created. These        */
-/*     messages are queued up in its virtual id block, whose address   */
-/*     it has available. The messages are then dequeued and sent over  */
-/*      to the processor on which the chare was finally created.        */
-/************************************************************************/
-
-void VidSendOverMessages(msgPtr, data_area)
-CHARE_ID_MSG *msgPtr;
-void *data_area;
-{
-    ChareIDType         ID;
-    ENVELOPE           *env;
-    CHARE_BLOCK                *vidblock;
-    void               *vidqueue;
-    int                chare_magic;
-    int                 chare_pe;
-    CHARE_BLOCK        *chare_block;
-
-    ID = msgPtr->ID;
-    env = ENVELOPE_UPTR(msgPtr);
-    vidblock = GetEnv_vidBlockPtr(env);
-    chare_magic = GetID_chare_magic_number(ID);
-    chare_pe = GetID_onPE(ID);
-    chare_block  = GetID_chareBlockPtr(ID);
-
-    if (vidblock->charekind != CHAREKIND_UVID) {
-      CmiPrintf("system error #12983781\n");
-      exit(1);
-    }
-    vidqueue = vidblock->x.vid_queue;
-    while (!FIFO_Empty(vidqueue))
-    {
-       FIFO_DeQueue(vidqueue, &env);
-       SetEnv_chareBlockPtr(env, chare_block);
-       SetEnv_chare_magic_number(env, chare_magic);
-        if(CpvAccess(traceOn))
-         trace_creation(GetEnv_msgType(env), GetEnv_EP(env), env);
-       CldEnqueue(chare_pe, env, CpvAccess(CkInfo_Index));
-       QDCountThisCreation(1);
-   }
-   FIFO_Destroy(vidqueue);
-   vidblock->charekind = CHAREKIND_FVID;
-   vidblock->x.realID = ID;
-}
-
-
-/************************************************************************/
-/*                     VidRetrieveMessages                             */
-/*     This is used by the newly-created chare to request the          */
-/*      messages that were stored in its VID                            */
-/************************************************************************/
-
-void VidRetrieveMessages(chareblockPtr,vidPE,vidBlockPtr)
-CHARE_BLOCK * chareblockPtr;
-PeNumType  vidPE;
-CHARE_BLOCK *vidBlockPtr;
-{
-    CHARE_ID_MSG * msg;
-    ENVELOPE * env;
-
-    msg = (CHARE_ID_MSG *)CkAllocMsg(sizeof(CHARE_ID_MSG));
-    CkMemError(msg);
-    msg->ID = CpvAccess(currentChareBlock)->selfID;
-    env = ENVELOPE_UPTR(msg);
-    SetEnv_msgType(env, VidSendOverMsg);
-    SetEnv_vidBlockPtr(env, vidBlockPtr);
-    SetEnv_EP(env, 0);
-
-    QDCountThisCreation(1);
-    if(CpvAccess(traceOn))
-      trace_creation(GetEnv_msgType(env), GetEnv_EP(env), env);
-    CmiSetHandler(env, CpvAccess(HANDLE_INCOMING_MSG_Index));
-    CldEnqueue(vidPE, env, CpvAccess(CkInfo_Index));
-}
diff --git a/src/ck-core/wrtone.c b/src/ck-core/wrtone.c
deleted file mode 100644 (file)
index 543536e..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-/*****************************************************************************
-                   Write once variable system boc (branch part)
-
-*****************************************************************************/
-
-#include "charm.h"
-
-#define MAXWRITEONCEVARS  50         /* arbitrary maximum number */
-
-#define isLeaf(peNum) (CmiNumSpanTreeChildren(peNum) == 0)
-
-/* Data Structures. We keep a different type for the host and for the nodes */
-/* This is because on the nodes we don't need a lot of the information that */
-/* is kept on the host to inform the user program that the wov has been     */
-/* created.                                                                 */
-
-typedef struct {              /* data needed for each write once variable */
-    EntryPointType ep;
-    ChareIDType    cid;
-    int                   numAcks;
-    int            wovSize;
-    char           *wovData;
-    } WOV_Elt_Data;
-
-/* this is the struct that holds the local boc data */
-typedef struct {           
-    int numWOVs;              /* current number of write once variables    */
-    WOV_Elt_Data WOVArray[MAXWRITEONCEVARS];
-    } WOV_Boc_Data;
-
-/* the rest of the structs are messaged that are passed around */
-typedef struct {            /* Original message sent from node up To the host.*/
-    ChareIDType    cid;
-    EntryPointType ep;
-    int            wovSize;
-    } Host_New_WOV_Msg;
-
-typedef struct {            /* Message sent from the host down to the nodes   */
-    WriteOnceID    wovID;
-    int            wovSize;
-    } Node_New_WOV_Msg;
-
-typedef struct {            /* Acknowledge msg passed up the tree to the host.*/
-    WriteOnceID    wovID;
-    } Ack_To_Host_Msg;
-
-typedef struct {            /* Final message returned to the user program.    */
-    WriteOnceID    wovID;
-    } Return_To_Origin_Msg;
-
-
-extern CHARE_BLOCK *CreateChareBlock();
-void HostReceiveAcknowledge();
-
-
-/*****************************************************************************
-*****************************************************************************/
-void WOVBocInit()
-{
-       CHARE_BLOCK *bocBlock;
-       WOV_Boc_Data *bocData;
-       int       i;
-
-       TRACE(CmiPrintf("[%d]: WOVBocInit() called\n", CmiMyPe()));
-
-       bocBlock = CreateChareBlock(sizeof(WOV_Boc_Data),CHAREKIND_BOCNODE,0);
-        bocBlock->x.boc_num = WOVBocNum;
-       SetBocBlockPtr(WOVBocNum, bocBlock);
-
-       bocData  = (WOV_Boc_Data *) (bocBlock + 1);
-
-       for(i = 0; i < MAXWRITEONCEVARS; i++)
-               bocData->WOVArray[i].numAcks =
-                                CmiNumSpanTreeChildren(CmiMyPe());
-}
-
-
-/*****************************************************************************
-*****************************************************************************/
-void NodeAddWriteOnceVar(msgptr_,localdataptr_)
-void *msgptr_,*localdataptr_;
-{
-       Node_New_WOV_Msg  *newWovMsg = (Node_New_WOV_Msg *) msgptr_;
-       WOV_Boc_Data *bocData   = (WOV_Boc_Data *) localdataptr_;
-       Ack_To_Host_Msg   *ackMsg;
-
-
-       /* instead of removing data from message just point to data IN msg */
-       bocData->WOVArray[(int) newWovMsg->wovID].wovData = 
-               (char *) ( (Node_New_WOV_Msg *) newWovMsg + 1);
-
-       /* now we need to acknowledge the fact that we have created the WOV */
-       if(isLeaf(CmiMyPe())) {
-               ackMsg = (Ack_To_Host_Msg *)CkAllocMsg(sizeof(Ack_To_Host_Msg));
-               CkMemError(ackMsg);
-               ackMsg->wovID = newWovMsg->wovID;
-
-               if(CmiMyPe() == 0) {
-TRACE(CmiPrintf("[%d]:: NodeWrtOnceVar...Ack to Host for wovID %d\n",
-                               CmiMyPe() ,ackMsg->wovID);)
-                       HostReceiveAcknowledge(ackMsg, bocData);
-               }
-               else
-               {
-              /* Note: we add TotalHostBocEps to deal with weird decrement */
-TRACE(CmiPrintf("[%d]:: NodeWrtOnceVar...Ack to Parent %d for wovID %d\n",
-                           CmiMyPe(), CmiSpanTreeParent(CmiMyPe()),
-                           ackMsg->wovID);)
-                       GeneralSendMsgBranch(CsvAccess(CkEp_WOV_RcvAck), ackMsg, 
-                                CmiSpanTreeParent(CmiMyPe()),
-                                ImmBocMsg, WOVBocNum);
-               }
-       }
-}
-
-
-/*****************************************************************************
-*****************************************************************************/
-void NodeReceiveAcknowledge(msgptr_,localdataptr_)
-void *msgptr_,*localdataptr_;
-{
-       Ack_To_Host_Msg   *theMsg  = (Ack_To_Host_Msg *) msgptr_;
-       WOV_Boc_Data *bocData = (WOV_Boc_Data *) localdataptr_;
-       Ack_To_Host_Msg   *ackMsg;  /* msg to pass up the tree */
-       WriteOnceID wovID;
-
-       wovID = theMsg->wovID;
-       bocData->WOVArray[(int) wovID].numAcks--; 
-
-
-TRACE(CmiPrintf("[%d]:: NodeRecvAck...wovID = %d, kids left = %d\n",
-               CmiMyPe(), wovID, bocData->WOVArray[(int) wovID].numAcks));
-       if(!(bocData->WOVArray[(int) wovID].numAcks)) 
-       {      
-               /* if we've got all acks */
-               ackMsg = (Ack_To_Host_Msg *)
-                                CkAllocMsg(sizeof(Ack_To_Host_Msg));
-               CkMemError(ackMsg);
-               ackMsg->wovID = theMsg->wovID;
-
-               if(CmiMyPe() == 0)
-                           HostReceiveAcknowledge(ackMsg, bocData);
-               else
-                           GeneralSendMsgBranch(CsvAccess(CkEp_WOV_RcvAck), ackMsg, 
-                               CmiSpanTreeParent(CmiMyPe()),
-                               ImmBocMsg, WOVBocNum);
-       }
-       else 
-               CkFreeMsg(msgptr_);
-}
-
-/*****************************************************************************
-*****************************************************************************/
-void *DerefWriteOnce(ID)
-WriteOnceID ID;
-{
-       WOV_Boc_Data * localBocData;
-
-
-       localBocData = (WOV_Boc_Data *) GetBocDataPtr(WOVBocNum);
-       return(localBocData->WOVArray[(int) ID].wovData);
-}
-
-
-/***************************************************************************
-***************************************************************************/
-void HostAddWriteOnceVar(msgptr_,localdataptr_)
-void *msgptr_,*localdataptr_;
-{
-       Host_New_WOV_Msg  *newWov   = (Host_New_WOV_Msg *)  msgptr_;
-       WOV_Boc_Data *localBocData  = (WOV_Boc_Data *) localdataptr_;
-       ENVELOPE *env;
-       int i, nodeMsgSize;
-
-       Node_New_WOV_Msg *msgForNodes; /* going to broadcast this to nodes */
-       char *src,*dest;               /* just indices to copy bytes       */
-
-
-       if (localBocData->numWOVs > MAXWRITEONCEVARS)
-       {
-               CmiPrintf("*** ERROR *** Exceeded permitted number of WriteOnce Variables.\n");
-               CkExit();
-       }
-       localBocData->WOVArray[localBocData->numWOVs].ep      = newWov->ep;
-       localBocData->WOVArray[localBocData->numWOVs].cid     = newWov->cid;
-       localBocData->WOVArray[localBocData->numWOVs].wovSize = newWov->wovSize;
-       localBocData->WOVArray[localBocData->numWOVs].wovData = 
-           (char *) (( Host_New_WOV_Msg *) newWov + 1);
-
-       nodeMsgSize = sizeof(Node_New_WOV_Msg) + newWov->wovSize;
-       msgForNodes = (Node_New_WOV_Msg *) CkAllocMsg(nodeMsgSize);
-       CkMemError(msgForNodes);
-
-       msgForNodes->wovID   = (WriteOnceID) localBocData->numWOVs;
-       msgForNodes->wovSize = newWov->wovSize;
-
-       src  = (char *) ((Host_New_WOV_Msg  *) newWov + 1);
-       dest = (char *) ((Node_New_WOV_Msg  *) msgForNodes + 1); 
-       for(i = 0; i < newWov->wovSize; i++)  
-               *dest++ = *src++; /* copy data into the message struct */
-
-TRACE(CmiPrintf("Host::  HostAddWriteOnceVar...wovID %d, size %d\n",
-                       msgForNodes->wovID, newWov->wovSize);)
-
-       GeneralBroadcastMsgBranch(CsvAccess(CkEp_WOV_AddWOV), msgForNodes,
-                       ImmBroadcastBocMsg, WOVBocNum);
-
-       localBocData->numWOVs++;            /* weve got one more wov */
-}
-
-
-/***************************************************************************
- Here we receive the acknowledgement from our child node (the root of the 
- spanning tree) that ALL the nodes have indeed created the write once variable
- in question. We can then send a message to the user program on the originating
- node, telling the user that it is now ok to access the WOV, or to broadcast
- the id to other nodes, or whatever.  ***************************************************************************/ 
-void HostReceiveAcknowledge(msgptr_,localdataptr_)
-void *msgptr_,*localdataptr_;
-{
-       Ack_To_Host_Msg *ackMessage    = (Ack_To_Host_Msg *) msgptr_;
-       WOV_Boc_Data    *localBocData  = (WOV_Boc_Data *) localdataptr_;
-       Return_To_Origin_Msg *msgForCreator;
-       WriteOnceID          wovID;
-
-TRACE(CmiPrintf("[%d]:: HostRecvAck...wovID %d, Notifying user at ep [%d]\n",
-               CmiMyPe(),
-               ackMessage->wovID,
-               localBocData->WOVArray[(int)ackMessage->wovID].ep);)
-
-       msgForCreator = (Return_To_Origin_Msg *)
-                               CkAllocMsg(sizeof(Return_To_Origin_Msg));
-       CkMemError(msgForCreator);
-       wovID = msgForCreator->wovID = ackMessage->wovID;
-
-       SendMsg(localBocData->WOVArray[(int) wovID].ep,msgForCreator,
-           &localBocData->WOVArray[(int) wovID].cid);
-}
-
-
-/***************************************************************************
-If we call WriteOnce from the host, we don't need to send a message, just
-call the appropriate routine.
-***************************************************************************/
-void WriteOnce(dataPtr,dataSize,ep,cid)
-char           *dataPtr;
-int            dataSize;
-EntryPointType ep;
-ChareIDType    cid;
-{
-       Host_New_WOV_Msg *newWov;
-       int msgSize,i;
-       char *src,*dest;
-
-       TRACE(CmiPrintf("Node %d : WriteOnce called.\n", CmiMyPe()));
-       msgSize = dataSize + sizeof(Host_New_WOV_Msg);
-       newWov = (Host_New_WOV_Msg *) CkAllocMsg(msgSize);
-       CkMemError(newWov);
-
-       newWov->cid = cid;
-       newWov->ep = ep;            /* fill up the fields of the struct */
-       newWov->wovSize = dataSize;
-       src  = dataPtr; 
-       dest = (char *) ((Host_New_WOV_Msg *) newWov + 1);
-       for(i = 0; i < dataSize; i++)
-               *dest++ = *src++;
-       /* here we bypass the SendMsg function and just call directly */
-       if (CmiMyPe() == 0)
-               HostAddWriteOnceVar((void *)newWov,(void *)GetBocDataPtr(WOVBocNum));
-       else
-               GeneralSendMsgBranch(CsvAccess(CkEp_WOV_HostAddWOV), newWov,
-                   0, ImmBocMsg, WOVBocNum);
-}
-
-
-void WOVAddSysBocEps(void)
-{
-  CsvAccess(CkEp_WOV_AddWOV) =
-    registerBocEp("CkEp_WOV_AddWOV",
-                 NodeAddWriteOnceVar,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_WOV_RcvAck) =
-    registerBocEp("CkEp_WOV_RcvAck",
-                 NodeReceiveAcknowledge,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_WOV_HostAddWOV) =
-    registerBocEp("CkEp_WOV_HostAddWOV",
-                 HostAddWriteOnceVar,
-                 CHARM, 0, 0);
-  CsvAccess(CkEp_WOV_HostRcvAck) =
-    registerBocEp("CkEp_WOV_HostRcvAck",
-                 HostReceiveAcknowledge,
-                 CHARM, 0, 0);
-}
-
diff --git a/src/ck-perf/charmreplay.c b/src/ck-perf/charmreplay.c
deleted file mode 100644 (file)
index ac74f4d..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-#include <sys/param.h>
-#include <stdio.h>
-#include <string.h>
-
-#define GOOD 0
-
-#define DEBUG 1
-#define PROJECTIONS 2
-
-#define MAXLENGTH 1024
-
-/** Needs to be changed in altered in charm.h **/
-#define NewChareMsg             0
-#define ForChareMsg             1
-#define BocInitMsg              2
-#define BocMsg                  3
-#define TerminateToZero         4
-#define TerminateSys            5
-#define InitCountMsg            6
-#define ReadVarMsg              7
-#define ReadMsgMsg              8
-#define BroadcastBocMsg         9
-#define DynamicBocInitMsg       10
-#define LdbMsg                  12
-#define VidMsg                  13
-#define QdBocMsg                14
-#define QdBroadcastBocMsg       15
-#define AccInitMsg              21
-#define MonoInitMsg             22
-
-
-
-#define  CREATION           1
-#define  BEGIN_PROCESSING   2
-#define  END_PROCESSING     3
-#define  ENQUEUE            4
-#define  DEQUEUE            5
-#define  BEGIN_COMPUTATION  6
-#define  END_COMPUTATION    7
-#define  BEGIN_INTERRUPT    8
-#define  END_INTERRUPT      9
-#define  INSERT             10
-#define  DELETE             11
-#define  FIND               12
-
-
-
-#define HASH_TABLE_SIZE 2591
-#define HashMap(a, b) ((20011*a+20021*b) % HASH_TABLE_SIZE)
-
-typedef struct entry {
-       int pe, event, destination; 
-       struct entry *next;
-} ENTRY;
-
-ENTRY *hash_table[HASH_TABLE_SIZE];
-
-int number_pe;
-char *filename, *pwd;
-int TotalChares, TotalEps, TotalMsgs, TotalPseudos;
-
-InsertDestination(pe, event, destination)
-int pe, event, destination;
-{
-       ENTRY *current;
-       int index = HashMap(pe, event);
-
-       current = (ENTRY *) malloc(sizeof(ENTRY));
-       current->pe = pe;
-       current->event = event;
-       current->destination = destination;
-       current->next = hash_table[index];
-       hash_table[index] = current;
-}
-
-
-
-FindDestination(event, pe)
-int event, pe;
-{
-       int index = HashMap(pe, event);
-       ENTRY *current = hash_table[index];
-
-       while (current != 0)
-               if (current->pe==pe && current->event==event)
-                       return current->destination;
-               else
-                       current = current->next;
-       printf("*** ERROR *** Cannot determine destination for %d, %d\n",
-                               pe, event);
-       return -1;
-}
-
-
-
-main(argc, argv)
-int argc;
-char *argv[];
-{ 
-       int     i, j;
-       FILE *fp;
-       int mode = -1;
-       char template[1000];
-       char *getcwd(), *mktemp();
-       char name[MAXLENGTH], what[MAXLENGTH], pathname[MAXLENGTH];
-
-       filename = argv[1];
-       read_in_state_file(filename);
-       strcpy(template,  ".tempXXXXXX");
-
-       if ((pwd = getcwd(pathname, MAXLENGTH)) == 0) printf("ERROR: %s\n", pathname);
-
-       for (i=0; i<HASH_TABLE_SIZE; i++)
-               hash_table[i] = 0;
-
-       for (i=0; i<number_pe; i++)
-       {
-               sprintf(name, "%s/%s.%d.log", pathname, filename, i);
-               fp = fopen(name, "r");
-               if (fp == 0) {
-                       printf("*** ERROR *** Unable to open log file %s\n", name);
-                       return GOOD;
-               }
-               fscanf(fp, "%s", what);
-               if (!strcmp(what, "DEBUG-REPLAY") || 
-                       !strcmp(what, "PROJECTIONS-REPLAY")) {
-                               fclose(fp);
-                               return GOOD;
-               }
-               if (!strcmp(what, "DEBUG-RECORD")) 
-                       mode = DEBUG;
-               else if (!strcmp(what, "PROJECTIONS-RECORD")) 
-                       mode = PROJECTIONS;
-               else 
-                       printf("*** ERROR *** Unknown type of log file %s\n", name);
-               
-               if (mode==DEBUG) read_in_debug_file(fp, i);
-               else if (mode==PROJECTIONS) read_in_projections_file(fp, i);
-               fclose(fp);
-       }
-
-       mktemp(template);
-       for (i=0; i<number_pe; i++)
-       {
-               FILE    *fp1, *fp2;
-               char    command[MAXLENGTH];
-
-               sprintf(name, "%s/%s.%d.log", pathname, filename, i);
-               fp1 = fopen(name, "r");
-               if (fp1 == 0) {
-                       printf("*** ERROR *** Unable to open log file %s\n", name);
-                       return GOOD;
-               }
-
-               fp2 = fopen(template, "w");
-               if (fp2 == 0) {
-                       printf("*** ERROR *** Unable to open log file %s\n", 
-                                       template);
-                       return GOOD;
-               }
-               
-               if (mode==DEBUG) write_out_debug_file(fp1, fp2, i);
-               else if (mode==PROJECTIONS) write_out_projections_file(fp1, fp2, i);
-               fclose(fp1);
-               fclose(fp2);
-
-               sprintf(name, "%s/%s.%d.rpy", pathname, filename, i);
-               sprintf(command, "cp %s %s", template, name);
-               system(command);
-       }
-       return GOOD;
-}
-
-
-/*************************************************************************/
-/** Read in state file information.                                                                            **/
-/*************************************************************************/
-read_in_state_file(filename)
-char *filename;
-{
-       FILE *fp;
-       int done;
-       int id, chareid,msgid;
-       char type[1000], name[1000];
-       int size, msg_index, pseudo_index, pseudo_type;
-
-       /*****************************************************************/
-       /** Get the file name and open it.              **/
-       /*****************************************************************/
-       sprintf(name, "%s.sts", filename);
-       fp = fopen(name, "r");
-       if (fp == 0)
-               printf("*** ERROR *** Unable to open log file %s\n", name);
-       done = 0;
-       while (!done)
-       {
-               fscanf(fp, "%s", type);
-               if (!strcmp(type, "ENTRY"))
-                       fscanf(fp, "%d %s %d %d", &id, name, &chareid, &msgid);
-               else if (!strcmp(type, "CHARE") || (!strcmp(type, "BOC")))
-                       fscanf(fp, "%d %s", &id, name);
-               else if (!strcmp(type, "MACHINE"))
-                       fscanf(fp, "%s", name);
-               else if (!strcmp(type, "PROCESSORS"))   
-                       fscanf(fp, "%d", &number_pe);
-               else if (!strcmp(type, "MESSAGE"))      
-                       fscanf(fp, "%d %d", &msg_index, &size);
-               else if (!strcmp(type, "PSEUDO"))       
-                       fscanf(fp, "%d %d %s", &pseudo_index, &pseudo_type, name);
-               else if (!strcmp(type, "TOTAL_CHARES")) 
-                       fscanf(fp, "%d", &TotalChares);
-               else if (!strcmp(type, "TOTAL_EPS"))    
-                       fscanf(fp, "%d", &TotalEps);
-               else if (!strcmp(type, "TOTAL_MSGS"))   
-                       fscanf(fp, "%d", &TotalMsgs);
-               else if (!strcmp(type, "TOTAL_PSEUDOS"))        
-                       fscanf(fp, "%d", &TotalPseudos);
-               else if (!strcmp(type, "END"))
-                       done = 1;
-       }
-}
-
-
-/*************************************************************************/
-/** This function is used to read in a log file and generate the display**/
-/** information for it.                                                        **/
-/*************************************************************************/
-
-read_in_debug_file(fp, me)
-FILE *fp;
-int me;
-{
-       int i;
-       unsigned int time;
-       int type, mtype, entry, event, dest, pe;
-
-       /*********************************************************/
-       /** Read in the entries and process them.               **/
-       /*********************************************************/
-       while (read_in_debug_line(fp, 0, &type, &mtype, &entry, &time, &event, 
-                                                               &dest, &pe) != EOF) {
-               /*************************************************/
-               /** Perform appropriate actions for this entry. **/
-               /*************************************************/
-               switch (type)
-               {
-               case BEGIN_PROCESSING:
-                       if (mtype==NewChareMsg) InsertDestination(pe, event, me);
-                       break;
-
-               case END_COMPUTATION: 
-                       break;
-               }
-       }
-}
-
-
-write_out_debug_file(fp1, fp2, me)
-       FILE *fp1, *fp2;
-       int me;
-{
-       int i;
-       char what[100];
-       unsigned int time;
-       int type, mtype, entry, event, pe, dest;
-
-       fscanf(fp1, "%s", what);
-       fprintf(fp2, "DEBUG-REPLAY\n");
-
-       /*********************************************************/
-       /** Read in the entries and process them.               **/
-       /*********************************************************/
-       while (read_in_debug_line(fp1, 0, &type, &mtype, &entry, &time, &event, 
-                                                               &dest, &pe) != EOF) {
-
-               write_out_debug_line(fp2, type, mtype, entry, time, event, pe);
-               switch (type) {
-
-               case CREATION:
-                       if (mtype==NewChareMsg) 
-                               fprintf(fp2, " %d", FindDestination(event, me));
-                       break;
-
-               case END_COMPUTATION:
-                       break;
-               }
-               fprintf(fp2, "\n");
-       }
-}
-
-
-/*************************************************************************/
-/** This function is used to read in a log file and generate the display**/
-/** information for it.                                                        **/
-/*************************************************************************/
-
-read_in_projections_file(fp, me)
-       FILE *fp;
-       int me;
-{
-       unsigned int time;
-       int type, mtype, entry, event, pe, dest;
-
-       /*********************************************************/
-       /** Read in the entries and process them.               **/
-       /*********************************************************/
-       while (read_in_projections_data(fp, 0, &type, &mtype, &entry, &time, 
-                                                                       &event, &dest, &pe) != EOF) {
-               /*************************************************/
-               /** Perform appropriate actions for this entry. **/
-               /*************************************************/
-               switch (type)
-               {
-               case BEGIN_PROCESSING:
-                       if (mtype == NewChareMsg) InsertDestination(pe, event, me);
-                       break;
-
-               case END_COMPUTATION:
-                       break;
-               }
-       }
-}
-
-write_out_projections_file(fp1, fp2, me)
-       FILE *fp1, *fp2;
-       int me;
-{
-       char what[100];
-       unsigned int time;
-       int type, mtype, entry, event, pe, dest;
-
-
-       fscanf(fp1, "%s", what);
-       fprintf(fp2, "PROJECTIONS-REPLAY\n");
-
-       /*********************************************************/
-       /** Read in the entries and process them.               **/
-       /*********************************************************/
-       while (read_in_projections_data(fp1, 0, &type, &mtype, &entry, &time, 
-                                                                       &event, &dest, &pe) != EOF) {
-               write_out_projections_line(fp2, type, mtype, entry, time, event, pe);
-
-               /*************************************************/
-               /** Perform appropriate actions for this entry. **/
-               /*************************************************/
-               switch (type)
-               {
-               case CREATION:
-                       if (mtype==NewChareMsg)
-                               fprintf(fp2, " %d", FindDestination(event, pe));
-                       break;
-
-               case END_COMPUTATION:
-                       break;
-
-               }
-               fprintf(fp2, "\n");
-       }
-}
diff --git a/src/ck-perf/trace-none.C b/src/ck-perf/trace-none.C
new file mode 100644 (file)
index 0000000..68d7f34
--- /dev/null
@@ -0,0 +1,21 @@
+#include "trace.h"
+
+CpvDeclare(Trace*, _trace);
+CpvDeclare(int, traceOn);
+
+extern "C"
+void traceInit(int*, char**)
+{
+  CpvInitialize(Trace*, _trace);
+  CpvAccess(_trace) = 0;
+  CpvAccess(traceOn) = 0;
+}
+
+extern "C" void traceBeginIdle(void) {}
+extern "C" void traceEndIdle(void) {}
+extern "C" void traceResume(void) {}
+extern "C" void traceSuspend(void) {}
+extern "C" void traceAwaken(void) {}
+extern "C" void traceUserEvent(int) {}
+extern "C" int  traceRegisterUserEvent(const char*) {return 0;}
+extern "C" void traceClose(void) {}
diff --git a/src/ck-perf/trace-none.c b/src/ck-perf/trace-none.c
deleted file mode 100644 (file)
index 0742802..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "charm.h"
-
-CpvExtern(int, CtrRecdTraceMsg);
-CpvExtern(CthThread, cThread);
-CpvExtern(int, traceOn);
-
-void traceModuleInit(pargc, argv) int *pargc; char **argv; 
-{
-  CpvInitialize(CthThread, cThread);
-  CpvInitialize(int, traceOn);
-  CpvAccess(traceOn) = 0;
-}
-
-void program_name(s,m) char *s, *m; {}
-
-void log_init(void) {CpvAccess(CtrRecdTraceMsg) = 1;}
-
-void trace_user_event(int eventNum)
-{}
-
-void trace_creation(msg_type,entry,envelope)
-int msg_type, entry;
-void *envelope;
-{}
-
-void trace_begin_execute(envelope)
-void *envelope;
-{}
-
-void trace_end_execute(id,msg_type,entry)
-int id, msg_type, entry;
-{}
-
-void trace_begin_charminit(void)
-{}
-
-void trace_end_charminit(void)
-{}
-
-void trace_begin_idle(void)
-{}
-
-void trace_end_idle(void)
-{}
-
-void trace_begin_pack(void){}
-void trace_end_pack(void){}
-void trace_begin_unpack(void){}
-void trace_end_unpack(void){}
-
-void trace_begin_computation(void)
-{}
-
-void trace_enqueue(envelope)
-void *envelope;
-{}
-
-void trace_dequeue(envelope)
-void *envelope;
-{}
-
-void trace_table(type,tbl,key,pe)
-int type,tbl,key,pe;
-{}
-
-
-void send_log(void) {}
-
-void CollectTraceFromNodes(msg, data)
-char msg, data;
-{}
-
-void close_log(void){}
-
-void PrintStsFile(str)
-char *str ;
-{
-}
diff --git a/src/ck-perf/trace-projections.C b/src/ck-perf/trace-projections.C
new file mode 100644 (file)
index 0000000..19bd0c8
--- /dev/null
@@ -0,0 +1,104 @@
+#include "trace-projections.h"
+
+CpvDeclare(Trace*, _trace);
+CpvDeclare(int, traceOn);
+CpvDeclare(int, CtrLogBufSize);
+CpvStaticDeclare(LogPool*, _logPool);
+
+extern "C" 
+void traceInit(int* argc, char **argv)
+{
+  CpvInitialize(Trace*, _trace);
+  CpvInitialize(LogPool*, _logPool);
+  CpvInitialize(int, traceOn);
+  CpvInitialize(int, CtrLogBufSize);
+  CpvAccess(traceOn) = 1;
+  // find +logsize and +traceoff here in argv
+  // and initialize the vars properly.
+}
+
+extern "C"
+void traceBeginIdle(void)
+{
+}
+
+extern "C"
+void traceEndIdle(void)
+{
+}
+
+extern "C"
+void traceResume(void)
+{
+}
+
+extern "C"
+void traceSuspend(void)
+{
+}
+
+extern "C"
+void traceAwaken(void)
+{
+}
+
+extern "C"
+void traceUserEvent(int)
+{
+}
+
+extern "C"
+int traceRegisterUserEvent(const char*)
+{
+  return 0;
+}
+
+extern "C"
+void traceClose(void)
+{
+}
+