finally decided to check in guna's code in sdag. After cleanup, it looks better now...
authorGengbin Zheng <gzheng@illinois.edu>
Fri, 25 Jul 2003 21:17:09 +0000 (21:17 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Fri, 25 Jul 2003 21:17:09 +0000 (21:17 +0000)
src/xlat-i/sdag/CEntry.C
src/xlat-i/sdag/CEntry.h
src/xlat-i/sdag/CParsedFile.h
src/xlat-i/sdag/CSdagConstruct.C
src/xlat-i/sdag/EToken.h

index 32026830241ad176323fe41bc226c16bc0c7a38c..aa979d22574ab6d26f910517c6e5cabc3e076841 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "CEntry.h"
 #include "xi-symbol.h"
+
 void CEntry::generateDeps(XStr& op)
 {
   SdagConstruct *cn;
@@ -54,15 +55,20 @@ void CEntry::generateCode(XStr& op)
   }
   op <<  ") {\n";
   op << "    CWhenTrigger *tr;\n";
+  op<<  "    void* _bgParentLog = NULL;\n";
+  op<<  "    BgElapse(0.01e-6);\n";
+  cn->generateTlineEndCall(op);
+
+  op << "    CMsgBuffer* cmsgbuf;\n";
+
   int hasArrays = 0;
   int paramMarshalling = 0;
   int count = 0;
   sv = (CStateVar *)myParameters->begin();
   i = 0;
   if (isVoid == 1) {
-     op << "    __cDep->bufferMessage("<<entryNum<<", (void *) CkAllocSysMsg(), 0);\n";
+     op << "   __cDep->bufferMessage("<<entryNum<<", (void *) CkAllocSysMsg(), 0);\n";
      op << "    tr = __cDep->getTrigger("<<entryNum<<", 0);\n";
-
   }
   else {
      for(; i<(myParameters->length());i++, sv=(CStateVar *)myParameters->next()) {
@@ -81,10 +87,10 @@ void CEntry::generateCode(XStr& op)
         if (paramMarshalling ==0) {
            if(refNumNeeded) {
               op << "    int refnum = CkGetRefNum(" <<sv->name->charstar() <<"_msg);\n";
-              op << "    __cDep->bufferMessage("<<entryNum<<",(void *) "<<sv->name->charstar() <<"_msg ,refnum);\n";
+              op << "    cmsgbuf = __cDep->bufferMessage("<<entryNum<<",(void *) "<<sv->name->charstar() <<"_msg , (void *) _bgParentLog, refnum);\n";
               op << "    tr = __cDep->getTrigger("<<entryNum<<", refnum);\n";
            } else {
-              op << "    __cDep->bufferMessage("<<entryNum<<", (void *) "<<sv->name->charstar() <<"_msg, 0);\n";
+              op << "    cmsgbuf = __cDep->bufferMessage("<<entryNum<<", (void *) "<<sv->name->charstar() <<"_msg,  (void *) _bgParentLog, 0);\n";
               op << "    tr = __cDep->getTrigger("<<entryNum<<", 0);\n";
            } 
         }
@@ -144,23 +150,27 @@ void CEntry::generateCode(XStr& op)
         }
        }
      }
+     
      if(refNumNeeded) {
      // When a reference number is needed and there are parameters that need marshalling 
      // (in other words the parameters of the entry method are not messages) 
      // then the first parameter of the entry method is an integer that specifies the 
      // reference number
           sv = (CStateVar *)myParameters->begin();
-          op << "    __cDep->bufferMessage("<<entryNum<<",(void *) impl_msg1,"<<sv->name->charstar()<<");\n";
+          op << "   cmsgbuf = __cDep->bufferMessage("<<entryNum<<",(void *) impl_msg1, (void*) _bgParentLog,"<<sv->name->charstar()<<");\n";
           op << "    tr = __cDep->getTrigger("<<entryNum<<","<<sv->name->charstar()<<");\n"; 
      } else {
-       op << "    __cDep->bufferMessage("<<entryNum<<", (void *) impl_msg1, 0);\n";
+       op << "    cmsgbuf = __cDep->bufferMessage("<<entryNum<<", (void *) impl_msg1, (void*) _bgParentLog, 0);\n";
        op << "    tr = __cDep->getTrigger("<<entryNum<<", 0);\n";
      }
