do synchronization after message handlers are up
authorbdemsky <bdemsky>
Thu, 30 Jun 2011 11:41:07 +0000 (11:41 +0000)
committerbdemsky <bdemsky>
Thu, 30 Jun 2011 11:41:07 +0000 (11:41 +0000)
Robust/src/Runtime/bamboo/multicoremsg.c
Robust/src/Runtime/bamboo/multicoremsg.h
Robust/src/Runtime/bamboo/multicoreruntime.c

index a9fd40c7a1951bdf847e9818667adcb59e9e89b6..420a6a805a368730460ee20d09dfeb7ffb54c384 100644 (file)
@@ -10,6 +10,8 @@
 
 int msgsizearray[] = {
   0, //MSGSTART,
+  1, //REQNOTIFYSTART
+  1, //NOTIFYSTART
  -1, //TRANSOBJ,              // 0xD1
   4, //TRANSTALL,             // 0xD2
   5, //LOCKREQUEST,           // 0xD3
@@ -706,6 +708,19 @@ INLINE void processmsg_gcfinishpref_I() {
 #endif // GC_CACHE_ADAPT
 #endif // #ifdef MULTICORE_GC
 
+void processmg_req_notify_start() {
+  startflag=true;
+  if(BAMBOO_CHECK_SEND_MODE()) {
+    cache_msg_1_I(STARTUPCORE,NOTIFYSTART);
+  } else {
+    send_msg_1_I(STARTUPCORE,NOTIFYSTART);
+  }  
+}
+
+void processmg_notify_start() {
+  numconfirm--;
+}
+
 // receive object transferred from other cores
 // or the terminate message from other cores
 // Should be invoked in critical sections!!
@@ -762,6 +777,16 @@ processmsg:
     msgdatafull = false;
 
     switch(type) {
+    case REQNOTIFYSTART: {
+      processmsg_req_notify_start();
+      break;
+    }
+
+    case NOTIFYSTART: {
+      processmsg_notify_start();
+      break;
+    }
+
 #ifdef TASK
     case TRANSOBJ: {
       // receive a object transfer msg
index 03fa5c554d5ab2cddfa8ac6303d8643c7d109b09..7f9fed18b6afb32efe67d899944989b798f117cf 100644 (file)
@@ -16,7 +16,7 @@ int outmsgindex;
 int outmsglast;
 int outmsgleft;
 volatile bool isMsgHanging;
-
+volatile bool startflag;
 #define MSG_INDEXINC_I() \
   msgdataindex = (msgdataindex + 1) & (BAMBOO_MSG_BUF_MASK) 
 
@@ -153,6 +153,8 @@ volatile bool isMsgHanging;
  */
 typedef enum {
   MSGSTART = 0x0,        // 0xD0
+  REQNOTIFYSTART,
+  NOTIFYSTART,
   TRANSOBJ,              // 0xD1
   TRANSTALL,             // 0xD2
   LOCKREQUEST,           // 0xD3
index 4d8e5f0e59d9037d4a991d69ed26784e2c51deb0..73835dd3556ee1f526cab7314ce2418dffc773d6 100644 (file)
@@ -753,13 +753,27 @@ inline void run(int argc, char** argv) {
   bool sendStall = false;
   bool isfirst = true;
   bool tocontinue = false;
-
+  startflag = false;
   corenum = BAMBOO_GET_NUM_OF_CORE();
 
   // initialize runtime data structures
   initruntimedata();
   initCommunication();
 
+  if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
+    numconfirm=NUMCORES-1;
+    for(int i=0;i<NUMCORES;i++) {
+      if (i!=STARTUPCORE) {
+       send_msg_1(STARTUPCORE,REQ_NOTIFY_START);
+      }
+    }
+    while(numconfirm!=0)
+      ;
+  } else {
+    while(!startflag)
+      ;
+  }
+
   CACHEADAPT_ENABLE_TIMER();
 
   initializeexithandler();