comparison example/renew_task/spe/SpeProfile.cc @ 192:4f5c64e713c7

add example/renew_task
author gongo@localhost.localdomain
date Tue, 13 Jan 2009 10:41:05 +0900
parents
children 58fd16298954
comparison
equal deleted inserted replaced
191:5e3b0405a44b 192:4f5c64e713c7
1 /**
2 * SPU Decrementerを用いた処理時間計測
3 */
4
5 #include "SpeProfile.h"
6 /* DMA転送に関する関数を使用するために必要なインクルードファイル */
7 #include <spu_intrinsics.h>
8 #include <stdio.h>
9
10 /* SPU Decrementerの初期値 */
11 #define SPU_DECREMENTER_INITIAL_VALUE 0x7FFFFFFFU
12
13 SpeProfile::SpeProfile(void): profile(0) {}
14
15 void SpeProfile::ProfStart(void)
16 {
17 /* SPU Decrementerに初期値を設定 */
18 spu_writech(SPU_WrDec, SPU_DECREMENTER_INITIAL_VALUE);
19
20 /* 計測開始時間をSPU Decrementerから読み取る */
21 profile = spu_readch(SPU_RdDec);
22 }
23
24 void SpeProfile::ProfStop(void)
25 {
26 /* 計測終了時間をSPU Decrementerから読み取り, 計測開始時間との差を計算 */
27 profile -= spu_readch(SPU_RdDec);
28 }
29
30 void SpeProfile::ProfPrint(void)
31 {
32 /* 処理時間を出力 */
33 printf("SPE time by SPU Decrementer: %f\n",
34 profile / 79800000.0f * 1000.0f);
35 }