-     
    }
 
   op << "    if (tr == 0)\n";
   op << "      return;\n"; 
+
+  cn->generateTraceEndCall(op);
+  cn->generateEndExec(op);
+
   XStr *whenParams; 
   int iArgs = 0;
   if(whenList.length() == 1) {
@@ -173,18 +183,31 @@ void CEntry::generateCode(XStr& op)
     i = 0;
     paramMarshalling = 0;
     lastWasVoid = 0;
-    for(; i<(cn->stateVars->length());i++, sv=(CStateVar *)cn->stateVars->next()) {
-       if ((sv->isMsg == 0) && (paramMarshalling == 0) && (sv->isVoid ==0)){
+
+    //Guna begin
+   
+    op <<"    cmsgbuf->bgLog2 = (void*)tr->args[1];\n";
+    //op << "    " << cn->label->charstar() << "(";    
+    //Guna end
+
+    for( i=0; i<(cn->stateVars->length());i++, sv=(CStateVar *)cn->stateVars->next()) {
+      if ((sv->isMsg == 0) && (paramMarshalling == 0) && (sv->isVoid ==0)){
           paramMarshalling =1;
           op << "    CkMarshallMsg *impl_msg = (CkMarshallMsg *) tr->args[" <<iArgs <<"];\n"; 
           op << "    char *impl_buf=((CkMarshallMsg *)impl_msg)->msgBuf;\n";
           op << "    PUP::fromMem implP(impl_buf);\n";
           iArgs++;
-       }
-       if (sv->isMsg == 1) {
-          if((i!=0) && (lastWasVoid == 0))
+      }
+      if (sv->isMsg == 1) {
+         if((i!=0) && (lastWasVoid == 0))
             whenParams->append(", ");
-          whenParams->append("(");
+         if(i==1){   
+          whenParams->append("NULL");
+          lastWasVoid=0;
+          iArgs++;
+          continue;
+         }
+         whenParams->append("(");
          whenParams->append(sv->type->charstar());
          whenParams->append(" *) tr->args[");
          *whenParams<<iArgs;
@@ -213,26 +236,32 @@ void CEntry::generateCode(XStr& op)
        if (sv->arrayLength != 0) 
           op<<"    "<<sv->type->charstar()<<" *"<<sv->name->charstar()<<"=("<<sv->type->charstar()<<" *)(impl_buf+impl_off_"<<sv->name->charstar()<<");\n";
     }
+
     if (paramMarshalling == 1) 
        op << "    delete (CkMarshallMsg *)impl_msg;\n";
     op << "    " << cn->label->charstar() << "(" << whenParams->charstar();
     op << ");\n";
   
     op << "    delete tr;\n";
+    cn->generateBeginExec(op, "dummy");
+    cn->generateDummyBeginExecute(op);
     op << "    return;\n";
-  } 
-  else {  
+  }
+  else {   
     op << "    switch(tr->whenID) {\n";
     for(cn=whenList.begin(); !whenList.end(); cn=whenList.next()) {
       whenParams = new XStr("");
       i = 0; iArgs = 0;
       op << "      case " << cn->nodeNum << ":\n";
       op << "      {\n";
-      lastWasVoid = 0;
+      
+      // bgLog2 stores the parent dependence of when, e.g. for, olist
+      op <<"  cmsgbuf->bgLog2 = (void*)tr->args[1];\n";         
       sv = (CStateVar *)cn->stateVars->begin();
       i = 0;
       paramMarshalling = 0;
       lastWasVoid = 0;
+
       for(; i<(cn->stateVars->length());i++, sv=(CStateVar *)cn->stateVars->next()) {
          if ((sv->isMsg == 0) && (paramMarshalling == 0) && (sv->isVoid ==0)){
             paramMarshalling =1;
@@ -241,9 +270,14 @@ void CEntry::generateCode(XStr& op)
             op << "        PUP::fromMem implP" <<cn->nodeNum <<"(impl_buf" <<cn->nodeNum <<");\n";
          }
          if (sv->isMsg == 1) {
-            if((i!=0) && (lastWasVoid == 0))
-              whenParams->append(", ");
-            whenParams->append("(");
+           if((i!=0) && (lastWasVoid == 0))
+             whenParams->append(", ");
+           if(i==1){
+              whenParams->append(" NULL ");
+              lastWasVoid=0;
+              continue;
+           }
+           whenParams->append("(");
            whenParams->append(sv->type->charstar());
            whenParams->append(" *) tr->args[");
            *whenParams<<iArgs;
@@ -279,6 +313,10 @@ void CEntry::generateCode(XStr& op)
       op << "        " << cn->label->charstar() << "(" << whenParams->charstar();
       op << ");\n";
       op << "        delete tr;\n";
+
+      cn->generateBeginExec(op, "dummy");
+      cn->generateDummyBeginExecute(op);
+
       op << "        return;\n";
       op << "      }\n";
     }
index 50c44802a2aae040486d8c0a9d19e9288a6c523d..231f67c25db61c8229126f5ffee934c5291ecea8 100644 (file)
@@ -20,7 +20,7 @@ class ParamList;
 class CEntry{
   public:
     XStr *entry;
-    Entry *decl_entry;
+    Entry *decl_entry;                 // point to the real Entry of the Chare
     //CParseNode *paramlist;
     ParamList *paramlist;
     int entryNum;
index cb26f43ca9fa3da87cbc01f021c97edd3a25aa3c..45678b94f31117ce741a8cbf795ca68f27100546 100644 (file)
@@ -21,8 +21,13 @@ class CParsedFile {
     void generateConnectEntries(XStr& output);
     void generateInitFunction(XStr& output);
     void generatePupFunction(XStr& output);
+    void generateRegisterEp(XStr& output);
+    void generateTraceEpDecl(XStr& output);
+    void generateTraceEpDef(XStr& output);
+    void generateTrace();
   public:
     Chare *container;
+    static XStr *className;
     TList<CEntry*> entryList;
     TList<SdagConstruct *> connectEntryList;
     TList<Entry*> nodeList;
@@ -30,19 +35,26 @@ class CParsedFile {
     ~CParsedFile(void){}
     void print(int indent);
     void doProcess(XStr& classname, XStr& output) {
+      className = &classname;
       output << "#define " << classname << "_SDAG_CODE \n";
       numberNodes();
       labelNodes();
       propagateState();
       generateConnectEntryList();
+      generateTrace();                         // for tracing Gengbin
       generateEntryList();
       mapCEntry();
       generateCode(output);
       generateEntries(output);
       generateInitFunction(output);
       generatePupFunction(output);
+      generateRegisterEp(output);              // for tracing Gengbin
+      generateTraceEpDecl(output);             // for tracing Gengbin
       output.line_append('\\');
       output << "\n";
+      output << "#define " << classname << "_SDAG_CODE_DEF \\\n";
+      generateTraceEpDef(output);
+      output << "\n";
     }
 
 };
index ed4bff3b5525b80ce96329c82f23e7689b1a2ad1..02faeef5028fe571ef5b447b0004a283d9f6b1df 100644 (file)
@@ -118,7 +118,6 @@ void SdagConstruct::labelNodes(void)
 
 void EntryList::generateEntryList(TList<CEntry*>& CEntrylist, SdagConstruct *thisWhen)
 {
-   Entry *e;
    EntryList *el;
    el = this;
    while (el != NULL)
@@ -298,7 +297,16 @@ void SdagConstruct::propagateState(int uniqueVarNum)
       stateVars->append(sv);
     }
   }
-  stateVarsChildren = stateVars; 
+
+  // adding _bgParentLog as the last extra parameter for tracing
+  //stateVarsChildren = stateVars; 
+  stateVarsChildren = new TList<CStateVar*>();
+
+  for(sv=stateVars->begin();!stateVars->end();sv=stateVars->next())
+    stateVarsChildren->append(sv);
+  sv = new CStateVar(0, "void *", 0,"_bgParentLog", 0, NULL, 1);  
+  stateVarsChildren->append(sv);
+
   SdagConstruct *cn;
   TList<CStateVar*> *whensEntryMethodStateVars; 
   whensEntryMethodStateVars = new TList<CStateVar*>();
@@ -346,7 +354,7 @@ void SdagConstruct::propagateState(TList<CStateVar*>& list, TList<CStateVar*>& w
       stateVarsChildrenHasVoid = 0;
       for(sv = stateVars->begin(); ((!stateVars->end()) && (stateVarsHasVoid != 1)); sv=stateVars->next()) {
          if (sv->isVoid == 1)
-            stateVarsHasVoid == 1;
+            stateVarsHasVoid == 1;     // what this means??? gengbin
       }
       for(sv=list.begin(); !list.end(); sv=list.next()) {
          if ((sv->isVoid == 1) && (stateVarsHasVoid != 1)) {
@@ -596,9 +604,11 @@ void SdagConstruct::generateForward(XStr& op) {
 
 void SdagConstruct::generateWhen(XStr& op)
 {
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
   op << "  int " << label->charstar() << "(";
   generatePrototype(op, *stateVars);
   op << ") {\n";
+  generateBeginTime(op);
 
   CStateVar *sv;
 
@@ -673,6 +683,32 @@ void SdagConstruct::generateWhen(XStr& op)
   }
   op << ") {\n";
 
+  // for tracing
+  //TODO: instead of this, add a length field to EntryList
+  int elen=0;
+  for(el=elist; el!=NULL; el=elist->next) elen++;
+  op << "         void * logs1["<< elen << "]; \n";
+  op << "         void * logs2["<< elen + 1<< "]; \n";
+  int localnum = 0;
+  for(el=elist; el!=NULL; el=elist->next) {
+    e = el->entry;
+       if ((e->paramIsMarshalled() == 1) || (e->param->isVoid() ==1)) {
+       op << "       logs1[" << localnum << "] = " << /*el->con4->text->charstar() sv->type->charstar()*/e->getEntryName() << "_buf->bgLog1; \n";
+       op << "       logs2[" << localnum << "] = " << /*el->con4->text->charstar() sv->type->charstar()*/e->getEntryName() << "_buf->bgLog2; \n";
+       localnum++;
+      }
+      else{
+       op << "       logs1[" << localnum << "] = " << /*el->con4->text->charstar()*/ sv->name->charstar()<< "_buf->bgLog1; \n";
+       op << "       logs2[" << localnum << "] = " << /*el->con4->text->charstar()*/ sv->name->charstar() << "_buf->bgLog2; \n";
+       localnum++;
+      }
+  }
+      
+  op << "       logs2[" << localnum << "] = " << "_bgParentLog; \n";
+  generateEventBracket(op,SWHEN);
+  op << "       _TRACE_BG_FORWARD_DEPS(logs1,logs2,"<< localnum << ",_bgParentLog);\n";
+
   el = elist;
   while (el != NULL) {
      e = el->entry;
@@ -880,11 +916,18 @@ void SdagConstruct::generateWhen(XStr& op)
 
   // end actual code
   op << "  }\n\n";
+
+  // trace
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
+  strcat(nameStr,"_end");
+
   // end function
   op << "  void " << label->charstar() << "_end(";
   generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
   // actual code here 
+  generateBeginTime(op);
+  generateEventBracket(op,SWHEN_END);
   if(nextBeginOrEnd == 1)
    op << "    " << next->label->charstar() << "(";
   else 
@@ -944,11 +987,15 @@ void SdagConstruct::generateWhile(XStr& op)
 void SdagConstruct::generateFor(XStr& op)
 {
   // inlined start function
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
   op << "  void " << label->charstar() << "(";
   generatePrototype(op, *stateVars);
   op << ") {\n";
   // actual code here 
+  generateBeginTime(op);
   op << "    " << con1->text->charstar() << ";\n";
+  //Record only the beginning for FOR
+  generateEventBracket(op,SFOR);
   op << "    if (" << con2->text->charstar() << ") {\n";
   op << "      " << constructs->front()->label->charstar() <<
         "(";
@@ -965,9 +1012,13 @@ void SdagConstruct::generateFor(XStr& op)
   // end actual code
   op << "  }\n";
   // inlined end function
+  // trace
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
+  strcat(nameStr,"_end");
   op << "  void " << label->charstar() << "_end(";
   generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
+  generateBeginTime(op);               // trace
   // actual code here 
   op << con3->text->charstar() << ";\n";
   op << "    if (" << con2->text->charstar() << ") {\n";
@@ -976,6 +1027,7 @@ void SdagConstruct::generateFor(XStr& op)
   generateCall(op, *stateVarsChildren);
   op << ");\n";
   op << "    } else {\n";
+  generateEventBracket(op,SFOR_END);   // trace
   if(nextBeginOrEnd == 1)
    op << "      " << next->label->charstar() << "(";
   else
@@ -990,9 +1042,12 @@ void SdagConstruct::generateFor(XStr& op)
 void SdagConstruct::generateIf(XStr& op)
 {
   // inlined start function
+  strcpy(nameStr,label->charstar());
   op << "  void " << label->charstar() << "(";
   generatePrototype(op, *stateVars);
   op << ") {\n";
+  generateBeginTime(op);
+  generateEventBracket(op,SIF);
   // actual code here 
   op << "    if (" << con1->text->charstar() << ") {\n";
   op << "      " << constructs->front()->label->charstar() <<
@@ -1013,9 +1068,14 @@ void SdagConstruct::generateIf(XStr& op)
   // end actual code
   op << "  }\n\n";
   // inlined end function
+  strcpy(nameStr,label->charstar());
+  strcat(nameStr,"_end");
   op << "  void " << label->charstar() << "_end(";
   generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
+  // trace
+  generateBeginTime(op);
+  generateEventBracket(op,SIF_END);
   // actual code here 
   if(nextBeginOrEnd == 1)
    op << "      " << next->label->charstar() << "(";
@@ -1030,9 +1090,13 @@ void SdagConstruct::generateIf(XStr& op)
 void SdagConstruct::generateElse(XStr& op)
 {
   // inlined start function
+  strcpy(nameStr,label->charstar());
   op << "  void " << label->charstar() << "(";
   generatePrototype(op, *stateVars);
   op << ") {\n";
+  // trace
+  generateBeginTime(op);
+  generateEventBracket(op,SELSE);
   // actual code here 
   op << "    " << constructs->front()->label->charstar() << 
         "(";
@@ -1041,9 +1105,15 @@ void SdagConstruct::generateElse(XStr& op)
   // end actual code
   op << "  }\n\n";
   // inlined end function
+  // trace
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
+  strcat(nameStr,"_end");
   op << "  void " << label->charstar() << "_end(";
   generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
+  // trace
+  generateBeginTime(op);
+  generateEventBracket(op,SELSE_END);
   // actual code here 
   if(nextBeginOrEnd == 1)
    op << "      " << next->label->charstar() << "(";
@@ -1117,15 +1187,28 @@ void SdagConstruct::generateOlist(XStr& op)
   }
   // end actual code
   op << "  }\n";
+
+  // trace
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
+  strcat(nameStr,"_end");
+  op << "  CkVec<void*> " <<label->charstar() << "_bgLogList;\n";     // trace
+
   // inlined end function
   op << "  void " << label->charstar() << "_end(";
   generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
+  generateBeginTime(op);
   // actual code here 
+  //Accumulate all the bgParent pointers that the calling when_end functions give
+  op << "    " <<label->charstar() << "_bgLogList.insertAtEnd(_bgParentLog);\n";                                                                                
   op << "    " << counter->charstar() << "->decrement();\n";
   op << "    if (" << counter->charstar() << "->isDone()) {\n";
   op << "      delete " << counter->charstar() << ";\n";
 
+  // trace
+  generateListEventBracket(op,SOLIST_END);
+  op << "       "<< label->charstar() <<"_bgLogList.length()=0;\n";
+
   if(nextBeginOrEnd == 1)
    op << "      " << next->label->charstar() << "(";
   else
@@ -1140,9 +1223,12 @@ void SdagConstruct::generateOlist(XStr& op)
 void SdagConstruct::generateOverlap(XStr& op)
 {
   // inlined start function
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
   op << "  void " << label->charstar() << "(";
   generatePrototype(op, *stateVars);
   op << ") {\n";
+  generateBeginTime(op);
+  generateEventBracket(op,SOVERLAP);
   // actual code here 
   op << "    " << constructs->front()->label->charstar() <<
         "(";
@@ -1150,10 +1236,15 @@ void SdagConstruct::generateOverlap(XStr& op)
   op << ");\n";
   // end actual code
   op << "  }\n";
+  // trace
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
+  strcat(nameStr,"_end");
   // inlined end function
   op << "  void " << label->charstar() << "_end(";
   generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
+  generateBeginTime(op);
+  generateEventBracket(op,SOVERLAP_END);
   // actual code here 
   if(nextBeginOrEnd == 1)
    op << "    " << next->label->charstar() << "(";
@@ -1187,7 +1278,6 @@ void SdagConstruct::generateSlist(XStr& op)
    op << "    " << next->label->charstar() << "(";
   else
    op << "    " << next->label->charstar() << "_end(";
-  //generateCall(op, *stateVars);
   generateCall(op, *stateVars);
   op << ");\n";
   // end actual code
@@ -1207,26 +1297,40 @@ void SdagConstruct::generateSdagEntry(XStr& op)
      for(sc1=sc->constructs->begin(); !sc->constructs->end(); sc1 = sc->constructs->next())
         op << "    _connect_" << sc1->text->charstar() <<"();\n";
      }
+  // trace
+  generateEndSeq(op);
   // actual code here 
   op << "    " << constructs->front()->label->charstar() <<
         "(";
   generateCall(op, *stateVarsChildren);
   op << ");\n";
+  // trace
+  generateBeginExec(op, "dummy");
+  generateDummyBeginExecute(op);
   // end actual code
   op << "  }\n\n";
   op << "private:\n";
   op << "  void " << con1->text->charstar() << "_end(";
-  generatePrototype(op, *stateVars);
+  // guna
+  //generatePrototype(op, *stateVars);
+  generatePrototype(op, *stateVarsChildren);
   op << ") {\n";
   op << "  }\n\n";
 }
 
 void SdagConstruct::generateAtomic(XStr& op)
 { 
+  sprintf(nameStr,"%s%s", CParsedFile::className->charstar(),label->charstar());
   op << "  void " << label->charstar() << "(";
   generatePrototype(op, *stateVars);
   op << ") {\n";
+  // trace
+  generateBeginExec(op, nameStr);
+  generateTraceBeginCall(op);
   op << "    " << text->charstar() << "\n";
+  // trace
+  generateTraceEndCall(op);
+  generateEndExec(op);
   SdagConstruct *cn;
   if(nextBeginOrEnd == 1)
     op << "    " << next->label->charstar() << "(";
@@ -1387,6 +1491,121 @@ void SdagConstruct::setNext(SdagConstruct *n, int boe)
   }
 }
 
+
+// for trace
+
+void SdagConstruct::generateTrace()
+{
+  char text[1024];
+  switch(type) {
+  case SATOMIC:
+    sprintf(text, "%s%s", CParsedFile::className->charstar(), label->charstar());
+    traceName = new XStr(text);
+    break;
+  default:
+    break;
+  }
+  SdagConstruct *cn;
+  for(cn=constructs->begin(); !constructs->end(); cn=constructs->next()) {
+    cn->generateTrace();
+  }
+}
+
+void SdagConstruct::generateTraceBeginCall(XStr& op)          // for trace
+{
+  if(traceName)
+    op << "    " << "_TRACE_BEGIN_EXECUTE_DETAILED(-1, -1, " << "__idx_" << traceName->charstar() << ", CkMyPe(), 0, NULL); \n";
+}
+
+void SdagConstruct::generateDummyBeginExecute(XStr& op)
+{
+    op << "    " << "_TRACE_BEGIN_EXECUTE_DETAILED(-1, -1, _dummyEP, CkMyPe(), 0, NULL); \n";
+}
+
+void SdagConstruct::generateTraceEndCall(XStr& op)          // for trace
+{
+  op << "    " << "_TRACE_END_EXECUTE(); \n";
+}
+
+void SdagConstruct::generateBeginExec(XStr& op, char *name){
+  op << "     " << "_TRACE_BG_BEGIN_EXECUTE(\""<<name<<"\",&_bgParentLog);\n"; 
+}
+
+void SdagConstruct::generateEndExec(XStr& op){
+  op << "     " << "_TRACE_BG_END_EXECUTE();\n";
+}
+
+void SdagConstruct::generateBeginTime(XStr& op)
+{
+  //Record begin time for tracing
+  op<< "    double __begintime = BgGetTime(); \n";
+}
+
+void SdagConstruct::generateTlineEndCall(XStr& op)
+{
+  //Trace this event
+  op<<"    _TRACE_BG_TLINE_END(&_bgParentLog);\n";
+}
+
+void SdagConstruct::generateEndSeq(XStr& op)
+{
+  op<<  "    void* _bgParentLog = NULL;\n";
+  op<<  "    BgElapse(0.01e-6);\n";
+  //op<<  "    BgElapse(1e-6);\n";
+  generateTlineEndCall(op);
+  generateTraceEndCall(op);
+  generateEndExec(op);
+}
+
+void SdagConstruct::generateEventBracket(XStr& op, int eventType)
+{
+  //Trace this event
+  op<<"     _TRACE_BG_USER_EVENT_BRACKET(\""<<nameStr<<"\", __begintime, BgGetTime(),&_bgParentLog); \n"; 
+}
+
+void SdagConstruct::generateListEventBracket(XStr& op, int eventType){
+
+  op<<"    _TRACE_BGLIST_USER_EVENT_BRACKET(\""<<nameStr<<"\",__begintime,BgGetTime(),&_bgParentLog, "<<label->charstar()<<"_bgLogList);\n";
+}
+
+void SdagConstruct::generateRegisterEp(XStr& op)          // for trace
+{
+  if (traceName) {
+    //   op << "    __idx_" << traceName->charstar() << 
+    //     " = CkRegisterEp(\"" << traceName->charstar() << "(void)\", NULL, 0, 0);\n";
+    op << "    __idx_" << traceName->charstar() <<
+      " = CkRegisterEp(\"" << traceName->charstar() << "(void)\", NULL, 0, CkIndex_" << CParsedFile::className->charstar() << "::__idx, 0);\n";
+
+  }
+  SdagConstruct *cn;
+  for(cn=constructs->begin(); !constructs->end(); cn=constructs->next()) {
+    cn->generateRegisterEp(op);
+  }
+}
+
+void SdagConstruct::generateTraceEpDecl(XStr& op)          // for trace
+{
+  if (traceName) {
+    op << "  static int __idx_" << traceName->charstar() << ";\n"; 
+  }
+  SdagConstruct *cn;
+  for(cn=constructs->begin(); !constructs->end(); cn=constructs->next()) {
+    cn->generateTraceEpDecl(op);
+  }
+}
+
+
+void SdagConstruct::generateTraceEpDef(XStr& op)          // for trace
+{
+  if (traceName) {
+    op << "  int " << CParsedFile::className->charstar() << "::__idx_" << traceName->charstar() << "=0;\\\n"; 
+  }
+  SdagConstruct *cn;
+  for(cn=constructs->begin(); !constructs->end(); cn=constructs->next()) {
+    cn->generateTraceEpDef(op);
+  }
+}
+
 void RemoveSdagComments(char *str)
 {
   char *ptr = str;
index a7d315595f4ca6c3728a9d4e7f232dee04c7708e..6612f20b4798d4adb2b04f2c06093481503d94ba 100644 (file)
@@ -61,12 +61,21 @@ enum EToken {
   ,SCONNECT=49
   ,SPUBLISHES=50
 
+  ,SOVERLAP_END=51
+  ,SWHEN_END=52
+  ,SIF_END=53
+  ,SELSE_END=54 
+  ,SWHILE_END=55
+  ,SFOR_END=56
+  ,SFOR_ENDALL=57
+
   ,SMATCHED_CPP_CODE=100
   ,SINT_EXPR=101
   ,SWSPACE=102
   ,SSLIST=103
   ,SELIST=104
   ,SOLIST=105
+  ,SOLIST_END=106
 };
 
 #endif /* _EToken_H_ */