|
| 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 | +### Vulkan2DeviceAPI |
| 22 | + |
| 23 | +Implements the TVM DeviceAPI interface. Owns the core Vulkan datastructures. Is responsible for initializing the Vulkan instance and devices, querying for possible extensions. |
| 24 | + |
| 25 | +### Vulkan2ThreadEntry |
| 26 | + |
| 27 | +Thread-local state for the Vulkan runtime. Maintains a staging buffer (for copies), and a Vulkan2Stream per device. |
| 28 | + |
| 29 | +### Vulkan2WrappedFunc |
| 30 | + |
| 31 | +Responsible for launching computation kernels. Responsible for obtaining a |
| 32 | +Vulkan2Pipeline instance (from the Vulkan2ModuleNode), and launches the kernel |
| 33 | +(via immediate or deferred mode) on the active Vulkan2Stream instance. |
| 34 | + |
| 35 | +## Stream execution in the Vulkan programming model. |
| 36 | + |
| 37 | +THe natural model for TVM DeviceAPI implementation and runtime follows the CUDA |
| 38 | +API model. That is, we launch "kernels" onto a (implicit or explicit) "stream" |
| 39 | +(which execute asynchronously with respect to the host, but ordered with respect |
| 40 | +to the stream), and explicitly synchronize the stream with respect to the host. |
| 41 | +We simulate this behaviour in the Vulkan model by maintaining a thread-local |
| 42 | +`vkCommandBuffer` instance, and queueing up (or eagerly executing, depending on |
| 43 | +the availability of the `VK_KHR_push_descriptor` extension). When we synchronize |
| 44 | +the stream, we end the command buffer recording, submit it to the device queue, |
| 45 | +and wait on the corresponding fence. |
0 commit comments