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