Next: , Previous: Profiling Background, Up: Profiling


5.2 Profiling Overview

Profiling typically entails two runs of the simulator, one in which data is collected and written to a profile file, called a training run, and another in which data is read from the profile file, called a reference run.

In a training run the profile object is used after the data has been collected and is ready to write. (It is also possible to write data to the file as it is collected.)

Suppose an extension uses profiling to implement something called hip branches. The code below would be executed near the end of a simulation in which data needed to implement hip branches was collected. It writes an array and two objects (which could be simple variables). The data is written immediately and the profile file is closed when execution leaves the bracketed scope.

     {
       Profile profile;
       profile.init( "write",  "hip-branches", "1.0");
       profile.write_array(my_array,my_array_len);
       profile << my_data;
       profile << more_data;
     }

After doing a simulation run to collect the data, a second run is done which reads the profile and uses the data to implement hip branches. The code below would be executed at the beginning of simulation.

     {
       Profile profile;
       profile.init( "read",  "hip-branches", "1.0");
       profile.read_array(my_array,my_array_len);
       profile >> my_data;
       profile >> more_data;
     }

Naming of profile files is automatic and the names are based on the benchmark that was run. Suppose training runs were done on gzip and vpr, then later reference runs were performed on the same benchmarks. The gzip reference run would read the profile file written during the gzip training run, and likewise for vpr

By default (and if RTI benchmark_id is specified) the profile is named using the first two components of the benchmark id, which would be the suite (scpu00, olden), and the program name (gzip, vpr). This way a training run on scpu00.crafty.train would write the same file that a subsequent reference run on scpu00.crafty.ref would read.

If option per=benchmark-id is used then the entire benchmark ID is used to name the profile file.