This repository has been archived by the owner on Apr 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 260
[WIP] [spirv] Add Vulkan runtime. #118
Open
denis0x0D
wants to merge
1
commit into
tensorflow:master
Choose a base branch
from
denis0x0D:sandbox/vulkan-runtime
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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")