Skip to content

Commit

Permalink
Merge branch '351-add-sorting-method-in-matrix_batch_csr-class' into …
Browse files Browse the repository at this point in the history
…'main'

Add sorting method in matrix_batch_csr class

Closes #351

See merge request gysela-developpers/gyselalibxx!692
  • Loading branch information
EmilyBourne committed Sep 24, 2024
1 parent 823c6ab commit c73c0e1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions vendor/sll/include/sll/matrix_batch_csr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,15 @@ class MatrixBatchCsr : public MatrixBatch<ExecSpace>
void setup_solver() final
{
std::shared_ptr const gko_exec = m_batch_matrix_csr->get_executor();

//Check if the indices array is sorted, and sort it if necessary.
//The values array corresponding to the indices is also reordered.
for (size_t i = 0; i < batch_size(); i++) {
std::unique_ptr<gko::matrix::Csr<double, int>> tmp_matrix
= m_batch_matrix_csr->create_view_for_item(i);
if (!tmp_matrix->is_sorted_by_column_index()) {
tmp_matrix->sort_by_column_index();
}
}
if constexpr (
Solver == MatrixBatchCsrSolver::CG || Solver == MatrixBatchCsrSolver::BICGSTAB) {
// Create the solver factory
Expand All @@ -212,7 +220,7 @@ class MatrixBatchCsr : public MatrixBatch<ExecSpace>
.on(gko_exec);

// Create the solvers
for (int i = 0; i < batch_size(); i++) {
for (size_t i = 0; i < batch_size(); i++) {
m_solver.emplace_back(solver_factory->generate(
m_batch_matrix_csr->create_const_view_for_item(i)));
}
Expand Down Expand Up @@ -247,7 +255,7 @@ class MatrixBatchCsr : public MatrixBatch<ExecSpace>

if constexpr (
Solver == MatrixBatchCsrSolver::CG || Solver == MatrixBatchCsrSolver::BICGSTAB) {
for (int i = 0; i < batch_size(); i++) {
for (size_t i = 0; i < batch_size(); i++) {
std::shared_ptr const gko_exec = m_solver[i]->get_executor();

// Create a logger to obtain the iteration counts and "implicit" residual norms for every system after the solve.
Expand Down

0 comments on commit c73c0e1

Please sign in to comment.