int run_graphcolor(
    crsMat_t input_mat,
    KokkosKernels::Experimental::Graph::ColoringAlgorithm coloring_algorithm,
    size_t &num_colors,
    typename crsMat_t::StaticCrsGraphType::entries_type::non_const_type & vertex_colors){
  typedef typename crsMat_t::StaticCrsGraphType graph_t;
  typedef typename graph_t::row_map_type lno_view_t;
  typedef typename graph_t::entries_type   lno_nnz_view_t;
  typedef typename crsMat_t::values_type::non_const_type scalar_view_t;

  typedef KokkosKernels::Experimental::KokkosKernelsHandle
      <lno_view_t,lno_nnz_view_t, scalar_view_t,
      typename device::execution_space, typename device::memory_space,typename device::memory_space > KernelHandle;

  KernelHandle kh;
  kh.set_team_work_size(16);
  kh.set_dynamic_scheduling(true);

  kh.create_graph_coloring_handle(coloring_algorithm);


  const size_t num_rows_1 = input_mat.numRows();
  const size_t num_cols_1 = input_mat.numCols();

  KokkosKernels::Experimental::Graph::graph_color_symbolic
    <KernelHandle,lno_view_t,lno_nnz_view_t> (&kh,num_rows_1, num_cols_1,
        input_mat.graph.row_map, input_mat.graph.entries);

  num_colors = kh.get_graph_coloring_handle()->get_num_colors();
  vertex_colors = kh.get_graph_coloring_handle()->get_vertex_colors();
  kh.destroy_graph_coloring_handle();
  return 0;
}
Exemplo n.º 2
0
void run_experiment(
    crsGraph_t crsGraph, Parameters params){
  //using namespace KokkosSparse;
  using namespace KokkosGraph;
  using namespace KokkosGraph::Experimental;
  //using namespace KokkosSparse::Experimental;

  int algorithm = params.algorithm;
  int repeat = params.repeat;
  int chunk_size = params.chunk_size;

  int shmemsize = params.shmemsize;
  int team_size = params.team_size;
  int use_dynamic_scheduling = params.use_dynamic_scheduling;
  int verbose = params.verbose;

  //char spgemm_step = params.spgemm_step;
  int vector_size = params.vector_size;

  typedef typename crsGraph_t3::row_map_type::non_const_type lno_view_t;
  typedef typename crsGraph_t3::entries_type::non_const_type lno_nnz_view_t;



  typedef typename lno_view_t::non_const_value_type size_type;
  typedef typename lno_nnz_view_t::non_const_value_type lno_t;

  typedef KokkosKernels::Experimental::KokkosKernelsHandle
      <size_type,lno_t, lno_t,
      ExecSpace, TempMemSpace,PersistentMemSpace > KernelHandle;

  KernelHandle kh;
  kh.set_team_work_size(chunk_size);
  kh.set_shmem_size(shmemsize);
  kh.set_suggested_team_size(team_size);
  kh.set_suggested_vector_size(vector_size);


  if (use_dynamic_scheduling){
    kh.set_dynamic_scheduling(true);
  }
  if (verbose){
    kh.set_verbose(true);
  }

  for (int i = 0; i < repeat; ++i){

    switch (algorithm){
    case 1:
      kh.create_graph_coloring_handle(COLORING_DEFAULT);

      break;
    case 2:
      kh.create_graph_coloring_handle(COLORING_SERIAL);

      break;
    case 3:
      kh.create_graph_coloring_handle(COLORING_VB);
      break;
    case 4:
      kh.create_graph_coloring_handle(COLORING_VBBIT);

      break;
    case 5:
      kh.create_graph_coloring_handle(COLORING_VBCS);

      break;
    case 6:
      kh.create_graph_coloring_handle(COLORING_EB);
      break;
    default:
      kh.create_graph_coloring_handle(COLORING_DEFAULT);

    }
    graph_color_symbolic(&kh,crsGraph.numRows(), crsGraph.numCols(), crsGraph.row_map, crsGraph.entries);

    std::cout <<
        "Time:" << kh.get_graph_coloring_handle()->get_overall_coloring_time() << " "
        "Num colors:" << kh.get_graph_coloring_handle()->get_num_colors() << " "
        "Num Phases:" << kh.get_graph_coloring_handle()->get_num_phases() << std::endl;
    std::cout << "\t"; KokkosKernels::Impl::print_1Dview(kh.get_graph_coloring_handle()->get_vertex_colors());

  }
}