Пример #1
0
sl_def(t_main, void)
{
  size_t i, j, nitems;
  int tag;

  for (i = 0; (tag = fibre_tag(i)) != -1; ++i) {
    printf("%zd: tag = %d rank = %zd\n", i, tag, fibre_rank(i));
    printf("%zd: shape = { ", i);
    for (j = 0; j < fibre_rank(i); ++j)
      printf("%zd ", fibre_shape(i)[j]);
    printf("}\n");

    nitems = 1;
    for (j = 0; j < fibre_rank(i); ++j)
      nitems *= fibre_shape(i)[j];
    printf("%zd: values = { ", i);
    for (j = 0; j < nitems; ++j) {
      switch(tag) {
      case 0: printf("%lu ", *((unsigned long*)fibre_data(i)+j)); break;
      case 1: printf("%ld ", *((long*)fibre_data(i)+j)); break;
      case 2: printf("%lg ", *((double*)fibre_data(i)+j)); break;
      default: printf("? "); break;
      }
    }
    printf("}\n");
  }
  printf("number of Fibre items: %zd\n", i);

}
Пример #2
0
sl_def(t_main, void)
{
  if (fibre_tag(0) != -1) {
    int x = 0;
    x += *(int*)fibre_data(0);
    x += *(int*)fibre_data(1);
    x += *(int*)fibre_data(2);
    x += *(int*)fibre_data(3);
    output_int(x, 1);
    output_char('\n', 1);
  }
}
Пример #3
0
sl_enddef

// XIGNORE: mts*:D
// SLT_RUN: -f TEST.d1
// SLT_RUN: -f TEST.d2

