446{
450#ifdef REGENERATE
451 int lastthread;
452#endif
453#ifdef MPX_DEBUG_OVERHEAD
454 long long usec;
455 int didwork = 0;
457#endif
458#ifdef MPX_DEBUG_TIMER
459 long long thiscall;
460#endif
461
463
464 MPXDBG(
"Handler in thread\n" );
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498#ifdef PTHREADS
500
501 if ( threads_responding == 0 ) {
502
503#ifdef MPX_DEBUG_TIMER
504 thiscall = _papi_hwd_get_real_usec( );
505 MPXDBG(
"last signal was %lld usec ago\n", thiscall - lastcall );
506 lastcall = thiscall;
507#endif
508 MPXDBG(
"%#x caught it, tlist is %p\n", self,
tlist );
509 for ( t =
tlist; t != NULL; t = t->
next ) {
510 if ( pthread_equal( t->thr, self ) == 0 ) {
511 ++threads_responding;
514#ifdef MPX_DEBUG_SIGNALS
515 MPXDBG(
"%#x signaling %#x\n", self, t->thr );
516#endif
517 }
518 }
519 } else {
520#ifdef MPX_DEBUG_SIGNALS
521 MPXDBG(
"%#x was tapped, tr = %d\n", self, threads_responding );
522#endif
523 --threads_responding;
524 }
525#ifdef REGENERATE
526 lastthread = ( threads_responding == 0 );
527#endif
529#endif
530
531
533 if ( head != NULL ) {
534
535
536
537
538
540
541
542
543
544
545
546 if ( me != NULL && me->
cur_event != NULL ) {
547 long long counts[2];
549 long long cycles = 0, total_cycles = 0;
550
552 MPXDBG(
"retval=%d, cur_event=%p, I'm tid=%lx\n",
554
556 MPXDBG(
"counts[0] = %lld counts[1] = %lld\n", counts[0],
557 counts[1] );
558
559 cur_event->
count += counts[0];
561 ? counts[0] : counts[1];
562
566
567
569 cur_event->
cycles += cycles;
572 ( double ) counts[0] / ( double ) cycles;
573 }
575 (
long long ) ( (
double ) total_cycles *
577 MPXDBG(
"New estimate = %lld (%lld cycles * %lf rate)\n",
580 } else {
581
582
583
584
587 } else {
588 cur_event->
count -= counts[0];
589 }
590 }
591 } else {
593 MPXDBG(
"%lx value = %lld cycles = %lld\n\n",
595 }
596
598 ( "tid(%lx): value = %lld (%lld) cycles = %lld (%lld) rate = %lf\n\n",
601
602
603
604
605
606
607
610 for ( mev =
611 ( cur_event->
next == NULL ) ? head : cur_event->
next;
612 mev != cur_event;
613 mev = ( mev->
next == NULL ) ? head : mev->
next ) {
614
617 break;
618 }
619 }
620 }
621
624 }
625#ifdef MPX_DEBUG_OVERHEAD
626 didwork = 1;
627#endif
628 }
629 }
630#ifdef ANY_THREAD_GETS_SIGNAL
631 else {
633 for ( t =
tlist; t != NULL; t = t->
next ) {
635 ( t->
head == NULL ) )
636 continue;
637 MPXDBG(
"forwarding signal to thread %lx\n", t->
tid );
640 MPXDBG(
"forwarding signal to thread %lx returned %d\n",
642 }
643 }
644 }
645#endif
646
647#ifdef REGENERATE
648
649
650
651
652
653
654
655
656
657
658
659 if ( lastthread ) {
662#ifdef MPX_DEBUG_TIMER
663 MPXDBG(
"timer restarted by %lx\n", me->
tid );
664#endif
665 }
666#endif
667
668#ifdef MPX_DEBUG_OVERHEAD
669 usec = _papi_hwd_get_real_usec( ) - usec;
670 MPXDBG(
"handler %#x did %swork in %lld usec\n",
671 self, ( didwork ? "" : "no " ), usec );
672#endif
673}
PAPI_os_info_t _papi_os_info
get real time counter value in microseconds
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
__sighandler_t signal(int __sig, __sighandler_t __handler) __attribute__((__nothrow__
int pthread_kill(pthread_t __threadid, int __signo) __attribute__((__nothrow__
struct _threadlist * mythr
struct _masterevent * next
static struct itimerval itime
static MasterEvent * get_my_threads_master_event_list(void)