Skip to content

Commit 64b55bb

Browse files
committed
Vulkan2 Runtime API
1 parent f07fe80 commit 64b55bb

File tree

14 files changed

+1698
-1532
lines changed

14 files changed

+1698
-1532
lines changed

cmake/modules/Vulkan.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if(USE_VULKAN)
2929
message(FATAL_ERROR "Cannot find Vulkan, USE_VULKAN=" ${USE_VULKAN})
3030
endif()
3131
message(STATUS "Build with VULKAN support")
32-
file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/*.cc)
32+
file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/vulkan2.cc)
3333
file(GLOB COMPILER_VULKAN_SRCS src/codegen/spirv/*.cc)
3434
list(APPEND RUNTIME_SRCS ${RUNTIME_VULKAN_SRCS})
3535
list(APPEND COMPILER_SRCS ${COMPILER_VULKAN_SRCS})

src/codegen/spirv/build_vulkan.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030
#include "codegen_spirv.h"
3131
#include "../build_common.h"
32-
#include "../../runtime/vulkan/vulkan_module.h"
32+
33+
#include "../../runtime/vulkan/vulkan2_shader.h"
34+
#include "../../runtime/vulkan/vulkan2_module.h"
3335

3436
namespace tvm {
3537
namespace codegen {

src/codegen/spirv/ir_builder.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ namespace spirv {
3333
void IRBuilder::InitHeader() {
3434
CHECK_EQ(header_.size(), 0U);
3535
header_.push_back(spv::MagicNumber);
36-
header_.push_back(spv::Version);
36+
// Use SPIR-V v1.0. This needs to be kept in sync (or at least behind)
37+
// `VkApplicationInfo.apiVersion` in `vulkan2.cc` to ensure Vulkan API
38+
// validation passes.
39+
header_.push_back(0x10000);
3740
// generator: set to 0, unknown
3841
header_.push_back(0U);
3942
// Bound: set during Finalize

src/runtime/vulkan/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
Key components
3+
4+
5+
VulkanStream abstraction. Stream abstraction supports several operations:
6+
7+
- stream->launch(function, args, ..)
8+
9+
This maps to:
10+
11+
- obtain current command buffer
12+
- dispatch
13+
- barrier -> (compute|transfer)
14+
15+
16+
- stream->synchronize();
17+
18+
This maps to
19+
20+
- vkEndCommandBuffer
21+
- vkQueueSubmit
22+
- vkQueueWaitIdle
23+
24+
25+
26+
- stream->copy(from=VULKAN, to=VULKAN)
27+
- stream->copy(from=CPU, to=VULKAN)
28+
- stream->copy(from=VULKAN, to=CPU)
29+
30+
This abstracts over CommandBuffer, CommandBufferPool, Fence, etc.
31+
32+
33+
Then, API command are fairly simple, and mirror existing CUDA design.
34+
35+
The key approach is:
36+

0 commit comments

Comments
 (0)