/* * report_write_pt2pttest_exectime: Write execution times of the point-to-point * operation to the report. */ int report_write_pt2pttest_exectime(bench_t *bench, double *exectime, int nruns, int ncorrectruns) { double exectime_mean, exectime_stderr, exectime_rse, exectime_min, exectime_max, exectime_errrel; double exectime_ci_lb = 0.0, exectime_ci_ub = 0.0, exectime_err = 0.0; int nresultruns = 0; stats_sample_t *sample = NULL; const char *fmt = NULL; double timescale = 0; if (mpiperf_timescale == MPIPERF_TIMESCALE_SEC) { fmt = "%-13d %-7d %-7d %-7d %-12.6f %-10.2f %-12.6f %-12.6f %-12.6f" "%-12.6f %-12.6f %-12.6f %-10.2f\n"; timescale = 1.0; } else { /* usec */ fmt = "%-13d %-7d %-7d %-7d %-14.2f %-10.2f %-14.2f %-14.2f %-14.2f" "%-14.2f %-14.2f %-14.2f %-10.2f\n"; timescale = 1E6; } if (!IS_MASTER_RANK) { return MPIPERF_SUCCESS; } if (ncorrectruns == 0) { printf(fmt, bench->paramseq_getcurrent(bench), nruns, 0, 0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); return MPIPERF_SUCCESS; } /* Remove outliers */ nresultruns = ncorrectruns; if (mpiperf_statanalysis) { /* Remove 25% of minimal values and 25% of maximal values */ nresultruns = stats_dataset_remove_extreme(exectime, ncorrectruns, OUTLIERS_FILTER_MIN, OUTLIERS_FILTER_MAX); } if ( (sample = stats_sample_create()) == NULL) { return MPIPERF_FAILURE; } stats_sample_add_dataset(sample, exectime, nresultruns); exectime_mean = stats_sample_mean(sample) * timescale; exectime_stderr = stats_sample_stderr(sample) * timescale; exectime_rse = stats_sample_stderr_rel(sample); exectime_min = stats_sample_min(sample) * timescale; exectime_max = stats_sample_max(sample) * timescale; /* Build confidence interval */ stats_sample_confidence_interval(sample, confidence_level_type, &exectime_ci_lb, &exectime_ci_ub, &exectime_err); exectime_ci_lb *= timescale; exectime_ci_ub *= timescale; exectime_err *= timescale; exectime_errrel = (exectime_err > 0.0) ? exectime_err / exectime_mean : 0.0; printf(fmt, bench->paramseq_getcurrent(bench), nruns, ncorrectruns, nresultruns, exectime_mean, exectime_rse, exectime_stderr, exectime_min, exectime_max, exectime_err, exectime_ci_lb, exectime_ci_ub, exectime_errrel); stats_sample_free(sample); return MPIPERF_SUCCESS; }
int main(int argc, char **argv) { struct context ctx = {0}; struct event *signal_int; struct evhttp_bound_socket *handle; char listen_addr[256]; if (argc != 2) { printf("usage: statsrv STATS\n"); return -1; } if (stats_cl_create(&ctx.cl) != S_OK) { printf("Failed to allocate stats counter list\n"); return ERROR_FAIL; } if (stats_sample_create(&ctx.sample) != S_OK) { printf("Failed to allocate stats sample\n"); return ERROR_FAIL; } if (stats_sample_create(&ctx.prev_sample) != S_OK) { printf("Failed to allocate stats sample\n"); return ERROR_FAIL; } ctx.stats = open_stats(argv[1]); if (!ctx.stats) { printf("Failed to open stats %s\n", argv[1]); return ERROR_FAIL; } ctx.base = event_base_new(); if (!ctx.base) { printf("Could not allocate event base\n"); return 1; } /* add a handler for SIGINT */ signal_int = evsignal_new(ctx.base, SIGINT, sigint_cb, event_self_cbarg()); evsignal_add(signal_int,0); /* Create a new evhttp object to handle requests. */ ctx.http = evhttp_new(ctx.base); if (!ctx.http) { printf("could not create evhttp.\n"); return ERROR_FAIL; } evhttp_set_gencb(ctx.http, http_request_cb, &ctx); /* Now we tell the evhttp what port to listen on */ handle = evhttp_bind_socket_with_handle(ctx.http, "0.0.0.0", 8080); if (!handle) { printf("couldn't bind to http port %d.\n", (int)8080); return ERROR_FAIL; } if (http_get_address(handle, listen_addr, sizeof(listen_addr)) == S_OK) printf("http: listening at %s\n", listen_addr); event_base_dispatch(ctx.base); event_free(signal_int); #if 0 start_time = current_time(); while (!signal_received) { err = stats_get_sample(stats,cl,sample); if (err != S_OK) { printf("Error %08x (%s) getting sample\n",err,error_message(err)); } clear(); sample_time = TIME_DELTA_TO_NANOS(start_time, sample->sample_time); mvprintw(0,0,"SAMPLE @ %6lld.%03llds SEQ:%d\n", sample_time / 1000000000ll, (sample->sample_time % 1000000000ll) / 1000000ll, sample->sample_seq_no); n = 1; maxy = getmaxy(stdscr); col = 0; for (j = 0; j < cl->cl_count; j++) { counter_get_key(cl->cl_ctr[j],counter_name,MAX_COUNTER_KEY_LENGTH+1); mvprintw(n,col+0,"%s", counter_name); mvprintw(n,col+29,"%15lld", stats_sample_get_value(sample,j)); mvprintw(n,col+46,"%15lld", stats_sample_get_delta(sample,prev_sample,j)); if (++n == maxy) { col += 66; n = 1; } } refresh(); tmp = prev_sample; prev_sample = sample; sample = tmp; FD_ZERO(&fds); FD_SET(0,&fds); now = current_time(); tv.tv_sec = 0; tv.tv_usec = 1000000 - (now % 1000000000) / 1000; ret = select(1, &fds, NULL, NULL, &tv); if (ret == 1) { ch = getch(); if (ch == 'c' || ch == 'C') { stats_reset_counters(stats); } } } close_screen(); #endif if (ctx.base) event_base_free(ctx.base); if (ctx.http) evhttp_free(ctx.http); if (ctx.stats) { stats_close(ctx.stats); stats_free(ctx.stats); } if (ctx.cl) stats_cl_free(ctx.cl); if (ctx.sample) stats_sample_free(ctx.sample); if (ctx.prev_sample) stats_sample_free(ctx.prev_sample); return 0; }
/* * report_write_colltest_synctime: Write execution times of the collective * operation to the report. */ int report_write_colltest_synctime(bench_t *bench, double *exectime_local, int nruns, int ncorrectruns) { double *exectime = NULL; double exectime_mean, exectime_stderr, exectime_rse, exectime_min, exectime_max, exectime_errrel; double exectime_ci_lb = 0.0, exectime_ci_ub = 0.0, exectime_err = 0.0; int nresultruns = 0; stats_sample_t *sample = NULL; const char *fmt = NULL; double timescale = 0; if (mpiperf_timescale == MPIPERF_TIMESCALE_SEC) { fmt = "%-13d %-7d %-7d %-7d %-12.6f %-10.2f %-12.6f %-12.6f %-12.6f" "%-12.6f %-12.6f %-12.6f %-10.2f\n"; timescale = 1.0; } else { /* usec */ fmt = "%-13d %-7d %-7d %-7d %-14.2f %-10.2f %-14.2f %-14.2f %-14.2f" "%-14.2f %-14.2f %-14.2f %-10.2f\n"; timescale = 1E6; } if (ncorrectruns == 0 && IS_MASTER_RANK) { printf(fmt, bench->paramseq_getcurrent(bench), nruns, 0, 0, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0, 0.0); return MPIPERF_SUCCESS; } if (IS_MASTER_RANK) { exectime = xmalloc(sizeof(*exectime) * ncorrectruns); } /* * Gather maximum time on all processes for each repetition; * T_mem = O(ncorrectruns) */ MPI_Reduce(exectime_local, exectime, ncorrectruns, MPI_DOUBLE, MPI_MAX, mpiperf_master_rank, bench->getcomm(bench)); if (IS_MASTER_RANK) { if ( (sample = stats_sample_create()) == NULL) { free(exectime); return MPIPERF_FAILURE; } /* Remove outliers */ nresultruns = ncorrectruns; if (mpiperf_statanalysis) { /* Remove 25% of minimal values and 25% of maximal values */ nresultruns = stats_dataset_remove_extreme(exectime, ncorrectruns, OUTLIERS_FILTER_MIN, OUTLIERS_FILTER_MAX); } stats_sample_add_dataset(sample, exectime, nresultruns); exectime_mean = stats_sample_mean(sample) * timescale; exectime_stderr = stats_sample_stderr(sample) * timescale; exectime_rse = stats_sample_stderr_rel(sample); exectime_min = stats_sample_min(sample) * timescale; exectime_max = stats_sample_max(sample) * timescale; /* Build confidence interval */ stats_sample_confidence_interval(sample, confidence_level_type, &exectime_ci_lb, &exectime_ci_ub, &exectime_err); exectime_ci_lb *= timescale; exectime_ci_ub *= timescale; exectime_err *= timescale; exectime_errrel = (exectime_err > 0.0) ? exectime_err / exectime_mean : 0.0; printf(fmt, bench->paramseq_getcurrent(bench), nruns, ncorrectruns, nresultruns, exectime_mean, exectime_rse, exectime_stderr, exectime_min, exectime_max, exectime_err, exectime_ci_lb, exectime_ci_ub, exectime_errrel); stats_sample_free(sample); } if (IS_MASTER_RANK) { free(exectime); } return MPIPERF_SUCCESS; }