annotate src/parallel_execution/examples/bitonicSort.cbc @ 375:ad44fdb11433

Fix compile error but not work
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 18 Jul 2017 16:13:11 +0900
parents fb50cf8aa615
children b46f38645587
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <string.h>
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include <stdlib.h>
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include <unistd.h>
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "../../context.h"
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 int cpu_num = 1;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 int length = 100;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 int gpu_num = 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 int CPU_ANY = -1;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 int CPU_CUDA = -1;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 void *start_taskManager(struct Context *context) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 goto initDataGears(context, Gearef(context, LoopCounter), Gearef(context, TaskManager));
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 return 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #ifdef USE_CUDAWorker
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #ifdef USE_CUDA_MAIN_THREAD
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 extern volatile int cuda_initialized;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #endif
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #endif
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 __code initDataGears(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 // loopCounter->tree = createRedBlackTree(context);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 loopCounter->i = 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 taskManager->taskManager = (union Data*)createTaskManagerImpl(context, cpu_num, gpu_num, 0);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #ifdef USE_CUDAWorker
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #ifdef USE_CUDA_MAIN_THREAD
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 while(! cuda_initialized) {};
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #endif
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #endif
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
34 goto meta(context, C_code1);
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 __code initDataGears_stub(struct Context* context) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 struct TaskManager* taskManager = Gearef(context, TaskManager);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 taskManager->taskManager = 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 #if (! defined(USE_CUDAWorker) || ! defined(USE_CUDA_MAIN_THREAD))
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 struct LoopCounter* loopCounter = Gearef(context, LoopCounter);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 goto initDataGears(context, loopCounter, taskManager);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #else
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 cuda_initialized = 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 pthread_t thread;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 pthread_create(&thread, NULL, (void*)&start_taskManager, context);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 while (taskManager->taskManager == 0);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 TaskManager *t = (TaskManager*)taskManager->taskManager;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 TaskManagerImpl *im = (TaskManagerImpl*)t->taskManager;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 struct Queue *q = (Queue *)im->workers[0];
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 createCUDAWorker(context,0,q, im);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 pthread_join(thread,0);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 exit(0);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 #endif
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 __code code1(struct Time* time) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 printf("cpus:\t\t%d\n", cpu_num);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 printf("gpus:\t\t%d\n", gpu_num);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 printf("length:\t\t%d\n", length);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 /* puts("queue"); */
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 /* print_queue(context->data[ActiveQueue]->queue.first); */
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 /* puts("tree"); */
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 /* print_tree(context->data[Tree]->tree.root); */
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 /* puts("result"); */
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
67 time->time = (union Data*)createTimeImpl(context);
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
68 time->next = C_createTask1;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
69 goto meta(context, time->time->Time.start);
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
72 //__code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
73 // int waitFlag = 0;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
74 // struct SortArray* inputSortArray = &ALLOCATE_DATA_GEAR(context, sortArray)->sortArray;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
75 // inputSortArray->array = array;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
76 // for (int i=2; i <= length; i=2*i) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
77 // int first = 1;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
78 // lastOne = (length <= i*2) ? true : false;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
79 // for (int j=i>>1; 0 < j; j=j>>1) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
80 // struct SortArray* outputSortArray = &ALLOCATE_DATA_GEAR(context, sortArray)->sortArray;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
81 // outputSortArray->array = array;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
82 // for(int k=0; 0 < length/2; k++) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
83 // struct Context* task = NEW(struct Context);
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
84 // struct Integer* integer1 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
85 // struct Integer* integer2 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
86 // struct Integer* integer3 = &ALLOCATE_DATA_GEAR(context, Integer)->Integer;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
87 // integer1->value = j;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
88 // integer2->value = first;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
89 // integer3->value = k;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
90 //
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
91 // task->next = C_swap;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
92 // if (waitFlag) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
93 // task->idgCount = length/2;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
94 // } else {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
95 // task->idgCount = 0;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
96 // }
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
97 // task->idg = task->dataNum;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
98 // task->data[task->idg] = (union Data*)inputSortArray;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
99 // task->data[task->idg+1] = (union Data*)integer1;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
100 // task->data[task->idg+2] = (union Data*)integer2;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
101 // task->data[task->idg+3] = (union Data*)integer3;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
102 // task->maxIdg = task->idg + 4;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
103 // task->odg = task->maxIdg;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
104 // task->data[task->odg] = outputSortArray;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
105 // task->maxOdg = task->odg + 1;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
106 // first = 0;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
107 // }
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
108 // inputSortArray = outputSortArray;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
109 // }
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
110 // waitFlag = 1;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
111 // }
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
112 // goto meta(context, taskManager->taskManager->TaskManager.shutdown);
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
113 //}
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
115 __code createTask1(struct LoopCounter* loopCounter, struct TaskManager* taskManager, struct Time* time) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
116 int i = loopCounter->i;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
117
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
118 if (i < length) {
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
119 loopCounter->i++;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
120 goto meta(context, C_createTask2);
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121 }
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
122
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
123 loopCounter->i = 0;
375
ad44fdb11433 Fix compile error but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 374
diff changeset
124 taskManager->next = C_exit_code;
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 goto meta(context, taskManager->taskManager->TaskManager.shutdown);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 __code createTask2(struct LoopCounter* loopCounter, struct TaskManager* taskManager) {
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
129 struct Context** tasks = (struct Context**)ALLOC_ARRAY(context, Context, 1);
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 struct Context* task = NEW(struct Context);
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
131 task->iterator = createOneDimIterator(context, 10);
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
132 task->next = C_printIterator;
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 task->idgCount = 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 task->idg = task->dataNum;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 task->maxIdg = task->idg;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 task->odg = task->maxIdg;
374
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
137 task->maxOdg = task->odg;
fb50cf8aa615 Add Iterator Interface
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 371
diff changeset
138 tasks[0] = task;
371
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 taskManager->contexts = tasks;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 taskManager->next1 = C_createTask1;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 goto meta(context, taskManager->taskManager->TaskManager.spawnTasks);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 void init(int argc, char** argv) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 for (int i = 1; argv[i]; ++i) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 if (strcmp(argv[i], "-cpu") == 0)
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 cpu_num = (int)atoi(argv[i+1]);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148 else if (strcmp(argv[i], "-l") == 0)
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 length = (int)atoi(argv[i+1]);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 else if (strcmp(argv[i], "-cuda") == 0) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 gpu_num = 1;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 CPU_CUDA = 0;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 }
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 int main(int argc, char** argv) {
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 init(argc, argv);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 struct Context* main_context = NEW(struct Context);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 initContext(main_context);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 main_context->next = C_initDataGears;
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 goto start_code(main_context);
c3a7a086e82a Add bitonicSort
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }