Page 1 of 1

Help using PAPI for multi-threaded application

PostPosted: Tue Jul 22, 2014 1:20 pm
by prats_sri
Hi All,

I am new to PAPI. So far, I have tried to use PAPI for single-threaded applications and it has gone well so far. Now, I want to use PAPI for getting the performance counter values for a multi-threaded application. But I don't need statistics per thread, instead I need to get the statistics for the entire application. The multi-threaded application uses pthreads.

Till now, I have tried attaching to the process instead of instrumenting it, but it keeps crashing on me. I do not fork out the process, the process is already running, I get the PID of the process using the ps tool and the I tried attaching PAPI to the running application directly using this PID value. But it crashed.

So, I am thinking of instrumenting the code directly using PAPI and see if it would work. Can you give me some pointers as to how I can use PAPI to gather statistics for the entire multi-threaded process (not individual threads).

Thanks for your help.

- Prats

Re: Help using PAPI for multi-threaded application

PostPosted: Tue Jul 22, 2014 4:57 pm
by James Ralph
Hi,

I'm not sure that there is a simple way to do what you want.
If you can, instrumenting each thread is reasonably easy to do.

See the pthrtough.c file in $(papi_src_dir)/ctests for a small example.

We have an inherit option (see PAPI_set_opt ) but I'm not sure that it works
for threads, I'll check and get back to you.

Hope that gets you started,
James

Re: Help using PAPI for multi-threaded application

PostPosted: Wed Jul 23, 2014 6:11 pm
by prats_sri
Thanks James,

I will get started with the pthrtough.c example to instrument indivdual threads.

What is the inherit option used for?

Thanks,
Prats

Re: Help using PAPI for multi-threaded application

PostPosted: Thu May 28, 2015 9:33 pm
by MrDalek
Hi James,

I am also interested in monitoring a multi-thread application. I tried using PAPI_inherit and PAPI_attach, but PAPI_read returns -3.

Is there a way to monitor all threads of a process that has been attached by its PID? If so can you provide an example (maybe based on inherit.c test code?)