PAPI 7.1.0.0
Loading...
Searching...
No Matches
extras.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int _papi_hwi_stop_timer (int timer, int signal)
 
int _papi_hwi_start_timer (int timer, int signal, int ms)
 
int _papi_hwi_stop_signal (int signal)
 
int _papi_hwi_start_signal (int signal, int need_context, int cidx)
 
int _papi_hwi_initialize (DynamicArray_t **)
 
int _papi_hwi_dispatch_overflow_signal (void *papiContext, vptr_t address, int *, long long, int, ThreadInfo_t **master, int cidx)
 
void _papi_hwi_dispatch_profile (EventSetInfo_t *ESI, vptr_t address, long long over, int profile_index)
 

Function Documentation

◆ _papi_hwi_dispatch_overflow_signal()

int _papi_hwi_dispatch_overflow_signal ( void *  papiContext,
vptr_t  address,
int isHardware,
long long  overflow_bit,
int  genOverflowBit,
ThreadInfo_t **  master,
int  cidx 
)

Definition at line 216 of file extras.c.

220{
221 int retval, event_counter, i, overflow_flag, pos;
222 int papi_index, j;
223 int profile_index = 0;
224 long long overflow_vector;
225
226 long long temp[_papi_hwd[cidx]->cmp_info.num_cntrs], over;
227 long long latest = 0;
229 EventSetInfo_t *ESI;
230 _papi_hwi_context_t *ctx = ( _papi_hwi_context_t * ) papiContext;
231
232 OVFDBG( "enter\n" );
233
234 if ( *t )
235 thread = *t;
236 else
238
239 if ( thread != NULL ) {
240 ESI = thread->running_eventset[cidx];
241
242 if ( ( ESI == NULL ) || ( ( ESI->state & PAPI_OVERFLOWING ) == 0 ) ) {
243 OVFDBG( "Either no eventset or eventset not set to overflow.\n" );
244#ifdef ANY_THREAD_GETS_SIGNAL
246#endif
247 return ( PAPI_OK );
248 }
249
250 if ( ESI->CmpIdx != cidx )
251 return ( PAPI_ENOCMP );
252
253 if ( ESI->master != thread ) {
255 ( "eventset->thread %p vs. current thread %p mismatch",
256 ESI->master, thread );
257 return ( PAPI_EBUG );
258 }
259
260 if ( isHardware ) {
262 ESI->state |= PAPI_PAUSED;
263 *isHardware = 1;
264 } else
265 *isHardware = 0;
266 }
267 /* Get the latest counter value */
268 event_counter = ESI->overflow.event_counter;
269
270 overflow_flag = 0;
271 overflow_vector = 0;
272
273 if ( !( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) ) {
274 retval = _papi_hwi_read( thread->context[cidx], ESI, ESI->sw_stop );
275 if ( retval < PAPI_OK )
276 return ( retval );
277 for ( i = 0; i < event_counter; i++ ) {
278 papi_index = ESI->overflow.EventIndex[i];
279 latest = ESI->sw_stop[papi_index];
280 temp[i] = -1;
281
282 if ( latest >= ( long long ) ESI->overflow.deadline[i] ) {
283 OVFDBG
284 ( "dispatch_overflow() latest %lld, deadline %lld, threshold %d\n",
285 latest, ESI->overflow.deadline[i],
286 ESI->overflow.threshold[i] );
287 pos = ESI->EventInfoArray[papi_index].pos[0];
288 overflow_vector ^= ( long long ) 1 << pos;
289 temp[i] = latest - ESI->overflow.deadline[i];
290 overflow_flag = 1;
291 /* adjust the deadline */
292 ESI->overflow.deadline[i] =
293 latest + ESI->overflow.threshold[i];
294 }
295 }
296 } else if ( genOverflowBit ) {
297 /* we had assumed the overflow event can't be derived event */
298 papi_index = ESI->overflow.EventIndex[0];
299
300 /* suppose the pos is the same as the counter number
301 * (this is not true in Itanium, but itanium doesn't
302 * need us to generate the overflow bit
303 */
304 pos = ESI->EventInfoArray[papi_index].pos[0];
305 overflow_vector = ( long long ) 1 << pos;
306 } else
307 overflow_vector = overflow_bit;
308
309 if ( ( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) || overflow_flag ) {
310 if ( ESI->state & PAPI_PROFILING ) {
311 int k = 0;
312 while ( overflow_vector ) {
313 i = ffsll( overflow_vector ) - 1;
314 for ( j = 0; j < event_counter; j++ ) {
315 papi_index = ESI->overflow.EventIndex[j];
316 /* This loop is here ONLY because Pentium 4 can have tagged *
317 * events that contain more than one counter without being *
318 * derived. You've gotta scan all terms to make sure you *
319 * find the one to profile. */
320 for ( k = 0, pos = 0; k < PAPI_EVENTS_IN_DERIVED_EVENT && pos >= 0;
321 k++ ) {
322 pos = ESI->EventInfoArray[papi_index].pos[k];
323 if ( i == pos ) {
324 profile_index = j;
325 goto foundit;
326 }
327 }
328 }
329 if ( j == event_counter ) {
331 ( "BUG! overflow_vector is 0, dropping interrupt" );
332 return ( PAPI_EBUG );
333 }
334
335 foundit:
336 if ( ( ESI->overflow.flags & PAPI_OVERFLOW_HARDWARE ) )
337 over = 0;
338 else
339 over = temp[profile_index];
340 _papi_hwi_dispatch_profile( ESI, address, over,
341 profile_index );
342 overflow_vector ^= ( long long ) 1 << i;
343 }
344 /* do not use overflow_vector after this place */
345 } else {
346 ESI->overflow.handler( ESI->EventSetIndex, ( void * ) address,
347 overflow_vector, ctx->ucontext );
348 }
349 }
350 ESI->state &= ~( PAPI_PAUSED );
351 }
352#ifdef ANY_THREAD_GETS_SIGNAL
353 else {
354 OVFDBG( "I haven't been noticed by PAPI before\n" );
356 }
357#endif
358 return ( PAPI_OK );
359}
int i
struct papi_vectors * _papi_hwd[]
void _papi_hwi_dispatch_profile(EventSetInfo_t *ESI, vptr_t pc, long long over, int profile_index)
Definition: extras.c:165
#define PAPI_EBUG
Definition: f90papi.h:176
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_PROFILING
Definition: f90papi.h:150
#define PAPI_PAUSED
Definition: f90papi.h:25
#define PAPI_ENOCMP
Definition: f90papi.h:79
#define PAPI_OVERFLOWING
Definition: f90papi.h:240
#define PAPI_OVERFLOW_HARDWARE
Definition: f90papi.h:157
void * thread(void *arg)
Definition: kufrin.c:38
unsigned long int(* _papi_hwi_thread_id_fn)(void)
Definition: threads.c:42
#define OVFDBG(format, args...)
Definition: papi_debug.h:69
void PAPIERROR(char *format,...)
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
static int cidx
long long int long long
Definition: sde_internal.h:85
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
long long * sw_stop
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)
Definition: threads.h:97
int _papi_hwi_broadcast_signal(unsigned int mytid)
int retval
Definition: zero_fork.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_dispatch_profile()

