Skip to content

Commit

Permalink
Add exception warnings
Browse files Browse the repository at this point in the history
Should not impact non-exception performance due to zero cost abstracions
in gcc/clang
  • Loading branch information
G-071 committed Aug 21, 2023
1 parent 07f3c41 commit 8b4d15b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions include/buffer_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,28 @@ For better performance configure CPPuddle with CPPUDDLE_DEACTIVATE_BUFFER_RECYCL
static T *get(size_t number_elements, bool manage_content_lifetime = false,
std::optional<size_t> location_hint = std::nullopt,
std::optional<size_t> device_id = std::nullopt) {
return buffer_manager<T, Host_Allocator>::get(
number_elements, manage_content_lifetime, location_hint, device_id);
try {
return buffer_manager<T, Host_Allocator>::get(
number_elements, manage_content_lifetime, location_hint, device_id);
} catch (const std::exception &exc) {
std::cerr << "ERROR: Encountered unhandled exception in cppuddle get: " << exc.what() << std::endl;
std::cerr << "Rethrowing exception... " << std::endl;;
throw;
}
}
/// Marks an buffer as unused and fit for reusage
template <typename T, typename Host_Allocator>
static void mark_unused(T *p, size_t number_elements,
std::optional<size_t> location_hint = std::nullopt,
std::optional<size_t> device_id = std::nullopt) {
return buffer_manager<T, Host_Allocator>::mark_unused(p, number_elements,
location_hint, device_id);
try {
return buffer_manager<T, Host_Allocator>::mark_unused(p, number_elements,
location_hint, device_id);
} catch (const std::exception &exc) {
std::cerr << "ERROR: Encountered unhandled exception in cppuddle mark_unused: " << exc.what() << std::endl;
std::cerr << "Rethrowing exception... " << std::endl;;
throw;
}
}
#endif
template <typename T, typename Host_Allocator>
Expand Down

0 comments on commit 8b4d15b

Please sign in to comment.