changeset 581:62166b0e0c7e

fix boundedBuffer example
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 27 Nov 2019 18:27:46 +0900
parents 39b5adbcd83f
children 2a97d22c2a76
files src/parallel_execution/examples/boundedBuffer/consumer.cbc src/parallel_execution/examples/boundedBuffer/initBuffer.cbc src/parallel_execution/examples/boundedBuffer/main.cbc src/parallel_execution/examples/boundedBuffer/producer.cbc src/parallel_execution/lib/Gears/Context.pm
diffstat 5 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/examples/boundedBuffer/consumer.cbc	Wed Nov 27 18:03:12 2019 +0900
+++ b/src/parallel_execution/examples/boundedBuffer/consumer.cbc	Wed Nov 27 18:27:46 2019 +0900
@@ -2,24 +2,24 @@
 #include <stdio.h>
 #interface "Buffer.h"
 
-__code consumer(struct Buffer* buffer, Int* length, __code next(...), struct LoopCounter* loopCounter) {
+__code consumer(struct Buffer* buffer, struct Integer* length, __code next(...), struct LoopCounter* loopCounter) {
     int i = loopCounter->i;
-    if (i < *length) {
+    if (i < length->value) {
         loopCounter->i++;
         goto buffer->take(consumer1);
     }
     goto next(...);
 }
 
-__code consumer1(struct Buffer* buffer, Int* length, __code next(...), struct Node* node) {
-    printf("getData %d\n", node->value->Int);
+__code consumer1(struct Buffer* buffer, struct Integer* length, __code next(...), struct Node* node) {
+    printf("getData %d\n", node->value->Integer.value);
     goto consumer();
 }
 
 __code consumer1_stub(struct Context* context) {
     goto consumer1(context,
                    &context->data[context->idg]->Buffer,
-                   &context->data[context->idg+1]->Int,
+                   &context->data[context->idg+1]->Integer,
                    context->next,
                    &Gearef(context, Buffer)->data->Node);
 }
--- a/src/parallel_execution/examples/boundedBuffer/initBuffer.cbc	Wed Nov 27 18:03:12 2019 +0900
+++ b/src/parallel_execution/examples/boundedBuffer/initBuffer.cbc	Wed Nov 27 18:27:46 2019 +0900
@@ -1,5 +1,5 @@
 #include "../../../context.h"
 
-__code initBuffer(__code next(struct Buffer* output, Int* output1, ...)) {
+__code initBuffer(__code next(struct Buffer* output, struct Integer* output1, ...)) {
     goto next(output, output1, ...);
 }
--- a/src/parallel_execution/examples/boundedBuffer/main.cbc	Wed Nov 27 18:03:12 2019 +0900
+++ b/src/parallel_execution/examples/boundedBuffer/main.cbc	Wed Nov 27 18:27:46 2019 +0900
@@ -38,8 +38,8 @@
 
 __code createTask1(struct TaskManager* taskManager) {
     struct Buffer* buffer = createBoundedBuffer(context, buffer_size);
-    Int* len = new Int();
-    *len = length;
+    Integer* len = new Integer();
+    len->value = length;
     par goto producer(buffer, len, __exit);
     par goto producer(buffer, len, __exit);
     par goto producer(buffer, len, __exit);
--- a/src/parallel_execution/examples/boundedBuffer/producer.cbc	Wed Nov 27 18:03:12 2019 +0900
+++ b/src/parallel_execution/examples/boundedBuffer/producer.cbc	Wed Nov 27 18:27:46 2019 +0900
@@ -1,12 +1,12 @@
 #include "../../../context.h"
 #interface "Buffer.h"
 
-__code producer(struct Buffer* buffer, Int* length, __code next(...), struct LoopCounter* loopCounter) {
+__code producer(struct Buffer* buffer, struct Integer* length, __code next(...), struct LoopCounter* loopCounter) {
     int i = loopCounter->i;
-    if (i < *length) {
+    if (i < length->value) {
         Node* node = new Node();
-        node->value = (union Data*)new Int();
-        node->value->Int = i;
+        node->value = (union Data*)new Integer();
+        node->value->Integer.value = i;
         loopCounter->i++;
         goto buffer->put(node, producer);
     }
--- a/src/parallel_execution/lib/Gears/Context.pm	Wed Nov 27 18:03:12 2019 +0900
+++ b/src/parallel_execution/lib/Gears/Context.pm	Wed Nov 27 18:27:46 2019 +0900
@@ -60,6 +60,13 @@
           next;
        }
 
+       if ($line =~ /ALLOCATE_DATA_GEAR\((\w+),\s*(\w+)\)/) {
+          my $implementation = $2;
+          $counter{impl}->{$implementation}++;
+          $self->{data_gears_with_count}->{$implementation}->{caller}->{$cbc_file}++;
+          next;
+       }
+
        #TaskManagerImpl* taskManager = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager);
        if ($line =~ /\((\w+)\*\)GearImpl\(context,\s*(\w+),\s*(\w+)\)/) {
           my $interface = $2;