Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move sorting functionality out of Impl:: #932

Merged
merged 3 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions perf_test/graph/KokkosGraph_run_triangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,16 @@ bool is_same_graph(crsGraph_t output_mat1, crsGraph_t output_mat2){
size_t nentries2 = output_mat2.entries.extent(0) ;
//size_t nvals2 = output_mat2.values.extent(0);


lno_nnz_view_t h_ent1 (Kokkos::ViewAllocateWithoutInitializing("e1"), nentries1);
lno_nnz_view_t h_vals1 (Kokkos::ViewAllocateWithoutInitializing("v1"), nentries1);


KokkosKernels::Impl::kk_sort_graph<typename crsGraph_t::row_map_type,
typename crsGraph_t::entries_type,
lno_nnz_view_t,
lno_nnz_view_t,
lno_nnz_view_t,
typename device::execution_space
>(
output_mat1.row_map, output_mat1.entries,h_vals1,
h_ent1, h_vals1
);

lno_nnz_view_t h_ent2 (Kokkos::ViewAllocateWithoutInitializing("e1"), nentries2);
lno_nnz_view_t h_vals2 (Kokkos::ViewAllocateWithoutInitializing("v1"), nentries2);
KokkosKernels::sort_crs_graph<typename device::execution_space,
typename crsGraph_t::row_map_type, typename crsGraph_t::entries_type>
(output_mat1.graph.row_map, output_mat1.entries);

if (nrows1 != nrows2) return false;
if (nentries1 != nentries2) return false;

KokkosKernels::Impl::kk_sort_graph
<typename crsGraph_t::row_map_type,
typename crsGraph_t::entries_type,
lno_nnz_view_t,
lno_nnz_view_t,
lno_nnz_view_t,
typename device::execution_space
>(
output_mat2.row_map, output_mat2.entries, h_vals2,
h_ent2, h_vals2
);
KokkosKernels::sort_crs_graph<typename device::execution_space,
typename crsGraph_t::row_map_type, typename crsGraph_t::entries_type>
(output_mat2.graph.row_map, output_mat2.entries);

bool is_identical = true;
is_identical = KokkosKernels::Impl::kk_is_identical_view
Expand All @@ -109,7 +86,7 @@ bool is_same_graph(crsGraph_t output_mat1, crsGraph_t output_mat2){

is_identical = KokkosKernels::Impl::kk_is_identical_view
<lno_nnz_view_t, lno_nnz_view_t, typename lno_nnz_view_t::value_type,
typename device::execution_space>(h_ent1, h_ent2, 0 );
typename device::execution_space>(output_mat1.entries, output_mat2.entries, 0 );
if (!is_identical) return false;

if (!is_identical) {
Expand Down
44 changes: 7 additions & 37 deletions perf_test/sparse/KokkosSparse_multimem_spgemm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,7 @@ namespace Experiment{
typedef Kokkos::Device<exec_space, sbm_mem_space> mySlowExecSpace;

typedef typename KokkosSparse::CrsMatrix<scalar_t, lno_t, myFastDevice, void, size_type > fast_crstmat_t;
//typedef typename fast_crstmat_t::StaticCrsGraphType fast_graph_t;
//typedef typename fast_crstmat_t::row_map_type::non_const_type fast_row_map_view_t;
typedef typename fast_crstmat_t::index_type::non_const_type fast_cols_view_t;
typedef typename fast_crstmat_t::values_type::non_const_type fast_values_view_t;
typedef typename fast_crstmat_t::row_map_type::const_type const_fast_row_map_view_t;
typedef typename fast_crstmat_t::index_type::const_type const_fast_cols_view_t;
typedef typename fast_crstmat_t::values_type::const_type const_fast_values_view_t;

typedef typename KokkosSparse::CrsMatrix<scalar_t, lno_t, mySlowExecSpace, void, size_type > slow_crstmat_t;
//typedef typename slow_crstmat_t::StaticCrsGraphType slow_graph_t;
//typedef typename slow_crstmat_t::row_map_type::non_const_type slow_row_map_view_t;
typedef typename slow_crstmat_t::index_type::non_const_type slow_cols_view_t;
typedef typename slow_crstmat_t::values_type::non_const_type slow_values_view_t;
typedef typename slow_crstmat_t::row_map_type::const_type const_slow_row_map_view_t;
typedef typename slow_crstmat_t::index_type::const_type const_slow_cols_view_t;
typedef typename slow_crstmat_t::values_type::const_type const_slow_values_view_t;

char *a_mat_file = params.a_mtx_bin_file;
char *b_mat_file = params.b_mtx_bin_file;
Expand Down Expand Up @@ -248,41 +233,26 @@ namespace Experiment{

if (c_mat_file != NULL){
if (params.c_mem_space == 1){

fast_cols_view_t sorted_adj("sorted adj", c_fast_crsmat.graph.entries.extent(0));
fast_values_view_t sorted_vals("sorted vals", c_fast_crsmat.graph.entries.extent(0));

KokkosKernels::Impl::kk_sort_graph
<const_fast_row_map_view_t, const_fast_cols_view_t, const_fast_values_view_t, fast_cols_view_t, fast_values_view_t, myExecSpace>(
c_fast_crsmat.graph.row_map,
c_fast_crsmat.graph.entries,
c_fast_crsmat.values, sorted_adj, sorted_vals);
KokkosKernels::sort_crs_matrix(c_fast_crsmat);

KokkosKernels::Impl::write_graph_bin(
(lno_t) (c_fast_crsmat.numRows()),
(size_type) (c_fast_crsmat.graph.entries.extent(0)),
c_fast_crsmat.graph.row_map.data(),
sorted_adj.data(),
sorted_vals.data(),
c_fast_crsmat.graph.entries.data(),
c_fast_crsmat.values.data(),
c_mat_file);
}
else {
slow_cols_view_t sorted_adj("sorted adj", c_fast_crsmat.graph.entries.extent(0));
slow_values_view_t sorted_vals("sorted vals", c_fast_crsmat.graph.entries.extent(0));

KokkosKernels::Impl::kk_sort_graph<
const_slow_row_map_view_t, const_slow_cols_view_t, const_slow_values_view_t, slow_cols_view_t, slow_values_view_t, myExecSpace>(
c_slow_crsmat.graph.row_map,
c_slow_crsmat.graph.entries,
c_slow_crsmat.values, sorted_adj, sorted_vals);
KokkosKernels::sort_crs_matrix(c_slow_crsmat);

KokkosKernels::Impl::write_graph_bin(
(lno_t) c_slow_crsmat.numRows(),
(size_type) c_slow_crsmat.graph.entries.extent(0),
c_slow_crsmat.graph.row_map.data(),
sorted_adj.data(),
sorted_vals.data(),
c_mat_file);
c_slow_crsmat.graph.entries.data(),
c_slow_crsmat.values.data(),
c_mat_file);
}
}
}
Expand Down
47 changes: 11 additions & 36 deletions perf_test/sparse/KokkosSparse_run_spgemm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#include "KokkosSparse_spgemm.hpp"
#include "KokkosKernels_TestParameters.hpp"

#include "KokkosKernels_Sorting.hpp"

#define TRANPOSEFIRST false
#define TRANPOSESECOND false
Expand All @@ -69,24 +69,7 @@ bool is_same_matrix(crsMat_t output_mat1, crsMat_t output_mat2){
size_t nentries2 = output_mat2.graph.entries.extent(0) ;
size_t nvals2 = output_mat2.values.extent(0);


lno_nnz_view_t h_ent1 (Kokkos::ViewAllocateWithoutInitializing("e1"), nentries1);
scalar_view_t h_vals1 (Kokkos::ViewAllocateWithoutInitializing("v1"), nvals1);


KokkosKernels::Impl::kk_sort_graph<typename graph_t::row_map_type,
typename graph_t::entries_type,
typename crsMat_t::values_type,
lno_nnz_view_t,
scalar_view_t,
typename device::execution_space
>(
output_mat1.graph.row_map, output_mat1.graph.entries, output_mat1.values,
h_ent1, h_vals1
);

lno_nnz_view_t h_ent2 (Kokkos::ViewAllocateWithoutInitializing("e1"), nentries2);
scalar_view_t h_vals2 (Kokkos::ViewAllocateWithoutInitializing("v1"), nvals2);
KokkosKernels::sort_crs_matrix(output_mat1);

if (nrows1 != nrows2) {
std::cerr <<"row count is different" << std::endl;
Expand All @@ -101,17 +84,7 @@ bool is_same_matrix(crsMat_t output_mat1, crsMat_t output_mat2){
return false;
}

KokkosKernels::Impl::kk_sort_graph
<typename graph_t::row_map_type,
typename graph_t::entries_type,
typename crsMat_t::values_type,
lno_nnz_view_t,
scalar_view_t,
typename device::execution_space
>(
output_mat2.graph.row_map, output_mat2.graph.entries, output_mat2.values,
h_ent2, h_vals2
);
KokkosKernels::sort_crs_matrix(output_mat2);

bool is_identical = true;
is_identical = KokkosKernels::Impl::kk_is_identical_view
Expand All @@ -124,21 +97,23 @@ bool is_same_matrix(crsMat_t output_mat1, crsMat_t output_mat2){

is_identical = KokkosKernels::Impl::kk_is_identical_view
<lno_nnz_view_t, lno_nnz_view_t, typename lno_nnz_view_t::value_type,
typename device::execution_space>(h_ent1, h_ent2, 0 );
typename device::execution_space>(output_mat1.graph.entries, output_mat2.graph.entries, 0 );
if (!is_identical) {
for (size_t i = 0; i < nrows1; ++i){
size_t rb = output_mat1.graph.row_map[i];
size_t re = output_mat1.graph.row_map[i + 1];
size_t rb = output_mat1.graph.row_map(i);
size_t re = output_mat1.graph.row_map(i + 1);
bool incorrect =false;
for (size_t j = rb; j < re; ++j){
if (h_ent1[j] != h_ent2[j]){
if (output_mat1.graph.entries(j) != output_mat2.graph.entries(j)){
incorrect = true;
break;
}
}
if (incorrect){
for (size_t j = rb; j < re; ++j){
std::cerr << "row:" << i << " j:" << j << " h_ent1[j]:" << h_ent1[j] << " h_ent2[j]:" << h_ent2[j] << " rb:" << rb << " re:" << re<< std::endl;
std::cerr << "row:" << i << " j:" << j <<
" h_ent1(j):" << output_mat1.graph.entries(j) << " h_ent2(j):" << output_mat2.graph.entries(j) <<
" rb:" << rb << " re:" << re << std::endl;
}
}

Expand All @@ -149,7 +124,7 @@ bool is_same_matrix(crsMat_t output_mat1, crsMat_t output_mat2){

is_identical = KokkosKernels::Impl::kk_is_identical_view
<scalar_view_t, scalar_view_t, typename scalar_view_t::value_type,
typename device::execution_space>(h_vals1, h_vals2, 0.000001);
typename device::execution_space>(output_mat1.values, output_mat2.values, 0.000001);
if (!is_identical) {
std::cerr << "Incorret values" << std::endl;
}
Expand Down
58 changes: 11 additions & 47 deletions perf_test/sparse/KokkosSparse_run_spgemm_jacobi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "KokkosSparse_CrsMatrix.hpp"
#include "KokkosKernels_TestParameters.hpp"
#include "KokkosSparse_spgemm.hpp"
#include "KokkosKernels_Sorting.hpp"

#define TRANSPOSEFIRST false
#define TRANSPOSESECOND false
Expand All @@ -69,16 +70,7 @@ namespace KokkosKernels{
size_t nentries2 = output_mat2.graph.entries.extent(0);
size_t nvals2 = output_mat2.values.extent(0);

lno_nnz_view_t h_ent1 (Kokkos::ViewAllocateWithoutInitializing("e1"), nentries1);
scalar_view_t h_vals1 (Kokkos::ViewAllocateWithoutInitializing("v1"), nvals1);

KokkosKernels::Impl::kk_sort_graph<typename graph_t::row_map_type, typename graph_t::entries_type, typename crsMat_t::values_type,
lno_nnz_view_t, scalar_view_t,
typename device::execution_space>(output_mat1.graph.row_map, output_mat1.graph.entries, output_mat1.values,
h_ent1, h_vals1);

lno_nnz_view_t h_ent2 (Kokkos::ViewAllocateWithoutInitializing("e1"), nentries2);
scalar_view_t h_vals2 (Kokkos::ViewAllocateWithoutInitializing("v1"), nvals2);
KokkosKernels::sort_crs_matrix(output_mat1);

if (nrows1 != nrows2) {
std::cerr <<"row count is different" << std::endl;
Expand All @@ -93,10 +85,7 @@ namespace KokkosKernels{
return false;
}

KokkosKernels::Impl::kk_sort_graph<typename graph_t::row_map_type, typename graph_t::entries_type, typename crsMat_t::values_type,
lno_nnz_view_t, scalar_view_t,
typename device::execution_space>(output_mat2.graph.row_map, output_mat2.graph.entries, output_mat2.values,
h_ent2, h_vals2);
KokkosKernels::sort_crs_matrix(output_mat2);

bool is_identical = true;
is_identical = KokkosKernels::Impl::kk_is_identical_view
Expand All @@ -109,7 +98,7 @@ namespace KokkosKernels{

is_identical = KokkosKernels::Impl::kk_is_identical_view
<lno_nnz_view_t, lno_nnz_view_t, typename lno_nnz_view_t::value_type,
typename device::execution_space>(h_ent1, h_ent2, 0);
typename device::execution_space>(output_mat1.graph.entries, output_mat2.graph.entries, 0);

if (!is_identical) {
std::cerr << "entries are different" << std::endl;
Expand All @@ -118,7 +107,7 @@ namespace KokkosKernels{

is_identical = KokkosKernels::Impl::kk_is_identical_view
<scalar_view_t, scalar_view_t, typename scalar_view_t::value_type,
typename device::execution_space>(h_vals1, h_vals2, 0.00001);
typename device::execution_space>(output_mat1.values, output_mat2.values, 0.00001);
if (!is_identical) {
std::cerr << "values are different" << std::endl;
}
Expand Down Expand Up @@ -318,18 +307,7 @@ namespace KokkosKernels{
typedef Kokkos::Device<exec_space, sbm_mem_space> mySlowExecSpace;

typedef typename KokkosSparse::CrsMatrix<scalar_t, lno_t, myFastDevice, void, size_type > fast_crstmat_t;
typedef typename fast_crstmat_t::index_type::non_const_type fast_cols_view_t;
typedef typename fast_crstmat_t::values_type::non_const_type fast_values_view_t;
typedef typename fast_crstmat_t::row_map_type::const_type const_fast_row_map_view_t;
typedef typename fast_crstmat_t::index_type::const_type const_fast_cols_view_t;
typedef typename fast_crstmat_t::values_type::const_type const_fast_values_view_t;

typedef typename KokkosSparse::CrsMatrix<scalar_t, lno_t, mySlowExecSpace, void, size_type > slow_crstmat_t;
typedef typename slow_crstmat_t::index_type::non_const_type slow_cols_view_t;
typedef typename slow_crstmat_t::values_type::non_const_type slow_values_view_t;
typedef typename slow_crstmat_t::row_map_type::const_type const_slow_row_map_view_t;
typedef typename slow_crstmat_t::index_type::const_type const_slow_cols_view_t;
typedef typename slow_crstmat_t::values_type::const_type const_slow_values_view_t;

char *a_mat_file = params.a_mtx_bin_file;
char *b_mat_file = params.b_mtx_bin_file;
Expand Down Expand Up @@ -505,37 +483,23 @@ namespace KokkosKernels{
if (c_mat_file != NULL){
if (params.c_mem_space == 1){

fast_cols_view_t sorted_adj("sorted adj", c_fast_crsmat.graph.entries.extent(0));
fast_values_view_t sorted_vals("sorted vals", c_fast_crsmat.graph.entries.extent(0));

KokkosKernels::Impl::kk_sort_graph
<const_fast_row_map_view_t, const_fast_cols_view_t, const_fast_values_view_t,
fast_cols_view_t, fast_values_view_t, myExecSpace>(c_fast_crsmat.graph.row_map,
c_fast_crsmat.graph.entries,
c_fast_crsmat.values, sorted_adj, sorted_vals);
KokkosKernels::sort_crs_matrix(c_fast_crsmat);

KokkosKernels::Impl::write_graph_bin((lno_t) (c_fast_crsmat.numRows()),
(size_type) (c_fast_crsmat.graph.entries.extent(0)),
c_fast_crsmat.graph.row_map.data(),
sorted_adj.data(),
sorted_vals.data(),
c_fast_crsmat.graph.entries.data(),
c_fast_crsmat.values.data(),
c_mat_file);
}
else {
slow_cols_view_t sorted_adj("sorted adj", c_fast_crsmat.graph.entries.extent(0));
slow_values_view_t sorted_vals("sorted vals", c_fast_crsmat.graph.entries.extent(0));

KokkosKernels::Impl::kk_sort_graph
<const_slow_row_map_view_t, const_slow_cols_view_t, const_slow_values_view_t,
slow_cols_view_t, slow_values_view_t, myExecSpace>(c_slow_crsmat.graph.row_map,
c_slow_crsmat.graph.entries,
c_slow_crsmat.values, sorted_adj, sorted_vals);
KokkosKernels::sort_crs_matrix(c_slow_crsmat);

KokkosKernels::Impl::write_graph_bin((lno_t) c_slow_crsmat.numRows(),
(size_type) c_slow_crsmat.graph.entries.extent(0),
c_slow_crsmat.graph.row_map.data(),
sorted_adj.data(),
sorted_vals.data(),
c_slow_crsmat.graph.entries.data(),
c_slow_crsmat.values.data(),
c_mat_file);
}
}
Expand Down
Loading