Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/HTask.h @ 1466:cb57420a8219 draft
TaskList on going...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jul 2012 13:36:55 +0900 |
parents | 8cf62aea798f |
children | b158873485f6 |
rev | line source |
---|---|
109 | 1 #ifndef INCLUDED_HTASK |
2 #define INCLUDED_HTASK | |
3 | |
307 | 4 #include "base.h" |
5 #include "types.h" | |
6 #include "Task.h" | |
1462
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1425
diff
changeset
|
7 #include "TaskList.h" |
955 | 8 #include "TaskQueue.h" |
9 #include "QueueInfo.h" | |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
10 #include "TaskLog.h" |
1142
801d57ae1e29
cut compile CreatePolygonTask on spe side because not enough spe memory. We have to use code loading.
yutaka@localhost.localdomain
parents:
1110
diff
changeset
|
11 //#include <stdio.h> |
109 | 12 |
13 class TaskManagerImpl; | |
539 | 14 class SchedTask; |
15 | |
547 | 16 typedef void (*PostFunction)(SchedTask *s, void *read, void *write); |
109 | 17 |
956
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
18 extern QueueInfo<TaskQueue>* taskQueuePool; |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
19 |
293 | 20 /*! |
21 @class | |
22 | |
23 @brief | |
24 | |
25 Cerium の Task で、spawn() でキューに格納されて順次実行される。 | |
26 cpu の指定があれば並列に実行される。 | |
27 特定の Task を待ち合わせる事が可能。 | |
28 Task の入出力は dma などで copy される。 | |
29 */ | |
688 | 30 |
31 #include "SimpleTask.h" | |
32 | |
641
0605f27ba7d9
Regression on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
634
diff
changeset
|
33 class HTask : public SimpleTask { |
109 | 34 public: |
35 BASE_NEW_DELETE(HTask); | |
36 | |
955 | 37 QueueInfo<TaskQueue> *wait_me; // List of task waiting for me |
38 QueueInfo<TaskQueue> *wait_i; // List of task for which I am waiting | |
546 | 39 PostFunction post_func; |
539 | 40 void *post_arg1; |
41 void *post_arg2; | |
109 | 42 CPU_TYPE cpu_type; |
43 TaskManagerImpl *mimpl; | |
1466 | 44 TaskPtr last; |
109 | 45 |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
46 TaskLog *tasklog; |
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
47 |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
48 HTask *waiter; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
49 HTask *next; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
50 HTask *prev; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
51 |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
52 struct { |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
53 unsigned no_auto_free:1; // bit 0 auto free flag (0 .. auto, 1 manual) |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
54 } flag; |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
55 |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
56 void spawn(); |
293 | 57 void wait_for(HTask *); |
397
ce86b0186a4a
delete manager (in kernel/ppe/TaskManager.h)
game@henri.cr.ie.u-ryukyu.ac.jp
parents:
366
diff
changeset
|
58 void set_cpu(CPU_TYPE type); |
539 | 59 void set_post(PostFunction func, void *read, void *write); |
700 | 60 Task *create_task_array(int task_id, int num_task, int num_param, int num_inData, int num_outData); |
61 Task *next_task_array(int task_id, Task *t); | |
1425 | 62 Task *next_task_array(int id, Task *t, int param_count, int inData_count, int outData_count); |
700 | 63 void spawn_task_array(Task *t); |
703 | 64 |
955 | 65 HTask *init(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) { |
66 init(cmd); | |
67 set_input(rbuf, rs); | |
68 set_output(wbuf, ws); | |
69 return this; | |
70 } | |
714 | 71 |
956
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
72 void initOnce() { |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
73 wait_me = new QueueInfo<TaskQueue>(taskQueuePool); |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
74 wait_i = new QueueInfo<TaskQueue>(taskQueuePool); |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
75 } |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
76 |
958 | 77 void freeOnce() { |
78 delete wait_me; | |
79 delete wait_i; | |
80 } | |
81 | |
713
97adb3fe85c6
remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
703
diff
changeset
|
82 private: |
703 | 83 |
84 // compatibility | |
85 public: // functions | |
86 void set_inData_t(int index, memaddr addr, int size) { | |
949 | 87 #ifdef EARLY_TOUCH |
88 if ((unsigned long)addr&0xf) { | |
787 | 89 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", |
90 command, index, (unsigned long)addr, size); | |
91 } | |
949 | 92 char *p = (char *)addr; char b = *p; |
93 p = (char *)(addr+size-1); b += *p; | |
94 #endif | |
1462
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1425
diff
changeset
|
95 Task *t = ((TaskList*)rbuf)->tasks; |
703 | 96 t->set_inData_t(index, addr,size); |
97 } | |
98 void set_outData_t(int index, memaddr addr, int size) { | |
949 | 99 #ifdef EARLY_TOUCH |
100 if ((unsigned long)addr&0xf) { | |
787 | 101 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", |
102 command, index, (unsigned long)addr, size); | |
103 } | |
949 | 104 char *p = (char *)addr; char b = *p; |
105 p = (char *)(addr+size-1); b += *p; | |
106 #endif | |
1462
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1425
diff
changeset
|
107 Task *t = ((TaskList*)rbuf)->tasks; |
788 | 108 t->set_outData_t(index, addr,size); |
703 | 109 } |
110 void set_param_t(int index, memaddr param) { | |
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
|
111 if (command==TaskArray1) { |
1462
8cf62aea798f
HTask/TaskList fix (on going)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
1425
diff
changeset
|
112 Task *t = ((TaskList*)rbuf)->tasks; |
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
|
113 t->set_param_t(index, param); |
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
|
114 } else { |
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
|
115 this->param = param; |
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
|
116 } |
703 | 117 } |
118 | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
119 void no_auto_free() { |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
120 flag.no_auto_free = 1; |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
121 } |
954 | 122 void auto_free() { |
123 flag.no_auto_free = 0; | |
124 } | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
125 |
955 | 126 void init() { |
714 | 127 next = prev = NULL; |
128 waiter = NULL; | |
955 | 129 } |
714 | 130 |
955 | 131 void init(int cmd) { |
714 | 132 command = cmd; |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
133 flag.no_auto_free = 0; |
714 | 134 self = (memaddr) this; |
135 | |
136 post_func = NULL; | |
137 mimpl = NULL; | |
138 cpu_type = CPU_PPE; | |
1089 | 139 |
140 post_arg1 = NULL; | |
141 post_arg2 = NULL; | |
714 | 142 } |
703 | 143 #define set_param(index,param) set_param_t(index, (memaddr) (param)) |
144 | |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
788
diff
changeset
|
145 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))); |
109 | 146 |
147 typedef HTask* HTaskPtr; | |
148 | |
149 #endif |