Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Commit 6ab4a57

Browse files
author
Denis Khalikov
committed
[spirv] Add Vulkan runtime.
Implements initial version of Vulkan runtime to test spirv::ModuleOp. Creates and runs Vulkan computation pipeline. Requirements: - Vulkan capable device and drivers installed. - Vulkan SDK installed and VULKAN_SDK environment variable is set. How to build: - Provide -DMLIR_VULKAN_RUNNER_ENABLED=ON as cmake variable.
1 parent a3bb5ad commit 6ab4a57

File tree

6 files changed

+1323
-0
lines changed

6 files changed

+1323
-0
lines changed

tools/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
add_subdirectory(mlir-cuda-runner)
2+
add_subdirectory(mlir-vulkan-runner)
23
add_subdirectory(mlir-cpu-runner)
34
add_subdirectory(mlir-opt)
45
add_subdirectory(mlir-tblgen)
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
set(LLVM_OPTIONAL_SOURCES
2+
VulkanRuntime.cpp
3+
)
4+
5+
if (MLIR_VULKAN_RUNNER_ENABLED)
6+
message(STATUS "Building the Vulkan runner")
7+
8+
# At first try "FindVulkan" from:
9+
# https://cmake.org/cmake/help/v3.7/module/FindVulkan.html
10+
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
11+
find_package(Vulkan)
12+
endif()
13+
14+
# If Vulkan is not found try a path specified by VULKAN_SDK.
15+
if (NOT Vulkan_FOUND)
16+
if ("$ENV{VULKAN_SDK}" STREQUAL "")
17+
message(FATAL_ERROR "VULKAN_SDK environment variable is empty")
18+
endif()
19+
20+
find_library(Vulkan_LIBRARY vulkan HINTS "$ENV{VULKAN_SDK}/lib" REQUIRED)
21+
if (Vulkan_LIBRARY)
22+
set(Vulkan_FOUND ON)
23+
set(Vulkan_INCLUDE_DIR "$ENV{VULKAN_SDK}/include")
24+
message(STATUS "Found Vulkan: " ${Vulkan_LIBRARY})
25+
endif()
26+
endif()
27+
28+
if (NOT Vulkan_FOUND)
29+
message(FATAL_ERROR "Cannot find Vulkan library")
30+
endif()
31+
32+
# Create archive for this moment.
33+
add_llvm_library(MLIRVulkanRuntime
34+
VulkanRuntime.cpp
35+
)
36+
37+
target_include_directories(MLIRVulkanRuntime PRIVATE ${Vulkan_INCLUDE_DIR})
38+
39+
target_link_libraries(MLIRVulkanRuntime
40+
MLIRSPIRVSerialization
41+
LLVMCore
42+
LLVMSupport
43+
${Vulkan_LIBRARY}
44+
)
45+
endif()

0 commit comments

Comments
 (0)