void run_experiment(
    crsMat_t crsmat){

  typedef typename crsMat_t::values_type scalar_view_t;

  idx nv = crsmat.numRows();
  scalar_view_t kok_x_original = create_x_vector<scalar_view_t>(nv, MAXVAL);

  KokkosKernels::Experimental::Util::print_1Dview(kok_x_original);
  scalar_view_t kok_b_vector = create_y_vector(crsmat, kok_x_original);

  //create X vector
  scalar_view_t kok_x_vector("kok_x_vector", nv);


  double solve_time = 0;
  const unsigned cg_iteration_limit = 100000;
  const double   cg_iteration_tolerance     = 1e-7 ;

  KokkosKernels::Experimental::Example::CGSolveResult cg_result ;

  typedef KokkosKernels::Experimental::KokkosKernelsHandle
        < typename crsMat_t::StaticCrsGraphType::row_map_type,
          typename crsMat_t::StaticCrsGraphType::entries_type,
          typename crsMat_t::values_type,
          ExecSpace, ExecSpace, ExecSpace > KernelHandle;

  KernelHandle kh;


  kh.create_gs_handle();
  Kokkos::Impl::Timer timer1;
  KokkosKernels::Experimental::Example::pcgsolve(
        kh
      , crsmat
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );
  Kokkos::fence();

  solve_time = timer1.seconds();


  std::cout  << "DEFAULT SOLVE:"
      << "\n\t(P)CG_NUM_ITER              [" << cg_result.iteration << "]"
      << "\n\tMATVEC_TIME                 [" << cg_result.matvec_time << "]"
      << "\n\tCG_RESIDUAL                 [" << cg_result.norm_res << "]"
      << "\n\tCG_ITERATION_TIME           [" << cg_result.iter_time << "]"
      << "\n\tPRECONDITIONER_TIME         [" << cg_result.precond_time << "]"
      << "\n\tPRECONDITIONER_INIT_TIME    [" << cg_result.precond_init_time << "]"
      << "\n\tPRECOND_APPLY_TIME_PER_ITER [" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << "\n\tSOLVE_TIME                  [" << solve_time<< "]"
      << std::endl ;



  /*
  kh.destroy_gs_handle();
  kh.create_gs_handle(KokkosKernels::Experimental::Graph::GS_PERMUTED);

  kok_x_vector = scalar_view_t("kok_x_vector", nv);
  timer1.reset();
  KokkosKernels::Experimental::Example::pcgsolve(
        kh
      , crsmat
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );

  Kokkos::fence();
  solve_time = timer1.seconds();
  std::cout  << "\nPERMUTED SGS SOLVE:"
      << "\n\t(P)CG_NUM_ITER              [" << cg_result.iteration << "]"
      << "\n\tMATVEC_TIME                 [" << cg_result.matvec_time << "]"
      << "\n\tCG_RESIDUAL                 [" << cg_result.norm_res << "]"
      << "\n\tCG_ITERATION_TIME           [" << cg_result.iter_time << "]"
      << "\n\tPRECONDITIONER_TIME         [" << cg_result.precond_time << "]"
      << "\n\tPRECONDITIONER_INIT_TIME    [" << cg_result.precond_init_time << "]"
      << "\n\tPRECOND_APPLY_TIME_PER_ITER [" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << "\n\tSOLVE_TIME                  [" << solve_time<< "]"
      << std::endl ;


  kh.destroy_gs_handle();
  kh.create_gs_handle(KokkosKernels::Experimental::Graph::GS_TEAM);

  kok_x_vector = scalar_view_t("kok_x_vector", nv);
  timer1.reset();
  KokkosKernels::Experimental::Example::pcgsolve(
        kh
      , crsmat
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );
  Kokkos::fence();

  solve_time = timer1.seconds();
  std::cout  << "\nTEAM SGS SOLVE:"
      << "\n\t(P)CG_NUM_ITER              [" << cg_result.iteration << "]"
      << "\n\tMATVEC_TIME                 [" << cg_result.matvec_time << "]"
      << "\n\tCG_RESIDUAL                 [" << cg_result.norm_res << "]"
      << "\n\tCG_ITERATION_TIME           [" << cg_result.iter_time << "]"
      << "\n\tPRECONDITIONER_TIME         [" << cg_result.precond_time << "]"
      << "\n\tPRECONDITIONER_INIT_TIME    [" << cg_result.precond_init_time << "]"
      << "\n\tPRECOND_APPLY_TIME_PER_ITER [" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << "\n\tSOLVE_TIME                  [" << solve_time<< "]"
      << std::endl ;




  kok_x_vector = scalar_view_t("kok_x_vector", nv);
  timer1.reset();
  KokkosKernels::Experimental::Example::pcgsolve(
        kh
      , crsmat
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , false
  );
  Kokkos::fence();

  solve_time = timer1.seconds();
  std::cout  << "\nCG SOLVE (With no Preconditioner):"
      << "\n\t(P)CG_NUM_ITER              [" << cg_result.iteration << "]"
      << "\n\tMATVEC_TIME                 [" << cg_result.matvec_time << "]"
      << "\n\tCG_RESIDUAL                 [" << cg_result.norm_res << "]"
      << "\n\tCG_ITERATION_TIME           [" << cg_result.iter_time << "]"
      << "\n\tPRECONDITIONER_TIME         [" << cg_result.precond_time << "]"
      << "\n\tPRECONDITIONER_INIT_TIME    [" << cg_result.precond_init_time << "]"
      << "\n\tPRECOND_APPLY_TIME_PER_ITER [" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << "\n\tSOLVE_TIME                  [" << solve_time<< "]"
      << std::endl ;
  */
}
Exemple #2
0
void run_experiment(
    int repeatcount, idx nv, idx ne,
    idx_array_type kok_xadj,
    idx_edge_array_type kok_adj,
    value_array_type kok_mtx_vals
){

  value_array_type kok_x_original = create_x_vector(nv, MAXVAL);
  value_array_type kok_b_vector = create_b_vector(
      nv,
      kok_xadj,
      kok_adj,
      kok_mtx_vals,
      kok_x_original);

  Experimental::KokkosKernels::Example::CrsMatrix<wt, idx, MyExecSpace> A(nv ,ne, kok_xadj, kok_adj, kok_mtx_vals);


  //create X vector
  value_array_type kok_x_vector("kok_x_vector", nv);


  double gs_time = 0;
  const unsigned cg_iteration_limit = 100000;
  const double   cg_iteration_tolerance     = 1e-7 ;

  Experimental::KokkosKernels::Example::CGSolveResult cg_result ;
  typedef Experimental::KokkosKernels::KokkosKernelsHandle
        <idx_array_type,idx_edge_array_type, value_array_type,
        MyExecSpace, TemporaryWorkSpace,PersistentWorkSpace > KernelHandle;

  KernelHandle kh;
  kh.set_row_map(A.graph.row_map);
  kh.set_entries(A.graph.entries);
  kh.set_values(A.coeff);

  Kokkos::Impl::Timer timer1;
  Experimental::KokkosKernels::Example::pcgsolve(
        kh
      , A
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );
  Kokkos::fence();
  gs_time = timer1.seconds();


  std::cout  << " cg_iteration[" << cg_result.iteration << "]"
      << " matvec_time[" << cg_result.matvec_time << "]"
      << " cg_residual[" << cg_result.norm_res << "]"
      << " cg_iter_time[" << cg_result.iter_time << "]"
      << " precond_time[" << cg_result.precond_time << "]"
      << " precond_init_time[" << cg_result.precond_init_time << "]"
      << " precond_time/iter[" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << " GSTIME[" << gs_time<< "]"
      << std::endl ;



  kh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_VB);
  Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kh);

  kok_x_vector = value_array_type("kok_x_vector", nv);
  timer1.reset();
  Experimental::KokkosKernels::Example::pcgsolve(
        kh
      , A
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );
  Kokkos::fence();

  gs_time = timer1.seconds();
  std::cout  << "\n\nCOLORING_VB PRECALL:\n cg_iteration[" << cg_result.iteration << "]"
      << " matvec_time[" << cg_result.matvec_time << "]"
      << " cg_residual[" << cg_result.norm_res << "]"
      << " cg_iter_time[" << cg_result.iter_time << "]"
      << " precond_time[" << cg_result.precond_time << "]"
      << " precond_init_time[" << cg_result.precond_init_time << "]"
      << " precond_time/iter[" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << " GSTIME[" << gs_time<< "]"
      << " numColor[" << kh.get_graph_coloring_handle()->get_num_colors()<<"]"
      << std::endl ;

  kh.destroy_graph_coloring_handle();
  kh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_EB);
  Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kh);

  kok_x_vector = value_array_type("kok_x_vector", nv);
  timer1.reset();
  Experimental::KokkosKernels::Example::pcgsolve(
        kh
      , A
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );
  Kokkos::fence();

  gs_time = timer1.seconds();
  std::cout  << "\n\nCOLORING_EB PRECALL:\n cg_iteration[" << cg_result.iteration << "]"
      << " matvec_time[" << cg_result.matvec_time << "]"
      << " cg_residual[" << cg_result.norm_res << "]"
      << " cg_iter_time[" << cg_result.iter_time << "]"
      << " precond_time[" << cg_result.precond_time << "]"
      << " precond_init_time[" << cg_result.precond_init_time << "]"
      << " precond_time/iter[" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << " GSTIME[" << gs_time<< "]"
      << " numColor[" << kh.get_graph_coloring_handle()->get_num_colors()<<"]"
      << std::endl ;

  kh.destroy_graph_coloring_handle();
  kh.destroy_gs_handle();
  kh.create_gs_handle(Experimental::KokkosKernels::Graph::GS_PERMUTED);


  kok_x_vector = value_array_type("kok_x_vector", nv);
  timer1.reset();
  Experimental::KokkosKernels::Example::pcgsolve(
        kh
      , A
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );

  Kokkos::fence();
  gs_time = timer1.seconds();
  std::cout  << "\n\nPERMUTED:\n cg_iteration[" << cg_result.iteration << "]"
      << " matvec_time[" << cg_result.matvec_time << "]"
      << " cg_residual[" << cg_result.norm_res << "]"
      << " cg_iter_time[" << cg_result.iter_time << "]"
      << " precond_time[" << cg_result.precond_time << "]"
      << " precond_init_time[" << cg_result.precond_init_time << "]"
      << " precond_time/iter[" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << " GSTIME[" << gs_time<< "]"
      << std::endl ;


  kh.destroy_graph_coloring_handle();
  kh.destroy_gs_handle();
  kh.create_gs_handle(Experimental::KokkosKernels::Graph::GS_TEAM);

  kok_x_vector = value_array_type("kok_x_vector", nv);
  timer1.reset();
  Experimental::KokkosKernels::Example::pcgsolve(
        kh
      , A
      , kok_b_vector
      , kok_x_vector
      , cg_iteration_limit
      , cg_iteration_tolerance
      , & cg_result
      , true
  );
  Kokkos::fence();

  gs_time = timer1.seconds();
  std::cout  << "\n\nGSTEAM:\n cg_iteration[" << cg_result.iteration << "]"
      << " matvec_time[" << cg_result.matvec_time << "]"
      << " cg_residual[" << cg_result.norm_res << "]"
      << " cg_iter_time[" << cg_result.iter_time << "]"
      << " precond_time[" << cg_result.precond_time << "]"
      << " precond_init_time[" << cg_result.precond_init_time << "]"
      << " precond_time/iter[" << cg_result.precond_time / (cg_result.iteration  + 1) << "]"
      << " GSTIME[" << gs_time<< "]"
      << std::endl ;




}