Skip to content
Merged
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
45 changes: 21 additions & 24 deletions backends/vulkan/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def define_common_targets(is_fbcode = False):
}),
exported_preprocessor_flags = get_vulkan_preprocessor_flags(no_volk, is_fbcode),
exported_deps = VK_API_DEPS + [
"//executorch/backends/vulkan_shared:runtime",
"//executorch/backends/vulkan_shared:device",
],
)

Expand Down Expand Up @@ -334,29 +334,26 @@ def define_common_targets(is_fbcode = False):
link_whole = True,
)

for no_volk in [False, True]:
if no_volk and is_fbcode:
continue
suffix = "_no_volk" if no_volk else ""
runtime.cxx_test(
name = "vulkan_shared_device_test{}".format(suffix),
srcs = [
"test/shared_device/SharedDevicePolicyTest.cpp",
"test/shared_device/SharedDeviceAdapterTest.cpp",
],
headers = ["runtime/ResolveSharedDevice.h"],
compiler_flags = get_vulkan_compiler_flags(),
labels = get_labels(no_volk),
platforms = get_platforms(),
deps = [
":vulkan_backend_lib{}".format(suffix),
":vulkan_graph_runtime{}".format(suffix),
"//executorch/backends/vulkan_shared:runtime",
"//executorch/runtime/backend:interface",
"//executorch/runtime/core:core",
"//executorch/runtime/platform:platform",
],
)
# Only the volk variant: the no_volk variants link libvulkan, which the
# test hosts do not have.
runtime.cxx_test(
name = "vulkan_shared_device_test",
srcs = [
"test/shared_device/SharedDevicePolicyTest.cpp",
"test/shared_device/SharedDeviceAdapterTest.cpp",
],
headers = ["runtime/ResolveSharedDevice.h"],
compiler_flags = get_vulkan_compiler_flags(),
platforms = get_platforms(),
deps = [
":vulkan_backend_lib",
":vulkan_graph_runtime",
"//executorch/backends/vulkan_shared:runtime",
"//executorch/runtime/backend:interface",
"//executorch/runtime/core:core",
"//executorch/runtime/platform:platform",
],
)

##
## AOT targets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ TEST_F(SharedDeviceAdapterTest, ReusesHandlesAndOnlyRegisteredQueueMetadata) {
EXPECT_EQ(first.physical_handle(), shared->physical_device());
auto queue = first.request_queue();
EXPECT_EQ(queue.family_index, shared->queue_family_index());
EXPECT_EQ(queue.handle, VK_NULL_HANDLE); // No unlocked queue escapes.
EXPECT_EQ(queue.handle, nullptr); // No unlocked queue escapes.
EXPECT_EQ(first.num_compute_queues(), 1u);
first.return_queue(queue);
EXPECT_NO_THROW(submit_empty(first));
Expand Down Expand Up @@ -535,7 +535,7 @@ TEST_F(SharedDeviceAdapterTest, BorrowsApplicationDeviceWithNonDefaultQueue) {
device_guard.handle = VK_NULL_HANDLE;
VkQueue supplied = VK_NULL_HANDLE;
vkGetDeviceQueue(device, family, index, &supplied);
ASSERT_NE(supplied, VK_NULL_HANDLE);
ASSERT_NE(supplied, nullptr);
SharedVulkanDeviceCreateInfo info;
info.key = {"application-nondefault", 1};
info.instance = shared->instance();
Expand All @@ -549,7 +549,7 @@ TEST_F(SharedDeviceAdapterTest, BorrowsApplicationDeviceWithNonDefaultQueue) {
vkapi::Adapter adapter(external, "");
auto metadata = adapter.request_queue();
EXPECT_EQ(metadata.family_index, family);
EXPECT_EQ(metadata.handle, VK_NULL_HANDLE);
EXPECT_EQ(metadata.handle, nullptr);
adapter.return_queue(metadata);
EXPECT_NO_THROW(submit_empty(adapter));
}
Expand Down
4 changes: 3 additions & 1 deletion backends/vulkan_shared/runtime/export.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#if defined(EXECUTORCH_VULKAN_SHARED_BUILDING)
#define EXECUTORCH_VULKAN_SHARED_API __declspec(dllexport)
#else
#define EXECUTORCH_VULKAN_SHARED_API __declspec(dllimport)
// No dllimport: a plain declaration links against both the import library and
// a static build of this library.
#define EXECUTORCH_VULKAN_SHARED_API
#endif
#else
#define EXECUTORCH_VULKAN_SHARED_API __attribute__((visibility("default")))
Expand Down
25 changes: 21 additions & 4 deletions backends/vulkan_shared/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,47 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
def define_common_targets():
"""Defines the shared Vulkan runtime and its unit tests."""

# The device has no ExecuTorch runtime deps, so the Vulkan compute API can
# export it without pulling the runtime into binaries that only use the
# compute API.
runtime.cxx_library(
name = "device",
srcs = ["runtime/SharedVulkanDevice.cpp"],
exported_headers = [
"runtime/SharedVulkanDevice.h",
"runtime/export.h",
],
force_static = False,
preprocessor_flags = [
"-DEXECUTORCH_VULKAN_SHARED_BUILDING",
],
visibility = ["PUBLIC"],
exported_deps = [
"fbsource//third-party/khronos:vulkan-headers",
],
)

# This target must be shareable rather than force-static. VGF and Vulkan can
# live in separate DSOs, but both must resolve the same process registry.
runtime.cxx_library(
name = "runtime",
srcs = [
"runtime/SharedVulkanDevice.cpp",
"runtime/SharedVulkanDeviceRegistry.cpp",
"runtime/SharedVulkanRuntimeConfig.cpp",
],
exported_headers = [
"runtime/SharedVulkanDevice.h",
"runtime/SharedVulkanDeviceRegistry.h",
"runtime/SharedVulkanRuntimeConfig.h",
"runtime/export.h",
],
force_static = False,
preprocessor_flags = [
"-DEXECUTORCH_VULKAN_SHARED_BUILDING",
],
visibility = ["PUBLIC"],
exported_deps = [
"//executorch/backends/vulkan_shared:device",
"//executorch/runtime/backend:interface",
"//executorch/runtime/core:core",
"fbsource//third-party/khronos:vulkan-headers",
],
)

Expand Down