Multiple regions of interest
Contents
Application source code changes
Include the header file which defines Sniper's magic instructions. Make sure to compile using -I $SNIPER_ROOT/include so sim_api.h can be found.
#include <sim_api.h>
Add Magic markers around regions of interest. Arguments to SimMarker(a, b) can be any two integers, but by convention, a=1 for start, a=2 for stop, while b is the region identifier.
(setup code) SimMarker(1, 1001); (region 1001 code) SimMarker(2, 1001); (uninteresting code) SimMarker(1, 2345); (region 2345 code) SimMarker(2, 2345); (fini code)
Or for an iteration-based benchmark:
for(int iter = 0; iter < 10; ++iter) { SimMarker(1, iter); (loop body) SimMarker(2, iter); }
Running a single selected region in Sniper
The roi-iter.py script can select the region of interest by watching for SimMarker calls, with optional cache warmup
run-sniper -c CONFIG --roi-script [--no-cache-warming] -s roi-iter:A:B:C -- benchmark args ...
With:
- A = region ID of when to start cache warmup
- B = region ID of first region to run in detailed mode
- C = region ID of last region to run in detailed mode
- --no-cache-warming is used to disable cache warmup in code before region A
Examples:
Run a single region with ID 42 in detailed mode, with all code before it in cache-only:
run-sniper -c CONFIG --roi-script -s roi-iter::42:42
Run benchmark iterations 100..110 in cache-only, 111-115 in detailed mode, fast-forward up to region 100 and after region 115:
run-sniper -c CONFIG --roi-script --no-cache-warming -s roi-iter:100:111:115
Selecting regions after simulating everything
Simulate the complete application (or everything inside the usual SimRoiBegin/SimRoiEnd markers), and store statistics snapshots whenever encountering a SimMarker;
run-sniper -c CONFIG [--roi] -s markers:stats
Select the region between two markers for processing using --partial=region-begin:region-end
# List all available markers $ ./tools/dumpstats.py -l start, roi-begin, marker-1-1001, marker-2-1001, marker-1-2345, marker-2-2345, roi-end, stop $ tools/cpistack.py --partial=marker-1-1001:marker-2-1001 (CPI stack for region 1001) $ tools/gen_simout.py --partial=marker-1-2345:marker-2-2345 (sim.out for region 2345)