Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/schedule/SchedTask.cc @ 1718:93f051a51d9e draft
fix profile
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Oct 2013 18:07:27 +0900 |
parents | 5d68a55d5561 |
children | 537707f376c8 |
rev | line source |
---|---|
736 | 1 |
308 | 2 #include <stdlib.h> |
3 #include <string.h> | |
42 | 4 #include "SchedTask.h" |
695 | 5 #include "SysFunc.h" |
308 | 6 #include "SchedTaskList.h" |
7 #include "SchedNop2Ready.h" | |
8 #include "DmaManager.h" | |
9 #include "error.h" | |
10 #include "TaskManager.h" | |
466
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
11 #include <stdarg.h> |
1701
4a3b3ec582f2
profile of each task
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1698
diff
changeset
|
12 #include "gettime.h" |
688 | 13 |
698
72b2da99e875
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
695
diff
changeset
|
14 extern TaskObject task_list[MAX_TASK_OBJECT]; |
308 | 15 |
16 SchedTask::SchedTask() | |
17 { | |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
18 list = NULL; |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
19 atask = NULL; |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
20 readbuf = NULL; |
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
21 writebuf = NULL; |
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
22 scheduler = NULL; |
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
23 cur_index = 0; |
1475 | 24 // din[0] = dout[0] = 0; |
466
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
25 this->stdout_ = stdout; |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
26 this->stderr_ = stderr; |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
27 this->stdin_ = stdin; |
308 | 28 } |
29 | |
403
e2f29e912d0b
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
30 SchedTask::~SchedTask() |
308 | 31 { |
32 } | |
33 | |
34 void | |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
35 SchedTask::init(TaskListPtr _list, TaskPtr _task, Scheduler* sc, int tag) |
308 | 36 { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
37 list = _list; |
1463 | 38 atask = _task; |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
39 scheduler = sc; |
972 | 40 this->tag = tag; |
567 | 41 |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
42 // scheduler->mainMem_wait(); // これはなんで? |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
43 manager = sc->manager; |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
44 connector = sc->connector; |
308 | 45 |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
46 inListData.bound = din; |
1463 | 47 inListData.size = 0; |
48 inListData.length = 0; | |
49 inListData.element = 0; | |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
50 outListData.bound = dout; |
1463 | 51 outListData.size = 0; |
52 outListData.length = 0; | |
53 outListData.element = 0; | |
54 | |
55 cur_index = _task; | |
56 this->tag = tag; | |
57 | |
888
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
58 #ifdef TASK_LIST_MAIL |
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
59 if (list) |
1606 | 60 waiter = (memaddr) list->waiter; |
888
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
61 #else |
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
62 if (task) |
1606 | 63 waiter = (memaddr) task->self; |
888
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
64 #endif |
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
65 |
567 | 66 } |
67 | |
502
fdc3e30de9d3
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
68 void |
fdc3e30de9d3
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
69 SchedTask::read() |
fdc3e30de9d3
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
70 { |
538 | 71 __debug("[SchedTask:%s]\n", __FUNCTION__); |
72 | |
73 // object creation をSchedTask生成時にやらないので、 | |
74 // exec の直前のread で十分に間に合う | |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
75 loadSchedTask(scheduler, atask->command); |
713
97adb3fe85c6
remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
708
diff
changeset
|
76 |
634 | 77 // 読むデータが一つもなければ無視 |
1463 | 78 if (atask->inData_count == 0) return; |
79 | |
80 inListData.length = atask->inData_count; | |
81 inListData.size = atask->inData_total_size(); | |
82 inListData.element = atask->inData(0); | |
1475 | 83 if (inListData.length>DefaultBoundSize) |
84 inListData.bound = (int*)manager->allocate(inListData.length*sizeof(int)); | |
634 | 85 // load Input Data |
1463 | 86 // inListData.print(); |
87 readbuf = connector->dma_loadList(scheduler, &inListData, (DMA_READ + this->tag)); | |
88 connector->bound(&inListData); | |
502
fdc3e30de9d3
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
89 } |
fdc3e30de9d3
Renew Task addInData (not yet worked).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
501
diff
changeset
|
90 |
1099
3b3b535baa51
add resize wbuff example.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1015
diff
changeset
|
91 void |
3b3b535baa51
add resize wbuff example.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1015
diff
changeset
|
92 SchedTask::setup_outputData() |
3b3b535baa51
add resize wbuff example.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1015
diff
changeset
|
93 { |
1463 | 94 // allocate write buffer |
95 outListData.length = atask->outData_count; | |
96 outListData.size = atask->outData_total_size(); | |
97 // atask->outData_offset += cur_index + 1 ; // to avoid compiler bug | |
98 outListData.element = atask->outData(0); | |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
99 // if (outListData.bound!=dout) free(outListData.bound); |
1475 | 100 if (outListData.length>DefaultBoundSize) |
101 outListData.bound = (int*)manager->allocate(outListData.length*sizeof(int)); | |
1463 | 102 connector->bound(&outListData); |
103 writebuf = connector->get_writebuf(scheduler, (memaddr)outListData.element[0].addr, outListData.size); | |
1099
3b3b535baa51
add resize wbuff example.
koba <koba@cr.ie.u-ryukyu.ac.jp>
parents:
1015
diff
changeset
|
104 } |
308 | 105 |
106 void | |
403
e2f29e912d0b
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
107 SchedTask::exec() |
308 | 108 { |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
109 task_list[atask->command].wait(scheduler,atask->command); |
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
110 TaskObjectRun run = task_list[atask->command].run; |
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
111 if (atask->outData_count > 0) { |
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
112 setup_outputData(); // we need write buffer before run() |
699 | 113 } |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
114 connector->dma_wait((DMA_READ + this->tag)); |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
115 void *read = get_input(readbuf, 0); void *write = get_output(writebuf, 0); |
1585 | 116 // set param (if exist dim ) |
1717 | 117 list->task_start_time = gettime(); |
1718 | 118 (*connector->start_dmawait_profile)(&connector->start_time); |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
119 if (list->dim) { |
1581
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
120 multi_dimension(list, read, write,run); |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
121 } else { |
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
122 run(this, read,write); |
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
123 } |
1718 | 124 (*connector->end_dmawait_profile)(&connector->global_busy_time,&connector->start_time,&connector->stop_time); |
1717 | 125 list->task_end_time = gettime(); |
126 this->printf("%d %s\t%lld\n",list->self->cpu_type,(char *)(task_list[atask->command].name),list->task_end_time-list->task_start_time); | |
1414
94ac6d8e73aa
fix free inifite loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1413
diff
changeset
|
127 connector->free_(readbuf); |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
128 // User 側で作る方法が必要... |
547 | 129 // 書き込む領域がなければ無視 |
1463 | 130 if (atask->outData_count > 0) { |
131 // outListData.print(); | |
132 connector->dma_storeList(&outListData, writebuf, DMA_WRITE); | |
635
c56f6847fb87
SimpleTask worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
634
diff
changeset
|
133 } |
308 | 134 } |
135 | |
136 void | |
1581
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
137 SchedTask::multi_dimension(TaskListPtr list, void* read, void* write,TaskObjectRun run) { |
1672
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
138 long min = scheduler->min_cpu(); |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
139 long max = scheduler->max_cpu(); |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
140 long id = scheduler->id; |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
141 long lx = list->x; |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
142 long ly = list->y; |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
143 long lz = list->z; |
1671 | 144 |
1672
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
145 x=y=z=0; |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
146 |
32bc4ea3557f
set_param in multi-dimension destroy shared TaskList. make dimension parammeter x,y,z in SchedTask.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1671
diff
changeset
|
147 long cpu=min; |
1582
046695c73cb0
add min_cpu(), max_cpu() (Who implements these?)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1581
diff
changeset
|
148 for (;;cpu++) { |
1671 | 149 if (cpu>max) cpu = min; |
150 if (cpu==id) { | |
1581
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
151 run(this, read,write); |
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
152 } |
1671 | 153 if (++x>=lx) { |
1581
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
154 x=0; |
1671 | 155 if (++y>=ly) { |
1581
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
156 y=0; |
1671 | 157 if (++z>=lz) { |
1581
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
158 break; |
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
159 } |
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
160 } |
8ee897303cd0
fix multi_dimention
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
1580
diff
changeset
|
161 } |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
162 } |
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
163 } |
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
164 |
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
165 void |
403
e2f29e912d0b
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
166 SchedTask::write() |
308 | 167 { |
168 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
373 | 169 |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
170 connector->dma_wait(DMA_WRITE); |
1414
94ac6d8e73aa
fix free inifite loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1413
diff
changeset
|
171 connector->free_(writebuf); |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
172 if (inListData.bound != din) free(inListData.bound); |
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
173 if (outListData.bound != dout) free(outListData.bound); |
888
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
174 #ifdef TASK_LIST_MAIL |
1463 | 175 if ((cur_index->next() >= list->last()) ) |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
176 connector->mail_write(waiter); |
888
b6c45005a3bc
call savedTask->write() in TaskArray finish.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
871
diff
changeset
|
177 #else |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
178 connector->mail_write(waiter); |
830 | 179 #endif |
308 | 180 } |
181 | |
182 SchedTaskBase* | |
403
e2f29e912d0b
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
183 SchedTask::next(Scheduler *scheduler, SchedTaskBase *p) |
308 | 184 { |
185 __debug("[SchedTask:%s]\n", __FUNCTION__); | |
186 | |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
187 if (cur_index == 0) { // 最初の一つ |
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
188 SchedTask *nextSched = new SchedTask(); |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
189 nextSched->init(list, &list->tasks[0], scheduler, this->tag^1); |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
190 return nextSched; |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
191 } |
1580
806b4658ced6
add multi dimension
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1522
diff
changeset
|
192 TaskPtr nextTask = cur_index->next(); // ここで一個一個のtaskを取ってきてる |
1467
d585a7614cd5
look like working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1466
diff
changeset
|
193 if (nextTask < list->last()) { |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
194 // Task List が残っているので、次を準備 |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
195 |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
196 TaskPtr nextTask = cur_index->next(); |
567 | 197 |
1464
3f2230d79eba
TaskList no compile errors
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1463
diff
changeset
|
198 SchedTask *nextSched = new SchedTask(); |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
199 nextSched->init(list, nextTask, scheduler, this->tag^1); |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
200 return nextSched; |
308 | 201 } else { |
603
57ec231bc8ac
long -> memaddr (64 or 32)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
602
diff
changeset
|
202 memaddr nextList = (memaddr)list->next; |
567 | 203 if (nextList == 0) { |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
204 // もう何もする必要がない |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
205 |
567 | 206 return new SchedNop2Ready(scheduler); |
207 } else { | |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
208 // 新しいリストに取り掛かる |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
209 int dma_tag_switch = 0; |
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
210 return new SchedTaskList(nextList, scheduler, dma_tag_switch); |
567 | 211 } |
308 | 212 } |
213 } | |
214 | |
215 | |
216 int | |
403
e2f29e912d0b
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
217 SchedTask::get_cpuid() |
308 | 218 { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
219 return scheduler->id; |
308 | 220 } |
221 | |
708 | 222 void SchedTask::free_(void *p) { |
223 scheduler->free_(p); | |
224 } | |
225 | |
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
|
226 /** |
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
|
227 * SimpleTask has one parameter , one input, one output |
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
|
228 */ |
698
72b2da99e875
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
695
diff
changeset
|
229 |
1463 | 230 /** |
231 * task->add_inData で与えられた順番に対応する index (0〜n-1) で、 | |
232 * buffer から対応するデータを返す。 | |
233 */ | |
234 void* | |
235 SchedTask::get_input(void *buff, int index) | |
236 { | |
237 return (void*)((char*)readbuf + inListData.bound[index]); | |
238 } | |
239 | |
240 /** | |
241 * get_input(index) のアドレスを返す | |
242 */ | |
243 memaddr | |
244 SchedTask::get_inputAddr(int index) | |
245 { | |
246 #ifdef __CERIUM_CELL__ | |
247 return (memaddr)inListData.element[index].addr; | |
248 #else | |
249 return inListData.element[index].addr; | |
250 #endif | |
251 } | |
252 | |
253 /** | |
254 * get_input(index) のサイズを返す | |
255 */ | |
256 int | |
257 SchedTask::get_inputSize(int index) | |
258 { | |
259 return inListData.element[index].size; | |
260 } | |
261 | |
1474 | 262 int |
263 SchedTask::read_size() | |
264 { | |
265 return get_inputSize(0); | |
266 } | |
267 | |
1463 | 268 /** |
269 * write buffer の領域を返す。 | |
270 */ | |
271 void* | |
272 SchedTask::get_output(void *buff, int index) | |
273 { | |
274 return (void*)((char *)writebuf + outListData.bound[index]); | |
275 } | |
276 | |
277 /** | |
278 * get_output(index) のアドレスを返す | |
279 */ | |
280 memaddr | |
281 SchedTask::get_outputAddr(int index) | |
282 { | |
283 #ifdef __CERIUM_CELL__ | |
284 return (memaddr)outListData.element[index].addr; | |
285 #else | |
286 return outListData.element[index].addr; | |
287 #endif | |
288 } | |
289 | |
290 /** | |
291 * get_output(index) のサイズを返す | |
292 */ | |
293 int | |
294 SchedTask::get_outputSize(int index) | |
295 { | |
296 return outListData.element[index].size; | |
297 } | |
298 | |
1474 | 299 int |
300 SchedTask::write_size() | |
301 { | |
302 return get_outputSize(0); | |
303 } | |
304 | |
305 | |
1463 | 306 void |
307 SchedTask::set_outputSize(int index, int size) | |
308 { | |
309 outListData.element[index].size = size; | |
310 } | |
311 | |
312 memaddr | |
313 SchedTask::get_param(int index) | |
314 { | |
315 return *atask->param(index); | |
316 } | |
317 | |
698
72b2da99e875
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
695
diff
changeset
|
318 |
308 | 319 |
320 void* | |
321 SchedTask::global_alloc(int id, int size) { | |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
322 return scheduler->global_alloc(id, size); |
308 | 323 } |
324 | |
325 void* | |
326 SchedTask::global_get(int id) { | |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
327 return scheduler->global_get(id); |
308 | 328 } |
329 | |
330 void | |
373 | 331 SchedTask::global_set(int id, void *addr) { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
332 scheduler->global_set(id, addr); |
373 | 333 } |
334 | |
335 void | |
308 | 336 SchedTask::global_free(int id) { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
337 scheduler->global_free(id); |
308 | 338 } |
339 | |
373 | 340 MemList* |
341 SchedTask::createMemList(int size, int count) { | |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
342 return scheduler->createMemList(size, count); |
373 | 343 } |
344 | |
308 | 345 void |
346 SchedTask::mainMem_alloc(int id, int size) { | |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
347 scheduler->mainMem_alloc(id, size); |
308 | 348 } |
349 | |
350 void | |
403
e2f29e912d0b
clean up and add more info on task_list
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
395
diff
changeset
|
351 SchedTask::mainMem_wait() { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
352 scheduler->mainMem_wait(); |
308 | 353 } |
354 | |
631
30dd8a3deb4a
Cell 64 bit tried, but not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
625
diff
changeset
|
355 memaddr |
308 | 356 SchedTask::mainMem_get(int id) { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
357 return scheduler->mainMem_get(id); |
308 | 358 } |
359 | |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
360 |
1418 | 361 void * |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
362 SchedTask::dma_load(void *buf, memaddr addr, uint32 size, uint32 mask) { |
1418 | 363 return connector->dma_load1(buf, addr, size, mask); // direct DMA API (should be purged ) |
364 } | |
365 | |
366 void * | |
367 SchedTask::get_load_buf(uint32 size) { | |
368 return connector->get_writebuf(scheduler, 0, size); // direct DMA API (should be purged ) | |
369 } | |
370 | |
371 void | |
372 SchedTask::free_load_buf(void *buf) { | |
373 return connector->free_(buf); // direct DMA API (should be purged ) | |
308 | 374 } |
375 | |
376 void | |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
619
diff
changeset
|
377 SchedTask::dma_store(void *buf,memaddr addr, uint32 size, uint32 mask) { |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
378 connector->dma_store(buf, addr, size, mask); |
308 | 379 } |
380 | |
381 void | |
382 SchedTask::dma_wait(uint32 mask) { | |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
383 connector->dma_wait(mask); |
308 | 384 } |
385 | |
334
7bc5cbc5fe04
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
386 void |
7bc5cbc5fe04
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
387 SchedTask::show_dma_wait() { |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
388 connector->show_dma_wait(scheduler, scheduler->id); |
334
7bc5cbc5fe04
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
389 } |
7bc5cbc5fe04
[in test_render] push L key , call show_dma_wait, but incomplete.
e065746@localhost.localdomain
parents:
321
diff
changeset
|
390 |
1124 | 391 |
674
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
392 long |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
393 SchedTask::get_random() { |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
394 return scheduler->get_random(); |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
395 } |
07351a5a51c9
fix many task example (sort).
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
672
diff
changeset
|
396 |
672 | 397 void |
398 SchedTask::start_profile() { | |
1213
a49c02dffe6f
DMA connector reogranization
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1175
diff
changeset
|
399 connector->start_profile(); |
672 | 400 } |
401 | |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
402 MemorySegment * SchedTask::get_segment(memaddr addr, MemList *m) { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
403 return scheduler->get_segment(addr,m); |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
404 } |
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
405 |
1173 | 406 MemorySegment * SchedTask::get_free_segment(memaddr addr, MemList *m) { |
407 return scheduler->get_free_segment(addr,m); | |
408 } | |
409 | |
1175 | 410 void SchedTask::overwrite_segment(MemorySegment *s, memaddr addr) { |
411 return scheduler->overwrite_segment(s,addr); | |
412 } | |
413 | |
1173 | 414 |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
415 void SchedTask::put_segment(MemorySegment *s) { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
416 scheduler->put_segment(s); |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
417 } |
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
418 |
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
419 void SchedTask::wait_segment(MemorySegment *s) { |
483
5f4ffff2c2aa
renew task worked. but not test_nogl...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
468
diff
changeset
|
420 scheduler->wait_segment(s); |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
421 } |
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
422 |
619 | 423 |
634 | 424 HTaskPtr |
425 SchedTask::create_task(int cmd) | |
619 | 426 { |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
427 return manager->create_task(cmd, __builtin_return_address(0)); |
619 | 428 } |
429 | |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
430 HTaskPtr |
634 | 431 SchedTask::create_task(int cmd, memaddr r, long rs, memaddr w, long ws) |
432 { | |
897
6bd218d3f643
add return address in SimpleTask for debugging.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
433 return manager->create_task(cmd,r,rs,w,ws, __builtin_return_address(0)); |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
434 } |
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
435 |
801 | 436 HTaskPtr |
437 SchedTask::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData) | |
438 { | |
1606 | 439 return manager->create_task_array(id, num_task, num_param, num_inData, num_outData, __builtin_return_address(0)); |
801 | 440 } |
441 | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
917
diff
changeset
|
442 void SchedTask::free_htask(HTask *p) { |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
917
diff
changeset
|
443 #if !defined(__SPU__) |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
917
diff
changeset
|
444 manager->free_htask(p); |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
917
diff
changeset
|
445 #endif |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
917
diff
changeset
|
446 } |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
917
diff
changeset
|
447 |
634 | 448 |
619 | 449 void SchedTask::set_task_depend(HTaskPtr master, HTaskPtr slave) |
450 { | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
451 manager->set_task_depend(master, slave); |
619 | 452 } |
453 | |
454 void SchedTask::spawn_task(HTaskPtr t) | |
455 { | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
456 manager->spawn_task(t); |
619 | 457 } |
458 | |
459 void SchedTask::set_task_cpu(HTaskPtr t, CPU_TYPE cpu) | |
460 { | |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
461 manager->set_task_cpu(t, cpu); |
619 | 462 } |
463 | |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
464 void* SchedTask::allocate(int size) |
619 | 465 { |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
466 return manager->allocate(size) ; |
619 | 467 } |
468 | |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
469 void* SchedTask::allocate(int size,int align) |
619 | 470 { |
800
54f0180cea0f
run16 word count ( not yet worked. )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
777
diff
changeset
|
471 return manager->allocate(size,align) ; |
619 | 472 } |
473 | |
833
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
474 void SchedTask::polling() |
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
475 { |
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
476 manager->polling(); |
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
477 } |
577bde5d0cec
poling (may recurse..)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
830
diff
changeset
|
478 |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
479 Scheduler* SchedTask::get_scheduler() |
619 | 480 { |
481 return scheduler; | |
482 } | |
483 | |
466
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
484 /* system call */ |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
485 |
1522
027d99ecb50e
run example/many_task
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1475
diff
changeset
|
486 int |
466
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
487 SchedTask::printf(const char * format, ...) |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
488 { |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
489 va_list ap; |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
490 va_start(ap,format); |
743 | 491 int ret= scheduler->vprintf0(format, ap); |
466
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
492 va_end(ap); |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
493 return ret; |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
494 } |
c73aff02db67
prohibit global variable in Task....
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
464
diff
changeset
|
495 |
387
b6fce69839b5
no compile error but not worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
373
diff
changeset
|
496 |
308 | 497 /* end */ |