fixed a bug in workstealing that when stealing is in progress, beginIdle should not...
authorGengbin Zheng <gzheng@bp-login1.(none)>
Wed, 23 Feb 2011 00:51:37 +0000 (18:51 -0600)
committerGengbin Zheng <gzheng@bp-login1.(none)>
Wed, 23 Feb 2011 00:51:37 +0000 (18:51 -0600)
src/conv-ldb/cldb.workstealing.c

index fd6fcde7e37609de2c3fbc8620b85e7b935f9c91..1403082c7553a2c631a8df913e3ca9125e56cb07 100644 (file)
@@ -26,6 +26,7 @@ int _stealonly1 = 0;
 CpvStaticDeclare(CldProcInfo, CldData);
 CpvStaticDeclare(int, CldAskLoadHandlerIndex);
 CpvStaticDeclare(int, CldAckNoTaskHandlerIndex);
+CpvStaticDeclare(int, isStealing);
 
 void LoadNotifyFn(int l)
 {
@@ -50,6 +51,9 @@ static void CldBeginIdle(void *dummy)
 
   CcdRaiseCondition(CcdUSER);
 
+  if (CpvAccess(isStealing)) return;    /* already stealing, return */
+  CpvAccess(isStealing) = 1;
+
   myload = CldLoad();
 
   mype = CmiMyPe();
@@ -121,6 +125,7 @@ void  CldAckNoTaskHandler(requestmsg *msg)
   CmiSetHandler(msg, CpvAccess(CldAskLoadHandlerIndex));
   CmiSyncSendAndFree(victim, sizeof(requestmsg),(char *)msg);
 
+  CpvAccess(isStealing) = 1;
 }
 
 void CldHandler(void *msg)
@@ -138,6 +143,7 @@ void CldBalanceHandler(void *msg)
 {
   CldRestoreHandler(msg);
   CldPutToken(msg);
+  CpvAccess(isStealing) = 0;
 }
 
 void CldEnqueueGroup(CmiGroup grp, void *msg, int infofn)
@@ -290,6 +296,9 @@ void CldModuleInit(char **argv)
   CldGraphModuleInit(argv);
 
   CpvAccess(CldLoadNotify) = 1;
+
+  CpvInitialize(int, isStealing);
+  CpvAccess(isStealing) = 0;
 }
 
 void CldCallback()