diff --git a/src/tests/interpolation/test_interpolation_finite_element_cached.cc b/src/tests/interpolation/test_interpolation_finite_element_cached.cc index 605e44021..5d75a8dfd 100644 --- a/src/tests/interpolation/test_interpolation_finite_element_cached.cc +++ b/src/tests/interpolation/test_interpolation_finite_element_cached.cc @@ -140,7 +140,7 @@ CASE("extract cache, copy it, and pass non-owning pointer") { const auto& matrix_storage = get_or_create_cache(grid_source, grid_target).matrix(); atlas::linalg::SparseMatrixStorage matrix_storage_copy(matrix_storage); - auto matrix = atlas::linalg::make_host_view(matrix_storage_copy); + auto matrix = atlas::linalg::make_host_view(matrix_storage_copy); EXPECT(not matrix.empty()); diff --git a/src/tests/interpolation/test_interpolation_k_nearest_neighbours.cc b/src/tests/interpolation/test_interpolation_k_nearest_neighbours.cc index 83e1aacb3..86677c1ae 100644 --- a/src/tests/interpolation/test_interpolation_k_nearest_neighbours.cc +++ b/src/tests/interpolation/test_interpolation_k_nearest_neighbours.cc @@ -40,7 +40,7 @@ class Access { std::string hash() { eckit::MD5 hash; - const auto m = atlas::linalg::make_host_view(matrix()); + const auto m = atlas::linalg::make_host_view(matrix()); const auto outer = m.outer(); const auto index = m.inner(); const auto weight = m.value(); diff --git a/src/tests/linalg/test_linalg_sparse_matrix.cc b/src/tests/linalg/test_linalg_sparse_matrix.cc index 88a87b0c0..f6c43645b 100644 --- a/src/tests/linalg/test_linalg_sparse_matrix.cc +++ b/src/tests/linalg/test_linalg_sparse_matrix.cc @@ -38,7 +38,7 @@ void do_matrix_multiply(const atlas::linalg::SparseMatrixView +template > Eigen::SparseMatrix create_eigen_sparsematrix() { Eigen::SparseMatrix matrix(3,3); std::vector> triplets; @@ -71,11 +71,11 @@ void check_array(const array::Array& array, const std::vector& expected) } -template +template void check_matrix(const SparseMatrixStorage& m) { - std::vector expected_value{2., -3., 2., 2.}; - std::vector expected_outer{0, 2, 3, 4}; - std::vector expected_inner{0, 2, 1, 2}; + std::vector expected_value{2., -3., 2., 2.}; + std::vector expected_outer{0, 2, 3, 4}; + std::vector expected_inner{0, 2, 1, 2}; EXPECT_EQ(m.rows(), 3); EXPECT_EQ(m.cols(), 3); @@ -85,11 +85,11 @@ void check_matrix(const SparseMatrixStorage& m) { check_array(m.outer(),expected_outer); check_array(m.inner(),expected_inner); - auto host_matrix_view = linalg::make_host_view(m); + auto host_matrix_view = linalg::make_host_view(m); - std::vector host_outer(host_matrix_view.outer_size()); - std::vector host_inner(host_matrix_view.inner_size()); - std::vector host_value(host_matrix_view.value_size()); + std::vector host_outer(host_matrix_view.outer_size()); + std::vector host_inner(host_matrix_view.inner_size()); + std::vector host_value(host_matrix_view.value_size()); array::ArrayT x(m.cols()); array::ArrayT y(m.rows()); @@ -103,11 +103,29 @@ void check_matrix(const SparseMatrixStorage& m) { } void check_matrix(const SparseMatrixStorage& m) { - if (m.value().datatype() == atlas::make_datatype()) { - check_matrix(m); + if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); } - else if (m.value().datatype() == atlas::make_datatype()) { - check_matrix(m); + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); } else { ATLAS_NOTIMPLEMENTED; diff --git a/src/tests/linalg/test_linalg_sparse_matrix_gpu.cc b/src/tests/linalg/test_linalg_sparse_matrix_gpu.cc index eaf003f31..5bb2da54d 100644 --- a/src/tests/linalg/test_linalg_sparse_matrix_gpu.cc +++ b/src/tests/linalg/test_linalg_sparse_matrix_gpu.cc @@ -48,10 +48,10 @@ void do_hicsparse_matrix_multiply(const atlas::linalg::SparseMatrixView hicsparseIndexType_t { - if (std::is_same_v,int> ) { + if (std::is_same_v>,int> ) { return HICSPARSE_INDEX_32I; } - else if (std::is_same_v,long> ) { + else if (std::is_same_v>,long> ) { return HICSPARSE_INDEX_64I; } ATLAS_NOTIMPLEMENTED; @@ -129,7 +129,7 @@ void do_hicsparse_matrix_multiply(const atlas::linalg::SparseMatrixView +template > Eigen::SparseMatrix create_eigen_sparsematrix() { Eigen::SparseMatrix matrix(3,3); std::vector> triplets; @@ -162,11 +162,11 @@ void check_array(const array::Array& array, const std::vector& expected) } -template +template void check_matrix(const SparseMatrixStorage& m) { - std::vector expected_value{2., -3., 2., 2.}; - std::vector expected_outer{0, 2, 3, 4}; - std::vector expected_inner{0, 2, 1, 2}; + std::vector expected_value{2., -3., 2., 2.}; + std::vector expected_outer{0, 2, 3, 4}; + std::vector expected_inner{0, 2, 1, 2}; EXPECT_EQ(m.rows(), 3); EXPECT_EQ(m.cols(), 3); @@ -177,16 +177,16 @@ void check_matrix(const SparseMatrixStorage& m) { check_array(m.inner(),expected_inner); m.updateDevice(); - auto host_matrix_view = make_host_view(m); - auto device_matrix_view = make_device_view(m); + auto host_matrix_view = make_host_view(m); + auto device_matrix_view = make_device_view(m); - std::vector host_outer(host_matrix_view.outer_size()); - std::vector host_inner(host_matrix_view.inner_size()); - std::vector host_value(host_matrix_view.value_size()); + std::vector host_outer(host_matrix_view.outer_size()); + std::vector host_inner(host_matrix_view.inner_size()); + std::vector host_value(host_matrix_view.value_size()); - hicMemcpy(host_outer.data(), device_matrix_view.outer(), device_matrix_view.outer_size() * sizeof(eckit::linalg::Index), hicMemcpyDeviceToHost); - hicMemcpy(host_inner.data(), device_matrix_view.inner(), device_matrix_view.inner_size() * sizeof(eckit::linalg::Index), hicMemcpyDeviceToHost); - hicMemcpy(host_value.data(), device_matrix_view.value(), device_matrix_view.value_size() * sizeof(Value), hicMemcpyDeviceToHost); + hicMemcpy(host_outer.data(), device_matrix_view.outer(), device_matrix_view.outer_size() * sizeof(Index), hicMemcpyDeviceToHost); + hicMemcpy(host_inner.data(), device_matrix_view.inner(), device_matrix_view.inner_size() * sizeof(Index), hicMemcpyDeviceToHost); + hicMemcpy(host_value.data(), device_matrix_view.value(), device_matrix_view.value_size() * sizeof(Value), hicMemcpyDeviceToHost); EXPECT(host_outer == expected_outer); EXPECT(host_inner == expected_inner); @@ -209,11 +209,29 @@ void check_matrix(const SparseMatrixStorage& m) { } void check_matrix(const SparseMatrixStorage& m) { - if (m.value().datatype() == atlas::make_datatype()) { - check_matrix(m); + if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); + } + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); } - else if (m.value().datatype() == atlas::make_datatype()) { - check_matrix(m); + else if (m.value().datatype() == atlas::make_datatype() && m.outer().datatype() == atlas::make_datatype()) { + check_matrix(m); } else { ATLAS_NOTIMPLEMENTED;