Mercurial > hg > Game > Cerium
annotate TaskManager/kernel/ppe/Task.h @ 1531:4443d59a8210 draft
SDL.h in main.cc
author | yuhi@cr.ie.u-ryukyu.ac.jp |
---|---|
date | Fri, 07 Dec 2012 15:46:27 +0900 |
parents | 8034e0212281 |
children | 57317332f6ef |
rev | line source |
---|---|
276 | 1 #ifndef INCLUDED_TASK |
2 #define INCLUDED_TASK | |
3 | |
307 | 4 #include "base.h" |
5 #include "types.h" | |
6 #include "ListData.h" | |
625
94d82f2c842f
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
616
diff
changeset
|
7 #include "SimpleTask.h" |
276 | 8 |
688 | 9 class SchedTask; |
736 | 10 class Scheduler; |
688 | 11 |
684 | 12 class Task { |
13 public: // variables | |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
14 int task_size; |
688 | 15 int command; |
696 | 16 int param_count; |
17 int inData_count; | |
18 int outData_count; | |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
19 int inData_offset; |
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
20 int outData_offset; |
686 | 21 void *data[] __attribute__ ((aligned (DEFAULT_ALIGNMENT))); |
684 | 22 |
23 public: // functions | |
687
25afcd4ae380
test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
686
diff
changeset
|
24 |
736 | 25 void print(Scheduler *s); |
687
25afcd4ae380
test code for TaskArray
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
686
diff
changeset
|
26 |
700 | 27 memaddr *param(int index) { |
1498
8034e0212281
run twice, but not return. dead lock?
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
1480
diff
changeset
|
28 memaddr p = (memaddr)data + sizeof(memaddr)*index; |
700 | 29 return (memaddr *)p; |
695 | 30 } |
31 | |
700 | 32 ListElement *inData(int index) { |
33 memaddr p = (memaddr)data + inData_offset; | |
34 p += sizeof(ListElement)*index; | |
35 return (ListElement*)p; | |
698
72b2da99e875
no compile error for Task Array
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
697
diff
changeset
|
36 } |
696 | 37 |
700 | 38 ListElement *outData(int index) { |
39 memaddr p = (memaddr)data + outData_offset; | |
40 p += sizeof(ListElement)* index; | |
41 return (ListElement*)p; | |
686 | 42 } |
43 | |
696 | 44 static int calc_size(int params, int ins, int outs) { |
689
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
45 int size = round_up16(sizeof(Task)) |
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
46 + round_up16(sizeof(memaddr)*params) |
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
47 + round_up16(sizeof(ListElement)*ins) |
ecf63089f5bb
Task Array generation worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
688
diff
changeset
|
48 + round_up16(sizeof(ListElement)*outs); |
688 | 49 return size; |
50 } | |
51 | |
700 | 52 void init(int task_id, int params, int ins, int outs) { |
53 set_task_id(task_id); | |
54 param_count = params; | |
55 inData_count = ins; | |
56 outData_count = outs; | |
57 inData_offset = round_up16(sizeof(memaddr)*params); | |
58 outData_offset = round_up16(inData_offset+sizeof(ListElement)*ins); | |
970
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
59 //task_size = round_up16(sizeof(Task)+outData_offset+sizeof(ListElement)*outs); |
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
60 |
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
61 task_size = round_up16(sizeof(Task)) |
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
62 + round_up16(sizeof(memaddr)*params) |
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
63 + round_up16(sizeof(ListElement)*ins) |
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
64 + round_up16(sizeof(ListElement)*outs); |
1a4849b2acad
change pipeline and TaskArray fast
Yutaka Kinjyo <yutaka@cr.ie.u-ryukyu.ac.jp>
parents:
949
diff
changeset
|
65 |
700 | 66 } |
67 | |
68 int size() { | |
69 return task_size; | |
70 } | |
71 | |
72 int inData_total_size() { | |
73 int size = 0; | |
74 ListElement *in= inData(0); | |
75 for(int i=0; i< inData_count; i++) { | |
76 size += in[i].size; | |
77 } | |
78 return size; | |
79 } | |
80 int outData_total_size() { | |
81 int size = 0; | |
82 ListElement *out= outData(0); | |
83 for(int i=0; i< outData_count; i++) { | |
84 size += out[i].size; | |
85 } | |
86 return size; | |
87 } | |
88 | |
89 void set_inData_t( int index, memaddr addr, int size) { | |
90 ListElement *list = inData(index); | |
949 | 91 #ifdef EARLY_TOUCH |
92 if ((unsigned long)addr&0xf) { | |
93 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", | |
94 command, index, (unsigned long)addr, size); | |
95 } | |
96 char *p = (char *)addr; int b = *p; | |
97 p = (char *)(addr+size-1); b += *p; | |
98 #endif | |
1480
f2512fb94223
GpuTaskManager no compile error
Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp>
parents:
970
diff
changeset
|
99 |
700 | 100 #ifdef __CERIUM_CELL__ |
101 list->addr = (uint32)addr; | |
102 #else | |
103 list->addr = addr; | |
104 #endif | |
105 list->size = size; | |
106 } | |
107 | |
108 void set_outData_t(int index, memaddr addr, int size) { | |
109 ListElement *list = outData(index); | |
949 | 110 #ifdef EARLY_TOUCH |
111 if ((unsigned long)addr&0xf) { | |
112 printf("inData is not aligned. command = %d, index = %d, addr = 0x%lx, size = %d\n", | |
113 command, index, (unsigned long)addr, size); | |
114 } | |
115 char *p = (char *)addr; int b = *p; | |
116 p = (char *)(addr+size-1); b += *p; | |
117 #endif | |
700 | 118 #ifdef __CERIUM_CELL__ |
119 list->addr = (uint32)addr; | |
120 #else | |
121 list->addr = addr; | |
122 #endif | |
123 list->size = size; | |
124 } | |
125 void set_task_id(int id) { command = id; } | |
126 void set_param_t(int index, memaddr param) { | |
127 memaddr *p = (memaddr*)this->param(index); | |
128 *p = param; | |
129 } | |
130 | |
690 | 131 Task * next() |
132 { | |
695 | 133 char *p = (char*)this; |
134 p += size(); | |
690 | 135 return (Task*)p; |
136 } | |
137 | |
138 | |
684 | 139 #define set_param(index,param) set_param_t(index, (memaddr) (param)) |
140 | |
141 #define set_inData(index, addr, size) \ | |
142 set_inData_t(index, (memaddr)(addr), (size)); | |
143 #define set_outData(index, addr, size) \ | |
144 set_outData_t(index, (memaddr)(addr), (size)); | |
895
b662e9dd26b0
add alignment of classes in SPU
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
787
diff
changeset
|
145 } __attribute__ ((aligned (DEFAULT_ALIGNMENT))) ; |
276 | 146 |
147 typedef Task* TaskPtr; | |
148 | |
149 #endif |