Search code examples
parallel-processingprofilingopenmpoprofile

OProfile with OpenMP


I am using OProfile for OpenMP parallelized code by doing the following,

$ gcc -I/usr/include/hdf5/serial/ -std=c11 -O3 -fopt-info -fopenmp sp_linsvm.c -o sp_linsvm -lhdf5_serial
$ sudo ocount --events=CPU_CLK_UNHALTED,LLC_MISSES,LLC_REFS,MEM_INST_RETIRED,BR_MISP_EXEC, ./sp_linsvm
Events were actively counted for 22.0 seconds.
Event counts (scaled) for /home/aidan/progs/linsvm/sp_linsvm:
    Event                    Count                    % time counted
    BR_MISP_EXEC             6,523,181                80.00
    CPU_CLK_UNHALTED         225,384,009,348          80.00
    LLC_MISSES               276,587,407              80.02
    LLC_REFS                 1,098,236,806            80.00
    MEM_INST_RETIRED         51,754,855,734           79.99

How do I know if the events are counted per CPU or as a whole? I am pretty sure its as a whole as they are close to the numbers if I compiled without OpenMP, but I want to be sure.


Solution

  • Default mode for ocount ... ./program is "command". As I understand, without -t (--separate-thread) or -c (--separate-cpu) options, data from all threads is aggregated.

    So, check documentation http://oprofile.sourceforge.net/doc/controlling-counter.html#controlling-ocount and try -t / -c options...

    --separate-thread / -t This option can be used in conjunction with either the --process-list or --thread-list option to display event counts on a per-thread (per-process) basis. Without this option, all counts are aggregated.

    --separate-cpu / -c This option can be used in conjunction with either the --system-wide or --cpu-list option to display event counts on a per-cpu basis. Without this option, all counts are aggregated.