add workstealing proactive option to make stealing more proactive
authorYanhua Yanhua <sun51@illinois.edu>
Sun, 27 Feb 2011 23:33:53 +0000 (17:33 -0600)
committerYanhua Yanhua <sun51@illinois.edu>
Sun, 27 Feb 2011 23:33:53 +0000 (17:33 -0600)
src/conv-ldb/cldb.workstealing.c

index 50c10f9a4834aea6fd428d6fe4c922a0c01e8bd4..024bfab03fcb853a2f82bdaa51043c901f3ed693 100644 (file)
@@ -22,24 +22,35 @@ typedef struct CldProcInfo_s {
 } *CldProcInfo;
 
 int _stealonly1 = 0;
+int workstealingproactive = 0;
 
 CpvStaticDeclare(CldProcInfo, CldData);
 CpvStaticDeclare(int, CldAskLoadHandlerIndex);
 CpvStaticDeclare(int, CldAckNoTaskHandlerIndex);
 CpvStaticDeclare(int, isStealing);
 
-void LoadNotifyFn(int l)
-{
-}
 
 char *CldGetStrategy(void)
 {
   return "work stealing";
 }
 
+void LoadNotifyFn(int l)
+{
+    if(workstealingproactive)
+    {
+        if(CldLoad() < 3)
+            StealLoad();
+    }
+}
 /* since I am idle, ask for work from neighbors */
 
 static void CldBeginIdle(void *dummy)
+{
+    StealLoad();
+
+}
+static inline void StealLoad()
 {
   int i;
   double startT;
@@ -270,6 +281,8 @@ void CldGraphModuleInit(char **argv)
   if (CmiMyRank() == CmiMyNodeSize())  return;
 
   _stealonly1 = CmiGetArgFlagDesc(argv, "+stealonly1", "Charm++> Work Stealing, every time only steal 1 task");
+  
+  workstealingproactive= CmiGetArgFlagDesc(argv, "+workstealingproactive", "Charm++> Work Stealing, steal before going idle(threshold = 3)");
 
   /* register idle handlers - when idle, keep asking work from neighbors */
   if(CmiNumPes() > 1)