diff --git a/perf_test/sparse/KokkosSparse_block_pcg.cpp b/perf_test/sparse/KokkosSparse_block_pcg.cpp index 5664e943fb..a1758c1ae7 100644 --- a/perf_test/sparse/KokkosSparse_block_pcg.cpp +++ b/perf_test/sparse/KokkosSparse_block_pcg.cpp @@ -322,7 +322,7 @@ void run_experiment( // typedef typename lno_nnz_view_t::value_type lno_t; // typedef typename lno_view_t::value_type size_type; // typedef typename scalar_view_t::value_type scalar_t; - KokkosSparse::Impl::kk_create_blockcrs_formated_point_crsmatrix( + KokkosSparse::Impl::kk_create_blockcrs_formatted_point_crsmatrix( block_size, crsmat.numRows(), crsmat.numCols(), crsmat.graph.row_map, crsmat.graph.entries, crsmat.values, out_r, out_c, pf_rm, pf_e, pf_v); diff --git a/perf_test/sparse/KokkosSparse_sptrsv_supernode.cpp b/perf_test/sparse/KokkosSparse_sptrsv_supernode.cpp index 612b327d5f..b7eb39d68e 100644 --- a/perf_test/sparse/KokkosSparse_sptrsv_supernode.cpp +++ b/perf_test/sparse/KokkosSparse_sptrsv_supernode.cpp @@ -59,13 +59,8 @@ #include "KokkosSparse_sptrsv_aux.hpp" -using namespace KokkosKernels; -using namespace KokkosKernels::Impl; -using namespace KokkosKernels::Experimental; -using namespace KokkosSparse; -using namespace KokkosSparse::Impl; -using namespace KokkosSparse::Experimental; -using namespace KokkosSparse::PerfTest::Experimental; +namespace KSExp = KokkosSparse::Experimental; +namespace KSPTE = KokkosSparse::PerfTest::Experimental; enum { CUSPARSE, @@ -213,23 +208,23 @@ int test_sptrsv_perf(std::vector tests, bool verbose, if (test == SUPERNODAL_NAIVE) { std::cout << " > create handle for SUPERNODAL_NAIVE" << std::endl << std::endl; - khL.create_sptrsv_handle(SPTRSVAlgorithm::SUPERNODAL_NAIVE, nrows, + khL.create_sptrsv_handle(KSExp::SPTRSVAlgorithm::SUPERNODAL_NAIVE, nrows, true); - khU.create_sptrsv_handle(SPTRSVAlgorithm::SUPERNODAL_NAIVE, nrows, + khU.create_sptrsv_handle(KSExp::SPTRSVAlgorithm::SUPERNODAL_NAIVE, nrows, true); } else if (test == SUPERNODAL_DAG) { std::cout << " > create handle for SUPERNODAL_DAG" << std::endl << std::endl; - khL.create_sptrsv_handle(SPTRSVAlgorithm::SUPERNODAL_DAG, nrows, + khL.create_sptrsv_handle(KSExp::SPTRSVAlgorithm::SUPERNODAL_DAG, nrows, true); - khU.create_sptrsv_handle(SPTRSVAlgorithm::SUPERNODAL_DAG, nrows, + khU.create_sptrsv_handle(KSExp::SPTRSVAlgorithm::SUPERNODAL_DAG, nrows, true); } else if (test == SUPERNODAL_SPMV_DAG) { std::cout << " > create handle for SUPERNODAL_SPMV_DAG" << std::endl << std::endl; - khL.create_sptrsv_handle(SPTRSVAlgorithm::SUPERNODAL_SPMV_DAG, + khL.create_sptrsv_handle(KSExp::SPTRSVAlgorithm::SUPERNODAL_SPMV_DAG, nrows, true); - khU.create_sptrsv_handle(SPTRSVAlgorithm::SUPERNODAL_SPMV_DAG, + khU.create_sptrsv_handle(KSExp::SPTRSVAlgorithm::SUPERNODAL_SPMV_DAG, nrows, true); } // verbose (optional, default is false) @@ -255,13 +250,13 @@ int test_sptrsv_perf(std::vector tests, bool verbose, // graph/dag) khU.get_sptrsv_handle()->set_column_major( !khL.get_sptrsv_handle()->is_column_major()); - sptrsv_supernodal_symbolic(nsuper, supercols.data(), etree, L.graph, - &khL, L.graph, &khU); + KSExp::sptrsv_supernodal_symbolic(nsuper, supercols.data(), etree, L.graph, + &khL, L.graph, &khU); // ============================================== // do numeric compute (copy numerical values from SuperLU data // structure to our sptrsv data structure) - sptrsv_compute(&khL, L); + KSExp::sptrsv_compute(&khL, L); // ============================================== // Preaparing for the first solve @@ -285,7 +280,7 @@ int test_sptrsv_perf(std::vector tests, bool verbose, // ============================================== // do L solve timer.reset(); - sptrsv_solve(&khL, sol, rhs); + KSExp::sptrsv_solve(&khL, sol, rhs); Kokkos::fence(); std::cout << " > Lower-TRI: " << std::endl; std::cout << " Solve Time : " << timer.seconds() << std::endl; @@ -297,7 +292,7 @@ int test_sptrsv_perf(std::vector tests, bool verbose, // Error Check ** on host ** Kokkos::fence(); std::cout << std::endl; - if (!check_errors(tol, A, rhs_host, sol_host)) { + if (!KSPTE::check_errors(tol, A, rhs_host, sol_host)) { num_failed++; } @@ -309,7 +304,7 @@ int test_sptrsv_perf(std::vector tests, bool verbose, Kokkos::fence(); for (int i = 0; i < loop; i++) { timer.reset(); - sptrsv_solve(&khL, sol, rhs); + KSExp::sptrsv_solve(&khL, sol, rhs); Kokkos::fence(); double time = timer.seconds(); ave_time += time; diff --git a/src/sparse/KokkosSparse_Utils.hpp b/src/sparse/KokkosSparse_Utils.hpp index 0ad7102dd5..db656c959b 100644 --- a/src/sparse/KokkosSparse_Utils.hpp +++ b/src/sparse/KokkosSparse_Utils.hpp @@ -72,7 +72,7 @@ namespace Impl { template -void kk_create_blockcrs_formated_point_crsmatrix( +void kk_create_blockcrs_formatted_point_crsmatrix( int block_size, size_t num_rows, size_t num_cols, in_row_view_t in_xadj, in_nnz_view_t in_adj, in_val_view_t in_vals, @@ -1958,7 +1958,7 @@ struct MatrixConverter { KokkosSparse::CrsMatrix, typename blockCrsMat_t = KokkosSparse::Experimental::BlockCrsMatrix< scalar_t, lno_t, device, void, size_type>> - static blockCrsMat_t from_blockcrs_formated_point_crsmatrix( + static blockCrsMat_t from_blockcrs_formatted_point_crsmatrix( const KokkosSparse::CrsMatrix &mtx, lno_t block_size) { @@ -1972,7 +1972,7 @@ struct MatrixConverter { typename device, typename bsrMtx_t = KokkosSparse::Experimental::BsrMatrix< scalar_t, lno_t, device, void, size_type>> - static bsrMtx_t from_blockcrs_formated_point_crsmatrix( + static bsrMtx_t from_blockcrs_formatted_point_crsmatrix( const KokkosSparse::CrsMatrix &mtx, lno_t block_size) { diff --git a/unit_test/sparse/Test_Sparse_block_gauss_seidel.hpp b/unit_test/sparse/Test_Sparse_block_gauss_seidel.hpp index 9092e78d79..b0c57ccf7e 100644 --- a/unit_test/sparse/Test_Sparse_block_gauss_seidel.hpp +++ b/unit_test/sparse/Test_Sparse_block_gauss_seidel.hpp @@ -59,20 +59,10 @@ #include #include "KokkosSparse_gauss_seidel.hpp" -// #ifndef kokkos_complex_double -// #define kokkos_complex_double Kokkos::complex -// #define kokkos_complex_float Kokkos::complex -// #endif +using kokkos_complex_double = Kokkos::complex; +using kokkos_complex_float = Kokkos::complex; -typedef Kokkos::complex kokkos_complex_double; -typedef Kokkos::complex kokkos_complex_float; - -using namespace KokkosKernels; -using namespace KokkosKernels::Impl; -using namespace KokkosKernels::Experimental; -using namespace KokkosSparse; -using namespace KokkosSparse::Impl; -using namespace KokkosSparse::Experimental; +namespace KSExp = KokkosSparse::Experimental; namespace Test { @@ -92,7 +82,7 @@ struct GSTestParams { // Note: GS_DEFAULT is same as GS_TEAM and - for blocks - as GS_PERMUTED // Note: GS_TWOSTAGE and GS_CLUSTER are not supported for blocks - std::vector gs_algorithms = {GS_DEFAULT}; + std::vector gs_algorithms = {KokkosSparse::GS_DEFAULT}; std::vector shmem_sizes = { 32128, 2008 // make the shmem small on gpus so that it will test 2 level @@ -121,12 +111,11 @@ int run_block_gauss_seidel_1( typedef typename lno_nnz_view_t::value_type lno_t; typedef typename scalar_view_t::value_type scalar_t; - constexpr auto format = MatrixTraits::format; + constexpr auto format = KokkosSparse::Impl::MatrixTraits::format; - typedef KokkosKernelsHandle< + using KernelHandle = KokkosKernels::Experimental::KokkosKernelsHandle< size_type, lno_t, scalar_t, typename mtx_t::execution_space, - typename mtx_t::memory_space, typename mtx_t::memory_space> - KernelHandle; + typename mtx_t::memory_space, typename mtx_t::memory_space>; KernelHandle kh; kh.set_team_work_size(16); kh.set_shmem_size(shmem_size); @@ -138,33 +127,33 @@ int run_block_gauss_seidel_1( const int apply_count = 100; if (!skip_symbolic) { - block_gauss_seidel_symbolic(&kh, num_rows_1, num_cols_1, block_size, + KSExp::block_gauss_seidel_symbolic(&kh, num_rows_1, num_cols_1, block_size, input_mat.graph.row_map, input_mat.graph.entries, is_symmetric_graph); } if (!skip_numeric) { - block_gauss_seidel_numeric( + KSExp::block_gauss_seidel_numeric( &kh, num_rows_1, num_cols_1, block_size, input_mat.graph.row_map, input_mat.graph.entries, input_mat.values, is_symmetric_graph); } switch (apply_type) { case Test::forward_sweep: - forward_sweep_block_gauss_seidel_apply( + KSExp::forward_sweep_block_gauss_seidel_apply( &kh, num_rows_1, num_cols_1, block_size, input_mat.graph.row_map, input_mat.graph.entries, input_mat.values, x_vector, y_vector, false, true, omega, apply_count); break; case Test::backward_sweep: - backward_sweep_block_gauss_seidel_apply( + KSExp::backward_sweep_block_gauss_seidel_apply( &kh, num_rows_1, num_cols_1, block_size, input_mat.graph.row_map, input_mat.graph.entries, input_mat.values, x_vector, y_vector, false, true, omega, apply_count); break; case Test::symmetric: default: - symmetric_block_gauss_seidel_apply( + KSExp::symmetric_block_gauss_seidel_apply( &kh, num_rows_1, num_cols_1, block_size, input_mat.graph.row_map, input_mat.graph.entries, input_mat.values, x_vector, y_vector, false, true, omega, apply_count); @@ -183,9 +172,9 @@ void test_block_gauss_seidel_rank1(lno_t numRows, size_type nnz, lno_t bandwidth, lno_t row_size_variance) { using namespace Test; srand(245); - typedef - typename KokkosSparse::CrsMatrix - crsMat_t; + using crsMat_t = + typename KokkosSparse::CrsMatrix; + using MatrixConverter = KokkosSparse::Impl::MatrixConverter; typedef typename device::execution_space exec_space; typedef typename crsMat_t::StaticCrsGraphType graph_t; @@ -213,7 +202,7 @@ void test_block_gauss_seidel_rank1(lno_t numRows, size_type nnz, // this makes consecutive 5 rows to have same columns. // it will add scalar 0's for those entries that does not exists. // the result is still a point crs matrix. - KokkosSparse::Impl::kk_create_blockcrs_formated_point_crsmatrix( + KokkosSparse::Impl::kk_create_blockcrs_formatted_point_crsmatrix( block_size, crsmat.numRows(), crsmat.numCols(), crsmat.graph.row_map, crsmat.graph.entries, crsmat.values, out_r, out_c, pf_rm, pf_e, pf_v); graph_t static_graph2(pf_e, pf_rm); @@ -221,7 +210,7 @@ void test_block_gauss_seidel_rank1(lno_t numRows, size_type nnz, // this converts the previous generated matrix to block matrix. auto input_mat = - MatrixConverter::from_blockcrs_formated_point_crsmatrix( + MatrixConverter::from_blockcrs_formatted_point_crsmatrix( crsmat2, block_size); lno_t nv = ((crsmat2.numRows() + block_size - 1) / block_size) * block_size; @@ -270,9 +259,9 @@ void test_block_gauss_seidel_rank2(lno_t numRows, size_type nnz, lno_t bandwidth, lno_t row_size_variance) { using namespace Test; srand(245); - typedef - typename KokkosSparse::CrsMatrix - crsMat_t; + using crsMat_t = + typename KokkosSparse::CrsMatrix; + using MatrixConverter = KokkosSparse::Impl::MatrixConverter; typedef typename device::execution_space exec_space; typedef typename crsMat_t::StaticCrsGraphType graph_t; @@ -301,14 +290,14 @@ void test_block_gauss_seidel_rank2(lno_t numRows, size_type nnz, // this makes consecutive 5 rows to have same columns. // it will add scalar 0's for those entries that does not exists. // the result is still a point crs matrix. - KokkosSparse::Impl::kk_create_blockcrs_formated_point_crsmatrix( + KokkosSparse::Impl::kk_create_blockcrs_formatted_point_crsmatrix( block_size, crsmat.numRows(), crsmat.numCols(), crsmat.graph.row_map, crsmat.graph.entries, crsmat.values, out_r, out_c, pf_rm, pf_e, pf_v); graph_t static_graph2(pf_e, pf_rm); crsMat_t crsmat2("CrsMatrix2", out_c, pf_v, static_graph2); auto input_mat = - MatrixConverter::from_blockcrs_formated_point_crsmatrix( + MatrixConverter::from_blockcrs_formatted_point_crsmatrix( crsmat2, block_size); lno_t nv = ((crsmat2.numRows() + block_size - 1) / block_size) * block_size; @@ -385,10 +374,9 @@ void test_block_gauss_seidel_empty() { typedef typename graph_t::row_map_type::non_const_type row_map_type; typedef typename graph_t::entries_type::non_const_type entries_type; typedef typename crsMat_t::values_type::non_const_type scalar_view_t; - typedef KokkosKernelsHandle< + using KernelHandle = KokkosKernels::Experimental::KokkosKernelsHandle< size_type, lno_t, scalar_t, typename device::execution_space, - typename device::memory_space, typename device::memory_space> - KernelHandle; + typename device::memory_space, typename device::memory_space>; // The rowmap of a zero-row matrix can be length 0 or 1, so Gauss-Seidel // should work with both (the setup and apply are essentially no-ops but they // shouldn't crash or throw exceptions) For this test, create size-0 and @@ -396,7 +384,7 @@ void test_block_gauss_seidel_empty() { // which can trigger different bugs. for (const int rowmapLen : {0, 1, 5}) { KernelHandle kh; - kh.create_gs_handle(GS_DEFAULT); + kh.create_gs_handle(KokkosSparse::GS_DEFAULT); const auto num_rows = KOKKOSKERNELS_MACRO_MAX(0, rowmapLen - 1); const lno_t block_size = 1; // irrelevant (no values here) // initialized to 0 @@ -404,14 +392,14 @@ void test_block_gauss_seidel_empty() { entries_type entries("Entries", 0); scalar_view_t values("Values", 0); // also, make sure graph symmetrization doesn't crash on zero rows - block_gauss_seidel_symbolic(&kh, num_rows, num_rows, block_size, rowmap, + KSExp::block_gauss_seidel_symbolic(&kh, num_rows, num_rows, block_size, rowmap, entries, false); - block_gauss_seidel_numeric(&kh, num_rows, num_rows, block_size, + KSExp::block_gauss_seidel_numeric(&kh, num_rows, num_rows, block_size, rowmap, entries, values, false); scalar_view_t x("X", num_rows); scalar_view_t y("Y", num_rows); scalar_t omega(0.9); - symmetric_block_gauss_seidel_apply( + KSExp::symmetric_block_gauss_seidel_apply( &kh, num_rows, num_rows, block_size, rowmap, entries, values, x, y, false, true, omega, 3); kh.destroy_gs_handle();