Skip to content
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
5 changes: 3 additions & 2 deletions backends/vulkan/cmake/ShaderLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ if(NOT EXECUTORCH_ROOT)
endif()

# find_program already searches the PATH environment variable and appends the
# platform executable suffix (.exe on Windows). Add the Vulkan SDK bin dir as a
# hint so glslc is found on Windows even when only VULKAN_SDK is set.
# platform executable suffix (.exe on Windows). Prefer the Vulkan SDK bin dir so
# an explicitly configured SDK takes precedence, including on Windows where the
# installer may not add it to PATH.
find_program(GLSLC_PATH glslc HINTS $ENV{VULKAN_SDK}/bin $ENV{VULKAN_SDK}/Bin)

if(NOT GLSLC_PATH AND EXECUTORCH_BUILD_VULKAN)
Expand Down
4 changes: 2 additions & 2 deletions backends/vulkan/runtime/VulkanBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <executorch/backends/vulkan/runtime/VulkanDelegateHeader.h>
#include <executorch/backends/vulkan/serialization/schema_generated.h>

#include <executorch/backends/vulkan/runtime/api/Context.h>
#include <executorch/backends/vulkan/runtime/graph/ComputeGraph.h>

#include <executorch/backends/vulkan/runtime/graph/ops/OperatorRegistry.h>
Expand Down Expand Up @@ -614,8 +615,7 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
~VulkanBackend() override = default;

bool is_available() const override {
// TODO(ssjia): replace with an actual Vulkan runtime availability check
return true;
return vkapi::set_and_get_external_adapter() != nullptr || api::available();
}

ET_NODISCARD Error compileModel(
Expand Down
20 changes: 13 additions & 7 deletions backends/vulkan/runtime/vk_api/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <mutex>
#include <sstream>

namespace vkcompute {
Expand Down Expand Up @@ -474,13 +475,18 @@ Adapter* set_and_get_external_adapter(
const VkInstance instance,
const VkPhysicalDevice physical_device,
const VkDevice logical_device) {
static const std::unique_ptr<Adapter> p_external_adapter =
init_external_adapter(
instance,
physical_device,
logical_device,
1,
set_and_get_pipeline_cache_data_path(""));
static std::mutex external_adapter_mutex;
static std::unique_ptr<Adapter> p_external_adapter;

const std::lock_guard<std::mutex> lock(external_adapter_mutex);
if (!p_external_adapter) {
p_external_adapter = init_external_adapter(
instance,
physical_device,
logical_device,
1,
set_and_get_pipeline_cache_data_path(""));
}

return p_external_adapter.get();
}
Expand Down
7 changes: 3 additions & 4 deletions install_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ def is_vulkan_available() -> bool:
Windows, the desktop GPU platforms the backend supports (macOS would require
MoltenVK).

glslc is looked up on PATH and, failing that, under $VULKAN_SDK/{bin,Bin} to
match the find_program() HINTS the build uses (see pybind.cmake and
ShaderLibrary.cmake): the Windows Vulkan SDK sets VULKAN_SDK but does not add
its bin directory to PATH, so a PATH-only probe would miss it there.
glslc is accepted from PATH or under $VULKAN_SDK/{bin,Bin}. The Windows
Vulkan SDK sets VULKAN_SDK but does not add its bin directory to PATH, so a
PATH-only probe would miss it there.

Returns:
True if glslc is available on a supported platform, False otherwise.
Expand Down
Loading