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/09/08 21:01:53 UTC

[GitHub] [tvm] JosephTheOctonaut commented on a diff in pull request #12727: [Hexagon] [runtime] Improve runtime resource management

JosephTheOctonaut commented on code in PR #12727:
URL: https://github.com/apache/tvm/pull/12727#discussion_r966412900


##########
src/runtime/hexagon/hexagon_device_api.h:
##########
@@ -45,11 +45,27 @@ class HexagonDeviceAPI final : public DeviceAPI {
   static HexagonDeviceAPI* Global();
 
   //! \brief Constructor
-  HexagonDeviceAPI() {}
+  HexagonDeviceAPI() { hexbuffs = std::make_unique<HexagonBufferManager>(); }
 
   //! \brief Destructor
   ~HexagonDeviceAPI() {}
 
+  //! \brief Creates resource managers for the runtime
+  void AcquireResources() {
+    if (!hexbuffs->empty()) {
+      LOG(INFO) << "hexbuffs was not empty in AcquireResources";
+    }
+  }
+
+  //! \brief Ensures we have freed all resources when we end the runtime
+  void ReleaseResources() {
+    if (!hexbuffs->empty()) {
+      LOG(INFO) << "hexbuffs was not empty in ReleaseResources, resetting";
+      hexbuffs.reset();
+      hexbuffs = std::make_unique<HexagonBufferManager>();

Review Comment:
   Doesn't `reset()` already replace the managed pointer with a new one? So the new declaration is redundant?



##########
src/runtime/hexagon/hexagon_device_api.h:
##########
@@ -45,11 +45,27 @@ class HexagonDeviceAPI final : public DeviceAPI {
   static HexagonDeviceAPI* Global();
 
   //! \brief Constructor
-  HexagonDeviceAPI() {}
+  HexagonDeviceAPI() { hexbuffs = std::make_unique<HexagonBufferManager>(); }
 
   //! \brief Destructor
   ~HexagonDeviceAPI() {}
 
+  //! \brief Creates resource managers for the runtime
+  void AcquireResources() {
+    if (!hexbuffs->empty()) {
+      LOG(INFO) << "hexbuffs was not empty in AcquireResources";

Review Comment:
   Is the expected situation here that a previous run crashed or exited without releasing the buffers? Or we're allowing for another user of the device to exist in parallel?
   
   If it's the former, could we just reset the buffer manager here? If it's the latter, it seems wrong to reset all buffers in `ReleaseResources()` (because some might belong to another running application).



-- 
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