# HG changeset patch # User Tatsuki IHA # Date 1467097164 -32400 # Node ID 135472238fb785a616dd01620482af9205c921dc # Parent 0f0459653d77d001422a3f929f7d64773d740b69 Add meta Data Gear allocate diff -r 0f0459653d77 -r 135472238fb7 src/parallel_execution/allocate.c --- a/src/parallel_execution/allocate.c Tue Jun 21 14:17:58 2016 +0900 +++ b/src/parallel_execution/allocate.c Tue Jun 28 15:59:24 2016 +0900 @@ -4,3 +4,8 @@ context->data[++context->dataNum] = context->heap; context->heap += context->data[Allocate]->allocate.size; } + +void metaAllocator(struct Context* context) { + context->mData[++context->metaDataNum] = context->heap; + context->heap += context->data[Allocate]->allocate.size; +} diff -r 0f0459653d77 -r 135472238fb7 src/parallel_execution/context.c --- a/src/parallel_execution/context.c Tue Jun 21 14:17:58 2016 +0900 +++ b/src/parallel_execution/context.c Tue Jun 28 15:59:24 2016 +0900 @@ -49,8 +49,8 @@ extern __code createData2_stub(struct Context*); extern __code createTask1_stub(struct Context*); extern __code createTask2_stub(struct Context*); -extern __code createTask3_stub(struct Context*); -extern __code createTask4_stub(struct Context*); +/* extern __code createTask3_stub(struct Context*); */ +/* extern __code createTask4_stub(struct Context*); */ extern __code putQueue1_stub(struct Context*); extern __code putQueue2_stub(struct Context*); extern __code putQueue3_stub(struct Context*); @@ -114,8 +114,8 @@ context->code[CreateData2] = createData2_stub; context->code[CreateTask1] = createTask1_stub; context->code[CreateTask2] = createTask2_stub; - context->code[CreateTask3] = createTask3_stub; - context->code[CreateTask4] = createTask4_stub; + /* context->code[CreateTask3] = createTask3_stub; */ + /* context->code[CreateTask4] = createTask4_stub; */ context->code[PutQueue1] = putQueue1_stub; context->code[PutQueue2] = putQueue2_stub; context->code[PutQueue3] = putQueue3_stub; @@ -166,6 +166,7 @@ context->dataNum = Queue; + context->metaDataNum = 0; context->node_stack = stack_init(sizeof(struct Node*), 100); context->code_stack = stack_init(sizeof(enum Code), 100); } diff -r 0f0459653d77 -r 135472238fb7 src/parallel_execution/context.h --- a/src/parallel_execution/context.h Tue Jun 21 14:17:58 2016 +0900 +++ b/src/parallel_execution/context.h Tue Jun 28 15:59:24 2016 +0900 @@ -60,8 +60,6 @@ CreateData2, CreateTask1, CreateTask2, - CreateTask3, - CreateTask4, PutQueue1, PutQueue2, PutQueue3, @@ -106,7 +104,9 @@ stack_ptr code_stack; stack_ptr node_stack; int dataNum; + int metaDataNum; union Data **data; + union MetaData **mData; }; union Data { @@ -133,8 +133,6 @@ struct Task { enum Code code; int key; - struct Queue* waitMe; - struct Queue* waitI; int idsCount; } task; struct Queue { @@ -176,13 +174,13 @@ enum Code next; long size; } allocate; - struct OutPutDataSegments { - union Data **data; - } ods; + struct Integer { + int value; + int mDataOffset; + } integer; }; union MetaData { struct Queue waitMeTasks; - struct Queue waitI; }; diff -r 0f0459653d77 -r 135472238fb7 src/parallel_execution/dependency.c --- a/src/parallel_execution/dependency.c Tue Jun 21 14:17:58 2016 +0900 +++ b/src/parallel_execution/dependency.c Tue Jun 28 15:59:24 2016 +0900 @@ -10,23 +10,25 @@ __code waitFor1(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { element->data = (union Data *)slave; // enqueue waitMe - goto meta_waitFor(context, master->waitMe, PutQueue1); + //goto meta_waitFor(context, master->waitMe, PutQueue1); } __code waitFor1_stub(struct Context* context) { // next think } -//__code waitFor2(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { -// element->task = master; -// task->next = context->next; -// // enqueue waitI -// goto meta_waitFor(context, task->waitI, PutQueue1); -//} -// -//__code waitFor2_stub(struct Context* context) { -// // next think -//} +/** +__code waitFor2(struct Context* context, struct Task* master, struct Task* slave, struct Element* element) { + element->task = master; + task->next = context->next; + // enqueue waitI + goto meta_waitFor(context, task->waitI, PutQueue1); +} + +__code waitFor2_stub(struct Context* context) { + // next think +} +*/ __code meta_spawnTask(struct Context* context, struct Queue* queue, enum Code next) { context->data[Queue] = (union Data *)queue; @@ -34,8 +36,9 @@ } __code spawnTask(struct Context* context, struct Task* task, struct Element* element, struct Queue* activeQueue, struct Queue* waitQueue) { - //printf("spawn Task\n"); element->data = (union Data *)task; + goto meta_spawnTask(context, activeQueue, PutQueue1); + /* if (task->waitI->count == task->idsCount) { //printf("put ActiveQueue\n"); // enqueue activeQueue @@ -45,11 +48,12 @@ // enqueue waitQueue goto meta_spawnTask(context, waitQueue, PutQueue1); } + */ } __code spawnTask_stub(struct Context* context) { goto spawnTask(context, - &context->data[context->dataNum-2]->task, + &context->data[context->dataNum]->task, &context->data[Element]->element, &context->data[ActiveQueue]->queue, &context->data[WaitQueue]->queue); diff -r 0f0459653d77 -r 135472238fb7 src/parallel_execution/main.c --- a/src/parallel_execution/main.c Tue Jun 21 14:17:58 2016 +0900 +++ b/src/parallel_execution/main.c Tue Jun 28 15:59:24 2016 +0900 @@ -68,13 +68,13 @@ goto code2(context, &context->data[Node]->node.value->array, &context->data[LoopCounter]->loopCounter); } +/* __code createData1(struct Context* context, struct Allocate* allocate, struct LoopCounter* loopCounter) { int i = loopCounter->i; if ((length/split*i) < length) { allocate->size = sizeof(struct Array); allocator(context); - goto meta(context, CreateData2); } @@ -107,6 +107,44 @@ &context->data[context->dataNum]->array, &context->data[Node]->node); } +*/ + +__code createData1(struct Context* context, struct Allocate* allocate, struct LoopCounter* loopCounter) { + int i = loopCounter->i; + + allocate->size = sizeof(struct Queue); + metaAllocator(context); + allocate->size = sizeof(struct Integer); + allocator(context); + goto meta(context, CreateData2); + + loopCounter->i = 0; + goto meta(context, Code1); +} + +__code createData1_stub(struct Context* context) { + goto createData1(context, &context->data[Allocate]->allocate, &context->data[LoopCounter]->loopCounter); +} + +__code createData2(struct Context* context, struct LoopCounter* loopCounter, struct Integer* integer, struct Node* node) { + int i = loopCounter->i; + + integer->value = i; + integer->mDataOffset = -sizeof(struct Integer); + node->key = i; + node->value = (union Data*)integer; + + context->next = CreateTask1; + + goto meta(context, PutTree); +} + +__code createData2_stub(struct Context* context) { + goto createData2(context, + &context->data[LoopCounter]->loopCounter, + &context->data[context->dataNum]->array, + &context->data[Node]->node); +} __code createTask1(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(struct Task); @@ -118,46 +156,11 @@ goto createTask1(context, &context->data[Allocate]->allocate); } -__code createTask2(struct Context* context, struct Allocate* allocate) { - allocate->size = sizeof(struct Queue); - allocator(context); - goto meta(context, CreateTask3); -} - -__code createTask2_stub(struct Context* context) { - goto createTask2(context, &context->data[Allocate]->allocate); -} - -__code createTask3(struct Context* context, struct Allocate* allocate) { - allocate->size = sizeof(struct Queue); - allocator(context); - goto meta(context, CreateTask4); -} - -__code createTask3_stub(struct Context* context) { - goto createTask3(context, &context->data[Allocate]->allocate); -} - -__code meta_createTask4(struct Context* context, struct Queue* activeQueue, enum Code next) { - context->data[Queue] = (union Data *)activeQueue; - goto (context->code[next])(context); -} - -__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct Queue* waitI, struct Element* element, struct Queue* activeQueue) { +__code createTask2(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Element* element, struct Queue* activeQueue) { int i = loopCounter->i; - waitMe->first = 0; - waitMe->last = 0; - waitMe->count = 0; - - waitI->first = 0; - waitI->last = 0; - waitI->count = 0; - task->code = Twice; task->key = i; - task->waitMe = waitMe; - task->waitI = waitI; task->idsCount = 0; element->data = (union Data *)task; @@ -168,62 +171,62 @@ goto meta(context, SpawnTask); } -__code createTask4_stub(struct Context* context) { - goto createTask4(context, +__code createTask2_stub(struct Context* context) { + goto createTask2(context, &context->data[LoopCounter]->loopCounter, - &context->data[context->dataNum-2]->task, - &context->data[context->dataNum-1]->queue, - &context->data[context->dataNum]->queue, + &context->data[context->dataNum]->task, &context->data[Element]->element, &context->data[ActiveQueue]->queue); } -//__code createTask4(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct OdsQueue* waitI, struct Element* element, struct Queue* activeQueue) { -// int i = loopCounter->i; -// -// task->code = TaskC; -// task->key = i; -// task->waitMe = waitMe; -// task->waitI = waitI; -// task->idsCount = 1; -// -// element->data = (union Data *)task; -// -// context->next = CreateData1; -// loopCounter->i++; -// -// goto meta_createTask2(context, activeQueue, PutQueue1); -//} -// -//__code createTask4_stub(struct Context* context) { -// goto createTask2(context, -// &context->data[LoopCounter]->loopCounter, -// &context->data[context->dataNum]->task, -// &context->data[context->dataNum-1]->queue, -// &context->data[context->dataNum-2]->odsQueue, -// &context->data[Element]->element, -// &context->data[ActiveQueue]->queue); -//} -// -//__code createTask5(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) { -// int i = loopCounter->i; -// -// task->code = TaskB; -// task->key = i; -// element->data = (union Data *)task; -// -// context->next = CreateData1; -// loopCounter->i++; -// -// goto meta(context, WaitFor1); -//} -// -//__code createTask5_stub(struct Context* context) { -// goto createTask2(context, -// &context->data[context->dataNum]->task, -// &context->data[Element]->element); -//} +/* + __code createTask2(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Queue* waitMe, struct OdsQueue* waitI, struct Element* element, struct Queue* activeQueue) { + int i = loopCounter->i; + + task->code = TaskC; + task->key = i; + task->waitMe = waitMe; + task->waitI = waitI; + task->idsCount = 1; + + element->data = (union Data *)task; + + context->next = CreateData1; + loopCounter->i++; + + goto meta_createTask2(context, activeQueue, PutQueue1); + } + + __code createTask2_stub(struct Context* context) { + goto createTask2(context, + &context->data[LoopCounter]->loopCounter, + &context->data[context->dataNum]->task, + &context->data[context->dataNum-1]->queue, + &context->data[context->dataNum-2]->odsQueue, + &context->data[Element]->element, + &context->data[ActiveQueue]->queue); + } + + __code createTask3(struct Context* context, struct LoopCounter* loopCounter, struct Task* task, struct Task* slave, struct Element* element) { + int i = loopCounter->i; + + task->code = TaskB; + task->key = i; + element->data = (union Data *)task; + + context->next = CreateData1; + loopCounter->i++; + + goto meta(context, WaitFor1); + } + + __code createTask3_stub(struct Context* context) { + goto createTask2(context, + &context->data[context->dataNum]->task, + &context->data[Element]->element); + } + */ __code putQueue1(struct Context* context, struct Allocate* allocate) { allocate->size = sizeof(struct Element);