int main(int argc, char **argv)
{
  int j;
  double x = .42;
  int n = 42;

  assert(fibre_tag(0) == 2 && fibre_rank(0) == 0);
  assert(fibre_tag(1) == 0 && fibre_rank(1) == 0);
  x = *(double*)fibre_data(0);
  n = *(long*)fibre_data(1);

  for(j = 0; j < MAX_TESTS; ++j) {
    values[j].desc = 0;
    values[j].f = values[j].d = x;
    values[j].i = values[j].l = values[j].ll = n;
  }

  sl_create(,,,,,,, do_test);
  sl_sync();

  double_t xd = x;
  float_t xf = x;
  output_string("dot forty two, d: ", 1);
  output_float(xd, 1, 4);
  output_char('\n', 1);
  output_string("dot forty two, f: ", 1);
  output_float(xf, 1, 4);
  output_char('\n', 1);
  output_string("HUGE_VAL: ", 1);
  output_float(HUGE_VAL, 1, 4);
  output_char('\n', 1);
  output_string("HUGE_VALF: ", 1);
  output_float(HUGE_VALF, 1, 4);
  output_char('\n', 1);
  output_string("INFINITY: ", 1);
  output_float(INFINITY, 1, 4);
  output_char('\n', 1);
  output_string("NAN: ", 1);
  output_float(NAN, 1, 4);
  output_char('\n', 1);
  output_string("FP_ILOGB0 // ilogb(0): ", 1);
  output_int(FP_ILOGB0 == ilogb(0), 1);
  output_char('\n', 1);
  output_string("FP_ILOGBNAN // ilogb(NAN): ", 1);
  output_int(FP_ILOGBNAN == ilogb(NAN), 1);
  output_char('\n', 1);
  output_string("M_2: ", 1);
  output_float(M_E, 1, 4);
  output_char('\n', 1);
  output_string("M_LOG2E: ", 1);
  output_float(M_LOG2E, 1, 4);
  output_char('\n', 1);
  output_string("M_LOG10E: ", 1);
  output_float(M_LOG10E, 1, 4);
  output_char('\n', 1);
  output_string("M_LN2: ", 1);
  output_float(M_LN2, 1, 4);
  output_char('\n', 1);
  output_string("M_LN10: ", 1);
  output_float(M_LN10, 1, 4);
  output_char('\n', 1);
  output_string("M_PI: ", 1);
  output_float(M_PI, 1, 4);
  output_char('\n', 1);
  output_string("M_PI_2: ", 1);
  output_float(M_PI_2, 1, 4);
  output_char('\n', 1);
  output_string("M_PI_4: ", 1);
  output_float(M_PI_4, 1, 4);
  output_char('\n', 1);
  output_string("M_1_PI: ", 1);
  output_float(M_1_PI, 1, 4);
  output_char('\n', 1);
  output_string("M_2_PI: ", 1);
  output_float(M_2_PI, 1, 4);
  output_char('\n', 1);
  output_string("M_2_SQRTPI: ", 1);
  output_float(M_2_SQRTPI, 1, 4);
  output_char('\n', 1);
  output_string("M_SQRT2: ", 1);
  output_float(M_SQRT2, 1, 4);
  output_char('\n', 1);
  output_string("M_SQRT1_2: ", 1);
  output_float(M_SQRT1_2, 1, 4);
  output_char('\n', 1);

  for (j = 0; j < p; ++j)
    {
      const char *d = 	   values[j].desc ? values[j].desc : ".";
      output_string(d, 1); output_char(' ', 1);
      output_float(values[j].d, 1, 4); output_char(' ', 1);
      output_float(values[j].f, 1, 4); output_char(' ', 1);
      output_int(values[j].i, 1); output_char(' ', 1);
      output_int(values[j].l, 1); output_char(' ', 1);
      output_int(values[j].ll, 1); output_char('\n', 1);
    }

  return 0;
}
Пример #4
0
sl_def(t_main, void)
{
    size_t f = 0;

    size_t L = 1;

    assert(fibre_tag(f) == 0);
    assert(fibre_rank(f) == 0);
    L = *(unsigned long*)fibre_data(f);

    ++f;
    assert(fibre_tag(f) == 0);
    assert(fibre_rank(f) == 0);
    size_t input_n = *(unsigned long*)fibre_data(f);
#ifdef N
    assert(N == input_n);
#else
    size_t N = input_n;
#endif
    
    ++f;
    assert(fibre_rank(f) == 2);
    assert(fibre_shape(f)[0] == N);
    assert(fibre_shape(f)[1] == N);
    number (*a)[N][N] = (number (*)[N][N])fibre_data(f);

    ++f;
    assert(fibre_rank(f) == 2);
    assert(fibre_shape(f)[0] == N);
    assert(fibre_shape(f)[1] == N);
    number (*b)[N][N] = (number (*)[N][N])fibre_data(f);

    ++f;
    assert(fibre_rank(f) == 2);
    assert(fibre_shape(f)[0] == N);
    assert(fibre_shape(f)[1] == N);
    number (*expected)[N][N] = (number (*)[N][N])fibre_data(f);

    ++f;
    assert(fibre_rank(f) == 2);
    assert(fibre_shape(f)[0] == N);
    assert(fibre_shape(f)[1] == N);
    number (*c)[N][N] = (number (*)[N][N])fibre_data(f);

    number (*c_other)[N][N] = malloc(sizeof(number)*N*N);
    assert(c_other != 0);
    number (*tmp)[N][N];


    struct s_interval ivs[L + 1];
    size_t i, j;

    mtperf_start_interval(ivs, 0, 1, "work");
    mtperf_start_interval(ivs, 1, 1, "compute");
    sl_proccall(matmul,
                sl_glarg(void*, , a),
                sl_glarg(void*, , b),
                sl_glarg(void*, , c)
#ifndef N
                , sl_glarg(size_t, , N)
#endif
        );
    mtperf_finish_interval(ivs, 1);

    // printm(N, c); output_string("----\n", 1);
    
    for (i = 2; i <= L; ++i)
    {
        mtperf_start_interval(ivs, i, i, "compute");
        sl_proccall(matmul,
                    sl_glarg(void*, , a),
                    sl_glarg(void*, , c),
                    sl_glarg(void*, , c_other)
#ifndef N
                    , sl_glarg(size_t, , N)
#endif
            );
        mtperf_finish_interval(ivs, i);
        tmp = c;
        c = c_other;
        c_other = tmp;

        // printm(N, c); output_string("----\n", 1);
    }
    mtperf_finish_interval(ivs, 0);
    mtperf_report_intervals(ivs, L, REPORT_FIBRE|REPORT_STREAM(2));

    number max = 0;
    for (i = 0; i < N; ++i)
        for (j = 0; j < N; ++j)
        {
            number v = (*c)[i][j] - (*expected)[i][j];
            if (v < 0) v = -v;
            if (v > max) max = v;
        }
    output_int(((long)(max * 1000)), 1);
    output_char('\n', 1);
}