| 
 | 1 | +<!--- Licensed to the Apache Software Foundation (ASF) under one -->  | 
 | 2 | +<!--- or more contributor license agreements.  See the NOTICE file -->  | 
 | 3 | +<!--- distributed with this work for additional information -->  | 
 | 4 | +<!--- regarding copyright ownership.  The ASF licenses this file -->  | 
 | 5 | +<!--- to you under the Apache License, Version 2.0 (the -->  | 
 | 6 | +<!--- "License"); you may not use this file except in compliance -->  | 
 | 7 | +<!--- with the License.  You may obtain a copy of the License at -->  | 
 | 8 | + | 
 | 9 | +<!---   http://www.apache.org/licenses/LICENSE-2.0 -->  | 
 | 10 | + | 
 | 11 | +<!--- Unless required by applicable law or agreed to in writing, -->  | 
 | 12 | +<!--- software distributed under the License is distributed on an -->  | 
 | 13 | +<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->  | 
 | 14 | +<!--- KIND, either express or implied.  See the License for the -->  | 
 | 15 | +<!--- specific language governing permissions and limitations -->  | 
 | 16 | +<!--- under the License. -->  | 
 | 17 | + | 
 | 18 | + | 
 | 19 | +## Components  | 
 | 20 | + | 
 | 21 | +### VulkanDeviceAPI  | 
 | 22 | + | 
 | 23 | +Implements the TVM DeviceAPI interface. Owns the core Vulkan datastructures. Is  | 
 | 24 | +responsible for initializing the Vulkan instance and devices, querying for  | 
 | 25 | +possible extensions.  | 
 | 26 | + | 
 | 27 | +### VulkanThreadEntry  | 
 | 28 | + | 
 | 29 | +Thread-local state for the Vulkan runtime. Maintains a staging buffer (for  | 
 | 30 | +copies), and a VulkanStream per device.  | 
 | 31 | + | 
 | 32 | +### VulkanWrappedFunc  | 
 | 33 | + | 
 | 34 | +Responsible for launching computation kernels. Responsible for obtaining a  | 
 | 35 | +VulkanPipeline instance (from the VulkanModuleNode), and launches the kernel  | 
 | 36 | +(via immediate or deferred mode) on the active VulkanStream instance.  | 
 | 37 | + | 
 | 38 | +## Stream execution in the Vulkan programming model.  | 
 | 39 | + | 
 | 40 | +The natural model for TVM DeviceAPI implementation and runtime follows the CUDA  | 
 | 41 | +API model. That is, we launch "kernels" onto a (implicit or explicit) "stream"  | 
 | 42 | +(which execute asynchronously with respect to the host, but ordered with respect  | 
 | 43 | +to the stream), and explicitly synchronize the stream with respect to the host.  | 
 | 44 | +We simulate this behaviour in the Vulkan model by maintaining a thread-local  | 
 | 45 | +`vkCommandBuffer` instance, and queueing up (or eagerly executing, depending on  | 
 | 46 | +the availability of the `VK_KHR_push_descriptor` extension). When we synchronize  | 
 | 47 | +the stream, we end the command buffer recording, submit it to the device queue,  | 
 | 48 | +and wait on the corresponding fence.  | 
0 commit comments