You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by ma...@apache.org on 2021/05/11 05:58:13 UTC

[tvm] branch main updated: [Bugfix][Vulkan] Call VulkanDeviceAPI destructor on program exit (#7997)

This is an automated email from the ASF dual-hosted git repository.

masahi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 58c3413  [Bugfix][Vulkan] Call VulkanDeviceAPI destructor on program exit (#7997)
58c3413 is described below

commit 58c3413a30e5b03208b6281651d38ee02c44f9c1
Author: Lunderberg <Lu...@users.noreply.github.com>
AuthorDate: Mon May 10 22:57:48 2021 -0700

    [Bugfix][Vulkan] Call VulkanDeviceAPI destructor on program exit (#7997)
    
    Most of the TVM Global() functions allocate with "new" and do
    not deallocate, as the OS can clean up any leftover buffers at
    the end.  In this case, we need the VulkanDeviceAPI destructor
    to call vkDestroyInstance, to prevent a segfault on exit when
    using some nvidia drivers.
    
    Co-authored-by: Eric Lunderberg <el...@octoml.ai>
---
 src/runtime/vulkan/vulkan.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/runtime/vulkan/vulkan.cc b/src/runtime/vulkan/vulkan.cc
index d82f6f4..b7fe2b1 100644
--- a/src/runtime/vulkan/vulkan.cc
+++ b/src/runtime/vulkan/vulkan.cc
@@ -412,8 +412,13 @@ class VulkanDeviceAPI final : public DeviceAPI {
   }
 
   static VulkanDeviceAPI* Global() {
-    static VulkanDeviceAPI* inst = new VulkanDeviceAPI();
-    return inst;
+    // Most of the TVM Global() functions allocate with "new" and do
+    // not deallocate, as the OS can clean up any leftover buffers at
+    // the end.  In this case, we need the VulkanDeviceAPI destructor
+    // to call vkDestroyInstance, to prevent a segfault on exit when
+    // using some nvidia drivers.
+    static VulkanDeviceAPI inst;
+    return &inst;
   }
 
   const VulkanContext& context(size_t device_id) const {