File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,9 @@ struct ur_device_handle_t_ {
114114 bool maxLocalMemSizeChosen () { return MaxLocalMemSizeChosen; };
115115
116116 uint32_t getNumComputeUnits () const noexcept { return NumComputeUnits; };
117+
118+ // bookkeeping for mipmappedArray leaks in Mapping external Memory
119+ std::map<CUarray, CUmipmappedArray> ChildCuarrayFromMipmapMap;
117120};
118121
119122int getAttribute (ur_device_handle_t Device, CUdevice_attribute Attribute);
Original file line number Diff line number Diff line change @@ -430,6 +430,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageFreeExp(
430430 ScopedContext Active (hDevice);
431431 try {
432432 UR_CHECK_ERROR (cuArrayDestroy ((CUarray)hImageMem));
433+ if (auto it = hDevice->ChildCuarrayFromMipmapMap .find ((CUarray)hImageMem);
434+ it != hDevice->ChildCuarrayFromMipmapMap .end ()) {
435+ UR_CHECK_ERROR (cuMipmappedArrayDestroy ((CUmipmappedArray)it->second ));
436+ hDevice->ChildCuarrayFromMipmapMap .erase (it);
437+ }
433438 } catch (ur_result_t Err) {
434439 return Err;
435440 } catch (...) {
@@ -1104,6 +1109,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesMapExternalArrayExp(
11041109 CUarray memArray;
11051110 UR_CHECK_ERROR (cuMipmappedArrayGetLevel (&memArray, memMipMap, 0 ));
11061111
1112+ hDevice->ChildCuarrayFromMipmapMap .emplace (memArray, memMipMap);
1113+
11071114 *phImageMem = (ur_exp_image_mem_native_handle_t )memArray;
11081115 }
11091116
You can’t perform that action at this time.
0 commit comments