Mercurial > hg > Gears > Gears
changeset 900:600340b6c03b
fix generate_stub
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Jan 2021 16:22:19 +0900 |
parents | d24f24e942de |
children | e4f918ebd927 |
files | src/parallel_execution/SingleLinkedQueue.cbc src/parallel_execution/examples/DPPMC/AtomicTImpl.cbc src/parallel_execution/generate_stub.pl |
diffstat | 3 files changed, 54 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/SingleLinkedQueue.cbc Wed Jan 27 13:44:47 2021 +0900 +++ b/src/parallel_execution/SingleLinkedQueue.cbc Wed Jan 27 16:22:19 2021 +0900 @@ -1,5 +1,6 @@ #include "../context.h" #include <stdio.h> +#include "state_db.h" #impl "Queue.h" for "SingleLinkedQueue.h" #data "Node.h" #data "Element.h" @@ -92,3 +93,42 @@ } return queue->top; } + + +typedef struct task_iterator { + struct task_iterator *prev; + StateDB state; + Element* list; + Element* last; +} TaskIterator, *TaskIteratorPtr; + + +Element* createQueueIterator(struct SingleLinkedQueue* queue) { + TaskIteratorPtr new = (TaskIteratorPtr)malloc(sizeof(TaskIterator)); + if (!new) exit(1); + + new->prev = queue->top; + new->state = NULL; + new->list = queue->top; + new->last = queue->last; + return new; +} + +Element* takeNextIterator(struct SingleLinkedQueue* queue, TaskIteratorPtr iterator) { + struct Element* elem = iterator->list; + if (!elem) { + return NULL; + } + + struct Element* next = elem->next; + if (next == NULL) { + return next; + } + + if (next == iterator->last) { + return NULL; + } + + iterator->list = next; + return next; +}
--- a/src/parallel_execution/examples/DPPMC/AtomicTImpl.cbc Wed Jan 27 13:44:47 2021 +0900 +++ b/src/parallel_execution/examples/DPPMC/AtomicTImpl.cbc Wed Jan 27 16:22:19 2021 +0900 @@ -14,14 +14,14 @@ } -__code checkAndSet_AtomicT_intImpl(struct AtomicT_intImpl_int* atomicT_int, int oldData, int newData, __code next(...), __code fail(...)) { +__code checkAndSet(struct AtomicT_intImpl_int* atomicT_int, int oldData, int newData, __code next(...), __code fail(...)) { if (__sync_bool_compare_and_swap(&atomicT_int->atomic, oldData, newData)) { goto next(...); } goto fail(...); } -__code set_AtomicT_intImpl(struct AtomicT_intImpl_int* atomicT_int, int newData, __code next(...) ) { +__code set(struct AtomicT_intImpl_int* atomicT_int, int newData, __code next(...) ) { atomicT_int->atomic = newData; goto next(...); }
--- a/src/parallel_execution/generate_stub.pl Wed Jan 27 13:44:47 2021 +0900 +++ b/src/parallel_execution/generate_stub.pl Wed Jan 27 16:22:19 2021 +0900 @@ -156,10 +156,15 @@ $generic{$name} = []; } elsif (/^(\w+)(\*)+ create(\w+)\(/) { # this case implementation constructor debug_print("getDataGear",__LINE__, $_) if $opt_debug; - #if (defined $implInterfaceInfo->{interface} ) { - # die "duplicate interface $implInterfaceInfo->{interface}\n"; - # } + #if (defined $implInterfaceInfo->{interface} ) { + # die "duplicate interface $implInterfaceInfo->{interface}\n"; + #} my $interfaceName = $1; + if ($implInterfaceInfo->{interface}) { + if ($implInterfaceInfo->{interface} ne $interfaceName) { + next; + } + } $implInterfaceInfo->{isImpl} = 1; $implInterfaceInfo->{interface} = $interfaceName; $implInterfaceInfo->{implementation} = $3; @@ -646,6 +651,10 @@ } elsif(/^#impl "(.*)"/) { debug_print("generateDataGear",__LINE__, $_) if $opt_debug; next unless ($implInterfaceInfo->{genConstructor}); + if ((!$implInterfaceInfo->{genConstructor}) || $implInterfaceInfo->{interface} ne $1) { + next; + } + my $constructInterface = { name => $implInterfaceInfo->{interface},