You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/10/18 15:58:54 UTC
[GitHub] [tvm] adstraw commented on a diff in pull request #13109: [Hexagon] Refactor HexagonBufferManager; add Release API
adstraw commented on code in PR #13109:
URL: https://github.com/apache/tvm/pull/13109#discussion_r998431377
##########
src/runtime/hexagon/hexagon_buffer_manager.h:
##########
@@ -82,28 +87,35 @@ class HexagonBufferManager {
//! \brief Returns whether the HexagonBufferManager has any allocations.
bool empty() {
- std::lock_guard<std::mutex> lock(map_mutex_);
+ std::lock_guard<std::mutex> lock(mutex_);
return hexagon_buffer_map_.empty();
}
- //! \brief Returns a vector of currently allocated pointers, owned by the manager.
- // Note - this should only be used by the device API to keep track of what
- // was in the manager when HexagonDeviceAPI::ReleaseResources is called.
- std::vector<void*> current_allocations() {
- std::vector<void*> allocated;
- std::lock_guard<std::mutex> lock(map_mutex_);
+ void Reset() {
+ std::lock_guard<std::mutex> lock(mutex_);
+ hexagon_buffer_map_.clear();
+ released_buffers_.clear();
+ }
+
+ void Release() {
for (const auto& [data_ptr, buffer] : hexagon_buffer_map_) {
- allocated.push_back(data_ptr);
+ FreeHexagonBuffer(data_ptr);
+ {
+ std::lock_guard<std::mutex> lock(mutex_);
Review Comment:
Good call. Thanks for this review.
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org