def run_benchmark(size): pred = bpredict.Local2BitPredictor(size) runner = bpredict.ExternalRunner(pred, benchmark, args=args) runner.run() predicted = runner.stats[0].find('condPredicted')[0].values[0] incorrect = runner.stats[0].find('condIncorrect')[0].values[0] return (incorrect / predicted)
def run_test(runner): start = time.time() runner.run() predicted = runner.stats[0].find('condPredicted')[0].values[0] incorrect = runner.stats[0].find('condIncorrect')[0].values[0] print(' misprediction rate: %f' % (incorrect / predicted)) print(' runtime: %f' % (time.time() - start)) # Run with the external TwoLevelAdaptive predictor (7168 bit) pred = bpredict.TwoLevelAdaptiveTrainingPredictor(512, 10) runner = bpredict.ExternalRunner(pred, benchmark, args) print('External TwoLevelAdaptiveTrainingPredictor:') run_test(runner) # Run with the external Local2Bit predictor (8192 bit) pred = bpredict.Local2BitPredictor(4096) runner = bpredict.ExternalRunner(pred, benchmark, args) print('External Local2BitPredictor:') run_test(runner) # Run with the perceptron predictor (8064 bit) pred = bpredict.PerceptronPredictor(256, 36, 48, 64) runner = bpredict.ExternalRunner(pred, benchmark, args) print('External PerceptronPredictor:') run_test(runner)