29#if (!defined(HAVE_FFSLL) || defined(__bgp__))
30int ffsll(
long long lli );
48 return (
unsigned short ) (
_rnum = 1664525 *
_rnum + 1013904223 );
59 int flags,
long long excess,
long long threshold )
80 if ( excess <= (
long long ) 1 )
95 int flags,
long long excess,
long long threshold )
97 unsigned short *buf16;
99 unsigned long long *buf64;
101 unsigned long long lloffset;
117 (
unsigned long long ) ( ( address - prof->
pr_off ) *
119 indx = (
unsigned long ) ( lloffset >> 17 );
123 if ( address >= prof->
pr_off ) {
126 if ( ( indx *
sizeof (
short ) ) < prof->
pr_size ) {
127 buf16 = (
unsigned short *) prof->
pr_base;
129 (
unsigned short ) ( (
unsigned short ) buf16[indx] +
133 PRFDBG(
"posix_profil_16() bucket %lu = %u\n", indx,
139 if ( ( indx *
sizeof (
int ) ) < prof->
pr_size ) {
140 buf32 = (
unsigned int *) prof->
pr_base;
141 buf32[indx] = (
unsigned int ) buf32[indx] +
144 PRFDBG(
"posix_profil_32() bucket %lu = %u\n", indx,
150 if ( ( indx *
sizeof (
long long ) ) < prof->
pr_size ) {
151 buf64 = (
unsigned long long *) prof->
pr_base;
152 buf64[indx] = (
unsigned long long ) buf64[indx] +
157 PRFDBG(
"posix_profil_64() bucket %lu = %lld\n", indx,
166 long long over,
int profile_index )
176 PRFDBG(
"handled IP %p\n", pc );
178 sprof = profile->
prof[profile_index];
183 if ( ( offset < pc ) && ( offset > best_offset ) ) {
185 best_offset = offset;
189 if ( best_index == -1 )
217 int *isHardware,
long long overflow_bit,
221 int retval, event_counter,
i, overflow_flag, pos;
223 int profile_index = 0;
224 long long overflow_vector;
227 long long latest = 0;
243 OVFDBG(
"Either no eventset or eventset not set to overflow.\n" );
244#ifdef ANY_THREAD_GETS_SIGNAL
255 (
"eventset->thread %p vs. current thread %p mismatch",
277 for (
i = 0;
i < event_counter;
i++ ) {
279 latest = ESI->
sw_stop[papi_index];
284 (
"dispatch_overflow() latest %lld, deadline %lld, threshold %d\n",
288 overflow_vector ^= (
long long ) 1 << pos;
296 }
else if ( genOverflowBit ) {
305 overflow_vector = (
long long ) 1 << pos;
307 overflow_vector = overflow_bit;
312 while ( overflow_vector ) {
313 i = ffsll( overflow_vector ) - 1;
314 for ( j = 0; j < event_counter; j++ ) {
320 for ( k = 0, pos = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT && pos >= 0;
329 if ( j == event_counter ) {
331 (
"BUG! overflow_vector is 0, dropping interrupt" );
339 over = temp[profile_index];
342 overflow_vector ^= (
long long ) 1 <<
i;
352#ifdef ANY_THREAD_GETS_SIGNAL
354 OVFDBG(
"I haven't been noticed by PAPI before\n" );
370 struct itimerval value;
376#ifdef ANY_THREAD_GETS_SIGNAL
379 INTDBG(
"itimer already installed\n" );
388 value.it_interval.tv_sec = 0;
389 value.it_interval.tv_usec = us;
390 value.it_value.tv_sec = 0;
391 value.it_value.tv_usec = us;
393 INTDBG(
"Installing itimer %d, with %d us interval\n", timer, us );
394 if ( setitimer( timer, &value, NULL ) < 0 ) {
410 INTDBG(
"_papi_hwi_using_signal is now %d\n",
417 action.sa_flags = SA_RESTART;
423 action.sa_flags |= SIGPWR;
425 action.sa_flags |= SA_SIGINFO;
428 INTDBG(
"installing signal handler\n" );
435 INTDBG(
"_papi_hwi_using_signal[%d] is now %d.\n",
signal,
447 INTDBG(
"removing signal handler\n" );
455 INTDBG(
"_papi_hwi_using_signal[%d] is now %d\n",
signal,
465 struct itimerval value;
467#ifdef ANY_THREAD_GETS_SIGNAL
470 INTDBG(
"itimer in use by another thread\n" );
479 value.it_interval.tv_sec = 0;
480 value.it_interval.tv_usec = 0;
481 value.it_value.tv_sec = 0;
482 value.it_value.tv_usec = 0;
484 INTDBG(
"turning off timer\n" );
485 if ( setitimer( timer, &value, NULL ) == -1 ) {
495#if (!defined(HAVE_FFSLL) || defined(__bgp__))
499ffsll(
long long lli )
501 int i, num, t, tmpint, len;
503 num =
sizeof (
long long ) /
sizeof (
int );
505 return ( ffs( (
int ) lli ) );
506 len =
sizeof (
int ) * CHAR_BIT;
508 for (
i = 0;
i < num;
i++ ) {
509 tmpint = (
int ) ( ( ( lli >> len ) << len ) ^ lli );
513 return ( t +
i * len );
struct papi_vectors * _papi_hwd[]
#define PAPI_PROFIL_BUCKET_32
#define PAPI_PROFIL_WEIGHTED
#define PAPI_PROFIL_POSIX
#define PAPI_PROFIL_BUCKET_16
#define PAPI_OVERFLOW_HARDWARE
#define PAPI_PROFIL_COMPRESS
#define PAPI_PROFIL_RANDOM
Return codes and api definitions.
#define INTDBG(format, args...)
unsigned long int(* _papi_hwi_thread_id_fn)(void)
#define OVFDBG(format, args...)
#define PRFDBG(format, args...)
__sighandler_t signal(int __sig, __sighandler_t __handler) __attribute__((__nothrow__
int sigaction(int __sig, const struct sigaction *__restrict __act, struct sigaction *__restrict __oact) __attribute__((__nothrow__
void PAPIERROR(char *format,...)
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
static void action(void *arg, int regno, const char *name, uint8_t bits)
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
EventSetProfileInfo_t profile
struct _ThreadInfo * master
EventInfo_t * EventInfoArray
EventSetOverflowInfo_t overflow
PAPI_overflow_handler_t handler
hwd_ucontext_t * ucontext
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)
inline_static int _papi_hwi_lock(int lck)
int _papi_hwi_broadcast_signal(unsigned int mytid)
inline_static int _papi_hwi_unlock(int lck)