721 {
722
726 int i,
cidx,
retval, isHardware, slow_down, speed_up;
727 int found_registered_counters, period_has_changed = 0;
729 struct itimerspec its;
730 long long overflow_vector = 0;
732
733 (void) n;
734
735 SUBDBG(
"SDE timer expired. Dispatching (papi internal) overflow handler\n");
736
739
741
744
747 return;
748
749 slow_down = 0;
750 speed_up = 0;
751 found_registered_counters = 0;
752
753
754 for (
i = 0;
i < event_counter;
i++ ) {
756 long long deadline,
threshold, latest, previous, diff;
757
758 uint32_t counter_uniq_id = sde_ctl->
which_counter[papi_index];
759 if( !sde_ti_is_simple_counter_ptr( counter_uniq_id ) )
760 continue;
761
762 found_registered_counters = 1;
763
764 latest = ESI->
sw_stop[papi_index];
767
768
770
771
772
773 diff = latest-previous;
774
775
776
778 slow_down = 1;
780 speed_up = 1;
781 }
782
783
785
786
787 if ( latest >= deadline ) {
788
789
790
792 SUBDBG (
"Event at index %d (and pos %d) has value %lld which exceeds deadline %lld (threshold %lld, accuracy %.2lf)\n",
793 papi_index, pos, latest, deadline,
threshold, 100.0*(
double)(latest-deadline)/(
double)
threshold);
794
795 overflow_vector ^= (
long long ) 1 << pos;
796
798 }
799 }
800
801 if( !found_registered_counters && sde_ctl->
has_timer ){
802 struct itimerspec zero_time;
803 memset(&zero_time, 0, sizeof(struct itimerspec));
804 if (timer_settime(sde_ctl->
timerid, 0, &zero_time, NULL) == -1){
806 timer_delete(sde_ctl->
timerid);
808 return;
809 }
810 goto no_change_in_period;
811 }
812
813
814
815 if( speed_up )
816 slow_down = 0;
817
818
819 if( !speed_up && !slow_down )
820 goto no_change_in_period;
821
823 goto no_change_in_period;
824
825
826 if( timer_gettime(sde_ctl->
timerid, &its) == -1){
827 PAPIERROR(
"timer_gettime() failed. Timer will not be modified.\n");
828 goto no_change_in_period;
829 }
830
831 period_has_changed = 0;
832
833 if( speed_up && (its.it_interval.tv_nsec > 131607) ){
834 double new_val = (double)its.it_interval.tv_nsec;
835 new_val /= 1.31607;
836 its.it_value.tv_nsec = (int)new_val;
837 its.it_interval.tv_nsec = its.it_value.tv_nsec;
838 period_has_changed = 1;
839 SUBDBG (
"Timer will be sped up to %ld ns\n", its.it_value.tv_nsec);
840 }
841
842
843 if( slow_down && (its.it_interval.tv_nsec < 75983800) ){
844 double new_val = (double)its.it_interval.tv_nsec;
845 new_val *= 1.31607;
846 its.it_value.tv_nsec = (int)new_val;
847 its.it_interval.tv_nsec = its.it_value.tv_nsec;
848 period_has_changed = 1;
849 SUBDBG (
"Timer will be slowed down to %ld ns\n", its.it_value.tv_nsec);
850 }
851
852 if( !period_has_changed )
853 goto no_change_in_period;
854
855 if (timer_settime(sde_ctl->
timerid, 0, &its, NULL) == -1){
856 PAPIERROR(
"timer_settime() failed when modifying PAPI internal timer. This might have broken overflow support for this eventset.\n");
857 goto no_change_in_period;
858 }
859
860no_change_in_period:
861
862
863 if( 0 == overflow_vector ){
864 return;
865 }
866
868 PAPIERROR(
"_sde_dispatch_timer(): 'Can not access overflow flags'");
869 return;
870 }
871
872 hw_context.
si = info;
874
876
877 int genOverflowBit = 0;
878
880
881 return;
882}
#define GET_OVERFLOW_ADDRESS(ctx)
#define SUBDBG(format, args...)
void PAPIERROR(char *format,...)
int _papi_hwi_read(hwd_context_t *context, EventSetInfo_t *ESI, long long *values)
papi_vector_t _sde_vector
int pos[PAPI_EVENTS_IN_DERIVED_EVENT]
EventInfo_t * EventInfoArray
hwd_control_state_t * ctl_state
EventSetOverflowInfo_t overflow
hwd_ucontext_t * ucontext
PAPI_component_info_t cmp_info
uint32_t which_counter[SDE_MAX_SIMULTANEOUS_COUNTERS]
long long previous_value[SDE_MAX_SIMULTANEOUS_COUNTERS]
inline_static ThreadInfo_t * _papi_hwi_lookup_thread(int custom_tid)