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

[WIP] [spirv] Add Vulkan runtime. #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a else and a proper error message here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error message is at L29. :) The probe is not done yet here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that there is a fallback, so throwing error here is not possible indeed, but I still feel that the "you're not using the right CMake version should be something surfaced at some point as a root cause of failure.
Something like adding here: an else if ("$ENV{VULKAN_SDK}" STREQUAL "") message(FATAL_ERROR "Please use at least Make 3.7.0 or provide the VULKAN_SDK path as an environment variable")


# 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