Cachegrind: a cache and branch-prediction profiler
be negative; this indicates that the counts for the relevant function are fewer in the second version than those in the
first version.
cg_diff does not attempt to check that the input files come from runs of the same executable. It will happily merge
together profile files from completely unrelated programs. It does however check that the
Events:
lines of all the
inputs are identical, so as to ensure that the addition of costs makes sense. For example, it would be nonsensical for it
to add a number indicating D1 read references to a number from a different file indicating LL write misses.
A number of other syntax and sanity checks are done whilst reading the inputs. cg_diff will stop and attempt to print
a helpful error message if any of the input files fail these checks.
Sometimes you will want to compare Cachegrind profiles of two versions of a program that you have sitting side-by-
side.
For example, you might have
version1/prog.c
and
version2/prog.c
, where the second is slightly
different to the first.
A straight comparison of the two will not be useful -- because functions are qualified with
filenames, a function
f
will be listed as
version1/prog.c:f
for the first version but
version2/prog.c:f
for the second version.
When this happens, you can use the
--mod-filename
option. Its argument is a Perl search-and-replace expression
that will be applied to all the filenames in both Cachegrind output files. It can be used to remove minor differences in
filenames. For example, the option
--mod-filename=’s/version[0-9]/versionN/’
will suffice for this
case.
Similarly, sometimes compilers auto-generate certain functions and give them randomized names.
For example,
GCC sometimes auto-generates functions with names like
T.1234
, and the suffixes vary from build to build.
You can use the
--mod-funcname
option to remove small differences like these; it works in the same way as
--mod-filename
.
5.3. Cachegrind Command-line Options
Cachegrind-specific options are:
--I1=<size>,<associativity>,<line size>
Specify the size, associativity and line size of the level 1 instruction cache.
--D1=<size>,<associativity>,<line size>
Specify the size, associativity and line size of the level 1 data cache.
--LL=<size>,<associativity>,<line size>
Specify the size, associativity and line size of the last-level cache.
--cache-sim=no|yes [yes]
Enables or disables collection of cache access and miss counts.
--branch-sim=no|yes [no]
Enables or disables collection of branch instruction and misprediction counts.
By default this is disabled as
it slows Cachegrind down by approximately 25%.
Note that you cannot specify
--cache-sim=no
and
--branch-sim=no
together, as that would leave Cachegrind with no information to collect.
86