Skip to content

Commit

Permalink
kokkos-kernels: Fix replaceValues / sumIntoValues bug
Browse files Browse the repository at this point in the history
The bug in question is the following:

kokkos/kokkos-kernels#11

I will fix this in Trilinos first, so that Trilinos users can see the
benefit of this fix immediately.  Once Trilinos tests pass, I'll add
the patch to kokkos-kernels.
  • Loading branch information
Mark Hoemmen committed Sep 19, 2017
1 parent e95c9df commit 5c903c6
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions packages/kokkos-kernels/src/sparse/KokkosSparse_CrsMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ class CrsMatrix {
ordinal_type numValid = 0; // number of valid local column indices

for (ordinal_type i = 0; i < ncol; ++i) {
// NOTE (mfh 19 Sep 2017) This assumes that row_view stores
// column indices contiguously. It does, but one could imagine
// changing that at some point.
const ordinal_type offset =
findRelOffset (&(row_view.colidx(0)), length, cols[i], hint, is_sorted);
if (offset != length) {
Expand All @@ -648,9 +651,13 @@ class CrsMatrix {
else {
row_view.value(offset) += vals[i];
}
++numValid;
// If the hint is out of range, findRelOffset will ignore it.
// Thus, while it's harmless to have a hint out of range, it
// may slow down searches for subsequent valid input column
// indices.
hint = offset + 1;
}
hint = offset + 1;
++numValid;
}
return numValid;
}
Expand All @@ -672,6 +679,9 @@ class CrsMatrix {
ordinal_type numValid = 0; // number of valid local column indices

for (ordinal_type i = 0; i < ncol; ++i) {
// NOTE (mfh 19 Sep 2017) This assumes that row_view stores
// column indices contiguously. It does, but one could imagine
// changing that at some point.
const ordinal_type offset =
findRelOffset (&(row_view.colidx(0)), length, cols[i], hint, is_sorted);
if (offset != length) {
Expand All @@ -681,9 +691,13 @@ class CrsMatrix {
else {
row_view.value(offset) = vals[i];
}
++numValid;
// If the hint is out of range, findRelOffset will ignore it.
// Thus, while it's harmless to have a hint out of range, it
// may slow down searches for subsequent valid input column
// indices.
hint = offset + 1;
}
hint = offset + 1;
++numValid;
}
return numValid;
}
Expand Down

0 comments on commit 5c903c6

Please sign in to comment.