annotate TaskManager/kernel/ppe/HTask.cc @ 970:1a4849b2acad draft

change pipeline and TaskArray fast
author Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
date Thu, 26 Aug 2010 20:38:06 +0900
parents 774eba654643
children 5393bebe0956
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
1 #include "HTask.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
2 #include "ListData.h"
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
3 #include "TaskManagerImpl.h"
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
4 #include "strings.h"
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
5
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
7 /*!
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
8 manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
9
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
10 ってやるより
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
11
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
12 task2->set_depend(task1);
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
13
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
14 ってやったほうがわかりやすいよねー的な話し合いで
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
15 下のようなAPIを作りました
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
16 */
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
17
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
18 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 HTask::spawn(void)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 {
836
74fd8d2a7b9d example fix 50%
tkaito
parents: 814
diff changeset
21 mimpl->spawn_task(this);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
22 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
23
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
24 /*!
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
25 @brief この Task が待ち合わせする Task を指定する
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
26 @param[in] master この Task が終了待ち合わせをする相手の Task
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
27
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
28 繰り返し使用する事で複数の Task を待ち合わせする事ができる。
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
29
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
30 wait_for している Task の入力バッファにこの Task から書き込みできる機能があると良い
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
31 */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
32 void
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
33 HTask::wait_for(HTaskPtr master)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 {
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
35 mimpl->set_task_depend(master, this);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
37
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
38 /**
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
39 * タスクが実行する CPU を選択する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
40 *
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
41 * 現在は CPU_PPE, CPU_SPE, SPE_ANY, SPE_0, SPE_1, ..., SPE_5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
42 * types.h に書いてます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
43 *
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
44 * mimpl によって使えるCPUが異なるので、mimpl に任せる必要がある
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
45 */
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
46 void
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
47 HTask::set_cpu(CPU_TYPE type)
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
48 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
49 mimpl->set_task_cpu(this, type);
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
50 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
51
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
52 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
53 @brief このTaskが終了した時に実行する関数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
54 @param arg1, arg2 の二つの引数を持つ (Task に合わせてある)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
55 */
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
56 void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
57 HTask::set_post(PostFunction func,void *arg1, void *arg2)
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
58 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
59 this->post_func = func;
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
60 this->post_arg1 = arg1;
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
61 this->post_arg2 = arg2;
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
62 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
63
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
64
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
65 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
66 @brief まとまって実行されるTask である Task Array の作成
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
67 @param id Task ID
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
68 @param num_task 実行する Task の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
69 @param num_param 一つのTaskがset_paramする数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
70 @param num_inData 一つのTaskが読み込む Data の数、set_inData の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
71 @param num_outData 一つのTaskが書き出す Data の数、set_outData の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
72 @return Task Array へのポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
73 */
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
74 Task *
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
75 HTask::create_task_array(int id, int num_task, int num_param, int num_inData, int num_outData)
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
76 {
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
77 r_size = Task::calc_size(num_param, num_inData, num_outData)*num_task;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
78 rbuf = (memaddr) mimpl->allocate(r_size);
970
1a4849b2acad change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents: 954
diff changeset
79 //printf("r_size %d\n",r_size);
704
ec6c897448ca Compatibility mode works.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 700
diff changeset
80 bzero(rbuf,r_size);
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
81 Task *task = (Task*)rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
82 task->init(id, num_param,num_inData,num_outData);
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
83 // task->print();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
84 return task; // first task
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
85 }
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
86
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
87 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
88 @brief Task Array の次のTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
89 @param t 今のTaskのポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
90 0 の場合は最初のTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
91 @return 次のTaskへのポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
92 */
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
93 Task *
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
94 HTask::next_task_array(int id, Task *t)
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
95 {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
96 Task *first = (Task*)rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
97 if (t==0) {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
98 // first->print();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
99 return first;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
100 }
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
101
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
102 Task *next = t->next();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
103 next->init(id, first->param_count, first->inData_count, first->outData_count);
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
104 if ((memaddr)next - (memaddr)rbuf > r_size)
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 713
diff changeset
105 mimpl->get_scheduler()->printf("too many task array used.\n");
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
106 return next;
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
107 }
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
108
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
109 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
110 @brief Task Array の中のすべてのTaskが書き込まれたかどうかをチェックする
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
111 TaskArray 自体の spawn() は別に必要
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
112 @param last 今のTaskのポインタ (最後である必要がある)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
113 */
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
114 void
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
115 HTask::spawn_task_array(Task * last)
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
116 {
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
117 int size = (memaddr)last - rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
118 if (size!= r_size) {
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 713
diff changeset
119 mimpl->get_scheduler()->printf("spawn task array size differ size 0x%x r_size 0x%x\n",
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
120 size, r_size);
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
121 }
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
122 }
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
123
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
124
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
125
954
774eba654643 auto_free
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 836
diff changeset
126
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
127 /* end */