Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/HTask.h @ 1546:61164c687b29 draft
fix GpuScheduler flip
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 05 Feb 2013 13:15:46 +0900 |
parents | a7895ab4d0e3 |
children | 614a3f62c881 |
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 | |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
22 |
293 | 23 @brief |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
24 |
293 | 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 |
1479
163220e54cc0
remove hard code for TaskLog
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1474
diff
changeset
|
46 int export_task_log; |
1423
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
47 TaskLog *tasklog; |
515a0f15b5d2
add to log taskdependency
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
1412
diff
changeset
|
48 |
498
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
49 HTask *waiter; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
50 HTask *next; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
51 HTask *prev; |
bce667ff20b9
double linked HTaskInfo/HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
480
diff
changeset
|
52 |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
53 struct htask_flag { |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
54 unsigned no_auto_free:1; // bit 0 auto free flag (0 .. auto, 1 manual) |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
55 unsigned flip:1; // use read write buffers for all |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
56 unsigned nd_range:1; // openCL nd_range |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
57 } flag; |
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
58 |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
59 void spawn(); |
293 | 60 void wait_for(HTask *); |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
61 void set_cpu(CPU_TYPE type); |
539 | 62 void set_post(PostFunction func, void *read, void *write); |
700 | 63 Task *create_task_array(int task_id, int num_task, int num_param, int num_inData, int num_outData); |
64 Task *next_task_array(int task_id, Task *t); | |
1425 | 65 Task *next_task_array(int id, Task *t, int param_count, int inData_count, int outData_count); |
700 | 66 void spawn_task_array(Task *t); |
703 | 67 |
955 | 68 HTask *init(int cmd, memaddr rbuf, int rs, memaddr wbuf, int ws) { |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
69 init(cmd); |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
70 set_input(rbuf, rs); |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
71 set_output(wbuf, ws); |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
72 return this; |
955 | 73 } |
714 | 74 |
956
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
75 void initOnce() { |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
76 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
|
77 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
|
78 } |
197b7e19a345
unified queue worked on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
955
diff
changeset
|
79 |
958 | 80 void freeOnce() { |
81 delete wait_me; | |
82 delete wait_i; | |
83 } | |
84 | |
713
97adb3fe85c6
remove SIMPLE_TASK conditional
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
703
diff
changeset
|
85 private: |
703 | 86 |
87 // compatibility | |
88 public: // functions | |
89 void set_inData_t(int index, memaddr addr, int size) { | |
949 | 90 #ifdef EARLY_TOUCH |
91 if ((unsigned long)addr&0xf) { | |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
92 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
93 command, index, (unsigned long)addr, size); |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
94 } |
949 | 95 char *p = (char *)addr; char b = *p; |
96 p = (char *)(addr+size-1); b += *p; | |
97 #endif | |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
98 Task *t = ((TaskList*)rbuf)->tasks; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
99 t->set_inData_t(index, addr,size); |
703 | 100 } |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
101 void set_outData_t(int index, memaddr addr, int size) { |
949 | 102 #ifdef EARLY_TOUCH |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
103 if ((unsigned long)addr&0xf) { |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
104 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
105 command, index, (unsigned long)addr, size); |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
106 } |
949 | 107 char *p = (char *)addr; char b = *p; |
108 p = (char *)(addr+size-1); b += *p; | |
109 #endif | |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
110 Task *t = ((TaskList*)rbuf)->tasks; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
111 t->set_outData_t(index, addr,size); |
703 | 112 } |
113 void set_param_t(int index, memaddr param) { | |
1474 | 114 Task *t = ((TaskList*)rbuf)->tasks; |
115 t->set_param_t(index, param); | |
703 | 116 } |
117 | |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
118 void no_auto_free() { |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
119 flag.no_auto_free = 1; |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
120 } |
954 | 121 void auto_free() { |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
122 flag.no_auto_free = 0; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
123 } |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
124 |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
125 void flip() { |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
126 flag.flip = 1; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
127 } |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
128 void no_flip() { |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
129 flag.flip = 0; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
130 } |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
131 |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
132 htask_flag get_flag(){ |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
133 return flag; |
954 | 134 } |
941
fc6cfaae6de7
add no_auto_free flag on HTask
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
895
diff
changeset
|
135 |
955 | 136 void init() { |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
137 next = prev = NULL; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
138 waiter = NULL; |
955 | 139 } |
714 | 140 |
955 | 141 void init(int cmd) { |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
142 command = cmd; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
143 flag.no_auto_free = 0; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
144 flag.flip = 0; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
145 flag.nd_range = 0; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
146 self = (memaddr) this; |
714 | 147 |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
148 post_func = NULL; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
149 mimpl = NULL; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
150 cpu_type = CPU_PPE; |
1089 | 151 |
1506
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
152 post_arg1 = NULL; |
a7895ab4d0e3
add flip flag and NDRange flag
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1479
diff
changeset
|
153 post_arg2 = NULL; |
714 | 154 } |
703 | 155 #define set_param(index,param) set_param_t(index, (memaddr) (param)) |
156 | |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
788
diff
changeset
|
157 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))); |
109 | 158 |
159 typedef HTask* HTaskPtr; | |
160 | |
161 #endif |