diff --git a/common/unit_test/Test_Common_Iota.hpp b/common/unit_test/Test_Common_Iota.hpp index ee1e33fda8..e36f985b45 100644 --- a/common/unit_test/Test_Common_Iota.hpp +++ b/common/unit_test/Test_Common_Iota.hpp @@ -26,22 +26,22 @@ void test_iota_constructor() { // empty iota { Iota i; - EXPECT_EQ(i.size(), 0); + EXPECT_EQ(i.size(), size_t(0)); } // basic iota { Iota ten(10); - EXPECT_EQ(ten.size(), 10); + EXPECT_EQ(ten.size(), size_t(10)); for (size_t i = 0; i < ten.size(); ++i) { - EXPECT_EQ(ten(i), i); + EXPECT_EQ(ten(i), T(i)); } } // iota with negative offset if constexpr (std::is_signed_v) { Iota three(3, -7); - EXPECT_EQ(three.size(), 3); + EXPECT_EQ(three.size(), size_t(3)); for (size_t i = 0; i < three.size(); ++i) { EXPECT_EQ(three(i), T(i) - T(7)); } @@ -50,9 +50,9 @@ void test_iota_constructor() { // iota with positive offset { Iota three(3, 2); - EXPECT_EQ(three.size(), 3); + EXPECT_EQ(three.size(), size_t(3)); for (size_t i = 0; i < three.size(); ++i) { - EXPECT_EQ(three(i), i + 2); + EXPECT_EQ(three(i), T(i + 2)); } } @@ -60,11 +60,11 @@ void test_iota_constructor() { if constexpr (std::is_signed_v) { { Iota i(-7); - EXPECT_EQ(i.size(), 0); + EXPECT_EQ(i.size(), size_t(0)); } { Iota i(-1, 2); - EXPECT_EQ(i.size(), 0); + EXPECT_EQ(i.size(), size_t(0)); } } } @@ -89,9 +89,9 @@ void test_iota_subview() { Iota ten(10, 1); // 1..<11 Iota sub(ten, Kokkos::pair{7, 9}); // 8, 9 - EXPECT_EQ(sub.size(), 2); - EXPECT_EQ(sub(0), 8); - EXPECT_EQ(sub(1), 9); + EXPECT_EQ(sub.size(), size_t(2)); + EXPECT_EQ(sub(0), T(8)); + EXPECT_EQ(sub(1), T(9)); } template diff --git a/graph/unit_test/Test_Graph_mis2.hpp b/graph/unit_test/Test_Graph_mis2.hpp index cd96badd44..61cee13e2b 100644 --- a/graph/unit_test/Test_Graph_mis2.hpp +++ b/graph/unit_test/Test_Graph_mis2.hpp @@ -157,8 +157,8 @@ void test_mis2_coarsening(lno_t numVerts, size_type nnz, lno_t bandwidth, lno_t symRowmap, symEntries, labels, numClusters, coarseRowmapNC, coarseEntriesNC, false); KokkosGraph::Experimental::graph_explicit_coarsen( symRowmap, symEntries, labels, numClusters, coarseRowmapC, coarseEntriesC, true); - EXPECT_EQ(coarseRowmapC.extent(0), numClusters + 1); - EXPECT_EQ(coarseRowmapNC.extent(0), numClusters + 1); + EXPECT_EQ(coarseRowmapC.extent(0), size_t(numClusters) + 1); + EXPECT_EQ(coarseRowmapNC.extent(0), size_t(numClusters) + 1); // Check that coarse graph doesn't have more edges than fine graph EXPECT_LE(coarseEntriesC.extent(0), symEntries.extent(0)); EXPECT_LE(coarseEntriesNC.extent(0), symEntries.extent(0)); @@ -175,7 +175,7 @@ void test_mis2_coarsening(lno_t numVerts, size_type nnz, lno_t bandwidth, lno_t uniqueEntries.insert(hostEntriesNC(j)); } size_type compressedRowLen = hostRowmapC(i + 1) - hostRowmapC(i); - ASSERT_EQ(uniqueEntries.size(), compressedRowLen); + ASSERT_EQ(uniqueEntries.size(), size_t(compressedRowLen)); auto it = uniqueEntries.begin(); for (size_type j = hostRowmapC(i); j < hostRowmapC(i + 1); j++) { EXPECT_EQ(*it, hostEntriesC(j)); @@ -200,18 +200,18 @@ void test_mis2_coarsening_zero_rows() { lno_t numClusters; auto labels = KokkosGraph::graph_mis2_coarsen(fineRowmap, fineEntries, numClusters); EXPECT_EQ(numClusters, 0); - EXPECT_EQ(labels.extent(0), 0); + EXPECT_EQ(labels.extent(0), size_t(0)); // coarsen, should also produce a graph with 0 rows/entries rowmap_t coarseRowmap; entries_t coarseEntries; KokkosGraph::Experimental::graph_explicit_coarsen( fineRowmap, fineEntries, labels, 0, coarseRowmap, coarseEntries, false); - EXPECT_LE(coarseRowmap.extent(0), 1); - EXPECT_EQ(coarseEntries.extent(0), 0); + EXPECT_LE(coarseRowmap.extent(0), size_t(1)); + EXPECT_EQ(coarseEntries.extent(0), size_t(0)); KokkosGraph::Experimental::graph_explicit_coarsen( fineRowmap, fineEntries, labels, 0, coarseRowmap, coarseEntries, true); - EXPECT_LE(coarseRowmap.extent(0), 1); - EXPECT_EQ(coarseEntries.extent(0), 0); + EXPECT_LE(coarseRowmap.extent(0), size_t(1)); + EXPECT_EQ(coarseEntries.extent(0), size_t(0)); } #define EXECUTE_TEST(SCALAR, ORDINAL, OFFSET, DEVICE) \ diff --git a/sparse/impl/KokkosSparse_sptrsv_solve_impl.hpp b/sparse/impl/KokkosSparse_sptrsv_solve_impl.hpp index 3afeadc559..0f01c26f8e 100644 --- a/sparse/impl/KokkosSparse_sptrsv_solve_impl.hpp +++ b/sparse/impl/KokkosSparse_sptrsv_solve_impl.hpp @@ -218,6 +218,17 @@ struct SptrsvWrap { for (size_type i = 0; i < MAX_VEC_SIZE; ++i) m_data[i] = rhs_.m_data[i]; } + // copy-assignment + KOKKOS_INLINE_FUNCTION + ArrayType& operator=(const ArrayType& rhs_) { + if (this != &rhs_) { + for (size_type i = 0; i < MAX_VEC_SIZE; ++i) { + m_data[i] = rhs_.m_data[i]; + } + } + return *this; + } + KOKKOS_INLINE_FUNCTION ArrayType(const Vector &) { init(); } diff --git a/sparse/unit_test/Test_Sparse_CrsMatrix.hpp b/sparse/unit_test/Test_Sparse_CrsMatrix.hpp index 1dc3bb3c91..a85e889c9c 100644 --- a/sparse/unit_test/Test_Sparse_CrsMatrix.hpp +++ b/sparse/unit_test/Test_Sparse_CrsMatrix.hpp @@ -139,14 +139,15 @@ void testCrsMatrixRawConstructor() { int nrows = 5; // note: last 2 columns will be empty. // This makes sure the ncols provided to constructor is preserved. - int ncols = 7; - int nnz = 9; + int ncols = 7; + size_type nnz = 9; // NOTE: this is not a mistake, the raw ptr constructor takes rowmap as // ordinal. std::vector rowmap = {0, 0, 2, 5, 6, 9}; std::vector entries = {3, 4, 0, 1, 2, 2, 0, 3, 4}; std::vector values; - for (int i = 0; i < nnz; i++) values.push_back(Kokkos::ArithTraits::one() * (1.0 * rand() / RAND_MAX)); + for (size_type i = 0; i < nnz; i++) + values.push_back(Kokkos::ArithTraits::one() * (1.0 * rand() / RAND_MAX)); KokkosSparse::CrsMatrix A("A", nrows, ncols, nnz, values.data(), rowmap.data(), entries.data()); EXPECT_EQ(A.numRows(), nrows); @@ -158,7 +159,7 @@ void testCrsMatrixRawConstructor() { auto checkEntries = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.entries); auto checkValues = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.values); for (int i = 0; i < nrows + 1; i++) EXPECT_EQ(checkRowmap(i), (size_type)rowmap[i]); - for (int i = 0; i < nnz; i++) { + for (size_type i = 0; i < nnz; i++) { EXPECT_EQ(checkEntries(i), entries[i]); EXPECT_EQ(checkValues(i), values[i]); } @@ -192,8 +193,8 @@ void testCrsMatrixHostMirror() { crs_matrix_host zeroHost("zero1Host", zero); EXPECT_EQ(zeroHost.numRows(), 0); EXPECT_EQ(zeroHost.numCols(), 0); - EXPECT_EQ(zeroHost.nnz(), 0); - EXPECT_EQ(zeroHost.graph.row_map.extent(0), 0); + EXPECT_EQ(zeroHost.nnz(), size_type(0)); + EXPECT_EQ(zeroHost.graph.row_map.extent(0), size_t(0)); } #define KOKKOSKERNELS_EXECUTE_TEST(SCALAR, ORDINAL, OFFSET, DEVICE) \ diff --git a/sparse/unit_test/Test_Sparse_MergeMatrix.hpp b/sparse/unit_test/Test_Sparse_MergeMatrix.hpp index 6a4f5b4e5d..d793938e21 100644 --- a/sparse/unit_test/Test_Sparse_MergeMatrix.hpp +++ b/sparse/unit_test/Test_Sparse_MergeMatrix.hpp @@ -366,7 +366,7 @@ void view_iota_empty_empty() { AView a("view-iota-empty-empty-a", 0); BView b(0); - EXPECT_EQ(MMD(a, b, 0).size(), 0); + EXPECT_EQ(MMD(a, b, 0).size(), size_t(0)); } /*! \brief merge-matrix of a full view and empty iota @@ -385,7 +385,7 @@ void view_iota_full_empty() { BView b(0); for (size_t diagonal = 0; diagonal < a.size() + b.size() - 1; ++diagonal) { - EXPECT_EQ(MMD(a, b, diagonal).size(), 0); + EXPECT_EQ(MMD(a, b, diagonal).size(), size_t(0)); } } @@ -404,7 +404,7 @@ void view_iota_empty_full() { BView b(4); for (size_t diagonal = 0; diagonal < a.size() + b.size() - 1; ++diagonal) { - EXPECT_EQ(MMD(a, b, diagonal).size(), 0); + EXPECT_EQ(MMD(a, b, diagonal).size(), size_t(0)); } } diff --git a/sparse/unit_test/Test_Sparse_SortCrs.hpp b/sparse/unit_test/Test_Sparse_SortCrs.hpp index 0877665ae0..9600a2b563 100644 --- a/sparse/unit_test/Test_Sparse_SortCrs.hpp +++ b/sparse/unit_test/Test_Sparse_SortCrs.hpp @@ -420,7 +420,7 @@ void testSortAndMerge(bool justGraph, int howExecSpecified, bool doStructInterfa EXPECT_EQ(goldEntries.size(), outEntries.extent(0)); if (!justGraph) { EXPECT_EQ(goldValues.size(), outValues.extent(0)); - EXPECT_EQ(goldValues.size(), output.nnz()); + EXPECT_EQ(goldValues.size(), size_t(output.nnz())); } for (size_t i = 0; i < goldRowmap.size(); i++) EXPECT_EQ(goldRowmap[i], outRowmap(i)); for (size_t i = 0; i < goldEntries.size(); i++) { diff --git a/sparse/unit_test/Test_Sparse_TestUtils_RandCsMat.hpp b/sparse/unit_test/Test_Sparse_TestUtils_RandCsMat.hpp index f958e2423f..32a11d0a12 100644 --- a/sparse/unit_test/Test_Sparse_TestUtils_RandCsMat.hpp +++ b/sparse/unit_test/Test_Sparse_TestUtils_RandCsMat.hpp @@ -19,10 +19,11 @@ namespace Test { template void doCsMat(size_t m, size_t n, ScalarType min_val, ScalarType max_val) { - using RandCs = RandCsMatrix; - using size_type = typename RandCs::size_type; - auto expected_min = ScalarType(1.0); - size_t expected_nnz = 0; + using RandCs = RandCsMatrix; + using ordinal_type = typename RandCs::ordinal_type; + using size_type = typename RandCs::size_type; + auto expected_min = ScalarType(1.0); + ordinal_type expected_nnz = 0; RandCs cm(m, n, min_val, max_val); for (size_type i = 0; i < cm.get_nnz(); ++i) ASSERT_GE(cm(i), expected_min) << cm.info; @@ -44,13 +45,13 @@ void doCsMat(size_t m, size_t n, ScalarType min_val, ScalarType max_val) { // No need to check data here. Kokkos unit-tests deep_copy. auto vals = cm.get_vals(); - ASSERT_EQ(vals.extent(0), cm.get_nnz() + 1) << cm.info; + ASSERT_EQ(vals.extent(0), size_t(cm.get_nnz()) + 1) << cm.info; auto row_ids = cm.get_ids(); - ASSERT_EQ(row_ids.extent(0), cm.get_nnz()) << cm.info; + ASSERT_EQ(row_ids.extent(0), size_t(cm.get_nnz())) << cm.info; auto col_map = cm.get_map(); - ASSERT_EQ(col_map.extent(0), cm.get_dim1() + 1); + ASSERT_EQ(col_map.extent(0), size_t(cm.get_dim1()) + 1); ASSERT_EQ(map(cm.get_dim1()), expected_nnz) << cm.info; } diff --git a/sparse/unit_test/Test_Sparse_crs2coo.hpp b/sparse/unit_test/Test_Sparse_crs2coo.hpp index 8e49067944..cd163a32af 100644 --- a/sparse/unit_test/Test_Sparse_crs2coo.hpp +++ b/sparse/unit_test/Test_Sparse_crs2coo.hpp @@ -51,9 +51,9 @@ void check_coo_matrix(CrsType crsMatRef, RowType row, ColType col, DataType data Kokkos::fence(); - ASSERT_EQ(crsMatRef.nnz(), row.extent(0)); - ASSERT_EQ(crsMatRef.nnz(), col.extent(0)); - ASSERT_EQ(crsMatRef.nnz(), data.extent(0)); + ASSERT_EQ(size_t(crsMatRef.nnz()), row.extent(0)); + ASSERT_EQ(size_t(crsMatRef.nnz()), col.extent(0)); + ASSERT_EQ(size_t(crsMatRef.nnz()), data.extent(0)); for (decltype(row.extent(0)) idx = 0; idx < row.extent(0); ++idx) { auto row_id = row_h(idx); diff --git a/sparse/unit_test/Test_Sparse_par_ilut.hpp b/sparse/unit_test/Test_Sparse_par_ilut.hpp index 7bb5b54864..7392e063ea 100644 --- a/sparse/unit_test/Test_Sparse_par_ilut.hpp +++ b/sparse/unit_test/Test_Sparse_par_ilut.hpp @@ -94,8 +94,8 @@ void run_test_par_ilut() { const size_type nnzL = par_ilut_handle->get_nnzL(); const size_type nnzU = par_ilut_handle->get_nnzU(); - ASSERT_EQ(nnzL, 10); - ASSERT_EQ(nnzU, 8); + ASSERT_EQ(nnzL, size_type(10)); + ASSERT_EQ(nnzU, size_type(8)); EntriesType L_entries("L_entries", nnzL); ValuesType L_values("L_values", nnzL); @@ -337,8 +337,8 @@ void run_test_par_ilut_zerorow_A() { const size_type nnzL = par_ilut_handle->get_nnzL(); const size_type nnzU = par_ilut_handle->get_nnzU(); - ASSERT_EQ(nnzL, 0); - ASSERT_EQ(nnzU, 0); + ASSERT_EQ(nnzL, size_type(0)); + ASSERT_EQ(nnzU, size_type(0)); EntriesType L_entries("L_entries", nnzL); ValuesType L_values("L_values", nnzL); diff --git a/sparse/unit_test/Test_Sparse_spiluk.hpp b/sparse/unit_test/Test_Sparse_spiluk.hpp index 1fde1ac5ed..ab8aa9c8b3 100644 --- a/sparse/unit_test/Test_Sparse_spiluk.hpp +++ b/sparse/unit_test/Test_Sparse_spiluk.hpp @@ -327,7 +327,7 @@ struct SpilukTest { const size_type nnz = values.extent(0); const lno_t fill_lev = 2; const size_type block_size = nrows % 2 == 0 ? 2 : 3; - ASSERT_EQ(nrows % block_size, 0); + ASSERT_EQ(nrows % block_size, size_type(0)); KernelHandle kh; @@ -560,7 +560,7 @@ struct SpilukTest { const size_type nrows = Afix.size(); const size_type block_size = nrows % 2 == 0 ? 2 : 3; const size_type block_items = block_size * block_size; - ASSERT_EQ(nrows % block_size, 0); + ASSERT_EQ(nrows % block_size, size_type(0)); // Convert to BSR Crs crs("crs for block spiluk test", nrows, nrows, values.extent(0), values, row_map, entries);