Skip to content

Commit

Permalink
Filter out private scratch allocations and fix typo for real this time
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Aug 6, 2024
1 parent 63c2d2e commit 9e7a2d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
10 changes: 8 additions & 2 deletions debugging/vov-bug-finder/kp_view_of_views_bug_finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ bool ignore_fence(std::string_view s) {
(s == "Kokkos::ThreadsInternal::fence: Unnamed Instance Fence");
}

bool ignore_alloc(std::string_view s) {
// TODO replace poor man's starts_with and ends_with when C++20 is available
return (s.find("Kokkos::") == 0 &&
s.rfind("::scratch_mem") == s.length() - 13);
}

std::optional<std::string> get_substr(std::string const &str,
std::string_view prefix,
std::string_view suffix) {
Expand Down Expand Up @@ -137,7 +143,7 @@ extern "C" void kokkosp_end_fence(uint64_t fenceID) {
extern "C" void kokkosp_allocate_data(SpaceHandle handle, const char *name,
void *ptr, uint64_t size) {
std::lock_guard lock(current.mutex);
if (!current.is_empty()) {
if (!current.is_empty() && !ignore_alloc(name)) {
std::cerr << "allocating \"" << name << "\" within parallel region \""
<< current.top() << "\"\n";
if (abort_on_error) {
Expand All @@ -154,7 +160,7 @@ extern "C" void kokkosp_allocate_data(SpaceHandle handle, const char *name,
extern "C" void kokkosp_deallocate_data(SpaceHandle handle, const char *name,
void *ptr, uint64_t size) {
std::lock_guard lock(current.mutex);
if (!current.is_empty()) {
if (!current.is_empty() && !ignore_alloc(name)) {
std::cerr << "deallocating \"" << name << "\" within parallel region \""
<< current.top() << "\"\n";
if (abort_on_error) {
Expand Down
20 changes: 19 additions & 1 deletion tests/vov-bug-finder/test_view_of_views_bug_finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,23 @@ void test_death_allocation_in_parallel_for() {
"allocating \"b\" within parallel region \"AllocatesInParallel]For\"");
}

// TODO intialize in main and split unit tests
void test_no_throw_team_scratch_pad_parallel_for() {
ASSERT_NO_THROW(({
Kokkos::parallel_for(
"L0",
Kokkos::TeamPolicy<>(1, Kokkos::AUTO)
.set_scratch_size(0, Kokkos::PerTeam(1000)),
KOKKOS_LAMBDA(Kokkos::TeamPolicy<>::member_type const &){});

Kokkos::parallel_for(
"L1",
Kokkos::TeamPolicy<>(1, Kokkos::AUTO)
.set_scratch_size(1, Kokkos::PerTeam(1000)),
KOKKOS_LAMBDA(Kokkos::TeamPolicy<>::member_type const &){});
}));
}

// TODO initialize in main and split unit tests
TEST(ViewOfViews, find_bugs) {
Kokkos::initialize();
{
Expand Down Expand Up @@ -104,6 +120,8 @@ TEST(ViewOfViews, find_bugs) {
test_no_throw_placement_new_in_parallel_for();

test_death_allocation_in_parallel_for();

test_no_throw_team_scratch_pad_parallel_for();
}
Kokkos::finalize();
}

0 comments on commit 9e7a2d2

Please sign in to comment.