Skip to content

Commit

Permalink
Throw instead of UB if ending wrong parallel for
Browse files Browse the repository at this point in the history
  • Loading branch information
dalg24 committed Aug 4, 2024
1 parent aa95292 commit 64e7633
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion debugging/vov-bug-finder/kp_view_of_views_bug_finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <atomic>
#include <cstdint>
#include <exception>
#include <iostream>
#include <mutex>
#include <optional>
Expand Down Expand Up @@ -82,7 +83,12 @@ extern "C" void kokkosp_begin_parallel_for(char const *kernelName,

extern "C" void kokkosp_end_parallel_for(uint64_t kernelID) {
std::lock_guard lock(current_mutex);
current.erase(current.find(kernelID));
auto it = current.find(kernelID);
if (it == current.end()) {
throw std::runtime_error(
"Bug: attempting to end a parallel_for that is not \"running\"");
}
current.erase(it);

if (verbose) {
std::cout << "end kernel " << kernelID << '\n';
Expand Down

0 comments on commit 64e7633

Please sign in to comment.