10.5 Configuring branch prediction

Fast Models supports branch prediction modeling by using the BranchPrediction plugin.

When loading the plugin into the model, the following plugin parameters are optional:

predictor-type
Specifies the type of branch predictor to use. It can be one of the following example branch predictors that ARM provides, or a user-defined one:
FixedDirectionPredictor
An example predictor that always takes a preset fixed direction.
BiModalPredictor
An example of a standard 2-bit strength predictor.
GSharePredictor
An example of a standard global history sharing predictor.
HybridPredictor
An example predictor that selects the majority result from the bimodal predictor, fixed-direction predictor, and a random predictor.
CortexA53Predictor
Cortex-A53 branch predictor.

Note:

If predictor-type is not provided, the default is CortexA53Predictor.
mispredict-latency
Configures the branch misprediction latency. This value is the number of instructions that are flushed for every misprediction. It is equal to the pipeline length of the processor. For example, in a processor where the prefetch unit has three stages and the execution units have five stages, the pipeline length is eight. Therefore the mispredict-latency is eight clock cycles.

If mispredict-latency is not provided, the default is eight.

bpstat-pathfilename
Configures the path and filename, relative to the current directory, of the log file that the branch predictor generates after the simulation terminates. This parameter is optional. If you omit it, no log file is generated.
bpstat-branchcount
Controls the display of information about individual branch instructions in the log file. This parameter is optional. The default is -1, which displays information about every branch in the log file. Otherwise, specify the number of branches to display.

Each parameter is prefixed with BranchPrediction.BranchPrediction, for example:

./EVS_Base_Cortex-A73x1 -a __image.axf \
-C Base.bp.secure_memory=false \ 
--plugin $PVLIB_HOME/plugins/Linux64_GCC-4.8/BranchPrediction.so \
-C BranchPrediction.BranchPrediction.predictor-type=BiModalPredictor \
-C BranchPrediction.BranchPrediction.mispredict-latency=8 \
-C BranchPrediction.BranchPrediction.bpstat-pathfilename=bpstat.txt \
-C BranchPrediction.BranchPrediction.bpstat-branchcount=5

This example command produces the following log file:

Processor Core: ARM_Cortex-A73
Cluster instance: 0
Core instance: 0
Mispredict Latency: 8
Image executed: __image.axf
PredictorType: BiModalPredictor
Total branch calls: 7757
Total Mispredictions: 130
Average prediction accuracy: 0.983241
Conditional Branches: 139
Total unique branch instructions: 289
--Branch instructions--
   		PC Addr      Calls    Mispredict Accuracy
	[0]	0x0          2        0          1
	[1]	0x80000000   1        0          1
	[2]	0x8000000c   10       0          1
	[3]	0x80000014   10       0          1
	[4]	0x8000001c   10       0          1

MTI trace events

To generate MTI trace events that report branch mispredictions, specify the following parameter to the GenericTrace plugin:

--plugin $PVLIB_HOME/plugins/Linux64_GCC-4.8/GenericTrace.so /
-C TRACE.GenericTrace.trace-sources=BRANCH_MISPREDICT

Note:

The BranchPrediction plugin must be loaded to generate these events.

PMU events

The BranchPrediction plugin is integrated with the PMU event counters. On a Linux boot simulation, you can track the number of simulated branch mispredictions in an application by loading the BranchPrediction plugin and running the perf tool. For example, the following command displays the number of branch mispredictions that are made in the testapp application:

perf stat –e branch-misses testapp
Non-ConfidentialPDF file icon PDF versionARM 100965_1101_00_en
Copyright © 2014–2017 ARM Limited or its affiliates. All rights reserved.