Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ GSYMS
GTAGS
GPATH
.gitignore
.cache

### OS
# temporary and backup files
Expand Down
11 changes: 11 additions & 0 deletions common/cuda_hip/matrix/csr_kernels.template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "core/matrix/csr_kernels.hpp"

#include <algorithm>
#include <exception>
#include <stdexcept>

#include <thrust/copy.h>
#include <thrust/count.h>
Expand Down Expand Up @@ -1397,6 +1399,15 @@ void spgeam(std::shared_ptr<const DefaultExecutor> exec,
const matrix::Csr<ValueType, IndexType>* b,
matrix::Csr<ValueType, IndexType>* c)
{
// check the sorting
bool sorted;
is_sorted_by_column_index(exec, a, &sorted);
if (!sorted)
throw std::invalid_argument("spgeam: a is not sorted by column index");
is_sorted_by_column_index(exec, b, &sorted);
if (!sorted)
throw std::invalid_argument("spgeam: b is not sorted by column index");
Comment on lines +1402 to +1409
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be in the data validation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where exactly?


auto total_nnz =
a->get_num_stored_elements() + b->get_num_stored_elements();
auto nnz_per_row = a->get_size()[0] ? total_nnz / a->get_size()[0] : 0;
Expand Down
2 changes: 2 additions & 0 deletions core/distributed/preconditioner/schwarz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ void Schwarz<ValueType, LocalIndexType, GlobalIndexType>::generate(
exec, local_matrix->get_size()[0], std::move(l1_diag_arr));
auto l1_diag_csr = Csr::create(exec);
l1_diag->move_to(l1_diag_csr);
l1_diag_csr->sort_by_column_index(); // spgeam requires sorting for
// some backends
auto id = matrix::Identity<ValueType>::create(
exec, local_matrix->get_size()[0]);
auto one = initialize<matrix::Dense<ValueType>>(
Expand Down
1 change: 1 addition & 0 deletions core/matrix/csr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void Csr<ValueType, IndexType>::apply_impl(const LinOp* alpha, const LinOp* b,
auto x_csr = as<TCsr>(x);
auto x_copy = x_csr->clone();
this->get_executor()->run(
// this here requires sorted diagonal matrix for some backends
csr::make_spgeam(as<Dense<ValueType>>(alpha), this,
as<Dense<ValueType>>(beta), x_copy.get(), x_csr));
} else {
Expand Down
Loading