To provide the profile information to the compiler initially a so-called training run is performed with an instrumented version of the program. In the second pass the profile data produced in the training run is consulted by the compiler during the various optimizations it performs.
The Simple Executive does not provide a file system where normally the profile data is saved. We provide different solutions to gather profile data on the simulator and on the hardware.
Profile data is emitted when the program exits. For programs that never exit, the bootloader provides a way to force an exit.
/tmp/a.c:2: error: coverage mismatch for function 'main' while reading counter 'arcs' /tmp/a.c:2: error: checksum is 1f18b8db instead of 112c2d5e
executive/cvmx-zone.c:164: note: file obj/cvmx-zone.gcda not found, execution counts estimated
It is expected that if an object file is included in an archive but never actually becomes part of the link there will be no profile data generated for it. In other cases this note probably means that GCC was not looking at the place where you put the profile data (see 2. Core-specific profile data how this can happen) or the training run has failed to produce profiling output because perhaps the program did not exit normally.
The rest of the page describes various issues in more details:
Before compiling in the second pass you need to provide a .gcda file for each module. This is the file that will be used by the compiler. You can either rename per-code data files to end with .gcda or you can merge the per-core files. Read on for examples on both of these.
For example to build the SDK example passthrough to perform a training run use these steps:
examples/passthrough$ make -s clean examples/passthrough$ make FDO_PASS=1 cvmx-config config/executive-config.h mipsisa64-octeon-elf-gcc -fprofile-generate -g -O2 -c -o obj/passthrough.o passthrough.c ......
For example to run the SDK example passthrough to generate profile data perform these steps:
examples/passthrough$ make FDO_PASS=1 run oct-packet-io -p 2000 -c 1 -o output-%d.data -i input-0.data -i input-1.data -i input-2.data -i input-3.data & oct-sim passthrough -quiet -serve=2000 -maxcycles=120000000 -numcores=4 Starting simulator.......
At this point the per-core profile data files will be under obj/. You can rebuild the application using profile data, see 7. Rebuilding the application using profile data..
$ telnet localhost 1234 Trying 127.0.0.1... Connected to localhost.localdomain. Escape character is '^]'. U-Boot 1.1.1 (U-boot build #: 189) (SDK version: 1.7.3-257) (Build time: May 22 2008 - 21:00:00)... ^] telnet> unset interrupt interrupt character is 'off'. ^C
^] stands for the escape character to enter command mode. After hitting ctrl-c you might need to hit an enter as well to flush out the ctrl-c in line mode.
The memory used for the files is allocated from the heap. In case the heap is exhausted while trying to write profile data, you should see the following messages:
memfile: out of memory
If necessary you can increase the heap size when booting (see Octeon Bootloader).
You should capture the console output in the profile run and then run oct-uudecode on the resulting file. The tool oct-uudecode unlike the standard uudecode tool can decode multiple files.
Here is a sample session using break option with the SDK example passthrough:
$ kermit C-Kermit 8.0.211, 10 Apr 2004, for Linux Copyright (C) 1985, 2004, Trustees of Columbia University in the City of New York. Type ? or HELP for help. C-Kermit>send log session session.log C-Kermit>c Connecting to /dev/ttyUSB0, speed 115200 Escape character: Ctrl-\ (ASCII 28, FS): enabled Type the escape character followed by C to get back, or followed by ? to see other options. Session Log: session.log, text ---------------------------------------------------- Octeon ebt3000# bootoct 0x100000 coremask=ffff break Bootloader: Booting Octeon Executive application at 0x00100000, core mask: 0xffff, stack size: 0x100000, heap size: 0x300000 Bootloader: Done loading app on coremask: 0xffff PP0:~CONSOLE-> Version: Cavium Networks Octeon SDK version 1.6.0, build 193 PP0:~CONSOLE-> Port 16: Up 1Gbs Full duplex PP0:~CONSOLE-> Port 17: Down 1Gbs Half duplex PP0:~CONSOLE-> Port 18: Down 1Gbs Half duplex PP0:~CONSOLE-> Port 19: Down 1Gbs Half duplex PP0:~CONSOLE-> Disabling backpressure
In this example we train with the traffic generator. After generating enough traffic we force the program to exit by hitting control-C on the console.
PP0:~CONSOLE-> Disabling backpressure ^C Dumping files on core 0 begin 644 examples/passthrough/obj/passthrough.gcda0 M9V-D830P,2KFX&JS 0 ( "H3^8_ @&A !8 0 M ! $ ! $ 0... begin 644 examples/passthrough/obj/octeon-model.gcda13 M9V-D830P,2KFX*(: 0 ( ND,M)Y &A H M M M M $ " &Q%MCS(!H0 @ M H0 D %0 $ M "C "22];ZT 97 0-*/+$ (//Z@ @\_J % ` end Done dumping files on core 13
C-Kermit>q Closing /dev/ttyUSB0...OK $ oct-uudecode session.log examples/passthrough/obj/passthrough.gcda0 examples/passthrough/obj/cvmx-fpa.gcda0 examples/passthrough/obj/cvmx-pko.gcda0 examples/passthrough/obj/cvmx-sysinfo.gcda0 examples/passthrough/obj/cvmx-coremask.gcda0... examples/passthrough/obj/cvmx-ebt3000.gcda13 examples/passthrough/obj/octeon-model.gcda13 examples/passthrough/obj/cvmx-interrupt.gcda13 $
At this point per-core profile data files are under examples/passthrough/obj.
Here we assumed that core0 was representative of the whole application. You can also merge all or specific per-core profile data files or you can merge profile data from different runs, see 8. Merging profile data.
examples/passthrough$ for i in obj/*.gcda0; do cp $i ${i%0}; done examples/passthrough$ make -s clean # preserves .gcda files examples/passthrough$ make FDO_PASS=2 run cvmx-config config/executive-config.h mipsisa64-octeon-elf-gcc -fprofile-use -g -O2 -c -o obj/passthrough.o passthrough.c ......
The merging tool is called merge-gcda:
$ mipsisa64-octeon-elf-merge-gcda --helpUsage: mipsisa64-octeon-elf-merge-gcda <option(s)> <files> or mipsisa64-octeon-elf-merge-gcda <option(s)> <directories> or mipsisa64-octeon-elf-merge-gcda <option(s)> Merge GCC profile output files. In the first variant <file(s)> are merged into a single output file. By default the output filename is derived from the first file name by removing the trailing numeric characters. In the second variant, files with the identical names from <directories> are merged into files with the same name under the current directory. If neither <files> nor <directories> are specified each <module>.gcda{0..15} file in the current directory is merged into a <module>.gcda file. Possible <option(s)> are: -o, --output=<output> When outputting a single file (first variant) this store the merged data in this file. When generating multiple files (first and second variant), store the files under this directory. -f, --factors=f1:f2:.. When merging, weigh the first input file with integer factor f1, second with f2, etc -h, --help Display help message
Assuming you have the profile data files for each module generated for each core in the current directory you can merge them per module by executing merge-gcda with no arguments. Assuming the passthrough example from above:
examples/passthrough$ cd obj examples/passthrough/obj$ mipsisa64-octeon-elf-merge-gcda Merging these files into cvmx-app-init.gcda: cvmx-app-init.gcda0 cvmx-app-init.gcda1 cvmx-app-init.gcda10 cvmx-app-init.gcda11 cvmx-app-init.gcda12 cvmx-app-init.gcda13 cvmx-app-init.gcda14 cvmx-app-init.gcda15 cvmx-app-init.gcda2 cvmx-app-init.gcda3 cvmx-app-init.gcda4 cvmx-app-init.gcda5 cvmx-app-init.gcda6 cvmx-app-init.gcda7 cvmx-app-init.gcda8 cvmx-app-init.gcda9 Merging these files into cvmx-bootmem-shared.gcda: cvmx-bootmem-shared.gcda0 cvmx-bootmem-shared.gcda1 cvmx-bootmem-shared.gcda10 cvmx-bootmem-shared.gcda11...
You can also merge profile data across different runs. Assuming that you have profile data for two runs in directory run1 and run2 you can merge them by passing the directories tomerge-gcda:
examples/passthrough/obj$ mipsisa64-octeon-elf-merge-gcda ../run1 ../run2 Merging these files into cvmx-app-init.gcda: ../run1/cvmx-app-init.gcda ../run2/cvmx-app-init.gcda Merging these files into cvmx-bootmem-shared.gcda: ../run1/cvmx-bootmem-shared.gcda ../run2/cvmx-bootmem-shared.gcda...
For example invoke gcov to display the profile data for passthrough's main module from the previous section:
examples/passthrough$ mipsisa64-octeon-elf-gcov -o obj passthrough.c File 'passthrough.c' Lines executed:77.17% of 127 passthrough.c:creating 'passthrough.c.gcov'... examples/passthrough$ cat passthrough.c.gcov -: 0:Source:passthrough.c -: 0:Graph:obj/passthrough.gcno -: 0:Data:obj/passthrough.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:/**************************************************************** -: 2: * Copyright (c) 2003-2005, Cavium Networks. All rights reserved.... -: 159:static void application_main_loop(void) 1: 160:{ -: 161: cvmx_wqe_t * work; -: 162: uint64_t port; -: 163: cvmx_buf_ptr_t packet_ptr; -: 164: cvmx_pko_command_word0_t pko_command; -: 165: -: 166: -: 167: /* Build a PKO pointer to this packet * / 1: 168: pko_command.u64 = 0; 1: 169: if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM) -: 170: { 1: 171: pko_command.s.size0 = CVMX_FAU_OP_SIZE_64; 1: 172: pko_command.s.subone0 = 1; 1: 173: pko_command.s.reg0 = FAU_OUTSTANDING; -: 174: } -: 175: -: 176: while (1) -: 177: { -: 178: -: 179: /* get the next packet/work to process from the POW unit. * / 1518: 180: if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_SIM_TYPE) -: 181: { 1518: 182: work = cvmx_pow_work_request_sync(CVMX_POW_NO_WAIT); 1518: 183: if (work == NULL) {
联系客服