source: perf/hrp2/perf/perf.c@ 19

Last change on this file since 19 was 19, checked in by ertl-honda, 12 years ago

HRP2用の性能評価プログラムの追加.

File size: 7.9 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2012 by Embedded and Real-Time Systems Laboratory
6 * Graduate School of Information Science, Nagoya Univ., JAPAN
7 *
8 * 上記著作権者は,以下の(1)〜(4)の条件を満たす場合に限り,本ソフトウェ
9 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
10 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
11 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
12 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
13 * スコード中に含まれていること.
14 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
15 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
16 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
17 * の無保証規定を掲載すること.
18 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
19 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
20 * と.
21 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
22 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
23 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
24 * 報告すること.
25 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
26 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
27 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
28 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
29 * 免責すること.
30 *
31 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
32 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
33 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
34 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
35 * の責任を負わない.
36 *
37 * @(#) $Id: sample1.h 1716 2010-01-31 11:39:18Z ertl-hiro $
38 */
39
40#include <kernel.h>
41#include <t_syslog.h>
42#include <t_stdlib.h>
43#include "syssvc/serial.h"
44#include "syssvc/syslog.h"
45#include "kernel_cfg.h"
46#include "perf.h"
47#include "histogram.h"
48#include "target_timer.h"
49#include "test_lib.h"
50
51/*
52 * サービスコールのエラーのログ出力
53 */
54Inline void
55svc_perror(const char *file, int_t line, const char *expr, ER ercd)
56{
57 if (ercd < 0) {
58 t_perror(LOG_ERROR, file, line, expr, ercd);
59 }
60}
61
62#define SVC_PERROR(expr) svc_perror(__FILE__, __LINE__, #expr, (expr))
63
64/*
65 * 起動時間測定用変数
66 */
67PERFCNT perf_boot_time[4];
68
69/*
70 * 起動時間計測用初期化ルーチン
71 */
72void
73perf_boot_time_inithdr(intptr_t exinf)
74{
75 x_get_pcc(&perf_boot_time[2]);
76 x_rst_pcc();
77}
78
79/*
80 * 起動時間計測用タスク
81 */
82void
83perf_boot_time_task(intptr_t exinf)
84{
85 x_get_pcc(&perf_boot_time[3]);
86 x_rst_pcc();
87}
88
89/*
90 * 計測回数と実行時間分布を記録する最大時間
91 */
92#define NO_MEASURE 10000U /* 計測回数 */
93#define MAX_TIME 10000U /* 実行時間分布を記録する最大時間 */
94
95/*
96 * 実行時間分布を記録するメモリ領域
97 */
98static uint_t histarea1[MAX_TIME + 1];
99static uint_t histarea2[MAX_TIME + 1];
100static uint_t histarea3[MAX_TIME + 1];
101static uint_t histarea4[MAX_TIME + 1];
102static uint_t histarea5[MAX_TIME + 1];
103
104/*
105 * act_tsk ディスパッチなし測定用関数
106 */
107void
108task_act_tsk_nodsp_low(intptr_t exinf)
109{
110
111}
112
113void
114task_act_tsk_nodsp_high(intptr_t exinf)
115{
116 uint_t i;
117
118 for (i = 0; i < NO_MEASURE; i++) {
119 begin_measure(1);
120 act_tsk(TASK_ACT_TSK_NODSP_LOW);
121 end_measure(1);
122 ter_tsk(TASK_ACT_TSK_NODSP_LOW);
123 }
124 wup_tsk(MAIN_TASK);
125}
126
127/*
128 * act_tsk ディスパッチあり測定用関数
129 */
130
131void
132task_act_tsk_dsp_low(intptr_t exinf)
133{
134 uint_t i;
135
136 for (i = 0; i < NO_MEASURE; i++) {
137 begin_measure(2);
138 act_tsk(TASK_ACT_TSK_DSP_HIGH);
139 end_measure(2);
140 }
141 wup_tsk(MAIN_TASK);
142}
143
144void
145task_act_tsk_dsp_high(intptr_t exinf)
146{
147
148}
149
150
151/*
152 * act_tsk ディスパッチなし測定用関数
153 */
154void
155task_act_tsk_nodsp_low_dom1(intptr_t exinf)
156{
157
158}
159
160void
161task_act_tsk_nodsp_high_dom1(intptr_t exinf)
162{
163 uint_t i;
164
165 for (i = 0; i < NO_MEASURE; i++) {
166 begin_measure(3);
167 act_tsk(TASK_ACT_TSK_NODSP_LOW_DOM1);
168 end_measure(3);
169 ter_tsk(TASK_ACT_TSK_NODSP_LOW_DOM1);
170 }
171 SVC_PERROR(wup_tsk(MAIN_TASK));
172}
173
174/*
175 * act_tsk ディスパッチあり測定用関数
176 */
177
178void
179task_act_tsk_dsp_low_dom1(intptr_t exinf)
180{
181 uint_t i;
182
183 for (i = 0; i < NO_MEASURE; i++) {
184 begin_measure(4);
185 act_tsk(TASK_ACT_TSK_DSP_HIGH_DOM1);
186 end_measure(4);
187 }
188 SVC_PERROR(wup_tsk(MAIN_TASK));
189}
190
191void
192task_act_tsk_dsp_high_dom1(intptr_t exinf)
193{
194
195}
196
197void
198task_act_tsk_dsp_low_dom2(intptr_t exinf)
199{
200 uint_t i;
201
202 for (i = 0; i < NO_MEASURE; i++) {
203 begin_measure(5);
204 act_tsk(TASK_ACT_TSK_DSP_HIGH_DOM1);
205 end_measure(5);
206 }
207 SVC_PERROR(wup_tsk(MAIN_TASK));
208}
209
210bool_t start_eval_int;
211bool_t end_eval_int;
212uint_t eval_int_hist[MAX_TIME + 1];
213int perf_int_latency_count;
214
215/*
216 * 割込み応答時間計測
217 */
218void
219perf_int_latency(void)
220{
221 uint_t timer_count;
222 if (start_eval_int == true) {
223 timer_count = target_timer_get_current();
224 if (TO_USEC(timer_count) < MAX_TIME){
225 eval_int_hist[TO_USEC(timer_count)]++;
226 }
227 else {
228 eval_int_hist[MAX_TIME]++;
229 }
230 perf_int_latency_count++;
231 if( perf_int_latency_count == NO_MEASURE) {
232 perf_int_latency_count = 0;
233 start_eval_int = false;
234 end_eval_int = true;
235 iwup_tsk(MAIN_TASK);
236 }
237 }
238
239}
240
241void
242print_perf_int_latency(void)
243{
244 uint32_t i;
245 int out_count = 0;
246
247 for(i = 0; i < (MAX_TIME + 1); i++) {
248 if (eval_int_hist[i] != 0) {
249 syslog_2(LOG_NOTICE, "%d us, %d", i, eval_int_hist[i]);
250 out_count++;
251 }
252 }
253}
254
255/*
256 * メインタスク
257 */
258void main_task(intptr_t exinf)
259{
260 ulong_t t0,t1,t2,t3;
261 uint32_t i;
262
263 /*
264 * BSSの初期化を使用しない場合があるため,ここで初期化.
265 */
266 for (i = 0; i <= MAX_TIME; i++) {
267 histarea1[i] = 0;
268 histarea2[i] = 0;
269 histarea3[i] = 0;
270 histarea4[i] = 0;
271 histarea5[i] = 0;
272 eval_int_hist[i] =0;
273 }
274
275 syslog_1(LOG_NOTICE, "Performance evaluation program start. Please wait about %d sec.", NO_MEASURE/1000);
276 syslog_flush();
277
278 /*
279 * act_tsk ディスパッチなしの測定
280 */
281 init_hist(1, MAX_TIME, histarea1);
282 act_tsk(TASK_ACT_TSK_NODSP_HIGH);
283 slp_tsk();
284 ter_tsk(TASK_ACT_TSK_NODSP_HIGH);
285
286 /*
287 * act_tsk ディスパッチありの測定
288 */
289 init_hist(2, MAX_TIME, histarea2);
290 act_tsk(TASK_ACT_TSK_DSP_LOW);
291 slp_tsk();
292 ter_tsk(TASK_ACT_TSK_DSP_LOW);
293
294 /*
295 * act_tsk ディスパッチなしの測定(ユーザードメイン)
296 */
297 init_hist(3, MAX_TIME, histarea1);
298 act_tsk(TASK_ACT_TSK_NODSP_HIGH_DOM1);
299 slp_tsk();
300 ter_tsk(TASK_ACT_TSK_NODSP_HIGH_DOM1);
301
302 /*
303 * act_tsk ディスパッチありの測定(ユーザードメイン)
304 */
305 init_hist(4, MAX_TIME, histarea2);
306 act_tsk(TASK_ACT_TSK_DSP_LOW_DOM1);
307 slp_tsk();
308 ter_tsk(TASK_ACT_TSK_DSP_LOW_DOM1);
309
310 /*
311 * act_tsk ディスパッチありの測定(ユーザードメイン間)
312 */
313 init_hist(5, MAX_TIME, histarea2);
314 act_tsk(TASK_ACT_TSK_DSP_LOW_DOM1);
315 slp_tsk();
316 ter_tsk(TASK_ACT_TSK_DSP_LOW_DOM1);
317
318 /*
319 * 割込み応答時間の測定
320 */
321// perf_int_latency_count = 0;
322// start_eval_int = true;
323// slp_tsk();
324
325 /*
326 * 計測結果の出力
327 */
328 t0 = x_cnv_nsec(perf_boot_time[0]);
329 t1 = x_cnv_nsec(perf_boot_time[1]);
330 t2 = x_cnv_nsec(perf_boot_time[2]);
331 t3 = x_cnv_nsec(perf_boot_time[3]);
332 syslog_0(LOG_NOTICE, "Boot time.");
333 syslog_1(LOG_NOTICE, "Total time %ld ns", t0+t1+t2+t3);
334 syslog_1(LOG_NOTICE, "Boot to sta_ker %ld ns", t0);
335 syslog_1(LOG_NOTICE, "target init %ld ns", t1);
336 syslog_1(LOG_NOTICE, "OS Obj init to inithdr %ld ns", t2);
337 syslog_1(LOG_NOTICE, "inithdr to inittask %ld ns", t3);
338 syslog_flush();
339
340 syslog_0(LOG_NOTICE, "act_tsk without dispatch[ns].");
341 print_hist(1);
342
343 syslog_0(LOG_NOTICE, "act_tsk with dispatch[ns].");
344 print_hist(2);
345
346 syslog_0(LOG_NOTICE, "act_tsk without dispatch[ns]. (User Domain)");
347 print_hist(3);
348
349 syslog_0(LOG_NOTICE, "act_tsk with dispatch[ns]. (User Domain)");
350 print_hist(4);
351
352 syslog_0(LOG_NOTICE, "act_tsk with dispatch[ns]. (User Domain(DOM1->DOM2))");
353 print_hist(5);
354
355 syslog_0(LOG_NOTICE, "Interrupt Latency.");
356 print_perf_int_latency();
357
358 syslog_0(LOG_NOTICE, "Performance measurement end.");
359 syslog_flush();
360
361 ext_ker();
362 assert(0);
363}
Note: See TracBrowser for help on using the repository browser.