I'm trying to profile some OpenMP code in C with PAPI 5.1.1 as follows on Intel Xeon, Ubuntu 12.04.2:
Outside the parallel region, init PAPI and PAPI_thread_init(), allocate arrays int *EventSets of length num_threads, and long long **values of dimensions num_threads x num_events. Initialize each EventSet to PAPI_NULL.
Then in the parallel region, each thread calls
PAPI_start(EventSets[thread_id]);
do_flops();
PAPI_stop(EventSets[thread_id],values[thread_id]);
This results in the following error if num_threads > 1, some of the time for some threads: "EventSet is currently counting." Sometimes all threads are able to start their respective EventSet and count properly. But most of the time one or more will fail (but never all of the threads fail to count). Each thread reports a unique thread ID, as well as a unique EventSet handle.
Any ideas on why this sometimes occurs, and sometimes not? Thanks
