Segmentation fault querying for values of all events...

Segmentation fault querying for values of all events...

Postby manumachu » Fri Feb 27, 2015 4:27 am

Dear PAPI Developers,

I am observing a segmentation fault in my program, which queries for all the PAPI event values (preset and native).

The program has the following loop:

For every event, the following steps are performed:

1). PAPI_library_init
2). If event is native, the event is added using PAPI_add_named_event and PAPI_start
3). If event is not native, PAPI_num_counters and PAPI_start_counters are called
4). My routine (simple matrix-matrix multiplication) is executed
5). If event is native, PAPI_stop is called before the event value is read
6). If event is not native, PAPI_read_counters is called to read the event value
7). If event is native, PAPI_shutdown is called
8). If event is not native, PAPI_stop_counters and PAPI_shutdown are called

Please let me know if this is the correct approach to get all the event values.

The program is executed on a Intel Ivybridge Processor (lscpu output shown below):

[b]shell$ lscpu[/b]
[code]Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 45
Stepping: 7
CPU MHz: 3601.000
BogoMIPS: 7183.28
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 10240K
NUMA node0 CPU(s): 0-7[/code]

Unfortunately I am not able to attach the file containing the valgrind errors. So, they are printed below for your study:
[code]...
<===MPEC===> (INFO) Native event UOPS_ISSUED retrieved
<===MPEC===> (INFO) Native event UOPS_RETIRED retrieved
<===MPEC===> (INFO) Native event CYCLE_ACTIVITY retrieved
<===MPEC===> (INFO) Native ev==5650== Invalid read of size 8
==5650== at 0x4C2F79E: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5650== by 0x4CB756: perf_table_clone (pfmlib_perf_event_pmu.c:233)
==5650== by 0x4CB9D1: gen_tracepoint_table (pfmlib_perf_event_pmu.c:338)
==5650== by 0x4CBF21: pfm_perf_init (pfmlib_perf_event_pmu.c:490)
==5650== by 0x4C85BB: pfmlib_pmu_activate (pfmlib_common.c:602)
==5650== by 0x4C8922: pfmlib_init_pmus (pfmlib_common.c:708)
==5650== by 0x4C8AB7: pfm_initialize (pfmlib_common.c:771)
==5650== by 0x4D597C: _papi_libpfm4_init (papi_libpfm4_events.c:105)
==5650== by 0x4C095F: _pe_init_component (perf_event.c:1688)
==5650== by 0x4B63F5: _papi_hwi_init_global (papi_internal.c:1907)
==5650== by 0x4B3EFC: PAPI_library_init (papi.c:615)
==5650== by 0x45C9B7: Mpec::CPUEvent::subscribe(unsigned int) (cpuevent.cpp:242)
==5650== Address 0x825000 is not stack'd, malloc'd or (recently) free'd
==5650==
==5650==
==5650== Process terminating with default action of signal 11 (SIGSEGV)
==5650== Access not within mapped region at address 0x825000
==5650== at 0x4C2F79E: memcpy@@GLIBC_2.14 (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5650== by 0x4CB756: perf_table_clone (pfmlib_perf_event_pmu.c:233)
==5650== by 0x4CB9D1: gen_tracepoint_table (pfmlib_perf_event_pmu.c:338)
==5650== by 0x4CBF21: pfm_perf_init (pfmlib_perf_event_pmu.c:490)
==5650== by 0x4C85BB: pfmlib_pmu_activate (pfmlib_common.c:602)
==5650== by 0x4C8922: pfmlib_init_pmus (pfmlib_common.c:708)
==5650== by 0x4C8AB7: pfm_initialize (pfmlib_common.c:771)
==5650== by 0x4D597C: _papi_libpfm4_init (papi_libpfm4_events.c:105)
==5650== by 0x4C095F: _pe_init_component (perf_event.c:1688)
==5650== by 0x4B63F5: _papi_hwi_init_global (papi_internal.c:1907)
==5650== by 0x4B3EFC: PAPI_library_init (papi.c:615)
==5650== by 0x45C9B7: Mpec::CPUEvent::subscribe(unsigned int) (cpuevent.cpp:242)
==5650== If you believe this happened as a result of a stack
==5650== overflow in your program's main thread (unlikely but
==5650== possible), you can try to increase the size of the
==5650== main thread stack using the --main-stacksize= flag.
==5650== The main thread stack size used in this run was 8388608.
ent OFFCORE_RESPONSE_0 retrieved
<===MPEC===> (INFO) Native event OFFCORE_RESPONSE_1 retrieved
...[/code]

Please let me know if you need further information. Thank you for your help.

Best Regards
Manumachu
manumachu
 
Posts: 3
Joined: Mon Nov 10, 2014 3:10 am

Re: Segmentation fault querying for values of all events...

Postby yarkhan » Tue Mar 10, 2015 11:34 am

In general, the code you are outlining looks right.
Take a look the papi src/ctests directory to see more example code.

What events are you trying to monitor with PAPI?
Make sure that the events are available using the PAPI utilities (papi_avail and papi_native_avail).
Try to count your event using the papi_command_line utility.
papi_command_line <eventname>

I am afraid that I cannot determine the problem from the valgrind information you sent.
My initial suggestion is to confirm that the event you are trying to measure exists on the platform.

Please let us know if your problem has been addressed or if we need to get more details.
Regards,
Asim
yarkhan
 
Posts: 12
Joined: Mon Aug 11, 2014 10:33 am


Return to Classic PAPI (read-only)

Who is online

Users browsing this forum: No registered users and 1 guest