# HG changeset patch # User Tatsuki IHA # Date 1513775108 -32400 # Node ID 8d7e5d48cad399b92d5ac4120ba6a3228d0f7d64 # Parent 6b71cf5b1c2298cb2c32fa2d978454906615440e Running CPU examples diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/AtomicReference.cbc --- a/src/parallel_execution/AtomicReference.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/AtomicReference.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,5 +1,5 @@ #include "../context.h" - +#include "Atomic.h" #include Atomic* createAtomicReference(struct Context* context) { diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/CPUWorker.cbc --- a/src/parallel_execution/CPUWorker.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/CPUWorker.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,5 +1,5 @@ #include "../context.h" - +#include "TaskManager.h" static void startWorker(Worker* worker); Worker* createCPUWorker(struct Context* context, int id, Queue* queue) { diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/CUDAExecutor.cbc --- a/src/parallel_execution/CUDAExecutor.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/CUDAExecutor.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,12 +1,6 @@ #include "../context.h" #include -// includes, project -#include -#include -#include "../helper_cuda.h" -#include "pthread.h" - Executor* createCUDAExecutor(struct Context* context, CUdevice device) { struct Executor* executor = new Executor(); struct CUDAExecutor* cudaExecutor = new CUDAExecutor(); diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/CUDAWorker.cbc --- a/src/parallel_execution/CUDAWorker.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/CUDAWorker.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,5 @@ #include "../context.h" +#include "Worker.h" extern void cudaInit(struct CUDAWorker *cudaWorker,int phase) ; diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/MultiDimIterator.cbc --- a/src/parallel_execution/MultiDimIterator.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/MultiDimIterator.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,6 @@ #include "../context.h" +#include "Iterator.h" +#include "TaskManager.h" #include Iterator* createMultiDimIterator(struct Context* context, int x, int y, int z) { @@ -77,7 +79,7 @@ int z = iterator->counterZ; struct Context* iterateTask = createMultiDimIterateTask(task, x, y, z); struct TaskManager* taskManager = task->taskManager; - goto taskManager->spawn(iterateTask, next(...)); + goto taskManager->spawn(iterateTask, execMultiDimIterator2); } __code execMultiDimIterator1_stub(struct Context* context) { diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/RedBlackTree.cbc --- a/src/parallel_execution/RedBlackTree.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/RedBlackTree.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -2,6 +2,8 @@ #include "../context.h" #include "../compare.c" +#include "Tree.h" +#include "Stack.h" extern enum Relational compare(struct Node* node1, struct Node* node2); diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/SemaphoreImpl.cbc --- a/src/parallel_execution/SemaphoreImpl.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/SemaphoreImpl.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,5 @@ #include "../context.h" +#include "semaphore.h" Semaphore* createSemaphoreImpl(struct Context* context, int n) { struct Semaphore* semaphore = new Semaphore(); diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/SingleLinkedQueue.cbc --- a/src/parallel_execution/SingleLinkedQueue.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/SingleLinkedQueue.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,5 @@ #include "../context.h" +#include "Queue.h" #include Queue* createSingleLinkedQueue(struct Context* context) { diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/SingleLinkedStack.cbc --- a/src/parallel_execution/SingleLinkedStack.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/SingleLinkedStack.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,5 @@ #include "../context.h" +#include "Stack.h" #include // typedef struct SingleLinkedStack { diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/SynchronizedQueue.cbc --- a/src/parallel_execution/SynchronizedQueue.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/SynchronizedQueue.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,6 @@ #include "../context.h" +#include "Queue.h" +#include "Atomic.h" #include diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/TaskIterator.cbc --- a/src/parallel_execution/TaskIterator.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/TaskIterator.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,4 +1,5 @@ #include "../context.h" +#include "Iterator.h" #include createTaskIterator(struct Context, struct List list) { diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/TaskManagerImpl.cbc --- a/src/parallel_execution/TaskManagerImpl.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/TaskManagerImpl.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -1,8 +1,8 @@ #include "../context.h" -#include "./TaskManager.h" -#include "./Iterator.h" -#include "./Queue.h" -#include "./Worker.h" +#include "TaskManager.h" +#include "Iterator.h" +#include "Queue.h" +#include "Worker.h" #include #include @@ -201,21 +201,9 @@ goto meta(context, next); } -__code shutdownTaskManagerImpl_stub(struct Context* context) { - TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - goto shutdownTaskManagerImpl(context, - taskManagerImpl, - Gearef(context, TaskManager)->next); -} - -__code shutdownTaskManagerImpl1(TaskManagerImpl* taskManager) { +__code shutdownTaskManagerImpl1(struct TaskManagerImpl* taskManager) { int i = taskManager->loopCounter->i; pthread_join(taskManager->workers[i]->thread, NULL); taskManager->loopCounter->i++; goto meta(context, C_shutdownTaskManagerImpl); } - -__code shutdownTaskManagerImpl1_stub(struct Context* context) { - TaskManagerImpl* taskManagerImpl = (TaskManagerImpl*)GearImpl(context, TaskManager, taskManager); - goto shutdownTaskManagerImpl1(context, taskManagerImpl); -} diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/TimeImpl.cbc --- a/src/parallel_execution/TimeImpl.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/TimeImpl.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -2,6 +2,7 @@ #include #include "../context.h" +#include "Time.h" Time* createTimeImpl(struct Context* context) { struct Time* time = new Time(); diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/context.h --- a/src/parallel_execution/context.h Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/context.h Wed Dec 20 22:05:08 2017 +0900 @@ -5,6 +5,9 @@ #include #ifdef USE_CUDAWorker #include +#include "../helper_cuda.h" +#include +#include #endif #define ALLOCATE_SIZE 20000000 diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/examples/bitonicSort/bitonicSort.cbc --- a/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/examples/bitonicSort/bitonicSort.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -5,6 +5,7 @@ #include #include "../../../context.h" +#include "TaskManager.h" int cpu_num = 1; int length = 1024; diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/examples/calc/calc.cbc --- a/src/parallel_execution/examples/calc/calc.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/examples/calc/calc.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -5,6 +5,7 @@ #include #include "../../../context.h" +#include "TaskManager.h" int cpu_num = 1; int length = 100; diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/examples/twice/main.cbc --- a/src/parallel_execution/examples/twice/main.cbc Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/examples/twice/main.cbc Wed Dec 20 22:05:08 2017 +0900 @@ -4,6 +4,7 @@ #include #include "../../../context.h" +#include "TaskManager.h" int cpu_num = 1; int length = 102400; diff -r 6b71cf5b1c22 -r 8d7e5d48cad3 src/parallel_execution/generate_stub.pl --- a/src/parallel_execution/generate_stub.pl Wed Dec 20 17:54:15 2017 +0900 +++ b/src/parallel_execution/generate_stub.pl Wed Dec 20 22:05:08 2017 +0900 @@ -162,7 +162,7 @@ my $next = $2; my @args = split(/,/,$3); push(@{$code{$name}->{$method}},"\_\_code $next"); - } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)?+\s(\w+)//) { + } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)*+\s(\w+)//) { my $structType = $1; my $typeName = $2; my $varName = $4; @@ -294,6 +294,10 @@ $inTypedef = 1; } elsif (/^int main\((.*)\) \{/) { $inMain = 1; + } elsif(/^#include "(.*)"/) { + my $interfaceHeader = $1; + # interface include not write + next unless ($interfaceHeader =~ /context.h/); } elsif (/^\_\_code (\w+)\((.*)\)(.*)/) { %localVarType = {}; $codeGearName = $1; @@ -539,8 +543,7 @@ my $varName = $3; $localVarType{$varName} = $type; s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new - } - elsif(/^}/) { + } elsif(/^}/) { $inParGoto = 0; } else { s/new\s+(\w+)\(\)/\&ALLOCATE(context, \1)->\1/g; # replacing new