Skip to content

Commit

Permalink
apply renaming to uses of matrix_data
Browse files Browse the repository at this point in the history
  • Loading branch information
upsj committed Sep 23, 2023
1 parent 2fb458d commit e7e7bb4
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions benchmark/sparse_blas/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ class SpgemmOperation : public BenchmarkOperation {
get_engine()));
}
}
data.ensure_row_major_order();
data.sort_row_major();
mtx2_ = Mtx::create(exec, size2);
mtx2_->read(data);
} else if (mode_str == "dense") {
const auto size2 = gko::dim<2>(size[1], FLAGS_spgemm_rowlength);
std::uniform_real_distribution<gko::remove_complex<etype>> dist(
-1.0, 1.0);
gko::matrix_data<etype, itype> data{size2, dist, get_engine()};
data.ensure_row_major_order();
data.sort_row_major();
mtx2_ = Mtx::create(exec, size2);
mtx2_->read(data);
} else {
Expand Down
2 changes: 1 addition & 1 deletion benchmark/sparse_blas/sparse_blas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct SparseBlasBenchmark : Benchmark<std::unique_ptr<Mtx>> {
json& test_case) const override
{
auto data = Generator::generate_matrix_data(test_case);
data.ensure_row_major_order();
data.sort_row_major();
std::clog << "Matrix is of size (" << data.size[0] << ", "
<< data.size[1] << "), " << data.nonzeros.size() << std::endl;
test_case["rows"] = data.size[0];
Expand Down
2 changes: 1 addition & 1 deletion benchmark/tools/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char** argv)
bool binary = std::string{argv[1]} == "-b";

auto data = gko::read_generic_raw<value_type, gko::int64>(std::cin);
data.ensure_row_major_order();
data.sort_row_major();
for (int argi = binary ? 2 : 1; argi < argc; argi++) {
std::string arg{argv[argi]};
if (arg == "lower-triangular") {
Expand Down
4 changes: 2 additions & 2 deletions core/base/mtx_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class mtx_io {
std::istringstream dimensions_stream(parsed_header.dimensions_line);
auto data = parsed_header.layout->read_data(
dimensions_stream, is, parsed_header.entry, parsed_header.modifier);
data.ensure_row_major_order();
data.sort_row_major();
return data;
}

Expand Down Expand Up @@ -868,7 +868,7 @@ matrix_data<ValueType, IndexType> read_binary_convert(std::istream& is,
result.nonzeros[i].column = column;
}
// sort the entries
result.ensure_row_major_order();
result.sort_row_major();
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions core/test/matrix/fbcsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,11 @@ TYPED_TEST(Fbcsr, GeneratesCorrectMatrixData)
using index_type = typename TestFixture::index_type;
using MtxData = typename TestFixture::MtxData;
MtxData refdata = this->fbsample.generate_matrix_data_with_explicit_zeros();
refdata.ensure_row_major_order();
refdata.sort_row_major();

MtxData data;
this->mtx->write(data);
data.ensure_row_major_order();
data.sort_row_major();

ASSERT_EQ(data.size, refdata.size);
ASSERT_EQ(data.nonzeros.size(), refdata.nonzeros.size());
Expand Down
2 changes: 1 addition & 1 deletion core/test/matrix/fbcsr_sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class FbcsrSample {
mdata.nonzeros.push_back({2, 3, 0.0});
mdata.nonzeros.push_back({2, 5, 0.0});
mdata.nonzeros.push_back({3, 6, 0.0});
mdata.ensure_row_major_order();
mdata.sort_row_major();
return mdata;
}

Expand Down
12 changes: 6 additions & 6 deletions core/test/utils/assertions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ ::testing::AssertionResult batch_matrices_near(
}

for (size_type b = 0; b < first_data.size(); ++b) {
first_data[b].ensure_row_major_order();
second_data[b].ensure_row_major_order();
first_data[b].sort_row_major();
second_data[b].sort_row_major();
}

return detail::batch_matrices_near_impl(
Expand Down Expand Up @@ -793,8 +793,8 @@ ::testing::AssertionResult matrices_near(
first->write(first_data);
second->write(second_data);

first_data.ensure_row_major_order();
second_data.ensure_row_major_order();
first_data.sort_row_major();
second_data.sort_row_major();

return detail::matrices_near_impl(
detail::remove_pointer_wrapper(first_expression),
Expand Down Expand Up @@ -977,8 +977,8 @@ ::testing::AssertionResult matrices_equal_sparsity(
first->write(first_data);
second->write(second_data);

first_data.ensure_row_major_order();
second_data.ensure_row_major_order();
first_data.sort_row_major();
second_data.sort_row_major();
// make sure if we write data to disk, it only contains ones.
for (auto& entry : first_data.nonzeros) {
entry.value = one<typename LinOp1::value_type>();
Expand Down
2 changes: 1 addition & 1 deletion core/test/utils/fb_matrix_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ std::unique_ptr<MatrixType> generate_random_matrix_with_diag(
});
}

data.ensure_row_major_order();
data.sort_row_major();

// convert to the correct matrix type
auto result = MatrixType::create(exec, std::forward<MatrixArgs>(args)...);
Expand Down
4 changes: 2 additions & 2 deletions core/test/utils/matrix_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ matrix_data<ValueType, IndexType> generate_random_matrix_data(
}
}

data.ensure_row_major_order();
data.sort_row_major();
return data;
}

Expand Down Expand Up @@ -315,7 +315,7 @@ matrix_data<ValueType, IndexType> generate_random_triangular_matrix_data(
}
}

data.ensure_row_major_order();
data.sort_row_major();
return data;
}

Expand Down
4 changes: 2 additions & 2 deletions core/utils/matrix_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void make_unit_diagonal(matrix_data<ValueType, IndexType>& data)
for (gko::int64 i = 0; i < num_diags; i++) {
data.nonzeros.emplace_back(i, i, one<ValueType>());
}
data.ensure_row_major_order();
data.sort_row_major();
}


Expand Down Expand Up @@ -222,7 +222,7 @@ void make_diag_dominant(matrix_data<ValueType, IndexType>& data,
}
}
}
data.ensure_row_major_order();
data.sort_row_major();
}


