changeset 729:13267f35c286

fix redefinition
author ikkun <ikkun@cr.ie.u-ryukyu.ac.jp>
date Tue, 01 Dec 2020 18:06:38 +0900
parents 9357393cc9a0
children a59398eea6c7
files src/parallel_execution/CMakeLists.txt src/parallel_execution/examples/calc/add.cbc src/parallel_execution/examples/calc/calc.cbc src/parallel_execution/examples/calc/initIntegerDataGears.cbc src/parallel_execution/examples/calc/mult.cbc
diffstat 5 files changed, 76 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Fri Nov 06 16:31:53 2020 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Tue Dec 01 18:06:38 2020 +0900
@@ -71,7 +71,7 @@
   TARGET
       calc
   SOURCES
-      examples/calc/calc.cbc examples/calc/add.cbc examples/calc/mult.cbc examples/calc/initIntegerDataGears.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc AtomicReference.cbc
+      examples/calc/calc.cbc examples/calc/add.cbc examples/calc/mult.cbc examples/calc/initIntegerDataGears.cbc CPUWorker.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc AtomicReference.cbc examples/calc/print.cbc 
 )
 
 GearsCommand(
@@ -150,3 +150,18 @@
 )
 
 
+#[[GearsCommand(
+  TARGET
+  DPP1
+  SOURCES
+  TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc SingleLinkedStack.cbc /emacs/DPP/DPP_TMImpl.cbc /emacs/DPP/main.cbc
+
+)]]
+
+
+GearsCommand(
+  TARGET
+  DPP
+  SOURCES
+  TaskManagerImpl.cbc CPUWorker.cbc SynchronizedQueue.cbc AtomicReference.cbc SingleLinkedStack.cbc /examoles/DPP1/dpp3.cbc  /examoles/DPP1/dpp2.cbc  /examoles/DPP1/ltl.cbc  /examoles/DPP1/scheduler.cbc  /examoles/DPP1/queue.cbc  /examoles/DPP1/tableau3.cbc  /examoles/DPP1/tableau2.cbc  /examoles/DPP1/dpp3.cbc  /examoles/DPP1/main.cbc  /examoles/DPP1/tableau.cbc
+)
--- a/src/parallel_execution/examples/calc/add.cbc	Fri Nov 06 16:31:53 2020 +0900
+++ b/src/parallel_execution/examples/calc/add.cbc	Tue Dec 01 18:06:38 2020 +0900
@@ -1,7 +1,18 @@
 #include "../../../context.h"
 #include <stdio.h>
 __code add(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
+
     output->value = input1->value + input2->value;
     printf("%d + %d = %d\n", input1->value, input2->value, output->value);
-    goto next(output, ...);
+    *O_output = output;
+    goto meta(context, next);
 }
+
+__code add_stub(struct Context* context) {
+    Integer** O_output = (struct Integer **)&context->data[context->odg];
+    goto add(context,
+            &context->data[context->idg]->Integer,
+            &context->data[context->idg + 1]->Integer,
+            context->next,
+            O_output);
+}
--- a/src/parallel_execution/examples/calc/calc.cbc	Fri Nov 06 16:31:53 2020 +0900
+++ b/src/parallel_execution/examples/calc/calc.cbc	Tue Dec 01 18:06:38 2020 +0900
@@ -6,6 +6,7 @@
 
 #include "../../../context.h"
 #interface "TaskManager.h"
+#interface "Timer.h"
 
 int cpu_num = 1;
 int length = 100;
@@ -13,6 +14,11 @@
 int CPU_ANY = -1;
 int CPU_CUDA = -1;
 
+void *start_taskManager(struct Context *context) {
+    goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
+    return 0;
+}
+
 __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
     // loopCounter->tree = createRedBlackTree(context);
     loopCounter->i = 0;
@@ -20,7 +26,14 @@
     goto meta(context, C_code1);
 }
 
-__code code1(struct Timer* timer) {
+__code initDataGears_stub(struct Context* context) {
+    struct TaskManager* taskManager =  Gearef(context, TaskManager);
+    taskManager->taskManager = 0;
+    struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
+    goto initDataGears(context, loopCounter, taskManager);
+}
+
+__code code1(struct Time* time) {
     printf("cpus:\t\t%d\n", cpu_num);
     printf("gpus:\t\t%d\n", gpu_num);
     printf("length:\t\t%d\n", length);
@@ -50,10 +63,10 @@
 
     loopCounter->i = 0;
     taskManager->next = C_exit_code;
-    goto meta(context, taskManager->taskManager->TaskManager.shutdown);
+    goto taskManager->shutdown(exit_code);
 }
 
-__code createTask2(struct LoopCounter* loopCounter) {
+__code createTask2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
     Integer* integer1 = new Integer();
     Integer* integer2 = new Integer();
     Integer* integer3 = new Integer();
@@ -83,5 +96,9 @@
 
 int main(int argc, char** argv) {
     init(argc, argv);
-    goto initDataGears();
+    struct Context* main_context = NEW(struct Context);
+    initContext(main_context);
+    main_context->next = C_initDataGears;
+
+    goto print();
 }
--- a/src/parallel_execution/examples/calc/initIntegerDataGears.cbc	Fri Nov 06 16:31:53 2020 +0900
+++ b/src/parallel_execution/examples/calc/initIntegerDataGears.cbc	Tue Dec 01 18:06:38 2020 +0900
@@ -4,5 +4,19 @@
     output1->value = 1;
     output2->value = 2;
     output3->value = 3;
-    goto next(output1, output2, output3, ...);
+    *O_output1 = output1;
+    *O_output2 = output2;
+    *O_output3 = output3;
+    goto meta(context, next);
 }
+
+__code initIntegerDataGears_stub(struct Context* context) {
+    Integer** O_output1 = (struct Integer **)&context->data[context->odg];
+    Integer** O_output2 = (struct Integer **)&context->data[context->odg+1];
+    Integer** O_output3 = (struct Integer **)&context->data[context->odg+2];
+    goto initIntegerDataGears(context,
+            context->next,
+            O_output1,
+            O_output2,
+            O_output3);
+}
--- a/src/parallel_execution/examples/calc/mult.cbc	Fri Nov 06 16:31:53 2020 +0900
+++ b/src/parallel_execution/examples/calc/mult.cbc	Tue Dec 01 18:06:38 2020 +0900
@@ -1,7 +1,18 @@
 #include "../../../context.h"
 #include <stdio.h>
 __code mult(struct Integer* input1, struct Integer* input2, __code next(struct Integer* output, ...)) {
+
     output->value = input1->value * input2->value;
     printf("%d * %d = %d\n", input1->value, input2->value, output->value);
-    goto next(output, ...);
+    *O_output = output;
+    goto meta(context, next);
 }
+
+__code mult_stub(struct Context* context) {
+    Integer** O_output = (struct Integer **)&context->data[context->odg];
+    goto mult(context,
+            &context->data[context->idg]->Integer,
+            &context->data[context->idg + 1]->Integer,
+            context->next,
+            O_output);
+}