Mercurial > hg > GearsTemplate
changeset 185:247a2c4a8908
fix compile errors
author | mir3636 |
---|---|
date | Thu, 15 Dec 2016 18:10:48 +0900 |
parents | 21840c7fb309 |
children | dbc064c26b98 |
files | src/parallel_execution/context.c src/parallel_execution/context.h src/parallel_execution/dependency.c src/parallel_execution/main.c src/parallel_execution/twice.c src/parallel_execution/worker.c |
diffstat | 6 files changed, 30 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/context.c Thu Dec 15 17:41:00 2016 +0900 +++ b/src/parallel_execution/context.c Thu Dec 15 18:10:48 2016 +0900 @@ -79,6 +79,11 @@ extern __code isEmptySynchronizedQueue_stub(struct Context *); extern __code spawnTaskManager_stub(struct Context*); extern __code shutdownTaskManager_stub(struct Context*); +extern __code executeWorker_stub(struct Context*); +extern __code taskSendWorker_stub(struct Context*); +extern __code taskReciveWorker_stub(struct Context*); +extern __code shutdownWorker_stub(struct Context*); + __code initContext(struct Context* context) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; @@ -144,6 +149,10 @@ /* context->code[DeleteCase5] = deleteCase5_stub; */ /* context->code[DeleteCase6] = deleteCase6_stub; */ context->code[CreateWorker] = createWorker_stub; + context->code[C_executeWorker] = executeWorker_stub; + context->code[C_taskSendWorker] = taskSendWorker_stub; + context->code[C_taskReciveWorker] = taskReciveWorker_stub; + context->code[C_shutdownWorker] = shutdownWorker_stub; context->code[TaskManager] = taskManager_stub; context->code[CreateData1] = createData1_stub; context->code[CreateData2] = createData2_stub; @@ -168,7 +177,7 @@ context->code[Exit] = exit_code; struct Worker* worker = ALLOC_DATA(context, Worker); - worker->num = 0; + worker->id = 0; worker->contexts = 0; struct Allocate* allocate = ALLOC_DATA(context, Allocate);
--- a/src/parallel_execution/context.h Thu Dec 15 17:41:00 2016 +0900 +++ b/src/parallel_execution/context.h Thu Dec 15 18:10:48 2016 +0900 @@ -80,6 +80,12 @@ DeleteCase6, CreateWorker, TaskManager, + C_spawnTaskManager, + C_shutdownTaskManager, + C_QueueTest1, + C_QueueTest2, + C_QueueTest3, + C_QueueTest4, CreateData1, CreateData2, CreateTask1, @@ -112,6 +118,10 @@ C_removeRedBlackTree, C_clearRedBlackTree, SpawnTask, + C_executeWorker, + C_taskSendWorker, + C_taskReciveWorker, + C_shutdownWorker, Twice, StartTime, EndTime, @@ -199,13 +209,13 @@ CUfunction code; CUdeviceptr* deviceptr; CUstream stream; - } cudatask; + } Cudatask; #endif struct Main { enum Code code; enum Code next; struct Queue* args; - } + } Main; struct Task { enum Code code; struct Queue* dataGears;
--- a/src/parallel_execution/dependency.c Thu Dec 15 17:41:00 2016 +0900 +++ b/src/parallel_execution/dependency.c Thu Dec 15 18:10:48 2016 +0900 @@ -10,7 +10,7 @@ __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*/ NULL , PutQueue1); } __code waitFor1_stub(struct Context* context) { @@ -28,28 +28,4 @@ // // next think //} -__code meta_spawnTask(struct Context* context, struct Queue* queue, enum Code next) { - context->data[D_Queue] = (union Data *)queue; - goto meta(context, context->next); -} -__code spawnTask(struct Context* context, struct Task* task, struct Element* element, struct Queue* queue, struct Queue* activeQueue, struct Queue* waitQueue) { - if (task->idsCount == 0) { - // enqueue activeQueue - queue->queue = (union Data*)activeQueue; - } else { - // enqueue waitQueue - queue->queue = (union Data*)waitQueue; - } - queue->data = element->data; - queue->next = context->next; - goto meta(context, queue->queue->put); -} - -__code spawnTask_stub(struct Context* context) { - goto spawnTask(context, - context->data[D_Element]->element.data, - &context->data[D_Element]->element, - &context->data[D_ActiveQueue]->Queue, - &context->data[D_WaitQueue]->Queue); -}
--- a/src/parallel_execution/main.c Thu Dec 15 17:41:00 2016 +0900 +++ b/src/parallel_execution/main.c Thu Dec 15 18:10:48 2016 +0900 @@ -15,7 +15,7 @@ void print_queue(struct Element* element) { while (element) { - printf("%d\n", ((struct Task *)(element->data))); + printf("%p\n", ((struct Task *)(element->data))); element = element->next; } } @@ -180,7 +180,7 @@ __code createWorker(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { int i = loopCounter->i; - if (i < worker->num) { + if (i < worker->id) { struct Context* worker_context = &worker->contexts[i]; worker_context->next = C_getTask1; worker_context->data[D_Tree] = context->data[D_Tree]; @@ -197,13 +197,13 @@ } __code createWorker_stub(struct Context* context) { - goto createWorker(context, &context->data[D_LoopCounter]->loopCounter, &context->data[D_Worker]->worker); + goto createWorker(context, &context->data[D_LoopCounter]->loopCounter, &context->data[D_Worker]->Worker); } __code taskManager(struct Context* context, struct LoopCounter* loopCounter, struct Worker* worker) { int i = loopCounter->i; - if (i < worker->num) { + if (i < worker->id) { pthread_join(worker->contexts[i].thread, NULL); loopCounter->i++; @@ -218,7 +218,7 @@ } __code taskManager_stub(struct Context* context) { - goto taskManager(context, &context->data[D_LoopCounter]->loopCounter, &context->data[D_Worker]->worker); + goto taskManager(context, &context->data[D_LoopCounter]->loopCounter, &context->data[D_Worker]->Worker); } void init(int argc, char** argv) { @@ -247,8 +247,8 @@ struct Context* worker_contexts = NEWN(cpu_num, struct Context); - struct Worker* worker = &main_context->data[D_Worker]->worker; - worker->num = cpu_num; + struct Worker* worker = &main_context->data[D_Worker]->Worker; + worker->id = cpu_num; worker->contexts = worker_contexts; for (int i = 0;i<cpu_num;i++)
--- a/src/parallel_execution/twice.c Thu Dec 15 17:41:00 2016 +0900 +++ b/src/parallel_execution/twice.c Thu Dec 15 18:10:48 2016 +0900 @@ -3,10 +3,6 @@ #include "context.h" #include "origin_cs.h" -struct LoopCounter { - int i; -} loopCounter; - __code twice(struct Context* context, struct LoopCounter* loopCounter, int index, int prefix, int* array) { int i = loopCounter->i;
--- a/src/parallel_execution/worker.c Thu Dec 15 17:41:00 2016 +0900 +++ b/src/parallel_execution/worker.c Thu Dec 15 18:10:48 2016 +0900 @@ -5,7 +5,6 @@ union Data* createWorker(struct Context* context) { struct Worker* worker = &ALLOCATE(context, Worker)->Worker; - struct Queue* tasks = &ALLOCATE(context, Queue)->Queue; worker->execute = C_executeWorker; worker->taskSend = C_taskSendWorker; worker->taskRecive = C_taskReciveWorker; @@ -23,10 +22,6 @@ } __code getTask2(struct Context* context, struct Task* task, struct Node* node) { - node->key = task->key; - - struct Tree *t = &context->data[D_Traverse]->Traverse; - t->next = task->code; context->next = C_getTask1; goto meta(context, C_get); }