Mercurial > hg > Game > Cerium
comparison TaskManager/Fifo/FifoDmaManager.cc @ 1698:7673e2ad2623 draft
fix profile
author | kkb |
---|---|
date | Fri, 04 Oct 2013 19:44:09 +0900 |
parents | bde20cca45ae |
children | 5d68a55d5561 |
comparison
equal
deleted
inserted
replaced
1697:ef1099c41449 | 1698:7673e2ad2623 |
---|---|
11 { | 11 { |
12 void *buf = 0; | 12 void *buf = 0; |
13 if (size == 0) return buf; | 13 if (size == 0) return buf; |
14 | 14 |
15 unsigned long long wait = 0; | 15 unsigned long long wait = 0; |
16 (this->*start_dmawait_profile)(); | 16 (*this->start_dmawait_profile)(); |
17 | 17 |
18 buf = s->manager->allocate(size); | 18 buf = s->manager->allocate(size); |
19 memcpy(buf, (void*)addr, size); | 19 memcpy(buf, (void*)addr, size); |
20 | 20 |
21 (this->*end_dmawait_profile)(&wait); | 21 (*this->end_dmawait_profile)(&wait); |
22 global_load_time += wait; | 22 global_load_time += wait; |
23 dma_load_time += wait; | 23 dma_load_time += wait; |
24 | 24 |
25 return buf; | 25 return buf; |
26 } | 26 } |
29 FifoDmaManager::dma_load1(void *buf, memaddr addr, uint32 size, uint32 mask) | 29 FifoDmaManager::dma_load1(void *buf, memaddr addr, uint32 size, uint32 mask) |
30 { | 30 { |
31 if (size == 0) return buf; | 31 if (size == 0) return buf; |
32 | 32 |
33 unsigned long long wait = 0; | 33 unsigned long long wait = 0; |
34 (this->*start_dmawait_profile)(); | 34 (*this->start_dmawait_profile)(); |
35 | 35 |
36 memcpy(buf, (void*)addr, size); | 36 memcpy(buf, (void*)addr, size); |
37 | 37 |
38 (this->*end_dmawait_profile)(&wait); | 38 (*this->end_dmawait_profile)(&wait); |
39 global_load_time += wait; | 39 global_load_time += wait; |
40 dma_load_time += wait; | 40 dma_load_time += wait; |
41 return buf; | 41 return buf; |
42 } | 42 } |
43 | 43 |
53 FifoDmaManager::dma_store(void *buf, memaddr addr, uint32 size, uint32 mask) | 53 FifoDmaManager::dma_store(void *buf, memaddr addr, uint32 size, uint32 mask) |
54 { | 54 { |
55 if (size == 0) return buf; | 55 if (size == 0) return buf; |
56 | 56 |
57 unsigned long long wait = 0; | 57 unsigned long long wait = 0; |
58 (this->*start_dmawait_profile)(); | 58 (*this->start_dmawait_profile)(); |
59 | 59 |
60 memcpy((void*)addr, buf, size); | 60 memcpy((void*)addr, buf, size); |
61 | 61 |
62 (this->*end_dmawait_profile)(&wait); | 62 (*this->end_dmawait_profile)(&wait); |
63 global_store_time += wait; | 63 global_store_time += wait; |
64 dma_store_time += wait; | 64 dma_store_time += wait; |
65 | 65 |
66 return buf; | 66 return buf; |
67 } | 67 } |
77 | 77 |
78 void * | 78 void * |
79 FifoDmaManager::dma_loadList(Scheduler *s, ListDataPtr list, uint32 mask) | 79 FifoDmaManager::dma_loadList(Scheduler *s, ListDataPtr list, uint32 mask) |
80 { | 80 { |
81 unsigned long long wait = 0; | 81 unsigned long long wait = 0; |
82 (this->*start_dmawait_profile)(); | 82 (*this->start_dmawait_profile)(); |
83 | 83 |
84 int list_size = list->length; | 84 int list_size = list->length; |
85 long bound; | 85 long bound; |
86 | 86 |
87 void *buff = s->manager->allocate(list->size); | 87 void *buff = s->manager->allocate(list->size); |
91 ListElementPtr elm = &list->element[i]; | 91 ListElementPtr elm = &list->element[i]; |
92 memcpy((void*)bound, (void*)elm->addr, elm->size); | 92 memcpy((void*)bound, (void*)elm->addr, elm->size); |
93 bound += elm->size; | 93 bound += elm->size; |
94 } | 94 } |
95 | 95 |
96 (this->*end_dmawait_profile)(&wait); | 96 (*this->end_dmawait_profile)(&wait); |
97 global_load_time += wait; | 97 global_load_time += wait; |
98 dma_loadList_time += wait; | 98 dma_loadList_time += wait; |
99 | 99 |
100 return buff; | 100 return buff; |
101 } | 101 } |
102 | 102 |
103 void | 103 void |
104 FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) | 104 FifoDmaManager::dma_storeList(ListDataPtr list, void *buff, uint32 mask) |
105 { | 105 { |
106 unsigned long long wait = 0; | 106 unsigned long long wait = 0; |
107 (this->*start_dmawait_profile)(); | 107 (*this->start_dmawait_profile)(); |
108 | 108 |
109 int list_size = list->length; | 109 int list_size = list->length; |
110 memaddr bound; | 110 memaddr bound; |
111 | 111 |
112 bound = (memaddr)(buff); | 112 bound = (memaddr)(buff); |
115 ListElementPtr elm = &list->element[i]; | 115 ListElementPtr elm = &list->element[i]; |
116 memcpy((void*)elm->addr, (void*)bound, elm->size); | 116 memcpy((void*)elm->addr, (void*)bound, elm->size); |
117 bound += elm->size; | 117 bound += elm->size; |
118 } | 118 } |
119 | 119 |
120 (this->*end_dmawait_profile)(&wait); | 120 (*this->end_dmawait_profile)(&wait); |
121 global_store_time += wait; | 121 global_store_time += wait; |
122 dma_storeList_time += wait; | 122 dma_storeList_time += wait; |
123 } | 123 } |
124 | 124 |
125 void | 125 void |
126 FifoDmaManager::mail_write(memaddr data) | 126 FifoDmaManager::mail_write(memaddr data) |
127 { | 127 { |
128 unsigned long long wait = 0; | 128 unsigned long long wait = 0; |
129 (this->*start_dmawait_profile)(); | 129 (*this->start_dmawait_profile)(); |
130 | 130 |
131 mail_queue1->send(data); | 131 mail_queue1->send(data); |
132 | 132 |
133 (this->*end_dmawait_profile)(&wait); | 133 (*this->end_dmawait_profile)(&wait); |
134 global_mail_time += wait; | 134 global_mail_time += wait; |
135 mail_write_time += wait; | 135 mail_write_time += wait; |
136 } | 136 } |
137 | 137 |
138 void | 138 void |
139 FifoDmaManager::mail_write_finish_list(memaddr data) | 139 FifoDmaManager::mail_write_finish_list(memaddr data) |
140 { | 140 { |
141 unsigned long long wait = 0; | 141 unsigned long long wait = 0; |
142 (this->*start_dmawait_profile)(); | 142 (*this->start_dmawait_profile)(); |
143 | 143 |
144 mail_queue1->send(data); | 144 mail_queue1->send(data); |
145 | 145 |
146 (this->*end_dmawait_profile)(&wait); | 146 (*this->end_dmawait_profile)(&wait); |
147 global_mail_time += wait; | 147 global_mail_time += wait; |
148 mail_write_time += wait; | 148 mail_write_time += wait; |
149 } | 149 } |
150 | 150 |
151 memaddr | 151 memaddr |
152 FifoDmaManager::mail_read() | 152 FifoDmaManager::mail_read() |
153 { | 153 { |
154 unsigned long long wait = 0; | 154 unsigned long long wait = 0; |
155 (this->*start_dmawait_profile)(); | 155 (*this->start_dmawait_profile)(); |
156 | 156 |
157 memaddr data; | 157 memaddr data; |
158 data = mail_queue2->recv(); | 158 data = mail_queue2->recv(); |
159 | 159 |
160 (this->*end_dmawait_profile)(&wait); | 160 (*this->end_dmawait_profile)(&wait); |
161 global_mail_time += wait; | 161 global_mail_time += wait; |
162 mail_read_time += wait; | 162 mail_read_time += wait; |
163 | 163 |
164 return data; | 164 return data; |
165 } | 165 } |
166 | 166 |
167 memaddr | 167 memaddr |
168 FifoDmaManager::task_list_mail_read() | 168 FifoDmaManager::task_list_mail_read() |
169 { | 169 { |
170 unsigned long long wait = 0; | 170 unsigned long long wait = 0; |
171 (this->*start_dmawait_profile)(); | 171 (*this->start_dmawait_profile)(); |
172 | 172 |
173 memaddr data; | 173 memaddr data; |
174 data = mail_queue2->recv(); | 174 data = mail_queue2->recv(); |
175 | 175 |
176 (this->*end_dmawait_profile)(&wait); | 176 (*this->end_dmawait_profile)(&wait); |
177 global_mail_time += wait; | 177 global_mail_time += wait; |
178 mail_read_time += wait; | 178 mail_read_time += wait; |
179 | 179 |
180 return data; | 180 return data; |
181 } | 181 } |
182 | 182 |
183 void | 183 void |
184 FifoDmaManager::mail_write_from_host(memaddr data) | 184 FifoDmaManager::mail_write_from_host(memaddr data) |
185 { | 185 { |
186 unsigned long long wait = 0; | 186 unsigned long long wait = 0; |
187 (this->*start_dmawait_profile)(); | 187 (*this->start_dmawait_profile)(); |
188 | 188 |
189 mail_queue2->send(data); | 189 mail_queue2->send(data); |
190 | 190 |
191 (this->*end_dmawait_profile)(&wait); | 191 (*this->end_dmawait_profile)(&wait); |
192 global_mail_time += wait; | 192 global_mail_time += wait; |
193 mail_write_from_host_time += wait; | 193 mail_write_from_host_time += wait; |
194 } | 194 } |
195 | 195 |
196 memaddr | 196 memaddr |
197 FifoDmaManager::mail_read_from_host() | 197 FifoDmaManager::mail_read_from_host() |
198 { | 198 { |
199 unsigned long long wait = 0; | 199 unsigned long long wait = 0; |
200 (this->*start_dmawait_profile)(); | 200 (*this->start_dmawait_profile)(); |
201 | 201 |
202 memaddr data; | 202 memaddr data; |
203 data = mail_queue1->recv(); | 203 data = mail_queue1->recv(); |
204 | 204 |
205 (this->*end_dmawait_profile)(&wait); | 205 (*this->end_dmawait_profile)(&wait); |
206 global_mail_time += wait; | 206 global_mail_time += wait; |
207 mail_read_from_host_time += wait; | 207 mail_read_from_host_time += wait; |
208 | 208 |
209 return data; | 209 return data; |
210 } | 210 } |
213 FifoDmaManager::has_mail_from_host() | 213 FifoDmaManager::has_mail_from_host() |
214 { | 214 { |
215 return mail_queue1->count(); | 215 return mail_queue1->count(); |
216 } | 216 } |
217 | 217 |
218 static unsigned long long start_time,stop_time; | |
219 void | |
220 do_start_dmawait_profile() | |
221 { | |
222 start_time = gettime(); | |
223 } | |
224 | |
225 void | |
226 do_end_dmawait_profile(unsigned long long *counter) | |
227 { | |
228 stop_time = gettime(); | |
229 *counter += stop_time - start_time; | |
230 } | |
231 | |
232 void null_start_dmawait_profile() {} | |
233 void null_end_dmawait_profile(unsigned long long *counter) {} | |
234 | |
218 void | 235 void |
219 FifoDmaManager::start_profile() | 236 FifoDmaManager::start_profile() |
220 { | 237 { |
238 global_start_time = gettime(); | |
221 global_busy_time = 0; | 239 global_busy_time = 0; |
222 global_load_time = 0; | 240 global_load_time = 0; |
223 global_store_time = 0; | 241 global_store_time = 0; |
224 global_mail_time = 0; | 242 global_mail_time = 0; |
225 dma_load_time = 0; | 243 dma_load_time = 0; |
229 mail_read_time = 0; | 247 mail_read_time = 0; |
230 mail_write_time = 0; | 248 mail_write_time = 0; |
231 mail_read_from_host_time = 0; | 249 mail_read_from_host_time = 0; |
232 mail_write_from_host_time = 0; | 250 mail_write_from_host_time = 0; |
233 | 251 |
234 start_dmawait_profile = &FifoDmaManager::do_start_dmawait_profile; | 252 start_dmawait_profile = &do_start_dmawait_profile; |
235 end_dmawait_profile = &FifoDmaManager::do_end_dmawait_profile; | 253 end_dmawait_profile = &do_end_dmawait_profile; |
236 | 254 |
237 stop_time = gettime(); | 255 stop_time = gettime(); |
238 } | 256 } |
239 | 257 |
240 void | 258 void |
241 FifoDmaManager::stop_profile() | 259 FifoDmaManager::stop_profile() |
242 { | 260 { |
243 start_time = gettime(); | 261 start_dmawait_profile = &null_start_dmawait_profile; |
244 global_busy_time += start_time - stop_time; | 262 end_dmawait_profile = &null_end_dmawait_profile; |
245 | 263 } |
246 start_dmawait_profile = &FifoDmaManager::null_start_dmawait_profile; | |
247 end_dmawait_profile = &FifoDmaManager::null_end_dmawait_profile; | |
248 } | |
249 | |
250 void | |
251 FifoDmaManager::do_start_dmawait_profile() | |
252 { | |
253 start_time = gettime(); | |
254 global_busy_time += start_time - stop_time; | |
255 } | |
256 | |
257 void | |
258 FifoDmaManager::do_end_dmawait_profile(unsigned long long *counter) | |
259 { | |
260 stop_time = gettime(); | |
261 *counter += stop_time - start_time; | |
262 } | |
263 | |
264 void FifoDmaManager::null_start_dmawait_profile() {} | |
265 void FifoDmaManager::null_end_dmawait_profile(unsigned long long *counter) {} | |
266 | 264 |
267 void | 265 void |
268 FifoDmaManager::show_dma_wait(Scheduler *s, int cpu) | 266 FifoDmaManager::show_dma_wait(Scheduler *s, int cpu) |
269 { | 267 { |
270 unsigned long long all_time = global_busy_time + global_load_time + | 268 unsigned long long all_time = gettime() - global_start_time; |
271 global_store_time + global_mail_time; | |
272 | 269 |
273 double busy = ((double)global_busy_time)/((double)all_time)*100.0; | 270 double busy = ((double)global_busy_time)/((double)all_time)*100.0; |
274 double load = ((double)global_load_time)/((double)all_time)*100.0; | 271 double load = ((double)global_load_time)/((double)all_time)*100.0; |
275 double store = ((double)global_store_time)/((double)all_time)*100.0; | 272 double store = ((double)global_store_time)/((double)all_time)*100.0; |
276 double mail = ((double)global_mail_time)/((double)all_time)*100.0; | 273 double mail = ((double)global_mail_time)/((double)all_time)*100.0; |