Skip to content

Commit

Permalink
Simplify variable
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenmccoy committed Dec 22, 2022
1 parent 3b7c376 commit 1a53a05
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
5 changes: 2 additions & 3 deletions include/deal.II/base/partitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,8 @@ namespace Utilities
*/
// The variable is mutable to enable lazy initialization in
// export_to_ghosted_array_start().
mutable std::vector<std::pair<
Kokkos::View<unsigned int *, MemorySpace::Device::kokkos_space>,
unsigned int>>
mutable std::vector<
Kokkos::View<unsigned int *, MemorySpace::Device::kokkos_space>>
import_indices_plain_dev;

/**
Expand Down
22 changes: 11 additions & 11 deletions include/deal.II/base/partitioner.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace Utilities
# if defined(DEAL_II_MPI_WITH_DEVICE_SUPPORT)
if (std::is_same<MemorySpaceType, MemorySpace::Device>::value)
{
const auto chunk_size = import_indices_plain_dev[i].second;
const auto chunk_size = import_indices_plain_dev[i].size();
using IndexType = decltype(chunk_size);

MemorySpace::Device::kokkos_space::execution_space exec;
Expand All @@ -134,7 +134,7 @@ namespace Utilities
KOKKOS_LAMBDA(IndexType idx) {
temp_array_ptr[idx] =
locally_owned_array
.data()[import_indices_plain_dev[i].first[idx]];
.data()[import_indices_plain_dev[i](idx)];
});
exec.fence();
}
Expand Down Expand Up @@ -584,7 +584,7 @@ namespace Utilities
for (auto const &import_indices_plain :
import_indices_plain_dev)
{
const auto chunk_size = import_indices_plain.second;
const auto chunk_size = import_indices_plain.size();

using IndexType = decltype(chunk_size);
MemorySpace::Device::kokkos_space::execution_space exec;
Expand All @@ -594,7 +594,7 @@ namespace Utilities
exec, 0, chunk_size),
KOKKOS_LAMBDA(IndexType idx) {
locally_owned_array
.data()[import_indices_plain.first[idx]] +=
.data()[import_indices_plain(idx)] +=
read_position[idx];
});
exec.fence();
Expand All @@ -607,7 +607,7 @@ namespace Utilities
for (auto const &import_indices_plain :
import_indices_plain_dev)
{
const auto chunk_size = import_indices_plain.second;
const auto chunk_size = import_indices_plain.size();

using IndexType = decltype(chunk_size);
MemorySpace::Device::kokkos_space::execution_space exec;
Expand All @@ -617,10 +617,10 @@ namespace Utilities
exec, 0, chunk_size),
KOKKOS_LAMBDA(IndexType idx) {
locally_owned_array
.data()[import_indices_plain.first[idx]] =
.data()[import_indices_plain(idx)] =
internal::get_min(
locally_owned_array
.data()[import_indices_plain.first[idx]],
.data()[import_indices_plain(idx)],
read_position[idx]);
});
exec.fence();
Expand All @@ -633,7 +633,7 @@ namespace Utilities
for (auto const &import_indices_plain :
import_indices_plain_dev)
{
const auto chunk_size = import_indices_plain.second;
const auto chunk_size = import_indices_plain.size();

using IndexType = decltype(chunk_size);
MemorySpace::Device::kokkos_space::execution_space exec;
Expand All @@ -643,10 +643,10 @@ namespace Utilities
exec, 0, chunk_size),
KOKKOS_LAMBDA(IndexType idx) {
locally_owned_array
.data()[import_indices_plain.first[idx]] =
.data()[import_indices_plain(idx)] =
internal::get_max(
locally_owned_array
.data()[import_indices_plain.first[idx]],
.data()[import_indices_plain(idx)],
read_position[idx]);
});
exec.fence();
Expand All @@ -661,7 +661,7 @@ namespace Utilities
{
// We can't easily assert here, so we just move the
// pointer matching the host code.
const auto chunk_size = import_indices_plain.second;
const auto chunk_size = import_indices_plain.size();
read_position += chunk_size;
}
}
Expand Down
16 changes: 6 additions & 10 deletions source/base/partitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,13 @@ namespace Utilities
}

// Move the indices to the device
// std::cout << import_indices_plain_dev[i].second << std::endl;
Kokkos::View<unsigned int *, MemorySpace::Device::kokkos_space> view(
"import_indices_plain_dev" + std::to_string(i),
import_indices_plain_host.size());
Kokkos::deep_copy(view,
const auto chunk_size = import_indices_plain_host.size();
import_indices_plain_dev.emplace_back("import_indices_plain_dev" +
std::to_string(i),
chunk_size);
Kokkos::deep_copy(import_indices_plain_dev.back(),
Kokkos::View<unsigned int *, Kokkos::HostSpace>(
import_indices_plain_host.data(),
import_indices_plain_host.size()));

import_indices_plain_dev.emplace_back(
std::make_pair(view, import_indices_plain_host.size()));
import_indices_plain_host.data(), chunk_size));
}
}

Expand Down

0 comments on commit 1a53a05

Please sign in to comment.