Mercurial > hg > Document > Growi
changeset 26:f0d19eb29616
backup 2021-01-19
author | autobackup |
---|---|
date | Tue, 19 Jan 2021 00:10:03 +0900 |
parents | c25e1386e469 |
children | 459b9fa6f047 |
files | user/anatofuz/note/2021/01/18.md |
diffstat | 1 files changed, 827 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/user/anatofuz/note/2021/01/18.md Tue Jan 19 00:10:03 2021 +0900 @@ -0,0 +1,827 @@ + + +```perl +\ { + Atomic { + elem { + content [ + [0] "union Data* atomic;", + [1] "union Data** ptr;", + [2] "union Data* oldData;", + [3] "union Data* newData;", + [4] "enum Code checkAndSet;", + [5] "enum Code next;", + [6] "enum Code fail;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Atomic.h", + inner_code_gears {}, + name "Atomic" + }, + impl { + AtomicReference { + content [], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/AtomicReference.h", + inner_code_gears {}, + isa "Atomic", + name "AtomicReference" + } + } + }, + CPUWorker { + elem { + content [ + [0] "pthread_mutex_t mutex;", + [1] "pthread_cond_t cond;", + [2] "struct Context* context;", + [3] "int id;", + [4] "int loopCounter;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/CPUWorker.h", + inner_code_gears {}, + name "CPUWorker" + }, + impl {} + }, + Element { + elem { + content [ + [0] "union Data* data;", + [1] "struct Element* next;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/Element.h", + inner_code_gears {}, + name "Element" + }, + impl {} + }, + Integer { + elem { + content [ + [0] "int value;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/Integer.h", + inner_code_gears {}, + name "Integer" + }, + impl {} + }, + Iterator { + elem { + content [ + [0] "union Data* iterator;", + [1] "struct Context* task;", + [2] "int numGPU;", + [3] "enum Code exec;", + [4] "enum Code barrier;", + [5] "enum Code whenWait;", + [6] "enum Code next;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Iterator.h", + inner_code_gears {}, + name "Iterator" + }, + impl {} + }, + LoopCounter { + elem { + content [ + [0] "int i;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/LoopCounter.h", + inner_code_gears {}, + name "LoopCounter" + }, + impl {} + }, + Meta { + elem { + content [ + [0] "enum DataType type;", + [1] "long size;", + [2] "long len;", + [3] "union Data* data;", + [4] "struct Queue* wait; // tasks waiting this dataGear;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/Meta.h", + inner_code_gears {}, + name "Meta" + }, + impl {} + }, + Queue { + elem { + content [ + [0] "enum Code whenEmpty;", + [1] "enum Code clear;", + [2] "union Data* queue;", + [3] "enum Code put;", + [4] "union Data* data;", + [5] "enum Code take;", + [6] "enum Code isEmpty;", + [7] "enum Code next;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Queue.h", + inner_code_gears { + next 1, + whenEmpty 1 + }, + name "Queue" + }, + impl { + SynchronizedQueue { + content [ + [0] "struct Element* top;", + [1] "struct Element* last;", + [2] "struct Atomic* atomic;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/SynchronizedQueue.h", + inner_code_gears {}, + isa "Queue", + name "SynchronizedQueue" + } + } + }, + StackGenerics { + elem { + content [ + [0] "enum Code clear;", + [1] "union Data* stack;", + [2] "enum Code push;", + [3] "TYPED_GENERICS_StackGenerics_T * data;", + [4] "enum Code pop;", + [5] "enum Code pop2;", + [6] "TYPED_GENERICS_StackGenerics_T * data1;", + [7] "enum Code isEmpty;", + [8] "enum Code get;", + [9] "enum Code get2;", + [10] "enum Code next;", + [11] "enum Code whenEmpty;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/interface/StackGenerics.h", + inner_code_gears { + next 1, + whenEmpty 1 + }, + name "StackGenerics", + typed_variable [ + [0] { + type "T", + vname "data" + }, + [1] { + type "T", + vname "data1" + } + ], + typed_variable_types { + T [ + [0] "data", + [1] "data1" + ] + } + }, + impl { + StackGenericsImpl { + content [ + [0] "enum Code next;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/impl/StackGenericsImpl.h", + inner_code_gears {}, + isa "StackGenerics", + name "StackGenericsImpl" + } + } + }, + TaskManager { + elem { + content [ + [0] "enum Code spawn;", + [1] "union Data* taskManager;", + [2] "struct Context* task;", + [3] "enum Code spawnTasks;", + [4] "union Data* taskManagerImpl;", + [5] "struct Element* taskList;", + [6] "enum Code setWaitTask;", + [7] "enum Code shutdown;", + [8] "enum Code incrementTaskCount;", + [9] "enum Code decrementTaskCount;", + [10] "enum Code next;", + [11] "enum Code next1;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/TaskManager.h", + inner_code_gears { + next 1, + next1 1 + }, + name "TaskManager" + }, + impl { + TaskManagerImpl { + content [ + [0] "int numWorker;", + [1] "int sendCPUWorkerIndex;", + [2] "int sendGPUWorkerIndex;", + [3] "int taskCount;", + [4] "pthread_mutex_t mutex;", + [5] "struct Queue* activeQueue;", + [6] "struct Worker** workers;", + [7] "struct Element* taskList;", + [8] "int loopCounter;", + [9] "int cpu;", + [10] "int gpu;", + [11] "int io;", + [12] "int maxCPU;", + [13] "enum Code next;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/TaskManagerImpl.h", + inner_code_gears {}, + isa "TaskManager", + name "TaskManagerImpl" + } + } + }, + Worker { + elem { + content [ + [0] "union Data* worker;", + [1] "struct Queue* tasks;", + [2] "struct Context* task;", + [3] "pthread_t thread;", + [4] "struct TaskManager* taskManager;", + [5] "enum Code taskReceive;", + [6] "enum Code shutdown;", + [7] "enum Code next;" + ], + file_name "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Worker.h", + inner_code_gears {}, + name "Worker" + }, + impl {} + } +} +\ { + StackGenerics { + name "StackGenerics", + typed_variable [ + [0] { + type "T", + vname "data" + }, + [1] { + type "T", + vname "data1" + } + ], + typed_variable_types { + T [ + [0] "data", + [1] "data1" + ] + } + } +} +\ {} +\ { + defined_type [ + [0] { + caller "/home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/c/examples/generics_test/main.c", + defined_type "Integer", + line_number 49, + name "StackGenerics" + } + ] +} +/* Context definition for llrb example */ +#ifndef CONTEXT_H +#define CONTEXT_H +#include <stdlib.h> +#include <pthread.h> +#ifdef USE_CUDAWorker +#include <cuda.h> +#include <driver_types.h> +#include <cuda_runtime.h> +#include "helper_cuda.h" +#endif + +#define ALLOCATE_SIZE 20000000 +#define NEW(type) (type*)(calloc(1, sizeof(type))) +#define NEWN(n, type) (type*)(calloc(n, sizeof(type))) + +#define ALLOC_DATA(context, dseg) ({\ + Meta* meta = (Meta*)context->heap;\ + meta->type = D_##dseg;\ + meta->size = sizeof(dseg);\ + meta->len = 1;\ + context->heap += sizeof(Meta);\ + meta->data = context->heap; \ + *context->metaData = meta; \ + context->metaData++; \ + context->data[D_##dseg] = context->heap; context->heap += sizeof(dseg); (dseg *)context->data[D_##dseg]; }) + +#define ALLOC_DATA_TYPE(context, dseg, t) ({\ + Meta* meta = (Meta*)context->heap;\ + meta->type = D_##t;\ + meta->size = sizeof(t);\ + meta->len = 1;\ + context->heap += sizeof(Meta);\ + meta->data = context->heap; \ + *context->metaData = meta; \ + context->metaData++; \ + context->data[D_##dseg] = context->heap; context->heap += sizeof(t); (t *)context->data[D_##dseg]; }) + +#define ALLOCATE(context, t) ({ \ + Meta* meta = (Meta*)context->heap;\ + context->heap += sizeof(Meta);\ + union Data* data = context->heap; \ + context->heap += sizeof(t); \ + meta->type = D_##t; \ + meta->size = sizeof(t); \ + meta->len = 1;\ + meta->data = data; \ + *context->metaData = meta; \ + context->metaData++; \ + data; }) + +#define ALLOCATE_ARRAY(context, t, length) ({ \ + Meta* meta = (Meta*)context->heap;\ + context->heap += sizeof(Meta);\ + union Data* data = context->heap; \ + context->heap += sizeof(t)*length; \ + meta->type = D_##t; \ + meta->size = sizeof(t)*length; \ + meta->len = length; \ + meta->data = data; \ + *context->metaData = meta; \ + context->metaData++; \ + data; }) + +#define ALLOCATE_PTR_ARRAY(context, dseg, length) ({\ + Meta* meta = (Meta*)context->heap;\ + context->heap += sizeof(Meta);\ + union Data* data = context->heap; \ + context->heap += sizeof(dseg *)*length; \ + meta->type = D_##dseg; \ + meta->size = sizeof(dseg *)*length; \ + meta->len = length; \ + meta->data = data; \ + *context->metaData = meta; \ + context->metaData++; \ + data; }) + +#define ALLOCATE_DATA_GEAR(context, t) ({ \ + union Data* data = ALLOCATE(context, t); \ + Meta* meta = GET_META(data); \ + meta->wait = createSynchronizedQueue(context); \ + data; }) + +#define ALLOC(context, t) (&ALLOCATE(context, t)->t) +#define NALLOC(t) (&ALLOCATE(context, t)->t) + +#define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta))) +#define GET_TYPE(dseg) (GET_META(dseg)->type) +#define GET_SIZE(dseg) (GET_META(dseg)->size) +#define GET_LEN(dseg) (GET_META(dseg)->len) +#define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait) +#define GET_PREV_META(dseg) ((Meta*)(((void*)dseg) - (sizeof(Meta) * 2))) + +#define Gearef(context, t) (&(context)->data[D_##t]->t) + +// (SingleLinkedStack *)context->data[D_Stack]->Stack.stack->Stack.stack + +#define GearImpl(context, intf, name) (Gearef(context, intf)->name->intf.name) + +#include "c/enumCode.h" + +enum Relational { + EQ, + GT, + LT, +}; + +#include "c/enumData.h" +struct Context { + enum Code next; + struct Worker* worker; + struct TaskManager* taskManager; + int codeNum; + __code (**code) (struct Context*); + union Data **data; + struct Meta **metaDataStart; + struct Meta **metaData; + void* heapStart; + void* heap; + long heapLimit; + int dataNum; + + // task parameter + int idgCount; //number of waiting dataGear + int idg; + int maxIdg; + int odg; + int maxOdg; + int gpu; // GPU task + struct Context* task; + struct Element* taskList; +#ifdef USE_CUDAWorker + int num_exec; + CUmodule module; + CUfunction function; +#endif + /* multi dimension parameter */ + int iterate; + struct Iterator* iterator; +}; + +typedef int Int; +#ifndef USE_CUDAWorker +typedef unsigned long long CUdeviceptr; +#endif +union Data { + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Atomic.h +#ifndef ATOMIC_STRUCT + struct Atomic { + union Data* atomic; + union Data** ptr; + union Data* oldData; + union Data* newData; + enum Code checkAndSet; + enum Code next; + enum Code fail; + } Atomic; +#define ATOMIC_STRUCT +#else + struct Atomic; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/AtomicReference.h +#ifndef ATOMICREFERENCE_STRUCT + struct AtomicReference { + } AtomicReference; +#define ATOMICREFERENCE_STRUCT +#else + struct AtomicReference; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/CPUWorker.h +#ifndef CPUWORKER_STRUCT + struct CPUWorker { + pthread_mutex_t mutex; + pthread_cond_t cond; + struct Context* context; + int id; + int loopCounter; + } CPUWorker; +#define CPUWORKER_STRUCT +#else + struct CPUWorker; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/Element.h +#ifndef ELEMENT_STRUCT + struct Element { + union Data* data; + struct Element* next; + } Element; +#define ELEMENT_STRUCT +#else + struct Element; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/Integer.h +#ifndef INTEGER_STRUCT + struct Integer { + int value; + } Integer; +#define INTEGER_STRUCT +#else + struct Integer; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Iterator.h +#ifndef ITERATOR_STRUCT + struct Iterator { + union Data* iterator; + struct Context* task; + int numGPU; + enum Code exec; + enum Code barrier; + enum Code whenWait; + enum Code next; + } Iterator; +#define ITERATOR_STRUCT +#else + struct Iterator; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/LoopCounter.h +#ifndef LOOPCOUNTER_STRUCT + struct LoopCounter { + int i; + } LoopCounter; +#define LOOPCOUNTER_STRUCT +#else + struct LoopCounter; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/interface/Meta.h +#ifndef META_STRUCT + struct Meta { + enum DataType type; + long size; + long len; + union Data* data; + struct Queue* wait; // tasks waiting this dataGear; + } Meta; +#define META_STRUCT +#else + struct Meta; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Queue.h +#ifndef QUEUE_STRUCT + struct Queue { + union Data* queue; + union Data* data; + enum Code whenEmpty; + enum Code clear; + enum Code put; + enum Code take; + enum Code isEmpty; + enum Code next; + } Queue; +#define QUEUE_STRUCT +#else + struct Queue; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/SynchronizedQueue.h +#ifndef SYNCHRONIZEDQUEUE_STRUCT + struct SynchronizedQueue { + struct Element* top; + struct Element* last; + struct Atomic* atomic; + } SynchronizedQueue; +#define SYNCHRONIZEDQUEUE_STRUCT +#else + struct SynchronizedQueue; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/interface/StackGenerics.h +#ifndef STACKGENERICS_STRUCT + struct StackGenerics { + union Data* stack; + TYPED_GENERICS_StackGenerics_T * data; + TYPED_GENERICS_StackGenerics_T * data1; + enum Code clear; + enum Code push; + enum Code pop; + enum Code pop2; + enum Code isEmpty; + enum Code get; + enum Code get2; + enum Code next; + enum Code whenEmpty; + } StackGenerics; +#define STACKGENERICS_STRUCT +#else + struct StackGenerics; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/impl/StackGenericsImpl.h +#ifndef STACKGENERICSIMPL_STRUCT + struct StackGenericsImpl { + enum Code next; + } StackGenericsImpl; +#define STACKGENERICSIMPL_STRUCT +#else + struct StackGenericsImpl; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/TaskManager.h +#ifndef TASKMANAGER_STRUCT + struct TaskManager { + union Data* taskManager; + struct Context* task; + union Data* taskManagerImpl; + struct Element* taskList; + enum Code spawn; + enum Code spawnTasks; + enum Code setWaitTask; + enum Code shutdown; + enum Code incrementTaskCount; + enum Code decrementTaskCount; + enum Code next; + enum Code next1; + } TaskManager; +#define TASKMANAGER_STRUCT +#else + struct TaskManager; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/plautogen/impl/TaskManagerImpl.h +#ifndef TASKMANAGERIMPL_STRUCT + struct TaskManagerImpl { + int numWorker; + int sendCPUWorkerIndex; + int sendGPUWorkerIndex; + int taskCount; + pthread_mutex_t mutex; + struct Queue* activeQueue; + struct Worker** workers; + struct Element* taskList; + int loopCounter; + int cpu; + int gpu; + int io; + int maxCPU; + enum Code next; + } TaskManagerImpl; +#define TASKMANAGERIMPL_STRUCT +#else + struct TaskManagerImpl; +#endif + ///home/anatofuz/src/firefly/hg/Gears/Gears/src/parallel_execution/../parallel_execution/Worker.h +#ifndef WORKER_STRUCT + struct Worker { + union Data* worker; + struct Queue* tasks; + struct Context* task; + pthread_t thread; + struct TaskManager* taskManager; + enum Code taskReceive; + enum Code shutdown; + enum Code next; + } Worker; +#define WORKER_STRUCT +#else + struct Worker; +#endif + struct Context Context; +}; // union Data end this is necessary for context generator +typedef union Data Data; +#include "c/typedefData.h" + +#include "c/extern.h" + +extern __code start_code(struct Context* context); +extern __code exit_code(struct Context* context); +extern __code meta(struct Context* context, enum Code next); +//extern __code par_meta(struct Context* context, enum Code spawns, enum Code next); +extern __code parGotoMeta(struct Context* context, enum Code next); +extern void initContext(struct Context* context); + +#endif +Filehandle STDOUT reopened as $fd only for input at generate_context.pl line 145. +Filehandle STDOUT reopened as $cx only for input at generate_context.pl line 159. +``` + + + +# Storeable + +- `dclone`を使えばいい感じにdeep copyが可能 + +```perl +#!/usr/bin/env perl +use strict; +use warnings; +use Storable qw/dclone/; +use Data::Dumper; + + +my $test = { + + cat => { + names => [qw/a a a/], + color => [qw/ blue yelow/], + say => { + one => 1, + two => 2, + }, + }, + + dog => { + say => { + one => 1, + two => 2, + }, + }, +}; + + +my $copy = dclone($test); + +delete $copy->{cat}->{say}; + + +print Dumper $copy; +print Dumper $test; +``` + + +```perl +use strict; +use warnings; + +my $line = 'Phils* createPhilsImpl(struct Context* context, int id, AtomicT<int> right, AtomicT<int> left) {'; + + +if ($line =~ /^\s*(\w+)(<(.*)>)?\*\s*create(\w+)\(([<>,*\w\s]+)\)/) { + my $interface = $1; + my $generics = $2; + my $method = $3; + + print "interface $interface\n"; + print "generics $generics\n"; + } +``` + + +```shell ++kajika+anatofuz$ perl generate_stub.pl --debug AtomicTImpl.cbc +[getDataGear] match 175 : #interface "AtomicT.h" +[getDataGear] match 137 : typedef struct AtomicT <T>{ +[getDataGear] match 315 : union Data* atomic_t; +[getDataGear] match 315 : T newData; +[getDataGear] match 315 : T init; +[getDataGear] match 338 : __code checkAndSet(Impl* atomic_t,T* ptr ,T init, T newData, __code next(...), __code fail(...)); +[getDataGear] match 338 : __code set(Impl* atomic_t,T* ptr ,T newData, __code next(...)); +[getDataGear] match 338 : __code next(...); +[getDataGear] match 338 : __code fail(...); +[getDataGear] match 315 : } AtomicT; +[getCodeGear] match 393 : typedef struct AtomicT <T>{ +[getCodeGear] match 398 : __code checkAndSet(Impl* atomic_t,T* ptr ,T init, T newData, __code next(...), __code fail(...)); +[getCodeGear] match 398 : __code set(Impl* atomic_t,T* ptr ,T newData, __code next(...)); +[getCodeGear] match 398 : __code next(...); +[getCodeGear] match 398 : __code fail(...); +[getDataGear] match 175 : #interface "AtomicTImpl.h" +[getDataGear] match 137 : typedef struct AtomicTImpl <T> impl AtomicT { +[getDataGear] match 315 : T atomic; +[getDataGear] match 315 : T init; +[getDataGear] match 338 : __code next(...); +[getDataGear] match 315 : } AtomicTImpl; +[getDataGear] match 206 : __code checkAndSet_AtomicTImpl(struct AtomicTImpl* atomic_t_impl, T* ptr,T init, T newData, __code next(...), __code fail(...)) { +[getDataGear] match 206 : __code set_AtomicTImpl(struct AtomicTImpl* atomic_t_impl, T* ptr, T newData, __code next(...) ) { +[generateDataGear] match 667 : #include "../context.h" +[generateDataGear] match 662 : #interface "AtomicT.h" +[generateDataGear] match 662 : #interface "AtomicTImpl.h" +[generateDataGear] match 796 : #include <stdio.h> +[generateDataGear] match 796 : +[generateDataGear] match 796 : AtomicT<T>* createAtomicTImpl(struct Context* context,T init) { +[generateDataGear] match 796 : struct AtomicT<T>* atomic_t = new AtomicT(); +[generateDataGear] match 796 : struct AtomicTImpl<T>* atomic_t_impl = new AtomicTImpl(); +[generateDataGear] match 796 : atomic_t->atomic_t = (union Data*)atomic_t_impl; +[generateDataGear] match 796 : atomic_t->checkAndSet = C_checkAndSetAtomicTImpl; +[generateDataGear] match 796 : atomic_t->set = C_setAtomicTImpl; +[generateDataGear] match 796 : atomic_t->fail = C_failAtomicTImpl; +[generateDataGear] match 796 : atomic_t_impl->atomic = init; +[generateDataGear] match 796 : atomic_t_impl->init = init; +[generateDataGear] match 796 : return atomic_t; +[generateDataGear] match 796 : +[generateDataGear] match 796 : } +[generateDataGear] match 796 : +[generateDataGear] match 686 : __code checkAndSet_AtomicTImpl(struct AtomicTImpl* atomic_t_impl, T* ptr,T init, T newData, __code next(...), __code fail(...)) { +[generateDataGear] match 1049 : if (__sync_bool_compare_and_swap(ptr, init, newData)) { +[generateDataGear] match 983 : goto next(...); +[generateDataGear] match 1049 : } +[generateDataGear] match 983 : goto fail(...); +[generateDataGear] match 1046 : } +[generateDataGear] match 1070 : } +[generateDataGear] match 796 : +[generateDataGear] match 686 : __code set_AtomicTImpl(struct AtomicTImpl* atomic_t_impl, T* ptr, T newData, __code next(...) ) { +[generateDataGear] match 1049 : *ptr = newData; +[generateDataGear] match 983 : goto next(...); +[generateDataGear] match 1046 : } +[generateDataGear] match 1070 : } +[generateDataGear] match 796 : +``` + + +AtomicTはわりとしょっぱいバグ + + +``` +changeset: 827:6359940aeb58 +tag: tip +user: anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> +date: Mon Jan 18 22:41:01 2021 +0900 +summary: ... + +diff -r af4c7116ad28 -r 6359940aeb58 src/parallel_execution/AtomicT.h +--- a/src/parallel_execution/AtomicT.h Mon Jan 18 22:27:36 2021 +0900 ++++ b/src/parallel_execution/AtomicT.h Mon Jan 18 22:41:01 2021 +0900 +@@ -1,8 +1,4 @@ + typedef struct AtomicT <T>{ +- union Data* atomic_t; +- T* ptr; +- T newData; +- T init; + __code checkAndSet(Impl* atomic_t,T* ptr ,T init, T newData, __code next(...), __code fail(...)); + __code set(Impl* atomic_t,T* ptr ,T newData, __code next(...)); + __code next(...); +diff -r af4c7116ad28 -r 6359940aeb58 src/parallel_execution/AtomicTImpl.cbc +--- a/src/parallel_execution/AtomicTImpl.cbc Mon Jan 18 22:27:36 2021 +0900 ++++ b/src/parallel_execution/AtomicTImpl.cbc Mon Jan 18 22:41:01 2021 +0900 +@@ -1,6 +1,5 @@ + #include "../context.h" +-#interface "AtomicT.h" +-#interface "AtomicTImpl.h" ++#impl "AtomicT.h" for "AtomicTImpl.h" + #include <stdio.h> + + AtomicT<T>* createAtomicTImpl(struct Context* context,T init) { + +changeset: 826:af4c7116ad28 +user: anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> +date: Mon Jan 18 22:27:36 2021 +0900 +summary: bug fix : AtomicT.h + +diff -r 4cb62fe4673a -r af4c7116ad28 src/parallel_execution/AtomicT.h +```