Commit 39b5ebdb authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

A call of PAPI_thread_init() seems necessary

Also, reliable results can only be obtained for threads that are bound
to a specific core (socket at least?), otherwise the FLOP and CPU
counters from different CPU's get mixed.

Since PAPI works now on my IvyBridge system with the newest version I
can do more detailed tests there.
parent 65eecca1
......@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -35,6 +36,13 @@ static int cycle_available = 0;
#ifdef HAVE_LIBPAPI
#include <papi.h>
#define papi_try(x, on_error) if ((ret = x) < 0) { \
fprintf(stderr, "ftimings: %s:%d: PAPI_library_init(%d): %s\n", \
__FILE__, __LINE__, PAPI_VER_CURRENT, PAPI_strerror(ret)); \
on_error; \
}
static void papi_uninit(void) {
PAPI_shutdown();
}
......@@ -46,7 +54,9 @@ static int papi_init(void) {
return papi_available;
}
#ifdef _OPENMP
#pragma omp critical
#endif
do {
/* Think about it :) */
if (tried_papi_init) {
......@@ -63,6 +73,7 @@ static int papi_init(void) {
papi_available = 0;
break;
}
papi_try(PAPI_thread_init(pthread_self), papi_available = 0; break)
if ((ret = PAPI_create_eventset(&event_set)) < 0) {
fprintf(stderr, "ftimings: %s:%d PAPI_create_eventset(): %s\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment