Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
84adf70
Add std cout to exchange boundaries
aliemen Jul 7, 2026
6adf2d9
Seg fault happens in the loop, add cout inside
aliemen Jul 7, 2026
7e65139
Also add cout inside pack for the HaloCells
aliemen Jul 7, 2026
01e2e64
Remove std::cout and don't use the subview wrapper: use direct view a…
aliemen Jul 7, 2026
0c3b0ce
Lot's of AI generated debugging statements inside scatter
aliemen Jul 7, 2026
2c897d1
More debugging output for and a explicit 3D path for testing
aliemen Jul 7, 2026
6b3e414
More checks and debugging in the buffer system
aliemen Jul 7, 2026
5b4cc24
Also add raw kernel launch just to be sure
aliemen Jul 7, 2026
d5eb029
A lot more debugging calls. It looks like the kernel launch itself is…
aliemen Jul 7, 2026
7ed6a1a
Remove debugging output and only keep the empty kernel launch that fi…
aliemen Jul 7, 2026
f6174c8
Add other stuff back in
aliemen Jul 7, 2026
e12129a
Add env var's to isolate different kernel launches to investigate - s…
aliemen Jul 8, 2026
04ff0fd
Somehow the empty launches have to be inlined? Also add some debuggin…
aliemen Jul 8, 2026
8febce7
Remove again the debug kernel launches and only add make indices expl…
aliemen Jul 8, 2026
958b76f
Initialize BufferHandler correctly and add logging to communicator
aliemen Jul 8, 2026
e4fadc0
more debugging output
aliemen Jul 8, 2026
263eed1
Prepare BareField accumulateHalo env probe
aliemen Jul 9, 2026
0ef0f30
Revert GH200 halo debug probes
aliemen Jul 9, 2026
a0817c6
Test BareField pre-halo fence
aliemen Jul 9, 2026
f35e7d9
Try putting the fence only inside scatte
aliemen Jul 9, 2026
0250506
Fence before the accumulateHalo call, but after the timer?
aliemen Jul 9, 2026
249e57d
Fence only inside HaloCells?
aliemen Jul 9, 2026
f93cd19
Put fence inside accumulateHalo() but only in the multi rank path
aliemen Jul 9, 2026
c48afc6
Put the fence only inside exchangeBoundaries
aliemen Jul 9, 2026
899ba7f
And what if we put the fence ONLY before exchangeBoundary?
aliemen Jul 9, 2026
0b626fb
Initialize buffer handler accounting
aliemen Jul 9, 2026
979f6f2
Test non-template halo exchange boundaries
aliemen Jul 9, 2026
900681a
Revert non-template halo exchange test
aliemen Jul 9, 2026
b1dbe43
Force no-inline templated exchangeBoundaries. Perhaps the fence only …
aliemen Jul 10, 2026
0058317
Revert "Force no-inline templated exchangeBoundaries. Perhaps the fen…
aliemen Jul 10, 2026
565f73c
Avoid CUDA extended-lambda helper mismatch in halo kernels
aliemen Jul 10, 2026
323a125
Merge branch 'master' into investigate-accumulate-halo-segfault
aliemen Jul 10, 2026
f7a3db2
Forgot to add also copy the comments into the functor
aliemen Jul 10, 2026
d5ba52d
Merge branch 'master' into investigate-accumulate-halo-segfault
aliemen Jul 11, 2026
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
4 changes: 2 additions & 2 deletions src/Communicate/BufferHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ namespace ippl {
buffer_type reallocateLargestFreeBuffer(size_type requiredSize);
buffer_type allocateNewBuffer(size_type requiredSize);

size_type usedSize_m; ///< Total size of all allocated buffers
size_type freeSize_m; ///< Total size of all free buffers
size_type usedSize_m = 0; ///< Total size of all allocated buffers
size_type freeSize_m = 0; ///< Total size of all free buffers

protected:
buffer_set_type used_buffers{
Expand Down
145 changes: 88 additions & 57 deletions src/Field/HaloCells.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,79 @@

namespace ippl {
namespace detail {
// These kernels are instantiated in multiple translation units. Named functors avoid
// NVCC's translation-unit-local extended-lambda copy/delete helper state.
template <typename Subview, typename Buffer, typename IndexArray, unsigned Dim>
struct HaloPackFunctor {
Subview subview;
Buffer buffer;

KOKKOS_INLINE_FUNCTION void operator()(const IndexArray& args) const {
int l = 0;

for (unsigned d1 = 0; d1 < Dim; ++d1) {
int next = args[d1];
for (unsigned d2 = 0; d2 < d1; ++d2) {
next *= subview.extent(d2);
}
l += next;
}

buffer(l) = apply(subview, args);
}
};

template <typename Subview, typename Buffer, typename Op, typename IndexArray, unsigned Dim>
struct HaloUnpackFunctor {
Subview subview;
Buffer buffer;
Op op;

KOKKOS_INLINE_FUNCTION void operator()(const IndexArray& args) const {
int l = 0;

for (unsigned d1 = 0; d1 < Dim; ++d1) {
int next = args[d1];
for (unsigned d2 = 0; d2 < d1; ++d2) {
next *= subview.extent(d2);
}
l += next;
}

op(apply(subview, args), buffer(l));
}
};

template <typename View, typename Op, typename IndexArray>
struct HaloPeriodicFunctor {
View view;
Op op;
unsigned dimension;
int extent;
int nghost;

KOKKOS_INLINE_FUNCTION void operator()(IndexArray coords) const {
// The ghosts are filled starting from the inside of the domain proceeding outwards
// for both lower and upper faces. The extra brackets and explicit mention

// nghost + i
coords[dimension] += nghost;
auto&& left = apply(view, coords);

// N - nghost - i
coords[dimension] = extent - coords[dimension];
auto&& right = apply(view, coords);

// nghost - 1 - i
coords[dimension] += 2 * nghost - 1 - extent;
op(apply(view, coords), right);

// N - (nghost - 1 - i) = N - (nghost - 1) + i
coords[dimension] = extent - coords[dimension];
op(apply(view, coords), left);
}
};

template <typename T, unsigned Dim, class... ViewArgs>
HaloCells<T, Dim, ViewArgs...>::HaloCells() {}

Expand Down Expand Up @@ -171,31 +244,20 @@ namespace ippl {
auto subview = makeSubview(view, range);

auto& buffer = fd.buffer;

size_t size = subview.size();
nsends = size;
size_t size = subview.size();
nsends = size;
if (buffer.size() < size) {
int overalloc = Comm->getDefaultOverallocation();
Kokkos::realloc(buffer, size * overalloc);
}

using index_array_type =
typename RangePolicy<Dim, typename view_type::execution_space>::index_array_type;
ippl::parallel_for(
"HaloCells::pack()", getRangePolicy(subview),
KOKKOS_LAMBDA(const index_array_type& args) {
int l = 0;

for (unsigned d1 = 0; d1 < Dim; d1++) {
int next = args[d1];
for (unsigned d2 = 0; d2 < d1; d2++) {
next *= subview.extent(d2);
}
l += next;
}

buffer(l) = apply(subview, args);
});
using buffer_view_type = typename databuffer_type::view_type;
using functor_type =
HaloPackFunctor<decltype(subview), buffer_view_type, index_array_type, Dim>;
ippl::parallel_for("HaloCells::pack()", getRangePolicy(subview),
functor_type{subview, buffer});
Kokkos::fence();
}

Expand All @@ -212,21 +274,10 @@ namespace ippl {

using index_array_type =
typename RangePolicy<Dim, typename view_type::execution_space>::index_array_type;
ippl::parallel_for(
"HaloCells::unpack()", getRangePolicy(subview),
KOKKOS_LAMBDA(const index_array_type& args) {
int l = 0;

for (unsigned d1 = 0; d1 < Dim; d1++) {
int next = args[d1];
for (unsigned d2 = 0; d2 < d1; d2++) {
next *= subview.extent(d2);
}
l += next;
}

op(apply(subview, args), buffer(l));
});
using functor_type =
HaloUnpackFunctor<decltype(subview), decltype(buffer), Op, index_array_type, Dim>;
ippl::parallel_for("HaloCells::unpack()", getRangePolicy(subview),
functor_type{subview, buffer, op});
Kokkos::fence();
}

Expand Down Expand Up @@ -271,30 +322,10 @@ namespace ippl {
using index_array_type =
typename RangePolicy<Dim,
typename view_type::execution_space>::index_array_type;
ippl::parallel_for(
"applyPeriodicSerialDim", createRangePolicy<Dim, exec_space>(begin, end),
KOKKOS_LAMBDA(index_array_type & coords) {
// The ghosts are filled starting from the inside
// of the domain proceeding outwards for both lower
// and upper faces. The extra brackets and explicit
// mention

// nghost + i
coords[d] += nghost;
auto&& left = apply(view, coords);

// N - nghost - i
coords[d] = N - coords[d];
auto&& right = apply(view, coords);

// nghost - 1 - i
coords[d] += 2 * nghost - 1 - N;
op(apply(view, coords), right);

// N - (nghost - 1 - i) = N - (nghost - 1) + i
coords[d] = N - coords[d];
op(apply(view, coords), left);
});
using functor_type = HaloPeriodicFunctor<view_type, Op, index_array_type>;
ippl::parallel_for("applyPeriodicSerialDim",
createRangePolicy<Dim, exec_space>(begin, end),
functor_type{view, op, d, N, nghost});

Kokkos::fence();
}
Expand Down
Loading