Expand Down
4 changes: 2 additions & 2 deletions examples/par-ilu-convergence/par-ilu-convergence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ double compute_ilu_residual_norm(
gko::matrix_data<ValueType, IndexType> mtx_data;
residual->write(residual_data);
mtx->write(mtx_data);
residual_data.ensure_row_major_order();
mtx_data.ensure_row_major_order();
residual_data.sort_row_major();
mtx_data.sort_row_major();
auto it = mtx_data.nonzeros.begin();
double residual_norm{};
for (auto entry : residual_data.nonzeros) {
Expand Down
2 changes: 1 addition & 1 deletion include/ginkgo/core/base/matrix_assembly_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class matrix_assembly_data {
entry.first.second,
entry.second};
});
data.ensure_row_major_order();
data.sort_row_major();
return data;
}

Expand Down
4 changes: 2 additions & 2 deletions include/ginkgo/core/base/matrix_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ struct matrix_data {
}
}
}
this->ensure_row_major_order();
this->sort_row_major();
}

/**
Expand Down Expand Up @@ -514,7 +514,7 @@ struct matrix_data {
*/
void sum_duplicates()
{
ensure_row_major_order();
sort_row_major();
std::vector<nonzero_type> new_nonzeros;
if (!nonzeros.empty()) {
new_nonzeros.emplace_back(nonzeros.front().row,
Expand Down
2 changes: 1 addition & 1 deletion reference/test/matrix/csr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ class CsrLookup : public ::testing::Test {
// row 3: very sparse
data.nonzeros.emplace_back(3, 0, 1.0);
data.nonzeros.emplace_back(3, 64, 1.0);
data.ensure_row_major_order();
data.sort_row_major();
// 1000 as min-sentinel
full_sizes = {0, 0, 1000, 1000, 0, 0};
bitmap_sizes = {0, 6, 4, 6, 2, 2};
Expand Down
2 changes: 1 addition & 1 deletion test/base/device_matrix_data_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DeviceMatrixData : public CommonTestFixture {
gko::zero<value_type>());
}
// remove duplicate nonzero locations
host_data.ensure_row_major_order();
host_data.sort_row_major();
host_data.nonzeros.erase(
std::unique(host_data.nonzeros.begin(), host_data.nonzeros.end(),
[](nonzero_type nz1, nonzero_type nz2) {
Expand Down
2 changes: 1 addition & 1 deletion test/distributed/vector_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ gko::device_matrix_data<ValueType, IndexType> generate_random_matrix_data_array(
num_rows, num_cols, std::forward<NonzeroDistribution>(nonzero_dist),
std::forward<ValueDistribution>(value_dist),
std::forward<Engine>(engine));
md.ensure_row_major_order();
md.sort_row_major();
return gko::device_matrix_data<ValueType, IndexType>::create_from_host(exec,
md);
}
Expand Down
2 changes: 1 addition & 1 deletion test/factorization/cholesky_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class Cholesky : public CommonTestFixture {
// add missing upper diagonal entries
// (values not important, only pattern important)
gko::utils::make_symmetric(mtx_chol_data);
mtx_chol_data.ensure_row_major_order();
mtx_chol_data.sort_row_major();
mtx_chol = matrix_type::create(ref);
mtx_chol->read(mtx_chol_data);
storage_offsets.resize_and_reset(num_rows + 1);
Expand Down
2 changes: 1 addition & 1 deletion test/matrix/csr_kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class CsrLookup : public CommonTestFixture {
data.nonzeros.emplace_back(221, i + 100, 1.0);
data.nonzeros.emplace_back(421, i * 3 + 100, 2.0);
}
data.ensure_row_major_order();
data.sort_row_major();
// initialize the matrices
mtx = Mtx::create(ref);
mtx->read(data);
Expand Down

0 comments on commit e7e7bb4

Please sign in to comment.