I’d like to recommend this new feature to advanced VTune™ Amplifier XE 2013 users, the feature aids the user to define their metrics from interest of PMU hardware events.
Let’s review what we have before using this new feature. Usually the user may try predefined analysis type in VTun Amplifier when starting a new analysis. Predefined analysis type includes many events and VTune Amplifier will collect these performance data. Meanwhile the tool will generate metrics data since all formulas of metrics and rules already were set in these predefined analysis types. For example, the tool can calculate the value of metric depending on event counts. If the value is greater than threshold – the tool will highlight this metrics on GUI (please note that you can see metrics in summary report by command line, if you use general-exploration analysis, latest Update is U11)
Unfortunately, sometime the user has interest of events which are not defined in existing predefined analysis types. This article (http://software.intel.com/en-us/articles/event-configuration-from-the-command-line) educates you how to quickly collect data for supported events in command line. The shortcoming is that the tool only provides all event counts but there is no metric data…It is same situation if the user to create a new analysis type, the metrics are hard to be added on GUI
This article is to teach you of creating user metrics. Please refer to below steps:
1. Ensure that your system has installed Python 2.6 or above
2. Extract user_metrics.zip, which is under vtune_amplifier_xe_2013/sdk/user_metrics, do “unzip user_metrics.zip”.
3. In user_metrics directory, there are many examples called .py files. Make sure what your processor architecture is – for example, Core™ 2, Core™ i7, Sand bridge or Ivy bridge, so you can choose (reference) right example .py to build a new one which can work on your processor. Here is a small example for your referencing. I work on Sandy bridge processor. The purpose of writing this small .py file is to use event BR_MISP_RETIRED.ALL_BRANCHES_PS to evaluate if it has high Performance Impact, and what Mispredict-Rate (average) is on branch instructions, in your program.
This is a simple example to show how to create user's metrics
BranchMispredictImpact = metric("Branch Mispredict Impact")
BranchMispredictImpact.formula["snb"] = 20* event("BR_MISP_RETIRED.ALL_BRANCHES_PS") /query("Clockticks")
BranchMispredictImpact.issue_eval["snb"] = ( formula() > .20) * (query("PMUHotspot") > .05)
BranchMispredictRate = metric("Branch Mispredict Rate")
BranchMispredictRate.formula["snb"] = event("BR_MISP_RETIRED.ALL_BRANCHES_PS") / event("BR_INST_RETIRED.ALL_BRANCHES_PS")
BranchMispredictRate.issue_eval["snb"] = ( formula() > .50) * (query("PMUHotspot") > .05)
SNBBranchMispredict = analysis("SNB Branch Mispredict")
SNBBranchMispredict.name = "Branch Mispredict"
SNBBranchMispredict.long_name = "Intel Microarchitectures Code Name Sandy Bridge and Ivy Bridge - Branch Mispredict"
SNBBranchMispredict.description = ""
SNBBranchMispredict.valid_architectures = ["snb,ivybridge"]
SNBBranchMispredict.alias_name = "snb-branch-mispredict"
SNBBranchMispredict.always_collect["snb,ivybridge"] = [ event("CPU_CLK_UNHALTED.THREAD"), event("CPU_CLK_UNHALTED.REF_TSC"), event("INST_RETIRED.ANY") ]
SNBBranchMispredict.metric_tree = [
( query("Clockticks"), set(["summary","grid","srcasm"]) ),
( query("InstructionsRetired"), set(["summary","grid","srcasm"]) ),
( query("CPI"), set(["summary","grid"]) ),
( query("BranchMispredictImpact"), set(["summary","grid","srcasm"]) ),
( query("BranchMispredictRate"), set(["summary","grid","srcasm"]) )
4. In this step, use “# python translate_metrics.pyc -m snb_branch_misp.py” to parse your .py file then generate new analysis type, default result is under GENERATED_OUTPUTS directory, which has sub-directories named “analysis_type” and “viewpoint”.
5. In analysis_type directory, do “cp snb-branch-mispredict_atype.cfg /opt/intel/vtune_amplifier_xe_2013/config/analysis_type/”
6. In viewpoint directory, do “cp snb-branch-mispredict_viewpoint.cfg /opt/intel/vtune_amplifier_xe_2013/config/viewpoint/”
7. Now you can see a new analysis type has been generated in your system.
# amplxe-cl -collect-list | grep snb-branch-mispredict
snb-branch-mispredict SNB Branch Mispredict
8. Use this new analysis to profile program
# amplxe-cl -collect snb-branch-mispredict -duration 60 -- ./nbench
9. Use VTune Amplifier GUI to review metrics