Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/TaskManagerImpl.cc @ 1887:94a824cde2e4 draft
remove some old code
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 03 Jan 2014 17:04:46 +0900 |
parents | b49aaf88eae6 |
children | f4c16bdddee0 |
rev | line source |
---|---|
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1064
diff
changeset
|
1 //#include <stdio.h> |
3 | 2 #include "TaskManagerImpl.h" |
46 | 3 #include "types.h" |
4 #include "error.h" | |
546 | 5 #include "SchedTask.h" |
619 | 6 #include "Scheduler.h" |
634 | 7 #include "SysTask.h" |
8 #include "SysFunc.h" | |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
9 #include "rdtsc.h" |
806 | 10 #include <string.h> |
11 | |
955 | 12 // singleton |
13 QueueInfo<TaskQueue> *taskQueuePool = new QueueInfo<TaskQueue>() ; | |
14 QueueInfo<HTask> *htaskPool = new QueueInfo<HTask>() ; | |
15 QueueInfo<TaskList> *taskListPool = new QueueInfo<TaskList>() ; | |
1428
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
16 QueueInfo<TaskLog> *taskLogQueue = new QueueInfo<TaskLog>(); |
955 | 17 |
220 | 18 static HTaskPtr systask_start; |
109 | 19 static HTaskPtr systask_finish; |
42 | 20 |
550 | 21 static void |
22 noaction(SchedTask *s, void *read, void *write) | |
3 | 23 { |
24 } | |
25 | |
835 | 26 TaskManagerImpl::TaskManagerImpl(int num) |
1605
5b99bcc6bdb0
fix mail_check and init dim_count and init _export_task_log.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1588
diff
changeset
|
27 : machineNum(num) ,_export_task_log(0){ |
853 | 28 // 実行可能なHTaskのリスト |
955 | 29 activeTaskQueue = new QueueInfo<HTask>(htaskPool); |
853 | 30 // wait_forで止まっているHTaskのリスト。必要ないが、Dead lock detection に使う |
955 | 31 waitTaskQueue = new QueueInfo<HTask>(htaskPool); |
32 // HTask の factory. QueueInfo<HTask> ならなんでもいい。 | |
33 htaskImpl = waitTaskQueue ; // any QueueInfo<HTask> | |
34 // Task の dependency を表現する double linked list. QueueInfo<HTask> とは別に必要。 | |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
35 taskQueueImpl = new QueueInfo<TaskQueue>(taskQueuePool); |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
36 |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
37 } |
50 | 38 |
220 | 39 /** |
298 | 40 * 一番最初に PPE で実行される systask_start |
220 | 41 */ |
42 | 42 void |
499 | 43 TaskManagerImpl::systask_init() |
42 | 44 { |
109 | 45 systask_register(); |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
46 systask_start = create_task(StartTask,0,0,0,0,__builtin_return_address(0)); |
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
47 systask_finish = create_task(FinishTask,0,0,0,0,__builtin_return_address(0)); |
220 | 48 |
49 systask_start->spawn(); | |
50 | |
634 | 51 // すべての Task が FinishTask を wait_for すると、 |
52 // あらゆる Task が FinishTask の waiting task queue を操作する | |
53 // ことになる。それは、重すぎる。PPE/SPE Task が終了した時点で、 | |
54 // TaskManager が実行する方が安い。 | |
55 // append_waitTask(systask_finish); | |
56 } | |
57 | |
945
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
58 /** |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
59 * Create Simple Task |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
60 */ |
634 | 61 HTaskPtr |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
62 TaskManagerImpl::create_task(int cmd,memaddr rbuf, long r_size, memaddr wbuf, long w_size, void *from) { |
1465 | 63 HTaskPtr new_task = htaskImpl->create(); |
1474 | 64 new_task->init(cmd, rbuf, r_size, wbuf, w_size); // この引数はもう意味がない |
1465 | 65 new_task->mimpl = this; |
1474 | 66 new_task->command = TaskArray1; |
67 new_task->create_task_array(cmd, 1, 8, 8, 8) ; // この引数はもう意味がない | |
634 | 68 new_task->post_func = noaction; |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
69 new_task->from = (memaddr)from; |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
70 |
1474 | 71 Task *t = new_task->next_task_array(cmd,0,8,1,1); |
72 t->set_inData(0,rbuf,r_size); | |
73 t->set_outData(0,wbuf,w_size); | |
74 | |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
75 new_task->export_task_log = _export_task_log; |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
76 if (_export_task_log) { |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
77 TaskLog *tasklog = new TaskLog(); |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
78 tasklog->set_cmd(cmd); |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
79 taskLogQueue->addLast(tasklog); |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
80 new_task->tasklog = tasklog; |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
81 } |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
82 |
949 | 83 #ifdef EARLY_TOUCH |
84 if (rbuf) { | |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
85 if ((unsigned long)rbuf&0xf) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
86 printf("Data is not aligned. command = %d, addr = 0x%lx, size = %ld\n", |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
87 cmd, (unsigned long)rbuf, r_size); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
88 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
89 char *p = (char *)rbuf; char b = *p; // これはコンパイラが落としてしまうのではないか... |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
90 p = (char *)(rbuf+r_size-1); b += *p; |
949 | 91 } |
92 if (wbuf) { | |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
93 if ((unsigned long)wbuf&0xf) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
94 printf("Data is not aligned. command = %d, addr = 0x%lx, size = %ld\n", |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
95 cmd, (unsigned long)wbuf, w_size); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
96 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
97 char *p = (char *)wbuf; char b = *p; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
98 p = (char *)(wbuf+w_size-1); b += *p; |
949 | 99 } |
100 #endif | |
634 | 101 |
102 return new_task; | |
42 | 103 } |
104 | |
945
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
105 /** |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
106 * Create Compatible Task (TaskArray1) |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
107 */ |
3 | 108 HTaskPtr |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
109 TaskManagerImpl::create_task(int cmd,void *from) |
3 | 110 { |
111 | |
1465 | 112 HTaskPtr new_task = create_task(TaskArray,0,0,0,0, from); |
703 | 113 new_task->post_func = noaction; |
114 new_task->mimpl = this; | |
736 | 115 new_task->create_task_array(cmd,1,8,8,8); |
713
97adb3fe85c6
remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
704
diff
changeset
|
116 // rbuf, r_size were set |
704
ec6c897448ca
Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
703
diff
changeset
|
117 new_task->command = TaskArray1; |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
118 new_task->from = (memaddr)from; |
1551
57317332f6ef
create fft example
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1543
diff
changeset
|
119 new_task->next_task_array(cmd,0,8,8,8); |
63 | 120 |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
121 new_task->export_task_log = _export_task_log; |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
122 if (_export_task_log) { |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
123 TaskLog *tasklog = new TaskLog(); |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
124 tasklog->set_cmd(cmd); |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
125 taskLogQueue->addLast(tasklog); |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
126 new_task->tasklog = tasklog; |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
127 } |
1428
af2adce9752e
add to export TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
128 |
3 | 129 return new_task; |
130 } | |
131 | |
945
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
132 /** |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
133 * Create Task Array |
9ed1c4a877ca
sort example fix ( simple task accepts one param and more compatible with old task)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
941
diff
changeset
|
134 */ |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
135 HTaskPtr |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
136 TaskManagerImpl::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData, void *from) |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
137 { |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
855
diff
changeset
|
138 HTaskPtr ta = create_task(TaskArray,0,0,0,0, from); |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
139 ta->create_task_array(id, num_task, num_param, num_inData, num_outData) ; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
140 return ta; |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
141 } |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
142 |
1432 | 143 TaskListPtr |
144 TaskManagerImpl::createTaskList() | |
145 { | |
146 return NULL; | |
147 } | |
148 | |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
149 /* call get_task_name from ppu only */ |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
150 const char * |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
151 TaskManagerImpl::get_task_name(int cmd) { |
1147 | 152 if (0 <= cmd && cmd < MAX_TASK_OBJECT) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
153 return task_list[cmd].name; |
1887 | 154 } else { |
1147 | 155 return NULL; |
156 } | |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
157 } |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
158 const char * |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
159 TaskManagerImpl::get_task_name(TaskPtr task) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
160 return task != NULL ? get_task_name(task->command) : NULL; |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
161 } |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
162 const char * |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
163 TaskManagerImpl::get_task_name(SimpleTaskPtr simple_task) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
164 return simple_task != NULL ? get_task_name(simple_task->command) : NULL; |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
165 } |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
166 const char * |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
167 TaskManagerImpl::get_task_name(SchedTaskBase *sched_task) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
168 if (sched_task == NULL) return NULL; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
169 if (sched_task->atask != NULL) { |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1462
diff
changeset
|
170 return get_task_name(sched_task->atask->command); |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
171 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
172 return NULL; |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
173 } |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
174 const char * |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
175 TaskManagerImpl::get_task_name(HTaskPtr htask) { |
1147 | 176 |
177 return get_task_name(htask, 0); | |
178 | |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1551
diff
changeset
|
179 } |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
180 const char * |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
181 TaskManagerImpl::get_task_name(HTaskPtr htask, int index) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
182 if (!htask) return NULL; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
183 switch (htask->command) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
184 case TaskArray1: |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
185 return get_task_name((TaskPtr)htask->rbuf); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
186 break; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
187 case TaskArray: { |
1147 | 188 |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
189 TaskPtr tmp = (TaskPtr)htask->rbuf; |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
190 return get_task_name(tmp[0].command); |
1147 | 191 |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
192 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
193 default: |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
194 return get_task_name(htask->command); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
195 } |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
196 return NULL; |
1062
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
197 } |
f994f5032299
add TaskManagerImpl::get_task_name()
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
198 |
3 | 199 /** |
298 | 200 * task の依存関係を設定 |
201 * master task が終わってから、slave task を実行するように | |
109 | 202 * master->wait_for(slave); |
3 | 203 */ |
204 void | |
205 TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave) | |
547 | 206 { |
3 | 207 TaskQueuePtr m, s; |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
940
diff
changeset
|
208 if (!master->self) return; |
547 | 209 |
955 | 210 m = taskQueueImpl->create(); m->init(master); |
211 s = taskQueueImpl->create(); s->init(slave); | |
547 | 212 |
479
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
213 master->wait_me->addLast(s); |
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
214 slave->wait_i->addLast(m); |
481
f9ffcffb6d09
Double linked list modification done (tested on Mac OS X)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
215 s->waiter = m; |
547 | 216 } |
217 | |
3 | 218 /** |
298 | 219 * タスクを実行可能キューまたは待機キューへ追加する。 |
220 * 依存関係が満たされていれば active, まだだったら wait へ。 | |
109 | 221 * task->spawn(); |
222 */ | |
3 | 223 void |
18 | 224 TaskManagerImpl::spawn_task(HTaskPtr task) |
3 | 225 { |
109 | 226 // waiter // master |
227 // waitee // slave | |
480
75e4afa40da2
TaskQueueInfo initiaization...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
479
diff
changeset
|
228 if (task->wait_i->empty()) { |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
497
diff
changeset
|
229 append_activeTask(task); |
3 | 230 } else { |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
497
diff
changeset
|
231 append_waitTask(task); |
3 | 232 } |
233 } | |
42 | 234 |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
736
diff
changeset
|
235 |
109 | 236 /** |
298 | 237 * Task を実行可能キューに追加する |
109 | 238 */ |
239 void | |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
497
diff
changeset
|
240 TaskManagerImpl::append_activeTask(HTaskPtr q) |
109 | 241 { |
479
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
242 activeTaskQueue->addLast(q); |
109 | 243 } |
244 | |
245 /** | |
298 | 246 * タスクが実行する CPU を選択する |
109 | 247 * |
298 | 248 * 現在は CPU_PPE, CPU_SPE, SPE_ANY, SPE_0, SPE_1, ..., SPE_5 |
249 * types.h に書いてます。 | |
109 | 250 */ |
65 | 251 void |
252 TaskManagerImpl::set_task_cpu(HTaskPtr task, CPU_TYPE type) | |
253 { | |
1492
73f4bfaeaf99
fix select cpu type
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1482
diff
changeset
|
254 task_list->cpu_type = type; |
664 | 255 if (machineNum==0) |
1588
f7d35318ea76
fix min_cpu() anc max_cpu()
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1561
diff
changeset
|
256 task->cpu_type = CPU_PPE ; |
664 | 257 else |
1588
f7d35318ea76
fix min_cpu() anc max_cpu()
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1561
diff
changeset
|
258 task->cpu_type = type; |
65 | 259 } |
260 | |
940
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
261 #if 0 |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
262 static void |
955 | 263 check_wait(TaskManagerImpl *tm, QueueInfo<TaskQueue> *wait_i) { |
940
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
264 for(TaskQueue *t = wait_i->getFirst(); t; t = wait_i->getNext(t)) { |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
265 if (!tm->waitTaskQueue->find(t->task)) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
266 //this->printf("stray waiting task%d %lx\n",t->task->command, (long)t->task); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
267 printf("stray waiting task%d %lx\n",t->task->command, (long)t->task); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
268 } else if (tm->activeTaskQueue->find(t->task)) { |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
269 //this->printf(" active task%d in waiting queue %lx\n",t->task->command, (long)t->task); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
270 printf(" active task%d in waiting queue %lx\n",t->task->command, (long)t->task); |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
271 } else |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
272 printf("."); |
940
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
273 } |
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
274 } |
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
275 #endif |
e01b551f25d6
unknown dead lock still...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
939
diff
changeset
|
276 |
109 | 277 /** |
830 | 278 * @brief 終了したタスクから依存の処理とか |
298 | 279 * post_func() はこのタスクが終了したら実行する関数。 |
109 | 280 * |
298 | 281 * @param [task] 終了したタスク |
109 | 282 */ |
283 void | |
955 | 284 TaskManagerImpl::check_task_finish(HTaskPtr me, QueueInfo<HTask> *wait_queue) |
42 | 285 { |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
286 if (_export_task_log) |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
287 me->tasklog->finish_time = rdtsc(); |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
288 |
497 | 289 while(TaskQueue *p = me->wait_me->poll()) { |
1666 | 290 HTaskPtr you = p->task; |
291 QueueInfo<TaskQueue> *wait_i = you->wait_i; | |
292 // 相手の wait queue から自分(を指しているTaskQueue)を削除 | |
293 wait_i->remove(p->waiter); | |
294 // queue を free する | |
295 wait_i->free_(p->waiter); | |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
481
diff
changeset
|
296 |
1666 | 297 if (wait_i->empty()) { |
298 wait_queue->remove(you); | |
299 append_activeTask(you); | |
300 } | |
497 | 301 |
1666 | 302 wait_i->free_(p); // p->wait_i, p->wait_me は再利用される |
479
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
303 } |
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
304 |
1466 | 305 // このTaskList は終わったので、今 free して良いが、TaskListInfo に入っているので、 |
306 // MY_SPE_STATUS_READY 時に、まとめてfree する。FifoTaskManager/CellTaskManager | |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
307 |
939 | 308 // me を誰かが持っていて、me が finish した後に、 |
309 // me->wait_for(i) とか、やられると気まずい。 | |
310 // 特に、me が他人に再利用されていると。そういう時には、 | |
311 // このfreeをコメントアウトしてみる。 | |
312 | |
313 // id かななんかでチェックした方が良いが... | |
314 | |
315 me->self = 0; | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
940
diff
changeset
|
316 if (!me->flag.no_auto_free) |
1666 | 317 htaskImpl->free_(me); |
109 | 318 } |
42 | 319 |
830 | 320 /** |
321 * @brief 終了したタスクリストの依存の処理 | |
322 * @param [task] 終了したタスク | |
323 */ | |
324 void | |
955 | 325 TaskManagerImpl::check_task_list_finish(SchedTask *s, TaskListPtr list, QueueInfo<HTask> *wait_queue) |
830 | 326 { |
1462
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
327 HTask *me = list->self; |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
328 if (me) { |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
329 me->post_func(s, me->post_arg1, me->post_arg2); |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
330 check_task_finish(me, wait_queue); |
830 | 331 } |
332 } | |
109 | 333 |
830 | 334 /** |
335 * @brief waitTaskqueue への挿入 。必須ではない。 | |
336 * 現状では、dead lock 検出にしか使ってない | |
337 * | |
338 * @param [task] 終了したタスク | |
339 */ | |
109 | 340 void |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
497
diff
changeset
|
341 TaskManagerImpl::append_waitTask(HTaskPtr q) |
109 | 342 { |
479
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
343 waitTaskQueue ->addLast(q); |
109 | 344 } |
345 | |
830 | 346 /** |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
347 @brief htask のTaskListを DMA でCPUに渡すための TaskListQueue に入れる |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
348 @param htask |
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
349 @param taskList |
830 | 350 */ |
806 | 351 void |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
352 TaskManagerImpl::set_taskList(HTaskPtr htask, QueueInfo<TaskList> * taskList) |
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1230
diff
changeset
|
353 { |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
354 if (_export_task_log) |
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
355 htask->tasklog->execute_time = rdtsc(); |
1542
9ccfdc408d51
fix gpu word count.but not count line num.
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1492
diff
changeset
|
356 |
1462
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
357 TaskListPtr tl = (TaskList*)htask->rbuf; |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
358 while(tl->prev) tl=tl->prev; |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
359 while(tl) { |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
360 TaskListPtr next = tl->next; |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
361 taskList->addLast(tl); |
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1424
diff
changeset
|
362 tl = next; |
806 | 363 } |
364 } | |
1561
e8c9a7099bcc
add set NDRange param
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1551
diff
changeset
|
365 |
1543 | 366 void |
367 error(const char *error_message) | |
368 { | |
369 fprintf(stderr,"%s \n",error_message); | |
370 exit(1); | |
371 } | |
54 | 372 |
479
bf2d2625485e
Double Linked List base TaskQueue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
373 /* end */ |