Lunderberg opened a new pull request #8196:
URL: https://github.com/apache/tvm/pull/8196


   Continuing refactoring from #8188.  The goal of this PR is to establish 
clear ownership of vulkan resources.  Previously, resources were owned both by 
VulkanDeviceAPI and by VulkanThreadEntry, depending on whether it is a 
per-CPU-thread resource.  This PR introduces a `ThreadMap<T>` class that 
behaves similarly to `thread_local`, but can be used for non-static data 
members, then uses `ThreadMap<T>` to move all ownership of vulkan resources to 
be relative to the `VulkanDeviceAPI`.  Individual steps are in separate commits 
for readability.
   
   * Moved ownership of per-thread active device id to VulkanDeviceAPI
   
     * Previously, the active device was owned by VulkanThreadEntry, so lookups 
to multiple global variables were required.  Now, everything goes from the 
VulkanDeviceAPI.
   
     * Removed VulkanThreadEntry, as all functionality has been moved to either 
VulkanDevice or VulkanDeviceAPI.
   
   * Moved ownership of per-thread workspace pool to VulkanDeviceAPI
   
     * Previously, the WorkspacePool was owned by VulkanThreadEntry, and 
required a lookup from VulkanDeviceAPI::AllocWorkspace.  As a result, 
non-global VulkanDeviceAPI would interact with each other.
   
   * Move ownership of per-thread uniform buffer to VulkanDevice
   
     * Previously, VulkanUniformBuffer was owned by VulkanThreadEntry, so any 
use required looking up both the thread entry and the device. Now, 
thread-specific lookup is handled in the VulkanDevice class.
   
   * Move the VulkanStagingBuffer to be owned by the VulkanDevice
   
     * Previously, was owned by VulkanThreadEntry, so any use required looking 
up both the thread entry and the device.  Now, thread-specific lookup is 
handled in the VulkanDevice class.
   
   * Pulled VulkanBuffer allocation/deallocation into constructor/destructor.
   
     * VulkanBuffer owns the VkBuffer and VkDeviceMemory that it allocates, and 
deallocates on destruction.
   
     * VulkanHostVisibleBuffer owns a VulkanBuffer, and additional calls 
vkUnmapMemory on destruction.
   
   * Moved VulkanStream ownership from VulkanThreadEntry to VulkanDevice
   
     * Implemented ThreadMap, a container for per-thread objects.  Unlike 
dmlc::ThreadLocalStore, ThreadMap is intended for use as a non-static 
thread-specific lookup.
   
     * Added ThreadMap<VulkanStream> as a member to VulkanDevice, updated all 
uses.
   


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

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


Reply via email to