The code in my_predictor.h defines two classes:
virtual branch_update *predict (branch_info &);
The driver program will call your predict method for every branch trace, giving information from the trace in a branch_info struct that is defined in branch.h. This struct contains fields for the branch address, the x86 branch opcode for a conditional branch, and a set of flags giving information on whether a branch is e.g. a return, a call, a conditional branch, etc. The return value from predict should be an object of (sub)class branch_update that gives the direction prediction for a conditional branch.
In addition to predict, you may define a method with the following signature in your my_predictor class:
virtual void update (branch_update *, bool, unsigned int);
The driver program will call your update method (if any) to give you a chance to update your predictor's state. The parameters are the branch_update pointer your predict method returned, a bool that is false if a conditional branch was not taken, true otherwise, and an unsigned integer target address of the branch.Note: The driver program reports mispredictions only for conditional and indirect branches, but it calls the branch predictor predict and update methods on every branch. That's because you might want to use the information in a the stream of all branches, not just conditional and indirect branches, to help you predict conditional and indirect branches. You are not required to try to predict these non-conditional branches.
This infrastructure uses a few commands that are present on most Unix systems. If the pathnames for xz and/or gzip on your system are different from those in trace.h then please customize them.
This page was written by Daniel A. Jiménez.