changeset 462:8d7e5d48cad3

Running CPU examples
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Wed, 20 Dec 2017 22:05:08 +0900
parents 6b71cf5b1c22
children b3a2246e3218
files src/parallel_execution/AtomicReference.cbc src/parallel_execution/CPUWorker.cbc src/parallel_execution/CUDAExecutor.cbc src/parallel_execution/CUDAWorker.cbc src/parallel_execution/MultiDimIterator.cbc src/parallel_execution/RedBlackTree.cbc src/parallel_execution/SemaphoreImpl.cbc src/parallel_execution/SingleLinkedQueue.cbc src/parallel_execution/SingleLinkedStack.cbc src/parallel_execution/SynchronizedQueue.cbc src/parallel_execution/TaskIterator.cbc src/parallel_execution/TaskManagerImpl.cbc src/parallel_execution/TimeImpl.cbc src/parallel_execution/context.h src/parallel_execution/examples/bitonicSort/bitonicSort.cbc src/parallel_execution/examples/calc/calc.cbc src/parallel_execution/examples/twice/main.cbc src/parallel_execution/generate_stub.pl
diffstat 18 files changed, 32 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- 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 <stdio.h>
 
 Atomic* createAtomicReference(struct Context* context) {
--- 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) {
--- 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 <stdio.h>
 
-// includes, project
-#include <driver_types.h>
-#include <cuda_runtime.h>
-#include "../helper_cuda.h"
-#include "pthread.h"
-
 Executor* createCUDAExecutor(struct Context* context, CUdevice device) {
     struct Executor* executor = new Executor();
     struct CUDAExecutor* cudaExecutor = new CUDAExecutor();
--- 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) ;
 
--- 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 <stdio.h>
 
 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) {
--- 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);
 
--- 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();
--- 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 <stdio.h>
 
 Queue* createSingleLinkedQueue(struct Context* context) {
--- 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 <stdio.h>
 
 // typedef struct SingleLinkedStack {
--- 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 <stdio.h>
 
--- 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 <stdio.h>
 
 createTaskIterator(struct Context, struct List list) {
--- 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 <stdio.h>
 #include <unistd.h>
@@ -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);
-}
--- 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 <sys/time.h>
 
 #include "../context.h"
+#include "Time.h"
 
 Time* createTimeImpl(struct Context* context) {
     struct Time* time = new Time();
--- 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 <pthread.h>
 #ifdef USE_CUDAWorker
 #include <cuda.h>
+#include "../helper_cuda.h"
+#include <driver_types.h>
+#include <cuda_runtime.h>
 #endif
 
 #define ALLOCATE_SIZE 20000000
--- 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 <math.h>
 
 #include "../../../context.h"
+#include "TaskManager.h"
 
 int cpu_num = 1;
 int length = 1024;
--- 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 <assert.h>
 
 #include "../../../context.h"
+#include "TaskManager.h"
 
 int cpu_num = 1;
 int length = 100;
--- 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 <unistd.h>
 
 #include "../../../context.h"
+#include "TaskManager.h"
 
 int cpu_num = 1;
 int length = 102400;
--- 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