예제 #1
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  (void)FillY;
  (void)RealScaleY;
  (void)ImagScaleY;
  (void)incY;
  int rc = 0;
  int i, j;

  util_random_seed();

  int nprocs;
  int rank;
  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  RMPI_Init();

  double *X = util_dvec_alloc(N, incX);
  double *Y = util_dvec_alloc(N, incX);
  double *IY = util_dvec_alloc(N * binned_dbnum(DEFAULT_FOLD), incX);
  double *IX = util_dvec_alloc(N * binned_dbnum(DEFAULT_FOLD), incX);

  //fill X
  util_dvec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);

  time_tic();
  for(i = 0; i < trials; i++){
    for (j = 0; j < N; j++){
      binned_dbdconv(DEFAULT_FOLD, X[j], IX + j * binned_dbnum(DEFAULT_FOLD));
    }
    MPI_Reduce(IX, IY, N, MPI_IDOUBLE, MPI_RSUM, 0, MPI_COMM_WORLD);
    if(rank == 0){
      for(j = 0; j < N; j++){
        Y[j] = binned_ddbconv(DEFAULT_FOLD, IY + j * binned_dbnum(DEFAULT_FOLD));
      }
    }
  }
  time_toc();

  if(rank == 0){
    metric_load_double("time", time_read());
    metric_load_long_long("trials", (long long)trials);
    metric_load_long_long("input", (long long)1 * N);
    metric_load_long_long("output", (long long)1);
    metric_load_long_long("d_add", (long long)N);
    metric_load_long_long("d_orb", (long long)N);
    metric_dump();
  }

  MPI_Finalize();

  free(X);
  free(Y);
  return rc;
}
예제 #2
0
int bench_matvec_fill_test(int argc, char** argv, char Order, char TransA, int M, int N, double RealAlpha, double ImagAlpha, int FillA, double RealScaleA, double ImagScaleA, int lda, int FillX, double RealScaleX, double ImagScaleX, int incX, double RealBeta, double ImagBeta, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  int rc = 0;
  int i = 0;

  util_random_seed();
  int NX;
  int NY;
  switch(TransA){
    case 'n':
    case 'N':
      NX = N;
      NY = M;
    break;
    default:
      NX = M;
      NY = N;
    break;
  }

  double *A  = util_dmat_alloc(Order, M, N, lda);
  double *X  = util_dvec_alloc(NX, incX);
  double *Y  = util_dvec_alloc(NY, incY);
  double alpha = RealAlpha;
  double beta = RealBeta;

  util_dmat_fill(Order, 'n', M, N, A, lda, FillA, RealScaleA, ImagScaleA);
  util_dvec_fill(NX, X, incX, FillX, RealScaleX, ImagScaleX);
  util_dvec_fill(NY, Y, incY, FillY, RealScaleY, ImagScaleY);
  double *res  = (double*)malloc(NY * incY * sizeof(double));

  for(i = 0; i < trials; i++){
    memcpy(res, Y, NY * incY * sizeof(double));
    time_tic();
    CALL_DGEMV(Order, TransA, M, N, alpha, A, lda, X, incX, beta, res, incY);
    time_toc();
  }

  double dN = (double)N;
  double dM = (double)M;
  double dNY = (double)NY;
  metric_load_double("time", time_read());
  metric_load_double("trials", (double)(trials));
  metric_load_double("input", dN * dM + dN + dM);
  metric_load_double("output", dNY);
  metric_load_double("normalizer", dN * dM);
  metric_load_double("d_fma", dN * dM);
  metric_dump();

  free(A);
  free(X);
  free(Y);
  free(res);
  return rc;
}
예제 #3
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  (void)FillY;
  (void)RealScaleY;
  (void)ImagScaleY;
  (void)incY;
  int rc = 0;
  int i;
  int k;
  double res = 0.0;
  double_binned *ires;

  bench_dbdbadd_options_initialize();
  opt_eval_option(argc, argv, &fold);

  util_random_seed();

  double *preX = util_dvec_alloc(N * preN._int.value, incX);
  double_binned *X;

  //fill x
  util_dvec_fill(N * preN._int.value, preX, incX, FillX, RealScaleX, ImagScaleX);

  X = (double_binned*)util_dvec_alloc(N * binned_dbnum(fold._int.value), 1);
  memset(X, 0, N * binned_dbsize(fold._int.value));
  for(i = 0; i < N; i++){
    binnedBLAS_dbdsum(fold._int.value, preN._int.value, preX + i * preN._int.value * incX, incX, X + i * binned_dbnum(fold._int.value));
  }
  ires = binned_dballoc(fold._int.value);
  time_tic();
  for(i = 0; i < trials; i++){
    binned_dbsetzero(fold._int.value, ires);
    for(k = 0; k < N; k++){
      binned_dbdbadd(fold._int.value, X + k * binned_dbnum(fold._int.value), ires);
    }
    res = binned_ddbconv(fold._int.value, ires);
  }
  time_toc();
  free(ires);
  free(X);

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_double("res", res);
  metric_load_double("trials", (double)trials);
  metric_load_double("input", dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_dump();

  free(preX);
  return rc;
}
예제 #4
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  (void)FillY;
  (void)RealScaleY;
  (void)ImagScaleY;
  (void)incY;
  int rc = 0;
  int i, j;
  double complex res = 0.0;

  util_random_seed();

  double complex *X = util_zvec_alloc(N, incX);

  //fill X
  util_zvec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);

  if(incX == 1){
    time_tic();
    for(i = 0; i < trials; i++){
      res = 0;
      for(j = 0; j < N; j++){
        res += X[j];
      }
    }
    time_toc();
  }else{
    time_tic();
    for(i = 0; i < trials; i++){
      res = 0;
      for(j = 0; j < N; j++){
        res += X[j * incX];
      }
    }
    time_toc();
  }

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_double("res_real", creal(res));
  metric_load_double("res_imag", cimag(res));
  metric_load_double("trials", (double)trials);
  metric_load_double("input", dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_load_double("d_add", 2.0 * dN);
  metric_dump();

  free(X);
  return rc;
}
예제 #5
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  (void)FillY;
  (void)RealScaleY;
  (void)ImagScaleY;
  (void)incY;
  int rc = 0;
  int i;
  float complex res = 0.0;

  bench_rcsum_options_initialize();
  opt_eval_option(argc, argv, &fold);

  util_random_seed();

  float complex *X = util_cvec_alloc(N, incX);

  //fill x
  util_cvec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);

  time_tic();
  for(i = 0; i < trials; i++){
    reproBLAS_rcsum_sub(fold._int.value, N, X, incX, &res);
  }
  time_toc();

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_float("res_real", crealf(res));
  metric_load_float("res_imag", cimagf(res));
  metric_load_double("trials", (double)trials);
  metric_load_double("input", dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_load_double("s_add", (3 * fold._int.value - 2) * 2.0 * dN);
  metric_load_double("s_orb", fold._int.value * 2.0 * dN);
  metric_dump();

  free(X);
  return rc;
}
예제 #6
0
파일: main.c 프로젝트: hreinecke/s390-tools
void setup_history()
{
	/*
	 * The /proc file size will vary during intervals, use double of current
	 * size to have enough buffer for growing values.
	 */
	meminfo_size = proc_read_size("/proc/meminfo") * 2;
	vmstat_size = proc_read_size("/proc/vmstat") * 2;
	cpustat_size = CPUSTAT_SIZE;

	meminfo = malloc(meminfo_size * (history_max + 1));
	if (!meminfo)
		cpuplugd_exit("Out of memory: meminfo\n");
	vmstat = malloc(vmstat_size * (history_max + 1));
	if (!vmstat)
		cpuplugd_exit("Out of memory: vmstat\n");
	cpustat = malloc(cpustat_size * (history_max + 1));
	if (!cpustat)
		cpuplugd_exit("Out of memory: cpustat\n");
	timestamps = malloc(sizeof(double) * (history_max + 1));
	if (!timestamps)
		cpuplugd_exit("Out of memory: timestamps\n");

	/*
	 * Read history data, at least 1 interval for swaprate, apcr, idle, etc.
	 */
	history_current = 0;
	cpuplugd_info("Waiting %i intervals to accumulate history.\n",
		      history_max);
	do {
		time_read(&timestamps[history_current]);
		proc_read(meminfo + history_current * meminfo_size,
			  "/proc/meminfo", meminfo_size);
		proc_read(vmstat + history_current * vmstat_size,
			  "/proc/vmstat", vmstat_size);
		proc_cpu_read(cpustat + history_current * cpustat_size);
		sleep(cfg.update);
		history_current++;
	} while (history_current < history_max);
	history_current--;
}
예제 #7
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  int rc = 0;
  int i;

  float complex res = 0.0;

  util_random_seed();

  float complex *X = util_cvec_alloc(N, incX);
  float complex *Y = util_cvec_alloc(N, incY);

  //fill X and Y
  util_cvec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);
  util_cvec_fill(N, Y, incY, FillY, RealScaleY, ImagScaleY);

  time_tic();
  for(i = 0; i < trials; i++){
    binnedBLAS_camaxm_sub(N, X, incX, Y, incY, &res);
  }
  time_toc();

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_float("res_real", crealf(res));
  metric_load_float("res_imag", cimagf(res));
  metric_load_double("trials", (double)trials);
  metric_load_double("input", 2.0 * dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_load_double("s_mul", 4.0 * dN);
  metric_load_double("s_cmp", 4.0 * dN);
  metric_load_double("s_orb", 4.0 * dN);
  metric_dump();

  free(X);
  free(Y);
  return rc;
}
예제 #8
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)FillY;
  (void)RealScaleY;
  (void)ImagScaleY;
  (void)incY;
  int rc = 0;
  int i;
  double res = 0.0;

  bench_rdnrm2_options_initialize();
  opt_eval_option(argc, argv, &fold);

  util_random_seed();

  double *X = util_dvec_alloc(N, incX);

  //fill X
  util_dvec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);

  time_tic();
  for(i = 0; i < trials; i++){
    res = reproBLAS_rdnrm2(fold._int.value, N, X, incX);
  }
  time_toc();

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_double("res", res);
  metric_load_double("trials", (double)trials);
  metric_load_double("input", dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_load_double("d_mul", 2.0 * dN);
  metric_load_double("d_add", (3 * fold._int.value - 2) * dN);
  metric_load_double("d_orb", fold._int.value * dN);
  metric_dump();

  free(X);
  return rc;
}
예제 #9
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  int rc = 0;
  int i;
  double res = 0.0;

  util_random_seed();

  double *X = util_dvec_alloc(N, incX);
  double *Y = util_dvec_alloc(N, incY);

  //fill X and Y
  util_dvec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);
  util_dvec_fill(N, Y, incY, FillY, RealScaleY, ImagScaleY);

  time_tic();
  for(i = 0; i < trials; i++){
    res = binnedBLAS_damaxm(N, X, incX, Y, incY);
  }
  time_toc();

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_double("res", res);
  metric_load_double("trials", (double)trials);
  metric_load_double("input", 2.0 * dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_load_double("d_mul", dN);
  metric_load_double("d_cmp", dN);
  metric_load_double("d_orb", dN);
  metric_dump();

  free(X);
  free(Y);
  return rc;
}
예제 #10
0
int bench_vecvec_fill_test(int argc, char** argv, int N, int FillX, double RealScaleX, double ImagScaleX, int incX, int FillY, double RealScaleY, double ImagScaleY, int incY, int trials){
  (void)argc;
  (void)argv;
  (void)FillY;
  (void)RealScaleY;
  (void)ImagScaleY;
  (void)incY;
  int rc = 0;
  int i;
  float res = 0.0;

  util_random_seed();

  float *X = util_svec_alloc(N, incX);

  //fill X
  util_svec_fill(N, X, incX, FillX, RealScaleX, ImagScaleX);

  time_tic();
  for(i = 0; i < trials; i++){
    CALL_SASUM(res, N, X, incX);
  }
  time_toc();

  double dN = (double)N;
  metric_load_double("time", time_read());
  metric_load_float("res", res);
  metric_load_double("trials", (double)trials);
  metric_load_double("input", dN);
  metric_load_double("output", 1.0);
  metric_load_double("normalizer", dN);
  metric_load_double("s_add", dN);
  metric_load_double("s_orb", dN);
  metric_dump();

  free(X);
  return rc;
}
예제 #11
0
int
locfile_read (struct localedef_t *result, const struct charmap_t *charmap)
{
    const char *filename = result->name;
    const char *repertoire_name = result->repertoire_name;
    int locale_mask = result->needed & ~result->avail;
    struct linereader *ldfile;
    int not_here = ALL_LOCALES;

    /* If no repertoire name was specified use the global one.  */
    if (repertoire_name == NULL)
        repertoire_name = repertoire_global;

    /* Open the locale definition file.  */
    ldfile = lr_open (filename, locfile_hash);
    if (ldfile == NULL)
    {
        if (filename != NULL && filename[0] != '/')
        {
            char *i18npath = getenv ("I18NPATH");
            if (i18npath != NULL && *i18npath != '\0')
            {
                const size_t pathlen = strlen (i18npath);
                char i18npathbuf[pathlen + 1];
                char path[strlen (filename) + 1 + pathlen
                          + sizeof ("/locales/") - 1];
                char *next;
                i18npath = memcpy (i18npathbuf, i18npath, pathlen + 1);

                while (ldfile == NULL
                        && (next = strsep (&i18npath, ":")) != NULL)
                {
                    stpcpy (stpcpy (stpcpy (path, next), "/locales/"), filename);

                    ldfile = lr_open (path, locfile_hash);

                    if (ldfile == NULL)
                    {
                        stpcpy (stpcpy (path, next), filename);

                        ldfile = lr_open (path, locfile_hash);
                    }
                }
            }

            /* Test in the default directory.  */
            if (ldfile == NULL)
            {
                char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)];

                stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename);
                ldfile = lr_open (path, locfile_hash);
            }
        }

        if (ldfile == NULL)
            return 1;
    }

    /* Parse locale definition file and store result in RESULT.  */
    while (1)
    {
        struct token *now = lr_token (ldfile, charmap, NULL, NULL, verbose);
        enum token_t nowtok = now->tok;
        struct token *arg;

        if (nowtok == tok_eof)
            break;

        if (nowtok == tok_eol)
            /* Ignore empty lines.  */
            continue;

        switch (nowtok)
        {
        case tok_escape_char:
        case tok_comment_char:
            /* We need an argument.  */
            arg = lr_token (ldfile, charmap, NULL, NULL, verbose);

            if (arg->tok != tok_ident)
            {
                SYNTAX_ERROR (_("bad argument"));
                continue;
            }

            if (arg->val.str.lenmb != 1)
            {
                lr_error (ldfile, _("\
argument to `%s' must be a single character"),
                          nowtok == tok_escape_char
                          ? "escape_char" : "comment_char");

                lr_ignore_rest (ldfile, 0);
                continue;
            }

            if (nowtok == tok_escape_char)
                ldfile->escape_char = *arg->val.str.startmb;
            else
                ldfile->comment_char = *arg->val.str.startmb;
            break;

        case tok_repertoiremap:
            /* We need an argument.  */
            arg = lr_token (ldfile, charmap, NULL, NULL, verbose);

            if (arg->tok != tok_ident)
            {
                SYNTAX_ERROR (_("bad argument"));
                continue;
            }

            if (repertoire_name == NULL)
            {
                char *newp = alloca (arg->val.str.lenmb + 1);

                *((char *) mempcpy (newp, arg->val.str.startmb,
                                    arg->val.str.lenmb)) = '\0';
                repertoire_name = newp;
            }
            break;

        case tok_lc_ctype:
            ctype_read (ldfile, result, charmap, repertoire_name,
                        (locale_mask & CTYPE_LOCALE) == 0);
            result->avail |= locale_mask & CTYPE_LOCALE;
            not_here ^= CTYPE_LOCALE;
            continue;

        case tok_lc_collate:
            collate_read (ldfile, result, charmap, repertoire_name,
                          (locale_mask & COLLATE_LOCALE) == 0);
            result->avail |= locale_mask & COLLATE_LOCALE;
            not_here ^= COLLATE_LOCALE;
            continue;

        case tok_lc_monetary:
            monetary_read (ldfile, result, charmap, repertoire_name,
                           (locale_mask & MONETARY_LOCALE) == 0);
            result->avail |= locale_mask & MONETARY_LOCALE;
            not_here ^= MONETARY_LOCALE;
            continue;

        case tok_lc_numeric:
            numeric_read (ldfile, result, charmap, repertoire_name,
                          (locale_mask & NUMERIC_LOCALE) == 0);
            result->avail |= locale_mask & NUMERIC_LOCALE;
            not_here ^= NUMERIC_LOCALE;
            continue;

        case tok_lc_time:
            time_read (ldfile, result, charmap, repertoire_name,
                       (locale_mask & TIME_LOCALE) == 0);
            result->avail |= locale_mask & TIME_LOCALE;
            not_here ^= TIME_LOCALE;
            continue;

        case tok_lc_messages:
            messages_read (ldfile, result, charmap, repertoire_name,
                           (locale_mask & MESSAGES_LOCALE) == 0);
            result->avail |= locale_mask & MESSAGES_LOCALE;
            not_here ^= MESSAGES_LOCALE;
            continue;

        case tok_lc_paper:
            paper_read (ldfile, result, charmap, repertoire_name,
                        (locale_mask & PAPER_LOCALE) == 0);
            result->avail |= locale_mask & PAPER_LOCALE;
            not_here ^= PAPER_LOCALE;
            continue;

        case tok_lc_name:
            name_read (ldfile, result, charmap, repertoire_name,
                       (locale_mask & NAME_LOCALE) == 0);
            result->avail |= locale_mask & NAME_LOCALE;
            not_here ^= NAME_LOCALE;
            continue;

        case tok_lc_address:
            address_read (ldfile, result, charmap, repertoire_name,
                          (locale_mask & ADDRESS_LOCALE) == 0);
            result->avail |= locale_mask & ADDRESS_LOCALE;
            not_here ^= ADDRESS_LOCALE;
            continue;

        case tok_lc_telephone:
            telephone_read (ldfile, result, charmap, repertoire_name,
                            (locale_mask & TELEPHONE_LOCALE) == 0);
            result->avail |= locale_mask & TELEPHONE_LOCALE;
            not_here ^= TELEPHONE_LOCALE;
            continue;

        case tok_lc_measurement:
            measurement_read (ldfile, result, charmap, repertoire_name,
                              (locale_mask & MEASUREMENT_LOCALE) == 0);
            result->avail |= locale_mask & MEASUREMENT_LOCALE;
            not_here ^= MEASUREMENT_LOCALE;
            continue;

        case tok_lc_identification:
            identification_read (ldfile, result, charmap, repertoire_name,
                                 (locale_mask & IDENTIFICATION_LOCALE) == 0);
            result->avail |= locale_mask & IDENTIFICATION_LOCALE;
            not_here ^= IDENTIFICATION_LOCALE;
            continue;

        default:
            SYNTAX_ERROR (_("\
syntax error: not inside a locale definition section"));
            continue;
        }

        /* The rest of the line must be empty.  */
        lr_ignore_rest (ldfile, 1);
    }
