@@ -297,9 +297,13 @@ void exec_graph_impl::makePartitions() {
297297}
298298
299299graph_impl::~graph_impl () {
300- clearQueues ();
301- for (auto &MemObj : MMemObjs) {
302- MemObj->markNoLongerBeingUsedInGraph ();
300+ try {
301+ clearQueues ();
302+ for (auto &MemObj : MMemObjs) {
303+ MemObj->markNoLongerBeingUsedInGraph ();
304+ }
305+ } catch (std::exception &e) {
306+ __SYCL_REPORT_EXCEPTION_TO_STREAM (" exception in ~graph_impl" , e);
303307 }
304308}
305309
@@ -784,34 +788,38 @@ exec_graph_impl::exec_graph_impl(sycl::context Context,
784788}
785789
786790exec_graph_impl::~exec_graph_impl () {
787- const sycl::detail::PluginPtr &Plugin =
788- sycl::detail::getSyclObjImpl (MContext)->getPlugin ();
789- MSchedule.clear ();
790- // We need to wait on all command buffer executions before we can release
791- // them.
792- for (auto &Event : MExecutionEvents) {
793- Event->wait (Event);
794- }
791+ try {
792+ const sycl::detail::PluginPtr &Plugin =
793+ sycl::detail::getSyclObjImpl (MContext)->getPlugin ();
794+ MSchedule.clear ();
795+ // We need to wait on all command buffer executions before we can release
796+ // them.
797+ for (auto &Event : MExecutionEvents) {
798+ Event->wait (Event);
799+ }
795800
796- for (const auto &Partition : MPartitions) {
797- Partition->MSchedule .clear ();
798- for (const auto &Iter : Partition->MPiCommandBuffers ) {
799- if (auto CmdBuf = Iter.second ; CmdBuf) {
801+ for (const auto &Partition : MPartitions) {
802+ Partition->MSchedule .clear ();
803+ for (const auto &Iter : Partition->MPiCommandBuffers ) {
804+ if (auto CmdBuf = Iter.second ; CmdBuf) {
805+ pi_result Res = Plugin->call_nocheck <
806+ sycl::detail::PiApiKind::piextCommandBufferRelease>(CmdBuf);
807+ (void )Res;
808+ assert (Res == pi_result::PI_SUCCESS);
809+ }
810+ }
811+ }
812+
813+ for (auto &Iter : MCommandMap) {
814+ if (auto Command = Iter.second ; Command) {
800815 pi_result Res = Plugin->call_nocheck <
801- sycl::detail::PiApiKind::piextCommandBufferRelease>(CmdBuf );
816+ sycl::detail::PiApiKind::piextCommandBufferReleaseCommand>(Command );
802817 (void )Res;
803818 assert (Res == pi_result::PI_SUCCESS);
804819 }
805820 }
806- }
807-
808- for (auto &Iter : MCommandMap) {
809- if (auto Command = Iter.second ; Command) {
810- pi_result Res = Plugin->call_nocheck <
811- sycl::detail::PiApiKind::piextCommandBufferReleaseCommand>(Command);
812- (void )Res;
813- assert (Res == pi_result::PI_SUCCESS);
814- }
821+ } catch (std::exception &e) {
822+ __SYCL_REPORT_EXCEPTION_TO_STREAM (" exception in ~exec_graph_impl" , e);
815823 }
816824}
817825
0 commit comments