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