void _papi_hwi_dispatch_profile ( EventSetInfo_t ESI,
vptr_t  address,
long long  over,
int  profile_index 
)

Definition at line 165 of file extras.c.

167{
168 EventSetProfileInfo_t *profile = &ESI->profile;
169 PAPI_sprofil_t *sprof;
170 vptr_t offset = 0;
171 vptr_t best_offset = 0;
172 int count;
173 int best_index = -1;
174 int i;
175
176 PRFDBG( "handled IP %p\n", pc );
177
178 sprof = profile->prof[profile_index];
179 count = profile->count[profile_index];
180
181 for ( i = 0; i < count; i++ ) {
182 offset = sprof[i].pr_off;
183 if ( ( offset < pc ) && ( offset > best_offset ) ) {
184 best_index = i;
185 best_offset = offset;
186 }
187 }
188
189 if ( best_index == -1 )
190 best_index = 0;
191
192 posix_profil( pc, &sprof[best_index], profile->flags, over,
193 profile->threshold[profile_index] );
194}
static long count
static void posix_profil(vptr_t address, PAPI_sprofil_t *prof, int flags, long long excess, long long threshold)
Definition: extras.c:94
void * vptr_t
Definition: papi.h:576
#define PRFDBG(format, args...)
Definition: papi_debug.h:70
EventSetProfileInfo_t profile
PAPI_sprofil_t ** prof
vptr_t pr_off
Definition: papi.h:582
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_initialize()

