Exemplo n.º 1
0
/* *************************************************************** */
void bench_blas_level_3_double(int rows)
{
    struct timeval tstart;
    struct timeval tend;
    double **A, **B, **C, *x, *y;

    x = G_alloc_vector(rows);
    y = G_alloc_vector(rows);

    A = G_alloc_matrix(rows, rows);
    B = G_alloc_matrix(rows, rows);
    C = G_alloc_matrix(rows, rows);

    fill_d_vector_range_1(x, 1, rows);
    fill_d_vector_range_1(y, 1, rows);

    fill_d_vector_range_1(A[0], 1, rows*rows);
    fill_d_vector_range_1(B[0], 1, rows*rows);


    gettimeofday(&tstart, NULL);
#pragma omp parallel default(shared)
{
    G_math_d_aA_B(A, B, 4.0 , C, rows , rows);
}
    gettimeofday(&tend, NULL);
    printf("Computation time G_math_d_aA_B: %g\n", compute_time_difference(tstart, tend));
    gettimeofday(&tstart, NULL);
#pragma omp parallel default(shared)
{
    G_math_d_AB(A, B, C, rows , rows , rows);
}
    gettimeofday(&tend, NULL);
    printf("Computation time G_math_d_AB: %g\n", compute_time_difference(tstart, tend));


    if(x)
      G_free_vector(x);
    if(y)
      G_free_vector(y);

    if(A)
      G_free_matrix(A);
    if(B)
      G_free_matrix(B);
    if(C)
      G_free_matrix(C);

    return;
}
Exemplo n.º 2
0
/* *************************************************************** */
int bench_solvers(int rows) {
    G_math_les *les;
    struct timeval tstart;
    struct timeval tend;

    G_message("\t * benchmarking gmath lu decomposition solver with unsymmetric matrix\n");

    les = create_normal_unsymmetric_les(rows);
    gettimeofday(&tstart, NULL);
    G_math_solver_lu(les->A, les->x, les->b, les->rows);
    gettimeofday(&tend, NULL);
    G_important_message("Computation time gmath lu decomposition: %g\n", compute_time_difference(tstart, tend));
    G_math_free_les(les);

    G_message("\t * benchmarking lu ccmath decomposition solver with unsymmetric matrix\n");

    les = create_normal_unsymmetric_les(rows);
    gettimeofday(&tstart, NULL);
    G_math_solv(les->A, les->b, les->rows);
    gettimeofday(&tend, NULL);
    G_important_message("Computation time ccmath lu decomposition: %g\n", compute_time_difference(tstart, tend));
    G_math_free_les(les);


    G_message("\t * benchmarking gauss elimination solver with unsymmetric matrix\n");

    les = create_normal_unsymmetric_les(rows);
    gettimeofday(&tstart, NULL);
    G_math_solver_gauss(les->A, les->x, les->b, les->rows);
    gettimeofday(&tend, NULL);
    G_important_message("Computation time gauss elimination: %g\n", compute_time_difference(tstart, tend));
    G_math_free_les(les);

    G_message("\t * benchmarking gmath cholesky decomposition solver with symmetric matrix\n");

    les = create_normal_symmetric_les(rows);
    gettimeofday(&tstart, NULL);
    G_math_solver_cholesky(les->A, les->x, les->b, les->rows, les->rows);
    gettimeofday(&tend, NULL);
    G_important_message("Computation time gmath cholesky decomposition: %g\n", compute_time_difference(tstart, tend));
    G_math_free_les(les);

    G_message("\t * benchmarking ccmath cholesky decomposition solver with symmetric matrix\n");

    les = create_normal_symmetric_les(rows);
    gettimeofday(&tstart, NULL);
    G_math_solvps(les->A, les->b, les->rows);
    gettimeofday(&tend, NULL);
    G_important_message("Computation time ccmath cholesky decomposition: %g\n", compute_time_difference(tstart, tend));
    G_math_free_les(les);

    G_message("\t * benchmarking gmath cholesky band matrix decomposition solver with symmetric band matrix\n");

    les = create_symmetric_band_les(rows);
    gettimeofday(&tstart, NULL);
    G_math_solver_cholesky_sband(les->A, les->x, les->b, les->rows, les->rows);
    gettimeofday(&tend, NULL);
    G_important_message("Computation time cholesky band matrix decomposition: %g\n", compute_time_difference(tstart, tend));
    G_math_free_les(les);


    return 1;
}
Exemplo n.º 3
0
// Handles events that come from Windows.
bool cen64_gl_window_pump_events(struct vi_controller *vi,
  cen64_time *last_update_time, unsigned *frame_count) {
  struct bus_controller *bus;
  bool exit_requested = false;
  MSG msg;

  memcpy(&bus, vi, sizeof(bus));

  while (1) {
    GetMessage(&msg, NULL, 0, 0);

    if (msg.message == WM_QUIT) {
      cen64_mutex_lock(&vi->window->event_mutex);
      vi->window->exit_requested = exit_requested = true;
      cen64_mutex_unlock(&vi->window->event_mutex);
      break;
    }

    else if (msg.message == WM_KEYDOWN) {
      cen64_mutex_lock(&vi->window->event_mutex);
      keyboard_press_callback(bus, msg.wParam);
      cen64_mutex_unlock(&vi->window->event_mutex);
    }

    else if (msg.message == WM_KEYUP) {
      cen64_mutex_lock(&vi->window->event_mutex);
      keyboard_release_callback(bus, msg.wParam);
      cen64_mutex_unlock(&vi->window->event_mutex);
    }

    else if (msg.message == WM_USER) {
      cen64_gl_window window = vi->window;

      cen64_mutex_lock(&window->render_mutex);

      gl_window_render_frame(vi, window->frame_buffer,
        window->frame_hres, window->frame_vres,
        window->frame_hskip, window->frame_type);

      cen64_mutex_unlock(&window->render_mutex);

      // Update the window title every 60 VIs
      // to display the current VI/s rate.
      if (++(*frame_count) == 60) {
        char title[128];
        cen64_time current_time;
        float ns;

        // Compute time spent rendering last 60 frames, reset timer/counter.
        get_time(&current_time);
        ns = compute_time_difference(&current_time, last_update_time);
        *last_update_time = current_time;
        *frame_count = 0;

        sprintf(title,
          "CEN64 ["CEN64_COMPILER" - "CEN64_ARCH_DIR"/"CEN64_ARCH_SUPPORT"]"
          " - %.1f VI/s", (60 / (ns / NS_PER_SEC)));

        cen64_gl_window_set_title(window, title);
      }
    }

    else {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }

  return exit_requested;
}