예제 #12
0
int bench_matmat_fill_test(int argc, char** argv, char Order, char TransA, char TransB, int M, int N, int K, double RealAlpha, double ImagAlpha, int FillA, double RealScaleA, double ImagScaleA, int lda, int FillB, double RealScaleB, double ImagScaleB, int ldb, double RealBeta, double ImagBeta, int FillC, double RealScaleC, double ImagScaleC, int ldc, int trials){
  int rc = 0;
  int i;

  util_random_seed();

  char NTransA;
  int opAM;
  int opAK;
  int opBK;
  int opBN;

  switch(TransA){
    case 'n':
    case 'N':
      opAM = M;
      opAK = K;
      NTransA = 't';
      break;
    default:
      opAM = K;
      opAK = M;
      NTransA = 'n';
      break;
  }

  switch(TransB){
    case 'n':
    case 'N':
      opBK = K;
      opBN = N;
      break;
    default:
      opBK = N;
      opBN = K;
      break;
  }

  double complex *A  = util_zmat_alloc(Order, opAM, opAK, lda);
  double complex *B  = util_zmat_alloc(Order, opBK, opBN, ldb);
  double complex *C  = util_zmat_alloc(Order, M, N, ldc);
  double complex *res  = util_zmat_alloc(Order, M, N, ldc);
  double complex alpha = RealAlpha + I * ImagAlpha;
  double complex beta = RealBeta + I * ImagBeta;

  util_zmat_fill(Order, NTransA, opAM, opAK, A, lda, FillA, RealScaleA, ImagScaleA);
  util_zmat_fill(Order, TransB, opBK, opBN, B, ldb, FillB, RealScaleB, ImagScaleB);
  util_zmat_fill(Order, 'n', M, N, C, ldc, FillC, RealScaleC, ImagScaleC);

  for(i = 0; i < trials; i++){
    switch(Order){
      case 'r':
      case 'R':
        memcpy(res, C, M * ldc * sizeof(complex double));
        break;
      default:
        memcpy(res, C, ldc * N * sizeof(complex double));
        break;
    }
    time_tic();
    CALL_ZGEMM(Order, TransA, TransB, M, N, K, &alpha, A, lda, B, ldb, &beta, res, ldc);
    time_toc();
  }

  double dM = (double)M;
  double dN = (double)N;
  double dK = (double)K;
  metric_load_double("time", time_read());
  metric_load_double("trials", (double)(trials));
  metric_load_double("input", dM * dK + dK * dN + dM * dN);
  metric_load_double("output", dN * dM);
  metric_load_double("normalizer", dN * dM * dK);
  metric_load_double("d_fma", 4.0 * dN * dM * dK);
  metric_dump();

  free(A);
  free(B);
  free(C);
  free(res);
  return rc;
}
예제 #13
0
파일: main.c 프로젝트: hreinecke/s390-tools
int main(int argc, char *argv[])
{
	double interval;
	int fd, rc;

	reload_pending = 0;
	sym_names_count = sizeof(sym_names) / sizeof(struct symbol_names);
	varinfo_size = VARINFO_SIZE;
	varinfo = calloc(varinfo_size, 1);
	if (!varinfo) {
		cpuplugd_error("Out of memory: varinfo\n");
		exit(1);
	}
	/*
	 * varinfo must start with '\n' for correct string matching
	 * in get_var_rvalue().
	 */
	varinfo[0] = '\n';

	/* Parse the command line options */
	parse_options(argc, argv);

	/* flock() lock file to prevent multiple instances of cpuplugd */
	fd = open(LOCKFILE, O_CREAT | O_RDONLY, S_IRUSR);
	if (fd == -1) {
		cpuplugd_error("Cannot open lock file %s: %s\n", LOCKFILE,
			       strerror(errno));
		exit(1);
	}
	rc = flock(fd, LOCK_EX | LOCK_NB);
	if (rc) {
		cpuplugd_error("flock() failed on lock file %s: %s\nThis might "
			       "indicate that an instance of this daemon is "
			       "already running.\n", LOCKFILE, strerror(errno));
		exit(1);
	}

	/* Make sure that the daemon is not started multiple times */
	check_if_started_twice();
	/* Store daemon pid also in foreground mode */
	handle_signals();
	handle_sighup();

	/* Need 1 history level minimum for internal symbols */
	history_max = 1;
	/*
	 * Parse arguments from the configuration file, also calculate
	 * history_max
	 */
	parse_configfile(configfile);
	if (history_max > MAX_HISTORY)
		cpuplugd_exit("History depth %i exceeded maximum (%i)\n",
			      history_max, MAX_HISTORY);
	/* Check the settings in the configuration file */
	check_config();

	if (!foreground) {
		rc = daemon(1, 0);
		if (rc < 0)
			cpuplugd_exit("Detach from terminal failed: %s\n",
				      strerror(errno));
	}
	/* Store daemon pid */
	store_pid();
	/* Unlock lock file */
	flock(fd, LOCK_UN);
	close(fd);

	/* Install signal handler for floating point exceptions */
	rc = feenableexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW |
			    FE_INVALID);
	act.sa_flags = SA_NODEFER;
	sigemptyset(&act.sa_mask);
	act.sa_handler = sigfpe_handler;
	if (sigaction(SIGFPE, &act, NULL) < 0)
		cpuplugd_exit("sigaction( SIGFPE, ... ) failed - reason %s\n",
			      strerror(errno));

	setup_history();

	/* Main loop */
	while (1) {
		if (reload_pending) {		// check for daemon reload
			reload_daemon();
			reload_pending = 0;
		}

		history_prev = history_current;
		history_current = (history_current + 1) % (history_max + 1);
		time_read(&timestamps[history_current]);
		proc_read(meminfo + history_current * meminfo_size,
			  "/proc/meminfo", meminfo_size);
		proc_read(vmstat + history_current * vmstat_size,
			  "/proc/vmstat", vmstat_size);
		proc_cpu_read(cpustat + history_current * cpustat_size);
		interval = timestamps[history_current] -
			   timestamps[history_prev];
		cpuplugd_debug("config update interval: %ld seconds\n",
			       cfg.update);
		cpuplugd_debug("real update interval: %f seconds\n", interval);

		/* Run code that may signal failure via longjmp. */
		if (cpu == 1) {
			if (setjmp(jmpenv) == 0)
				eval_cpu_rules();
			else
				cpuplugd_error("Floating point exception, "
					       "skipping cpu rule "
					       "evaluation.\n");
		}
		if (memory == 1) {
			if (setjmp(jmpenv) == 0)
				eval_mem_rules(interval);
			else
				cpuplugd_error("Floating point exception, "
					       "skipping memory rule "
					       "evaluation.\n");
		}
		sleep(cfg.update);
	}
	return 0;
}
예제 #14
0
int bench_matmat_fill_test(int argc, char** argv, char Order, char TransA, char TransB, int M, int N, int K, double RealAlpha, double ImagAlpha, int FillA, double RealScaleA, double ImagScaleA, int lda, int FillB, double RealScaleB, double ImagScaleB, int ldb, double RealBeta, double ImagBeta, int FillC, double RealScaleC, double ImagScaleC, int ldc, int trials){
  int rc = 0;
  int i;

  bench_rdgemm_options_initialize();

  opt_eval_option(argc, argv, &fold);

  util_random_seed();

  char NTransA;
  int opAM;
  int opAK;
  int opBK;
  int opBN;

  switch(TransA){
    case 'n':
    case 'N':
      opAM = M;
      opAK = K;
      NTransA = 't';
      break;
    default:
      opAM = K;
      opAK = M;
      NTransA = 'n';
      break;
  }

  switch(TransB){
    case 'n':
    case 'N':
      opBK = K;
      opBN = N;
      break;
    default:
      opBK = N;
      opBN = K;
      break;
  }

  double *A  = util_dmat_alloc(Order, opAM, opAK, lda);
  double *B  = util_dmat_alloc(Order, opBK, opBN, ldb);
  double *C  = util_dmat_alloc(Order, M, N, ldc);
  double *res  = util_dmat_alloc(Order, M, N, ldc);
  double alpha = RealAlpha;
  double beta = RealBeta;

  util_dmat_fill(Order, NTransA, opAM, opAK, A, lda, FillA, RealScaleA, ImagScaleA);
  util_dmat_fill(Order, TransB, opBK, opBN, B, ldb, FillB, RealScaleB, ImagScaleB);
  util_dmat_fill(Order, 'n', M, N, C, ldc, FillC, RealScaleC, ImagScaleC);

  for(i = 0; i < trials; i++){
    switch(Order){
      case 'r':
      case 'R':
        memcpy(res, C, M * ldc * sizeof(double));
        break;
      default:
        memcpy(res, C, ldc * N * sizeof(double));
        break;
    }
    time_tic();
    reproBLAS_rdgemm(fold._int.value, Order, TransA, TransB, M, N, K, alpha, A, lda, B, ldb, beta, res, ldc);
    time_toc();
  }

  double dM = (double)M;
  double dN = (double)N;
  double dK = (double)K;
  metric_load_double("time", time_read());
  metric_load_double("trials", (double)(trials));
  metric_load_double("input", dM * dK + dK * dN + dM * dN);
  metric_load_double("output", dN * dM);
  metric_load_double("normalizer", dN * dM * dK);
  metric_load_double("d_mul", dN * dM * dK);
  metric_load_double("d_add", (3 * fold._int.value - 2) * dN * dM * dK);
  metric_load_double("d_orb", fold._int.value * dN * dM * dK);
  metric_dump();

  free(A);
  free(B);
  free(C);
  free(res);
  return rc;
}