int _papi_hwi_initialize ( DynamicArray_t **  )

◆ _papi_hwi_start_signal()

int _papi_hwi_start_signal ( int  signal,
int  need_context,
int  cidx 
)

Definition at line 403 of file extras.c.

404{
405 struct sigaction action;
406
409 if ( _papi_hwi_using_signal[signal] - 1 ) {
410 INTDBG( "_papi_hwi_using_signal is now %d\n",
413 return ( PAPI_OK );
414 }
415
416 memset( &action, 0x00, sizeof ( struct sigaction ) );
417 action.sa_flags = SA_RESTART;
418 action.sa_sigaction =
419 ( void ( * )( int, siginfo_t *, void * ) ) _papi_hwd[cidx]->
420 dispatch_timer;
421 if ( need_context )
422#if (defined(_BGL) /*|| defined (__bgp__)*/)
423 action.sa_flags |= SIGPWR;
424#else
425 action.sa_flags |= SA_SIGINFO;
426#endif
427
428 INTDBG( "installing signal handler\n" );
429 if ( sigaction( signal, &action, NULL ) < 0 ) {
430 PAPIERROR( "sigaction errno %d", errno );
432 return ( PAPI_ESYS );
433 }
434
435 INTDBG( "_papi_hwi_using_signal[%d] is now %d.\n", signal,
438
439 return ( PAPI_OK );
440}
int errno
int _papi_hwi_using_signal[PAPI_NSIG]
Definition: extras.c:365
#define PAPI_ESYS
Definition: f90papi.h:136
#define INTDBG(format, args...)
Definition: papi_debug.h:66
__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__
#define INTERNAL_LOCK
Definition: papi_internal.h:85
int
Definition: sde_internal.h:89
static void action(void *arg, int regno, const char *name, uint8_t bits)
inline_static int _papi_hwi_lock(int lck)
Definition: threads.h:69
inline_static int _papi_hwi_unlock(int lck)
Definition: threads.h:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_start_timer()

int _papi_hwi_start_timer ( int  timer,
int  signal,
int  ms 
)

Definition at line 368 of file extras.c.

369{
370 struct itimerval value;
371 int us = ns / 1000;
372
373 if ( us == 0 )
374 us = 1;
375
376#ifdef ANY_THREAD_GETS_SIGNAL
378 if ( ( _papi_hwi_using_signal[signal] - 1 ) ) {
379 INTDBG( "itimer already installed\n" );
381 return ( PAPI_OK );
382 }
384#else
385 ( void ) signal; /*unused */
386#endif
387
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;
392
393 INTDBG( "Installing itimer %d, with %d us interval\n", timer, us );
394 if ( setitimer( timer, &value, NULL ) < 0 ) {
395 PAPIERROR( "setitimer errno %d", errno );
396 return ( PAPI_ESYS );
397 }
398
399 return ( PAPI_OK );
400}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_stop_signal()

int _papi_hwi_stop_signal ( int  signal)

Definition at line 443 of file extras.c.

444{
446 if ( --_papi_hwi_using_signal[signal] == 0 ) {
447 INTDBG( "removing signal handler\n" );
448 if ( sigaction( signal, NULL, NULL ) == -1 ) {
449 PAPIERROR( "sigaction errno %d", errno );
451 return ( PAPI_ESYS );
452 }
453 }
454
455 INTDBG( "_papi_hwi_using_signal[%d] is now %d\n", signal,
458
459 return ( PAPI_OK );
460}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _papi_hwi_stop_timer()

int _papi_hwi_stop_timer ( int  timer,
int  signal 
)

Definition at line 463 of file extras.c.

464{
465 struct itimerval value;
466
467#ifdef ANY_THREAD_GETS_SIGNAL
469 if ( _papi_hwi_using_signal[signal] > 1 ) {
470 INTDBG( "itimer in use by another thread\n" );
472 return ( PAPI_OK );
473 }
475#else
476 ( void ) signal; /*unused */
477#endif
478
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;
483
484 INTDBG( "turning off timer\n" );
485 if ( setitimer( timer, &value, NULL ) == -1 ) {
486 PAPIERROR( "setitimer errno %d", errno );
487 return PAPI_ESYS;
488 }
489
490 return PAPI_OK;
491}
Here is the call graph for this function:
Here is the caller graph for this function: