Skip to content

Commit 9116e73

Browse files
Wrap call to sycl::free in try/catch
Report caugh exception to std::cerr by ignore it otherwise.
1 parent b78698e commit 9116e73

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dpctl/memory/_opaque_smart_ptr.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#include <memory>
3636
#include <sycl/sycl.hpp>
3737

38+
#include <exception>
39+
#include <iostream>
40+
3841
namespace
3942
{
4043

@@ -48,7 +51,13 @@ class USMDeleter
4851
USMDeleter(const ::sycl::context &context) : _context(context) {}
4952
template <typename T> void operator()(T *ptr) const
5053
{
51-
::sycl::free(ptr, _context);
54+
try {
55+
::sycl::free(ptr, _context);
56+
} catch (const std::exception &e) {
57+
std::cout << "Call to sycl::free caught an exception: " << e.what()
58+
<< std::endl;
59+
// std::terminate();
60+
}
5261
}
5362

5463
private:

0 commit comments

Comments
 (0)