From 2fdf7e9cbadcc0dceea63fbc5d849bf1ddd203dc Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 19 Apr 2024 15:20:58 +0200 Subject: [PATCH] Remove the runner from the repository It has been moved to an standalone tool at https://github.com/rodarima/bigotes/ --- src/CMakeLists.txt | 1 - src/tools/CMakeLists.txt | 7 - src/tools/config.in.h | 10 -- src/tools/runner.c | 352 --------------------------------------- 4 files changed, 370 deletions(-) delete mode 100644 src/tools/CMakeLists.txt delete mode 100644 src/tools/config.in.h delete mode 100644 src/tools/runner.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b7370b2..2bef695 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ add_subdirectory(bench6) add_subdirectory(ompss2) add_subdirectory(heat) -add_subdirectory(tools) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt deleted file mode 100644 index 34bc51c..0000000 --- a/src/tools/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -get_property(BENCH6_LIST GLOBAL PROPERTY bench6_list) -configure_file(config.in.h config.h) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -add_executable(bigote runner.c) -target_link_libraries(bigote PRIVATE m bench6_lib) -install(TARGETS bigote RUNTIME DESTINATION bin) diff --git a/src/tools/config.in.h b/src/tools/config.in.h deleted file mode 100644 index c5cd9d0..0000000 --- a/src/tools/config.in.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) - * SPDX-License-Identifier: GPL-3.0-or-later */ - -#ifndef CONFIG_H -#define CONFIG_H - -/* Where the benchmark binaries are located */ -#define BENCH6_BENCHDIR "@CMAKE_INSTALL_LIBEXECDIR@" - -#endif /* CONFIG_H */ diff --git a/src/tools/runner.c b/src/tools/runner.c deleted file mode 100644 index 5a08507..0000000 --- a/src/tools/runner.c +++ /dev/null @@ -1,352 +0,0 @@ -#include "bench6.h" -#include "common.h" -#include "config.h" -#include -#include -#include -#include -#include -#include -#include -#include - -static char *progname = "bench6"; - -struct sampling { - long nmax; - long nmin; - long n; - double *samples; - double rsem; - double last; - double wall; - double min_rsem; - const char *name; - double t0; - double min_time; -}; - -static int -do_run(char *argv[], double *ptime) -{ - int ret = 0; - FILE *p = popen(argv[0], "r"); - - if (p == NULL) { - err("popen failed:"); - return -1; - } - - char line[4096]; - if (fgets(line, 4096, p) == NULL) { - err("missing stdout line"); - ret = -1; - goto bad_close; - } - - char *nl = strchr(line, '\n'); - if (nl != NULL) - *nl = '\0'; - - /* Clean status line */ - //fprintf(stderr, "%s\n", line); - - double time; - sscanf(line, "%le", &time); - //printf("got %e\n", time); - *ptime = time; - - /* Drain the rest of the stdout */ - while (fgets(line, 4096, p) != NULL) { - //fprintf(stderr, "%s", line); - } - -bad_close: - pclose(p); - - return ret; -} - -static int -cmp_double(const void *pa, const void *pb) -{ - double a = *(const double *) pa; - double b = *(const double *) pb; - - if (a < b) - return -1; - else if (a > b) - return 1; - else - return 0; -} - -//static void -//resample(double *values, long n, double *out) -//{ -// for (long i = 0; i < n; i++) { -// /* FIXME: Not really uniform */ -// out[i] = values[rand() % n]; -// //printf("out[%ld] = %e\n", i, out[i]); -// } -//} -// -//static double -//mad_bootstrap(double *values, long n) -//{ -// long m = 1000; -// -// double *r = calloc(n, sizeof(double)); -// if (r == NULL) { -// perror("calloc failed"); -// exit(1); -// } -// -// double *absdev = calloc(n, sizeof(double)); -// if (absdev == NULL) { -// perror("calloc failed"); -// exit(1); -// } -// -// double *mad = calloc(m, sizeof(double)); -// if (mad == NULL) { -// perror("calloc failed"); -// exit(1); -// } -// -// for (long sample = 0; sample < m; sample++) { -// resample(values, n, r); -// -// qsort(r, n, sizeof(double), cmp_double); -// double median = r[n / 2]; -// -// for (long i = 0; i < n; i++) { -// absdev[i] = fabs(r[i] - median); -// } -// -// qsort(absdev, n, sizeof(double), cmp_double); -// mad[sample] = absdev[n / 2]; -// //printf("mad[%ld] = %e\n", sample, mad[sample]); -// } -// -// double sum = 0.0; -// for (long i = 0; i < m; i++) -// sum += mad[i]; -// -// double mean = sum / (double) m; -// double sumsqr = 0.0; -// for (long i = 0; i < m; i++) { -// double dev = mad[i] - mean; -// sumsqr += dev * dev; -// } -// -// double var = sumsqr / m; -// double stdev = sqrt(var); -// double sem = stdev / sqrt(m); -// double rsem = 100.0 * sem * 1.96 / mean; -// -// free(mad); -// free(absdev); -// free(r); -// -// return rsem; -//} - -static void -stats(struct sampling *s) -{ - if (s->n < 1) - return; - - long outliers = 0; - double last = s->samples[s->n - 1]; - double median = last; - double mean = last; - double var = NAN; - double stdev = NAN; - double rstdev = NAN; - double sem = NAN; - double rsem = NAN; - double mad = NAN; - //double mad_se = NAN; - double q1 = NAN; - double q3 = NAN; - double iqr = NAN; - double pol = NAN; - double smin = s->samples[s->n - 1]; - double smax = s->samples[s->n - 1]; - - /* Need at least two samples */ - if (s->n >= 2) { - /* Sort samples to take the median */ - qsort(s->samples, s->n, sizeof(double), cmp_double); - - double *absdev = calloc(s->n, sizeof(double)); - if (absdev == NULL) { - perror("calloc failed"); - exit(1); - } - - smin = s->samples[0]; - q1 = s->samples[s->n / 4]; - median = s->samples[s->n / 2]; - q3 = s->samples[(s->n * 3) / 4]; - smax = s->samples[s->n - 1]; - - //qcd = (q3 - q1) / (q3 + q1); - iqr = q3 - q1; - - double sum = 0.0; - for (long i = 0; i < s->n; i++) - sum += s->samples[i]; - - double n = s->n; - mean = sum / n; - double sumsqr = 0.0; - for (long i = 0; i < s->n; i++) { - double x = s->samples[i]; - double dev = x - mean; - sumsqr += dev * dev; - absdev[i] = fabs(s->samples[i] - median); - //printf("absdev[%3ld] = %e\n", i, absdev[i]); - if (x < q1 - 1.5 * iqr || x > q3 + iqr * 1.5) - outliers++; - } - qsort(absdev, s->n, sizeof(double), cmp_double); - mad = absdev[s->n / 2] * 1.4826; - //mad_se = mad_bootstrap(s->samples, s->n); - pol = (double) outliers * 100.0 / n; - - var = sumsqr / n; - stdev = sqrt(var); - rstdev = 100.0 * stdev / mean; - sem = stdev / sqrt(n); - rsem = 100.0 * sem * 1.96 / mean; - s->rsem = rsem; - free(absdev); - } - - /* Print the header at the beginning only */ - if (s->n == 1) { - //printf("# --- bench6 ---\n"); - //printf("# Min %ld runs, max %ld\n", s->nmin, s->nmax); - //printf("# Cutoff %%RSEM value set to %f\n", s->min_rsem); - //printf("# RUN Number of run\n"); - //printf("# LAST Value of last run\n"); - //printf("# MEDIAN Median of values until now\n"); - //printf("# AVG Mean of values until now\n"); - //printf("# SD Standard deviation\n"); - //printf("# %%RSD Relative standard deviation to the mean\n"); - //printf("# %%RSEM Relative standard error of the mean\n"); - printf("%4s %5s" - " %8s %8s %8s %8s %8s" - " %8s %8s %8s" - " %5s %5s" - " %5s\n", - "RUN", "WALL", - "MIN", "Q1", "MEDIAN", "Q3", "MAX", - "MAD", "IQR", "SD", - "%RSD", "%RSEM", - "%OUTLIERS"); - } -//RUN WALL LAST MEDIAN AVG SD %RSD %RSEM -// 89 125.5 5.085e-03 5.075e-03 5.303e-03 3.500e-03 66.00 7.611 -//RUN WALL LAST MEDIAN AVG SD %RSD %RSEM -// 34 3.0 5.110e-03 5.097e-03 5.121e-03 1.327e-04 2.59 0.87 - printf( - "\r%4ld %5.1f" - " %8.2e %8.2e %8.2e %8.2e %8.2e" - " %8.2e %8.2e %8.2e" - " %5.2f %5.2f" - " %5.1f ", - s->n, s->wall, /* progress */ - smin, q1, median, q3, smax, /* centrality */ - mad, iqr, stdev, /* dispersion */ - rstdev, rsem, /* rel. dispersion */ - pol /* outliers */ - ); - fflush(stdout); -} - -static int -should_continue(struct sampling *s) -{ - stats(s); - - if (s->n < s->nmin) - return 1; - - if (s->rsem > s->min_rsem) - return 1; - - double dt = bench6_time() - s->t0; - if (dt < s->min_time) - return 1; - - return 0; -} - -static void -add_sample(struct sampling *s, double metric, double walltime) -{ - if (s->n >= s->nmax) { - die("overflowing samples"); - } else { - s->samples[s->n] = metric; - s->n++; - s->last = metric; - s->wall += walltime; - } -} - -static int -sample(char *argv[]) -{ - struct sampling s = { 0 }; - s.nmax = 4000; - s.nmin = 50; - s.min_rsem = 0.5; - s.min_time = 60.0; /* At least one minute */ - s.samples = calloc(s.nmax, sizeof(double)); - s.n = 0; - s.name = argv[0]; - s.t0 = bench6_time(); - - while (should_continue(&s)) { - double t0 = bench6_time(); - double metric; - if (do_run(argv, &metric) != 0) { - err("failed to run benchmark"); - return 1; - } - double t1 = bench6_time(); - double walltime = t1 - t0; - - add_sample(&s, metric, walltime); - } - - fprintf(stdout, "\n"); - - free(s.samples); - - return 0; -} - -int -main(int argc, char *argv[]) -{ - progname_set(progname); - (void) argc; - - //while (argc && argv && strcmp(argv, "--") != 0) { - // argv++; - // argc--; - //} - - if (sample(argv+1) != 0) { - err("failed to sample the benchmark"); - return 1; - } - - return 0; -}