|
8 | 8 |
|
9 | 9 | #pragma once |
10 | 10 |
|
| 11 | +#include "sycl/detail/common.hpp" |
11 | 12 | #include <detail/physical_mem_impl.hpp> // For physical_mem_impl |
12 | 13 | #include <sycl/context.hpp> // For context |
13 | 14 | #include <sycl/device.hpp> // For device |
@@ -51,15 +52,19 @@ class graph_mem_pool { |
51 | 52 | const device &Device) |
52 | 53 | : MGraph(GraphImpl), MContext(Context), MDevice(Device) {} |
53 | 54 | ~graph_mem_pool() { |
54 | | - for (auto &[Ptr, AllocInfo] : MAllocations) { |
55 | | - // Unmap allocations if required before physical memory is released |
56 | | - // Physical mem is released when MPhysicalMem is cleared |
57 | | - if (AllocInfo.Mapped) { |
58 | | - unmap(Ptr, AllocInfo.Size, MContext); |
| 55 | + try { |
| 56 | + for (auto &[Ptr, AllocInfo] : MAllocations) { |
| 57 | + // Unmap allocations if required before physical memory is released |
| 58 | + // Physical mem is released when MPhysicalMem is cleared |
| 59 | + if (AllocInfo.Mapped) { |
| 60 | + unmap(Ptr, AllocInfo.Size, MContext); |
| 61 | + } |
| 62 | + // Free the VA range |
| 63 | + free_virtual_mem(reinterpret_cast<uintptr_t>(Ptr), AllocInfo.Size, |
| 64 | + MContext); |
59 | 65 | } |
60 | | - // Free the VA range |
61 | | - free_virtual_mem(reinterpret_cast<uintptr_t>(Ptr), AllocInfo.Size, |
62 | | - MContext); |
| 66 | + } catch (std::exception &e) { |
| 67 | + __SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~graph_mem_pool", e); |
63 | 68 | } |
64 | 69 | MPhysicalMem.clear(); |
65 | 70 | } |
@@ -119,7 +124,7 @@ class graph_mem_pool { |
119 | 124 | [&](sycl::handler &CGH) { CGH.memset(Ptr, 0, AllocInfo.Size); }); |
120 | 125 | } |
121 | 126 |
|
122 | | - MPhysicalMem.push_back(PhysicalMem); |
| 127 | + MPhysicalMem.push_back(std::move(PhysicalMem)); |
123 | 128 | AllocInfo.PhysicalMemID = MPhysicalMem.size() - 1; |
124 | 129 | AllocInfo.Mapped = true; |
125 | 130 | } |
|
0 commit comments