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

Commit

Permalink
[spirv] Add Vulkan runtime.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
denis0x0D committed Sep 7, 2019
1 parent a3bb5ad commit 6ab4a57
Show file tree
Hide file tree
Showing 6 changed files with 1,323 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(mlir-cuda-runner)
add_subdirectory(mlir-vulkan-runner)
add_subdirectory(mlir-cpu-runner)
add_subdirectory(mlir-opt)
add_subdirectory(mlir-tblgen)
Expand Down
45 changes: 45 additions & 0 deletions tools/mlir-vulkan-runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
set(LLVM_OPTIONAL_SOURCES
VulkanRuntime.cpp
)

if (MLIR_VULKAN_RUNNER_ENABLED)
message(STATUS "Building the Vulkan runner")

# At first try "FindVulkan" from:
# https://cmake.org/cmake/help/v3.7/module/FindVulkan.html
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
find_package(Vulkan)
endif()

# If Vulkan is not found try a path specified by VULKAN_SDK.
if (NOT Vulkan_FOUND)
if ("$ENV{VULKAN_SDK}" STREQUAL "")
message(FATAL_ERROR "VULKAN_SDK environment variable is empty")
endif()

find_library(Vulkan_LIBRARY vulkan HINTS "$ENV{VULKAN_SDK}/lib" REQUIRED)
if (Vulkan_LIBRARY)
set(Vulkan_FOUND ON)
set(Vulkan_INCLUDE_DIR "$ENV{VULKAN_SDK}/include")
message(STATUS "Found Vulkan: " ${Vulkan_LIBRARY})
endif()
endif()

if (NOT Vulkan_FOUND)
message(FATAL_ERROR "Cannot find Vulkan library")
endif()

# Create archive for this moment.
add_llvm_library(MLIRVulkanRuntime
VulkanRuntime.cpp
)

target_include_directories(MLIRVulkanRuntime PRIVATE ${Vulkan_INCLUDE_DIR})

target_link_libraries(MLIRVulkanRuntime
MLIRSPIRVSerialization
LLVMCore
LLVMSupport
${Vulkan_LIBRARY}
)
endif()
Loading

0 comments on commit 6ab4a57

Please sign in to comment.