void hpcrun_process_sample_source_none(void) { sample_source_t *none = &_none_obj; METHOD_CALL(none, process_event_list, 0); if (getenv("SHOW_NONE") && hpcrun_get_disabled()) { static char none_msg[] = "NOTE: sample source NONE is specified\n"; write(2, none_msg, strlen(none_msg)); } }
// // Special NONE protocol: // if event is NONE@xxx, then create log file and process the TMSG logging // if event is just plain NONE, then // no log file or any other evidence of hpcrun // static void METHOD_FN(process_event_list,int lush_metrics) { char *event_str = METHOD_CALL(self,get_event_str); char *none_str = strstr(event_str,"NONE"); if (none_str) { char *use_log = strchr(none_str,'@'); if (use_log == NULL) { hpcrun_set_disabled(); } } }
static void METHOD_FN(shutdown) { METHOD_CALL(self, stop); // make sure stop has been called TMSG(ITIMER_CTL, "shutdown %s", the_event_name); // delete the realtime timer to avoid a timer leak if (use_realtime || use_cputime) { thread_data_t *td = hpcrun_get_thread_data(); hpcrun_delete_real_timer(td); } self->state = UNINIT; }
void hpcrun_sample_sources_from_eventlist(char* evl) { if (evl == NULL) { hpcrun_ssfail_none(); } TMSG(EVENTS,"evl (before processing) = |%s|",evl); for(char *event = start_tok(evl); more_tok(); event = next_tok()){ sample_source_t *s; if (strcasecmp(event, "LIST") == 0) { hpcrun_display_avail_events(); } else if ( (s = hpcrun_source_can_process(event)) ){ add_source(s); METHOD_CALL(s, add_event, event); } else { hpcrun_ssfail_unknown(event); } } }
static int _tst_signal_handler(int sig, siginfo_t* siginfo, void* context) { // If the interrupt came from inside our code, then drop the sample // and return and avoid any MSG. void* pc = hpcrun_context_pc(context); if (! hpcrun_safe_enter_async(pc)) { hpcrun_stats_num_samples_blocked_async_inc(); } else { TMSG(_TST_HANDLER,"_Tst sample event"); uint64_t metric_incr = 1; // default: one time unit #ifdef USE_ELAPSED_TIME_FOR_WALLCLOCK uint64_t cur_time_us; int ret = time_getTimeCPU(&cur_time_us); if (ret != 0) { EMSG("time_getTimeCPU (clock_gettime) failed!"); abort(); } metric_incr = cur_time_us - TD_GET(last_time_us); #endif int metric_id = hpcrun_event2metric(&__tst_obj, _TST_EVENT); hpcrun_sample_callpath_w_bt(context, metric_id, metric_incr, NULL, NULL, 0); } if (hpcrun_is_sampling_disabled()) { TMSG(SPECIAL, "No _tst restart, due to disabled sampling"); return 0; } #ifdef RESET_ITIMER_EACH_SAMPLE METHOD_CALL(&__tst_obj, start); #endif return 0; /* tell monitor that the signal has been handled */ }
static void METHOD_FN(shutdown) { METHOD_CALL(self,stop); // make sure stop has been called self->state = UNINIT; }
static void METHOD_FN(process_event_list, int lush_metrics) { // fetch the event string for the sample source char* _p = METHOD_CALL(self, get_event_str); // // EVENT: Only 1 wallclock event // char* event = start_tok(_p); char name[1024]; // local buffer needed for extract_ev_threshold TMSG(_TST_CTL,"checking event spec = %s",event); // extract event threshold hpcrun_extract_ev_thresh(event, sizeof(name), name, &period, DEFAULT_THRESHOLD); // store event threshold METHOD_CALL(self, store_event, _TST_EVENT, period); TMSG(OPTIONS,"_TST period set to %ld",period); // set up file local variables for sample source control int seconds = period / 1000000; int microseconds = period % 1000000; TMSG(OPTIONS,"init timer w sample_period = %ld, seconds = %ld, usec = %ld", period, seconds, microseconds); // signal once after the given delay itimer.it_value.tv_sec = seconds; itimer.it_value.tv_usec = microseconds; // macros define whether automatic restart or not itimer.it_interval.tv_sec = AUTOMATIC_ITIMER_RESET_SECONDS(seconds); itimer.it_interval.tv_usec = AUTOMATIC_ITIMER_RESET_MICROSECONDS(microseconds); // handle metric allocation hpcrun_pre_allocate_metrics(1 + lush_metrics); int metric_id = hpcrun_new_metric(); METHOD_CALL(self, store_metric_id, _TST_EVENT, metric_id); // set metric information in metric table #ifdef USE_ELAPSED_TIME_FOR_WALLCLOCK # define sample_period 1 #else # define sample_period period #endif TMSG(_TST_CTL, "setting metric _TST, period = %ld", sample_period); hpcrun_set_metric_info_and_period(metric_id, "_TST", MetricFlags_ValFmt_Int, sample_period, metric_property_none); if (lush_metrics == 1) { int mid_idleness = hpcrun_new_metric(); lush_agents->metric_time = metric_id; lush_agents->metric_idleness = mid_idleness; hpcrun_set_metric_info_and_period(mid_idleness, "idleness (ms)", MetricFlags_ValFmt_Real, sample_period, metric_property_none); } event = next_tok(); if (more_tok()) { EMSG("MULTIPLE _TST events detected! Using first event spec: %s"); } }
static void METHOD_FN(process_event_list, int lush_metrics) { char name[1024]; // local buffer needed for extract_ev_threshold TMSG(ITIMER_CTL, "process event list, lush_metrics = %d", lush_metrics); // fetch the event string for the sample source char* evlist = METHOD_CALL(self, get_event_str); char* event = start_tok(evlist); TMSG(ITIMER_CTL,"checking event spec = %s",event); if (hpcrun_ev_is(event, WALLCLOCK_EVENT_NAME)) { #ifdef HOST_SYSTEM_IBM_BLUEGENE use_itimer = true; the_event_name = WALLCLOCK_EVENT_NAME; the_metric_name = WALLCLOCK_METRIC_NAME; the_signal_num = ITIMER_SIGNAL; #else #ifdef ENABLE_CLOCK_CPUTIME use_cputime = true; the_event_name = CPUTIME_EVENT_NAME; the_metric_name = CPUTIME_METRIC_NAME; the_signal_num = REALTIME_SIGNAL; #else EEMSG("Event %s (%s) is not available on this system.", WALLCLOCK_EVENT_NAME, CPUTIME_EVENT_NAME); hpcrun_ssfail_unknown(event); #endif #endif } if (hpcrun_ev_is(event, REALTIME_EVENT_NAME)) { #ifdef ENABLE_CLOCK_REALTIME use_realtime = true; the_event_name = REALTIME_EVENT_NAME; the_metric_name = REALTIME_METRIC_NAME; the_signal_num = REALTIME_SIGNAL; #else EEMSG("Event %s is not available on this system.", REALTIME_EVENT_NAME); hpcrun_ssfail_unknown(event); #endif } if (hpcrun_ev_is(event, CPUTIME_EVENT_NAME)) { #ifdef ENABLE_CLOCK_CPUTIME use_cputime = true; the_event_name = CPUTIME_EVENT_NAME; the_metric_name = CPUTIME_METRIC_NAME; the_signal_num = REALTIME_SIGNAL; #else EEMSG("Event %s is not available on this system.", CPUTIME_EVENT_NAME); hpcrun_ssfail_unknown(event); #endif } if (hpcrun_ev_is(event, ITIMER_EVENT_NAME)) { use_itimer = true; the_event_name = ITIMER_EVENT_NAME; the_metric_name = ITIMER_METRIC_NAME; the_signal_num = ITIMER_SIGNAL; } if (!use_itimer && !use_realtime && !use_cputime) { // should never get here if supports_event is true hpcrun_ssfail_unknown(event); } // extract event threshold hpcrun_extract_ev_thresh(event, sizeof(name), name, &period, DEFAULT_PERIOD); // store event threshold METHOD_CALL(self, store_event, ITIMER_EVENT, period); TMSG(OPTIONS,"wallclock period set to %ld",period); // set up file local variables for sample source control int seconds = period / 1000000; int microseconds = period % 1000000; TMSG(ITIMER_CTL, "init %s sample_period = %ld, seconds = %d, usec = %d", the_event_name, period, seconds, microseconds); itval_start.it_value.tv_sec = seconds; itval_start.it_value.tv_usec = microseconds; itval_start.it_interval.tv_sec = 0; itval_start.it_interval.tv_usec = 0; itspec_start.it_value.tv_sec = seconds; itspec_start.it_value.tv_nsec = 1000 * microseconds; itspec_start.it_interval.tv_sec = 0; itspec_start.it_interval.tv_nsec = 0; // older versions of BG/P incorrectly delivered SIGALRM when // interval is zero. I (krentel) believe this is no longer // necessary, but it can't really hurt. #ifdef HOST_SYSTEM_IBM_BLUEGENE itval_start.it_interval.tv_sec = 3600; itspec_start.it_interval.tv_sec = 3600; #endif memset(&itval_stop, 0, sizeof(itval_stop)); memset(&itspec_stop, 0, sizeof(itspec_stop)); sigemptyset(&timer_mask); sigaddset(&timer_mask, the_signal_num); // handle metric allocation hpcrun_pre_allocate_metrics(1 + lush_metrics); int metric_id = hpcrun_new_metric(); METHOD_CALL(self, store_metric_id, ITIMER_EVENT, metric_id); // set metric information in metric table TMSG(ITIMER_CTL, "setting metric timer period = %ld", sample_period); hpcrun_set_metric_info_and_period(metric_id, the_metric_name, MetricFlags_ValFmt_Int, sample_period, metric_property_time); if (lush_metrics == 1) { int mid_idleness = hpcrun_new_metric(); lush_agents->metric_time = metric_id; lush_agents->metric_idleness = mid_idleness; hpcrun_set_metric_info_and_period(mid_idleness, IDLE_METRIC_NAME, MetricFlags_ValFmt_Real, sample_period, metric_property_time); } event = next_tok(); if (more_tok()) { EEMSG("Can't use multiple timer events in the same run."); hpcrun_ssfail_conflict("timer", event); } }