adstraw commented on code in PR #13109:
URL: https://github.com/apache/tvm/pull/13109#discussion_r998706808


##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -40,14 +40,19 @@ class HexagonBufferManager {
    * \param ptr Address of the HexagonBuffer as returned by 
`AllocateHexagonBuffer`.
    */
   void FreeHexagonBuffer(void* ptr) {
+    std::lock_guard<std::mutex> lock(mutex_);
+    // Check the list of buffers that were still allocated at the time of 
release.  If this buffer
+    // is in that list, this is a no-op as it is being freed as part of 
another object teardown.
+    auto it_released = std::find(released_buffers_.begin(), 
released_buffers_.end(), ptr);
+    if (it_released != released_buffers_.end()) {
+      released_buffers_.erase(it_released);
+      return;
+    }

Review Comment:
   > I think what we want here is to not allow any new allocations when 
released_buffers_ has any values.
   
   This PR will fail / assert if we `Enable` the HexagonBufferManager with 
unfreed buffers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to