FPGA開発日記

カテゴリ別記事インデックス https://msyksphinz.github.io/github_pages , English Version https://fpgadevdiary.hatenadiary.com/

分岐予測の評価キット Branch Prediction Championship Kit を試す (3. 静的予測を試してみる)

Branch Prediction Championship Simulatorの続きを試す。

静的予測を作ってみる

常にジャンプすると予測するPredictorを作ってみよう。

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <inttypes.h>
#include <math.h>

#include "utils.h"
#include <vector>

class PREDICTOR {

public:

  PREDICTOR(void);
  bool    GetPrediction(UINT64 PC);
  void    UpdatePredictor(UINT64 PC, OpType OPTYPE,bool resolveDir, bool predDir, UINT64 branchTarget);
  void    TrackOtherInst(UINT64 PC, OpType opType, bool taken, UINT64 branchTarget);
};
#include "predictor_static.h"

PREDICTOR::PREDICTOR (void)
{
}

bool
PREDICTOR::GetPrediction (UINT64 PC)
{
  return true;
}

void
PREDICTOR::UpdatePredictor (UINT64 PC, OpType OPTYPE, bool resolveDir,
                            bool predDir, UINT64 branchTarget)
{
}

void
PREDICTOR::TrackOtherInst (UINT64 PC, OpType opType, bool taken,
                           UINT64 branchTarget)
{
}

SHORT24で確認してみる。こちらが結果。めっちゃミスしている。

   MPKBr_1K           :   343.0000
   MPKBr_10K              :    89.0000
   MPKBr_100K             :    62.1200
   MPKBr_1M           :    57.6590
   MPKBr_10M              :    57.5524
   MPKBr_30M              :    57.5686
   TRACE      : ../traces/SHORT_MOBILE-24.bt9.trace.gz
   NUM_INSTRUCTIONS               : 1000000000
   NUM_BR                         :   38684342
   NUM_UNCOND_BR                  :    2221649
   NUM_CONDITIONAL_BR             :   36462693
   NUM_MISPREDICTIONS             :    2226407
   MISPRED_PER_1K_INST            :     2.2264

こちらが通常版。

   MPKBr_1K           :   185.0000
   MPKBr_10K              :    25.3000
   MPKBr_100K             :     2.8200
   MPKBr_1M           :     0.3720
   MPKBr_10M              :     0.0426
   MPKBr_30M              :     0.0239
   TRACE      : ../traces/SHORT_MOBILE-24.bt9.trace.gz
   NUM_INSTRUCTIONS               : 1000000000
   NUM_BR                         :   38684342
   NUM_UNCOND_BR                  :    2221649
   NUM_CONDITIONAL_BR             :   36462693
   NUM_MISPREDICTIONS             :        725
   MISPRED_PER_1K_INST            :     0.0007