SDAG: Reference messages before buffering them, unreference after delivery
authorPhil Miller <mille121@illinois.edu>
Wed, 23 Jun 2010 04:07:55 +0000 (23:07 -0500)
committerPhil Miller <mille121@illinois.edu>
Wed, 23 Jun 2010 04:12:15 +0000 (23:12 -0500)
CharmLU uses [nokeep] entry methods to make the runtime not make
excess copies of messages that it wasn't going to modify. On
conversion to SDAG, Jonathan and I found that the CmiReference calls
in the client code weren't reached before control returned to the
runtime, because SDAG buffers messages internally when the client code
isn't ready to receive them (i.e. hasn't reached the corresponding
`when' clause).

Since SDAG hangs onto the messages given to it, make it claim a
reference to those messages, and release those references after the
message has been delivered to its client code.

src/xlat-i/sdag/CEntry.C
src/xlat-i/sdag/CSdagConstruct.C

index 037cbccd0da8b780166e5ea925b12aa4d36c403f..a1e9846d54fd7b63c271770284e631fa3a301a8d 100644 (file)
@@ -88,6 +88,7 @@ void CEntry::generateCode(XStr& op)
            op <<"    impl_off+=(impl_cnt_"<<sv->name->charstar()<<"=sizeof("<<sv->type->charstar()<<")*("<<sv->arrayLength->charstar()<<"));\n";
         }
         if (paramMarshalling ==0) {
+          op << "    CmiReference(UsrToEnv(" << sv->name->charstar() << "_msg));\n";
            if(refNumNeeded) {
               op << "    int refnum = CkGetRefNum(" <<sv->name->charstar() <<"_msg);\n";
               op << "    cmsgbuf = __cDep->bufferMessage("<<entryNum<<",(void *) "<<sv->name->charstar() <<"_msg , (void *) _bgParentLog, refnum);\n";
index 08ee83afb9aa1900953b3b0f1f14a783ceb62489..4ce926d0b553cc944281347e0c96b07900da1139 100644 (file)
@@ -799,6 +799,8 @@ void SdagConstruct::generateWhen(XStr& op)
     e = el->entry;
     if (e->paramIsMarshalled() == 1) {
         op << "       delete " << e->getEntryName() << "_msg;\n";
+    } else if (e->param->isMessage() == 1) {
+       op << "       CmiFree(UsrToEnv(" << e->param->param->getGivenName() << "));\n";
     }
     el = el->next;
   }