int main (int argc, char ** argv){ if (argc < 2){ std::cerr << "Usage:" << argv[0] << " input_bin_file" << std::endl; exit(1); } Kokkos::initialize(argc, argv); MyExecSpace::print_configuration(std::cout); idx nv = 0, ne = 0; idx *xadj, *adj, *half_srcs, *half_dsts; wt *ew; Experimental::KokkosKernels::Graph::Utils::read_graph_bin<idx, wt> (&nv, &ne, &xadj, &adj, &ew, argv[1]); Experimental::KokkosKernels::Graph::Utils::md_malloc<idx>(&half_srcs, ne/2); Experimental::KokkosKernels::Graph::Utils::md_malloc<idx>(&half_dsts, ne/2); Experimental::KokkosKernels::Graph::Utils::convert_crs_to_lower_triangle_edge_list<idx>(nv, xadj, adj, half_srcs, half_dsts); std::cout << "nv:" << nv << " ne:" << ne << std::endl; um_array_type _xadj (xadj, nv + 1); um_edge_array_type _adj (adj, ne); um_edge_array_type _half_srcs (half_srcs, ne/2); um_edge_array_type _half_dests (half_dsts, ne/2); idx_array_type kok_xadj ("xadj", nv + 1); idx_edge_array_type kok_adj("adj", ne); Kokkos::deep_copy (kok_xadj, _xadj); Kokkos::deep_copy (kok_adj, _adj); idx_edge_array_type kok_half_srcs("adj", ne/2), kok_half_dsts("adj", ne/2); Kokkos::deep_copy (kok_half_srcs, _half_srcs); Kokkos::deep_copy (kok_half_dsts, _half_dests); wt_um_edge_array_type _mtx_vals (ew, ne); value_array_type kok_mtx_vals ("MTX_VALS", ne); Kokkos::deep_copy (kok_mtx_vals, _mtx_vals); delete [] xadj; delete [] adj; delete [] half_srcs; delete [] half_dsts; delete [] ew; //fill_experiments(nv, ne, kok_xadj, kok_adj, kok_half_srcs, kok_half_dsts); run_experiment(REPEAT, nv, ne, kok_xadj, kok_adj, kok_mtx_vals); //free_experiments(); Kokkos::finalize(); return 0; }
int main (int argc, char ** argv){ if (argc < 2){ std::cerr << "Usage:" << argv[0] << " input_bin_file" << std::endl; exit(1); } Kokkos::initialize(argc, argv); MyExecSpace::print_configuration(std::cout); idx nv = 0, ne = 0; idx *xadj, *adj; wt *ew; KokkosKernels::Experimental::Graph::Utils::read_graph_bin<idx, wt> (&nv, &ne, &xadj, &adj, &ew, argv[1]); std::cout << "nv:" << nv << " ne:" << ne << std::endl; um_array_type _xadj (xadj, nv + 1); um_edge_array_type _adj (adj, ne); idx_array_type kok_xadj ("xadj", nv + 1); idx_edge_array_type kok_adj("adj", ne); idx_array_type sym_xadj; idx_edge_array_type sym_adj; Kokkos::deep_copy (kok_xadj, _xadj); Kokkos::deep_copy (kok_adj, _adj); wt_um_edge_array_type _mtx_vals (ew, ne); value_array_type kok_mtx_vals ("MTX_VALS", ne); Kokkos::deep_copy (kok_mtx_vals, _mtx_vals); delete [] xadj; delete [] adj; delete [] ew; KokkosKernels::Experimental::Util::symmetrize_graph_symbolic< idx_array_type, idx_edge_array_type, idx_array_type, idx_edge_array_type, MyExecSpace> (nv, kok_xadj, kok_adj,sym_xadj, sym_adj); KokkosKernels::Experimental::Util::print_1Dview(kok_xadj); KokkosKernels::Experimental::Util::print_1Dview(kok_adj); std::cout << "Symetric Graph" << std::endl; KokkosKernels::Experimental::Util::print_1Dview(sym_xadj); KokkosKernels::Experimental::Util::print_1Dview(sym_adj); Kokkos::finalize(); return 0; }
int main (int argc, char ** argv){ if (argc < 2){ std::cerr << "Usage:" << argv[0] << " input_bin_file" << std::endl; exit(1); } Kokkos::initialize(argc, argv); MyExecSpace::print_configuration(std::cout); idx nv = 0, ne = 0; idx *xadj, *adj; //idx *half_srcs, *half_dsts; wt *ew; Experimental::KokkosKernels::Graph::Utils::read_graph_bin<idx, wt> ( &nv, &ne, &xadj, &adj, &ew, argv[1]); delete [] ew; um_array_type _xadj (xadj, nv + 1); um_edge_array_type _adj (adj, ne); idx_array_type kok_xadj ("xadj", nv + 1); idx_edge_array_type kok_adj("adj", ne); Kokkos::deep_copy (kok_xadj, _xadj); Kokkos::deep_copy (kok_adj, _adj); delete [] xadj; delete [] adj; typedef Experimental::KokkosKernels::KokkosKernelsHandle <idx_array_type,idx_edge_array_type, value_array_type, MyExecSpace, TemporaryWorkSpace,PersistentWorkSpace > KernelHandle; KernelHandle kkh; kkh.set_row_map(kok_xadj); kkh.set_entries(kok_adj); //kkh.set_values(); kkh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_EB); Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "EB " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "EBS " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; kkh.destroy_graph_coloring_handle(); kkh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_SERIAL); Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "SEQ " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; kkh.destroy_graph_coloring_handle(); kkh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_VB); Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "VB " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; kkh.destroy_graph_coloring_handle(); kkh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_VBBIT); //kkh.get_graph_coloring_handle()->set_tictoc(true); Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "VBBIT " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; kkh.destroy_graph_coloring_handle(); kkh.create_graph_coloring_handle(Experimental::KokkosKernels::Graph::COLORING_VBCS); //kkh.get_graph_coloring_handle()->set_tictoc(true); Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "VBCS " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; Experimental::KokkosKernels::Graph::graph_color_solve<KernelHandle> (&kkh); std::cout << "VBCSS " << "Time:" << kkh.get_graph_coloring_handle()->get_overall_coloring_time() << " " "Num colors:" << kkh.get_graph_coloring_handle()->get_num_colors() << " " "Num Phases:" << kkh.get_graph_coloring_handle()->get_num_phases() << std::endl; kkh.destroy_graph_coloring_handle(); Kokkos::finalize(); return 0; }
int main (int argc, char ** argv){ if (argc < 2){ std::cerr << "Usage:" << argv[0] << " input_bin_file" << std::endl; exit(1); } Kokkos::initialize(argc, argv); MyExecSpace::print_configuration(std::cout); idx m = 0, nnzA = 0, n = 0, k = 0; idx *xadj, *adj; wt *ew; KokkosKernels::Experimental::Graph::Utils::read_graph_bin<idx, wt> (&m, &nnzA, &xadj, &adj, &ew, argv[1]); std::cout << "m:" << m << " nnzA:" << nnzA << std::endl; k = n = m; um_array_type _xadj (xadj, m + 1); um_edge_array_type _adj (adj, nnzA); wt_um_edge_array_type _mtx_vals (ew, nnzA); idx_array_type kok_xadj ("xadj", m + 1); idx_edge_array_type kok_adj("adj", nnzA); value_array_type kok_mtx_vals ("MTX_VALS", nnzA); Kokkos::deep_copy (kok_xadj, _xadj); Kokkos::deep_copy (kok_adj, _adj); Kokkos::deep_copy (kok_mtx_vals, _mtx_vals); delete [] xadj; delete [] adj; delete [] ew; idx_array_type row_mapC, row_mapC2; idx_edge_array_type entriesC, entriesC2; value_array_type valuesC, valuesC2; typedef KokkosKernels::Experimental::KokkosKernelsHandle <idx_array_type,idx_edge_array_type, value_array_type, MyExecSpace, TemporaryWorkSpace,PersistentWorkSpace > KernelHandle; KernelHandle kh; kh.create_spgemm_handle(KokkosKernels::Experimental::Graph::SPGEMM_CUSP); Kokkos::Impl::Timer timer1; KokkosKernels::Experimental::Graph::spgemm_symbolic<KernelHandle> ( &kh, m, n, k, kok_xadj, kok_adj, false, kok_xadj, kok_adj, false, row_mapC, entriesC ); Kokkos::fence(); double symbolic_time = timer1.seconds(); Kokkos::Impl::Timer timer2; KokkosKernels::Experimental::Graph::spgemm_numeric( &kh, m, n, k, kok_xadj, kok_adj, kok_mtx_vals, false, kok_xadj, kok_adj, kok_mtx_vals, true, row_mapC, entriesC, valuesC ); Kokkos::fence(); double numeric_time = timer2.seconds(); std::cout << "mm_time:" << numeric_time + symbolic_time << " symbolic_time:" << symbolic_time << " numeric:" << numeric_time << std::endl; std::cout << "row_mapC:" << row_mapC.dimension_0() << std::endl; std::cout << "entriesC:" << entriesC.dimension_0() << std::endl; std::cout << "valuesC:" << valuesC.dimension_0() << std::endl; kh.create_spgemm_handle(); Kokkos::Impl::Timer timer3; KokkosKernels::Experimental::Graph::spgemm_symbolic<KernelHandle> ( &kh, m, n, k, kok_xadj, kok_adj, false, kok_xadj, kok_adj, false, row_mapC2, entriesC2 ); Kokkos::fence(); symbolic_time = timer3.seconds(); Kokkos::Impl::Timer timer4; KokkosKernels::Experimental::Graph::spgemm_numeric( &kh, m, n, k, kok_xadj, kok_adj, kok_mtx_vals, false, kok_xadj, kok_adj, kok_mtx_vals, true, row_mapC2, entriesC2, valuesC2 ); Kokkos::fence(); numeric_time = timer4.seconds(); std::cout << "mm_time:" << numeric_time + symbolic_time << " symbolic_time:" << symbolic_time << " numeric:" << numeric_time << std::endl; std::cout << "row_mapC:" << row_mapC2.dimension_0() << std::endl; std::cout << "entriesC:" << entriesC2.dimension_0() << std::endl; std::cout << "valuesC:" << valuesC2.dimension_0() << std::endl; typedef Kokkos::RangePolicy<MyExecSpace> my_exec_space; size_t map = 0, ent = 0, val = 0; Kokkos::parallel_reduce(my_exec_space(0,row_mapC2.dimension_0()), compare<idx_array_type>(row_mapC,row_mapC2), map); Kokkos::parallel_reduce(my_exec_space(0,entriesC2.dimension_0()), compare<idx_edge_array_type>(entriesC,entriesC2), ent); Kokkos::parallel_reduce(my_exec_space(0,valuesC2.dimension_0()), compare<value_array_type>(valuesC,valuesC2), val); std::cout << "map:" << map << " ent:" << ent << " val:" << val << std::endl; Kokkos::finalize(); return 0; }