annotate TaskManager/kernel/ppe/HTask.cc @ 1424:0ce6c6880b4b draft

change to the queue form the list.
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Sun, 11 Mar 2012 16:36:20 +0900
parents 515a0f15b5d2
children 8bd889db45a1
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"
1423
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
5 #include "rdtsc.h"
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
6
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
7
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
8 /*!
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
9 manager->set_task_depend(task1, task2); // task2 は task1 の終了を待つ
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
10
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
11 ってやるより
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
12
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
13 task2->set_depend(task1);
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
14
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
15 ってやったほうがわかりやすいよねー的な話し合いで
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
16 下のようなAPIを作りました
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
17 */
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
18
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
19 void
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
20 HTask::spawn(void)
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
21 {
1423
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
22 tasklog->create_time = rdtsc();
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
23 mimpl->spawn_task(this);
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
24 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
25
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
26 /*!
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
27 @brief この Task が待ち合わせする Task を指定する
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
28 @param[in] master この Task が終了待ち合わせをする相手の 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 繰り返し使用する事で複数の Task を待ち合わせする事ができる。
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
31
297
54725883131b start task config
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 293
diff changeset
32 wait_for している Task の入力バッファにこの Task から書き込みできる機能があると良い
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
33 */
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
34 void
293
da8edd0735f2 add wait_for document
e065746@localhost.localdomain
parents: 109
diff changeset
35 HTask::wait_for(HTaskPtr master)
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
36 {
1423
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
37 waitTask *wait_task = new waitTask;
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
38 wait_task->task_id = master->tasklog->mtask_id;
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
39 wait_task->cmd = master->command;
1424
0ce6c6880b4b change to the queue form the list.
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1423
diff changeset
40 tasklog->wait_for_list.addLast(wait_task);
1423
515a0f15b5d2 add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1191
diff changeset
41
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
42 mimpl->set_task_depend(master, this);
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
43 }
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
44
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
45 /**
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
46 * タスクが実行する CPU を選択する
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
47 *
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
48 * 現在は CPU_PPE, CPU_SPE, SPE_ANY, SPE_0, SPE_1, ..., SPE_5
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
49 * types.h に書いてます。
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
50 *
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
51 * mimpl によって使えるCPUが異なるので、mimpl に任せる必要がある
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
52 */
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
53 void
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
54 HTask::set_cpu(CPU_TYPE type)
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
55 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
56 mimpl->set_task_cpu(this, type);
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
57 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
58
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
59 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
60 @brief このTaskが終了した時に実行する関数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
61 @param arg1, arg2 の二つの引数を持つ (Task に合わせてある)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
62 */
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
63 void
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
64 HTask::set_post(PostFunction func,void *arg1, void *arg2)
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
65 {
109
028ffc9c0375 Cerium cvs version
gongo@gendarme.local
parents:
diff changeset
66 this->post_func = func;
550
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
67 this->post_arg1 = arg1;
a9f27334963a old ball_bound fix...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 539
diff changeset
68 this->post_arg2 = arg2;
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
69 }
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
70
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
71
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
72 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
73 @brief まとまって実行されるTask である Task Array の作成
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
74 @param id Task ID
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
75 @param num_task 実行する Task の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
76 @param num_param 一つのTaskがset_paramする数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
77 @param num_inData 一つのTaskが読み込む Data の数、set_inData の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
78 @param num_outData 一つのTaskが書き出す Data の数、set_outData の数
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
79 @return Task Array へのポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
80 */
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
81 Task *
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
82 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
83 {
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
84 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
85 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
86 //printf("r_size %d\n",r_size);
1191
bd4a27ae2524 success run to ballbound
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1179
diff changeset
87 //bzeroするのはcostが高いので外したい
bd4a27ae2524 success run to ballbound
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1179
diff changeset
88 bzero(rbuf,r_size);
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
89 Task *task = (Task*)rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
90 task->init(id, num_param,num_inData,num_outData);
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
91 // task->print();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
92 return task; // first task
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
93 }
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
94
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
95 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
96 @brief Task Array の次のTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
97 @param t 今のTaskのポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
98 0 の場合は最初のTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
99 @return 次のTaskへのポインタ
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
100 */
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
101 Task *
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
102 HTask::next_task_array(int id, Task *t)
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
103 {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
104 Task *first = (Task*)rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
105 if (t==0) {
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
106 // first->print();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
107 return first;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
108 }
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
109
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
110 Task *next = t->next();
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
111 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
112 if ((memaddr)next - (memaddr)rbuf > r_size)
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 713
diff changeset
113 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
114 return next;
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
115 }
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
116
814
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
117 /*!
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
118 @brief Task Array の中のすべてのTaskが書き込まれたかどうかをチェックする
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
119 TaskArray 自体の spawn() は別に必要
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
120 @param last 今のTaskのポインタ (最後である必要がある)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 736
diff changeset
121 */
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
122 void
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
123 HTask::spawn_task_array(Task * last)
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
124 {
700
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
125 int size = (memaddr)last - rbuf;
ef08dd70eafb fix fix ...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 697
diff changeset
126 if (size!= r_size) {
736
1b225972ae88 cut printf
hiroki@localhost.localdomain
parents: 713
diff changeset
127 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
128 size, r_size);
689
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
129 }
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
130 }
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
131
ecf63089f5bb Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 688
diff changeset
132
687
25afcd4ae380 test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 567
diff changeset
133
954
774eba654643 auto_free
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 836
diff changeset
134
547
e5431e658038 continue..
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 546
diff changeset
135 /* end */