changeset 883:b69b748e61d9

fix MCWorker
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 24 Jan 2021 18:03:25 +0900
parents 24ba42caf425
children 084639a31aaf
files src/parallel_execution/CMakeLists.txt src/parallel_execution/MCTaskManagerImpl.cbc src/parallel_execution/MCWorker.h src/parallel_execution/ModelChecking/MCWorker.cbc src/parallel_execution/examples/DPPMC/main.cbc
diffstat 5 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Sun Jan 24 17:11:08 2021 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Sun Jan 24 18:03:25 2021 +0900
@@ -153,7 +153,7 @@
   TARGET
   DPPMC
   SOURCES
-  CPUWorker.cbc SynchronizedQueue.cbc examples/DPPMC/AtomicTImpl.cbc SingleLinkedStack.cbc examples/DPPMC/PhilsImpl.cbc examples/DPPMC/main.cbc examples/DPPMC/ForkImpl.cbc ModelChecking/crc32.c ModelChecking/memory.c ModelChecking/state_db.c AtomicReference.cbc ModelChecking/MCWorker.cbc MCTaskManagerImpl.cbc
+  CPUWorker.cbc SynchronizedQueue.cbc examples/DPPMC/AtomicTImpl.cbc SingleLinkedStack.cbc examples/DPPMC/PhilsImpl.cbc examples/DPPMC/main.cbc examples/DPPMC/ForkImpl.cbc ModelChecking/crc32.c ModelChecking/memory.c ModelChecking/state_db.c AtomicReference.cbc ModelChecking/MCWorker.cbc MCTaskManagerImpl.cbc SingleLinkedQueue.cbc
 )
 
 GearsCommand(
--- a/src/parallel_execution/MCTaskManagerImpl.cbc	Sun Jan 24 17:11:08 2021 +0900
+++ b/src/parallel_execution/MCTaskManagerImpl.cbc	Sun Jan 24 18:03:25 2021 +0900
@@ -83,7 +83,7 @@
 
 __code spawnTasksMCTaskManagerImpl3(struct MCTaskManagerImpl* taskManagerImpl, __code next1(...), struct TaskManager* taskManager) {
     if (taskManagerImpl->taskList == NULL) {
-        goto next1(...);
+        goto taskManager->spawn(NULL, next1);
     }
     struct Context* task = (struct Context*)taskManagerImpl->taskList->data;
     taskManagerImpl->taskList = taskManagerImpl->taskList->next;
--- a/src/parallel_execution/MCWorker.h	Sun Jan 24 17:11:08 2021 +0900
+++ b/src/parallel_execution/MCWorker.h	Sun Jan 24 18:03:25 2021 +0900
@@ -4,4 +4,5 @@
   struct Context* context;
   int id;
   int loopCounter;
+  struct Queue* mcQueue;
 } MCWorker;
--- a/src/parallel_execution/ModelChecking/MCWorker.cbc	Sun Jan 24 17:11:08 2021 +0900
+++ b/src/parallel_execution/ModelChecking/MCWorker.cbc	Sun Jan 24 18:03:25 2021 +0900
@@ -9,6 +9,7 @@
 Worker* createMCWorker(struct Context* context, int id, Queue* queue) {
     struct Worker* worker = new Worker();
     struct MCWorker* mcWorker = new MCWorker();
+    mcWorker->mcQueue = createSingleLinkedQueue(context);
     worker->worker = (union Data*)mcWorker;
     worker->tasks = queue;
     mcWorker->id = id;
@@ -32,14 +33,24 @@
     goto tasks->take(getTaskMCWorker);
 }
 
+__code startModelChecker(struct MCWorker* worker) {
+    struct SingleLinkedQueue* mcQueue = (struct SingleLinkedQueue*) worker->mcQueue->queue;
+    struct Element* taskElement = (struct Element*)mcQueue->top;
+    struct Context* task = (struct Context*) taskElement->data;
+    goto meta(task, task->next);
+}
+
 __code getTaskMCWorker(struct MCWorker* mcWorker, struct Context* task, struct Worker* worker) {
-    if (!task) {
-        goto worker->shutdown(); // end thread
+    if (task == NULL) {
+      // get all task for model checking
+      // start model checker
+      // we should goto odgCommitMCWorker foreach mctask
+      goto startModelChecker();
     }
     task->worker = worker;
     enum Code taskCg = task->next;
-    task->next = C_odgCommitMCWorker; // commit outputDG after task exec
-    goto meta(task, taskCg); // switch task context
+    struct Queue* mcQueue = mcWorker->mcQueue;
+    goto mcQueue->put(task, taskReceiveMCWorker);
 }
 
 __code getTaskMCWorker_stub(struct Context* context) {
--- a/src/parallel_execution/examples/DPPMC/main.cbc	Sun Jan 24 17:11:08 2021 +0900
+++ b/src/parallel_execution/examples/DPPMC/main.cbc	Sun Jan 24 18:03:25 2021 +0900
@@ -10,7 +10,7 @@
 #interface "Fork.h"
 #interface "AtomicT_int.h"
 
-int cpu_num = 5;
+int cpu_num = 1;
 int length = 102400;
 int split = 8;
 int* array_ptr;