Skip to content

Commit

Permalink
Correct indexing copy+paste error.
Browse files Browse the repository at this point in the history
  • Loading branch information
CKegel committed Feb 7, 2024
1 parent 00b6532 commit 0954ba0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/MeshField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ template <class Slice> class Field {

Kokkos::View<base_type*> serial ("serialized field", N);

Kokkos::fence();
Kokkos::parallel_for("field serializer", N, KOKKOS_CLASS_LAMBDA (const int index) {
constexpr std::size_t rank = RANK;
auto serial_data = serial;
Expand Down Expand Up @@ -89,7 +90,7 @@ template <class Slice> class Field {
else if constexpr (rank == 5) {
s = index / (size(4) * size(3) * size(2) * size(1));
temp_index -= s * size(4) * size(3) * size(2) * size(1);
a = index / (size(3) * size(2) * size(1));
a = temp_index / (size(3) * size(2) * size(1));
temp_index -= a * size(3) * size(2) * size(1);
i = temp_index / (size(2) * size(1));
temp_index -= i * size(2) * size(1);
Expand All @@ -99,6 +100,7 @@ template <class Slice> class Field {
}

});
Kokkos::fence();
return std::move(serial);
}

Expand All @@ -107,7 +109,7 @@ template <class Slice> class Field {
for(size_t i = 1; i < RANK; ++i)
N *= size(i);
assert(N == serialized.size());

Kokkos::fence();
Kokkos::parallel_for("field deserializer", N, KOKKOS_CLASS_LAMBDA (const int index) {
auto serialized_data = serialized;
size_t temp_index = index;
Expand Down Expand Up @@ -141,7 +143,7 @@ template <class Slice> class Field {
else if constexpr (rank == 5) {
s = index / (size(4) * size(3) * size(2) * size(1));
temp_index -= s * size(4) * size(3) * size(2) * size(1);
a = index / (size(3) * size(2) * size(1));
a = temp_index / (size(3) * size(2) * size(1));
temp_index -= a * size(3) * size(2) * size(1);
i = temp_index / (size(2) * size(1));
temp_index -= i * size(2) * size(1);
Expand All @@ -150,6 +152,7 @@ template <class Slice> class Field {
slice(s, a, i, j, k) = serialized_data(index);
}
});
Kokkos::fence();
}
};

Expand Down

0 comments on commit 0954ba0

Please sign in to comment.