Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0c29d88

Browse files
SamGondelmanfacebook-github-bot
authored andcommittedJun 6, 2025·
Ability to set external instance + devices (#11393)
Summary: Adds a new extension to ETVK, set_and_get_external_adapter, which allows clients to share their Vulkan instance/devices with ETVK. This is useful when using volk, which does not support multiple devices when using volkLoadDevice. Differential Revision: D71372344
1 parent b632906 commit 0c29d88

File tree

15 files changed

+254
-94
lines changed

15 files changed

+254
-94
lines changed
 

‎backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
#include <executorch/backends/vulkan/runtime/graph/ops/OperatorRegistry.h>
1515

16+
#include <executorch/backends/vulkan/runtime/vk_api/Runtime.h>
17+
1618
#include <executorch/runtime/backend/interface.h>
1719
#include <executorch/runtime/core/error.h>
1820
#include <executorch/runtime/core/evalue.h>
@@ -517,7 +519,9 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
517519
return Error::MemoryAllocationFailed;
518520
}
519521

520-
new (compute_graph) ComputeGraph(get_graph_config(compile_specs));
522+
GraphConfig graph_config = get_graph_config(compile_specs);
523+
graph_config.external_adapter = vkapi::set_and_get_external_adapter();
524+
new (compute_graph) ComputeGraph(graph_config);
521525

522526
Error err = compileModel(processed->data(), compute_graph);
523527

‎backends/vulkan/runtime/api/Context.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
namespace vkcompute {
2525
namespace api {
2626

27-
Context::Context(size_t adapter_i, const ContextConfig& config)
27+
Context::Context(vkapi::Adapter* adapter, const ContextConfig& config)
2828
: config_(config),
2929
// Important handles
30-
adapter_p_(vkapi::runtime()->get_adapter_p(adapter_i)),
30+
adapter_p_(adapter),
3131
device_(adapter_p_->device_handle()),
3232
queue_(adapter_p_->request_queue()),
3333
// Resource pools
@@ -256,7 +256,7 @@ Context* context() {
256256
query_pool_config,
257257
};
258258

259-
return new Context(vkapi::runtime()->default_adapter_i(), config);
259+
return new Context(vkapi::runtime()->get_adapter_p(), config);
260260
} catch (...) {
261261
}
262262

‎backends/vulkan/runtime/api/Context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct ContextConfig final {
4242

4343
class Context final {
4444
public:
45-
explicit Context(size_t adapter_i, const ContextConfig&);
45+
explicit Context(vkapi::Adapter*, const ContextConfig&);
4646

4747
Context(const Context&) = delete;
4848
Context& operator=(const Context&) = delete;

‎backends/vulkan/runtime/graph/ComputeGraph.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ ComputeGraph::ComputeGraph(GraphConfig config)
122122
prepack_descriptor_counts_{},
123123
execute_descriptor_counts_{},
124124
context_{new api::Context(
125-
vkapi::runtime()->default_adapter_i(),
125+
config.external_adapter ? config.external_adapter
126+
: vkapi::runtime()->get_adapter_p(),
126127
config_.context_config)},
127128
shared_objects_{},
128129
values_{},

‎backends/vulkan/runtime/graph/GraphConfig.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ GraphConfig::GraphConfig() {
6363

6464
enable_local_wg_size_override = false;
6565
local_wg_size_override = {};
66+
67+
external_adapter = nullptr;
6668
}
6769

6870
void GraphConfig::set_storage_type_override(utils::StorageType storage_type) {

‎backends/vulkan/runtime/graph/GraphConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct GraphConfig final {
3333
bool enable_local_wg_size_override;
3434
utils::uvec3 local_wg_size_override;
3535

36+
vkapi::Adapter* external_adapter;
37+
3638
// Generate a default graph config with pre-configured settings
3739
explicit GraphConfig();
3840

‎backends/vulkan/runtime/vk_api/Adapter.cpp

Lines changed: 106 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@ namespace vkapi {
1717

1818
namespace {
1919

20-
VkDevice create_logical_device(
20+
void find_compute_queues(
2121
const PhysicalDevice& physical_device,
2222
const uint32_t num_queues_to_create,
23-
std::vector<Adapter::Queue>& queues,
24-
std::vector<uint32_t>& queue_usage) {
25-
// Find compute queues up to the requested number of queues
26-
27-
std::vector<VkDeviceQueueCreateInfo> queue_create_infos;
23+
std::vector<VkDeviceQueueCreateInfo>& queue_create_infos,
24+
std::vector<std::pair<uint32_t, uint32_t>>& queues_to_get) {
2825
queue_create_infos.reserve(num_queues_to_create);
29-
30-
std::vector<std::pair<uint32_t, uint32_t>> queues_to_get;
3126
queues_to_get.reserve(num_queues_to_create);
3227

3328
uint32_t remaining_queues = num_queues_to_create;
@@ -60,12 +55,44 @@ VkDevice create_logical_device(
6055
break;
6156
}
6257
}
58+
}
6359

60+
void populate_queue_info(
61+
const PhysicalDevice& physical_device,
62+
VkDevice logical_device,
63+
const std::vector<std::pair<uint32_t, uint32_t>>& queues_to_get,
64+
std::vector<Adapter::Queue>& queues,
65+
std::vector<uint32_t>& queue_usage) {
6466
queues.reserve(queues_to_get.size());
6567
queue_usage.reserve(queues_to_get.size());
6668

67-
// Create the VkDevice
69+
// Obtain handles for the created queues and initialize queue usage heuristic
70+
71+
for (const std::pair<uint32_t, uint32_t>& queue_idx : queues_to_get) {
72+
VkQueue queue_handle = VK_NULL_HANDLE;
73+
VkQueueFlags flags =
74+
physical_device.queue_families.at(queue_idx.first).queueFlags;
75+
vkGetDeviceQueue(
76+
logical_device, queue_idx.first, queue_idx.second, &queue_handle);
77+
queues.push_back({queue_idx.first, queue_idx.second, flags, queue_handle});
78+
// Initial usage value
79+
queue_usage.push_back(0);
80+
}
81+
}
82+
83+
VkDevice create_logical_device(
84+
const PhysicalDevice& physical_device,
85+
const uint32_t num_queues_to_create,
86+
std::vector<Adapter::Queue>& queues,
87+
std::vector<uint32_t>& queue_usage) {
88+
// Find compute queues up to the requested number of queues
6889

90+
std::vector<VkDeviceQueueCreateInfo> queue_create_infos;
91+
std::vector<std::pair<uint32_t, uint32_t>> queues_to_get;
92+
find_compute_queues(
93+
physical_device, num_queues_to_create, queue_create_infos, queues_to_get);
94+
95+
// Create the VkDevice
6996
std::vector<const char*> requested_device_extensions{
7097
#ifdef VK_KHR_portability_subset
7198
VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
@@ -143,19 +170,42 @@ VkDevice create_logical_device(
143170
volkLoadDevice(handle);
144171
#endif /* USE_VULKAN_VOLK */
145172

146-
// Obtain handles for the created queues and initialize queue usage heuristic
173+
populate_queue_info(
174+
physical_device, handle, queues_to_get, queues, queue_usage);
147175

148-
for (const std::pair<uint32_t, uint32_t>& queue_idx : queues_to_get) {
149-
VkQueue queue_handle = VK_NULL_HANDLE;
150-
VkQueueFlags flags =
151-
physical_device.queue_families.at(queue_idx.first).queueFlags;
152-
vkGetDeviceQueue(handle, queue_idx.first, queue_idx.second, &queue_handle);
153-
queues.push_back({queue_idx.first, queue_idx.second, flags, queue_handle});
154-
// Initial usage value
155-
queue_usage.push_back(0);
176+
return handle;
177+
}
178+
179+
bool test_linear_tiling_3d_image_support(VkDevice device) {
180+
// Test creating a 3D image with linear tiling to see if it is supported.
181+
// According to the Vulkan spec, linear tiling may not be supported for 3D
182+
// images.
183+
VkExtent3D image_extents{1u, 1u, 1u};
184+
const VkImageCreateInfo image_create_info{
185+
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
186+
nullptr, // pNext
187+
0u, // flags
188+
VK_IMAGE_TYPE_3D, // imageType
189+
VK_FORMAT_R32G32B32A32_SFLOAT, // format
190+
image_extents, // extents
191+
1u, // mipLevels
192+
1u, // arrayLayers
193+
VK_SAMPLE_COUNT_1_BIT, // samples
194+
VK_IMAGE_TILING_LINEAR, // tiling
195+
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, // usage
196+
VK_SHARING_MODE_EXCLUSIVE, // sharingMode
197+
0u, // queueFamilyIndexCount
198+
nullptr, // pQueueFamilyIndices
199+
VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
200+
};
201+
VkImage image = VK_NULL_HANDLE;
202+
VkResult res = vkCreateImage(device, &image_create_info, nullptr, &image);
203+
204+
if (res == VK_SUCCESS) {
205+
vkDestroyImage(device, image, nullptr);
156206
}
157207

158-
return handle;
208+
return res == VK_SUCCESS;
159209
}
160210

161211
} // namespace
@@ -186,37 +236,44 @@ Adapter::Adapter(
186236
compute_pipeline_cache_(device_.handle, cache_data_path),
187237
sampler_cache_(device_.handle),
188238
vma_(instance_, physical_device_.handle, device_.handle),
189-
linear_tiling_3d_enabled_{true} {
190-
// Test creating a 3D image with linear tiling to see if it is supported.
191-
// According to the Vulkan spec, linear tiling may not be supported for 3D
192-
// images.
193-
VkExtent3D image_extents{1u, 1u, 1u};
194-
const VkImageCreateInfo image_create_info{
195-
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
196-
nullptr, // pNext
197-
0u, // flags
198-
VK_IMAGE_TYPE_3D, // imageType
199-
VK_FORMAT_R32G32B32A32_SFLOAT, // format
200-
image_extents, // extents
201-
1u, // mipLevels
202-
1u, // arrayLayers
203-
VK_SAMPLE_COUNT_1_BIT, // samples
204-
VK_IMAGE_TILING_LINEAR, // tiling
205-
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, // usage
206-
VK_SHARING_MODE_EXCLUSIVE, // sharingMode
207-
0u, // queueFamilyIndexCount
208-
nullptr, // pQueueFamilyIndices
209-
VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
210-
};
211-
VkImage image = VK_NULL_HANDLE;
212-
VkResult res =
213-
vkCreateImage(device_.handle, &image_create_info, nullptr, &image);
214-
if (res != VK_SUCCESS) {
215-
linear_tiling_3d_enabled_ = false;
216-
} else {
217-
vkDestroyImage(device_.handle, image, nullptr);
239+
linear_tiling_3d_enabled_{
240+
test_linear_tiling_3d_image_support(device_.handle)},
241+
owns_device_{true} {}
242+
243+
Adapter::Adapter(
244+
VkInstance instance,
245+
VkPhysicalDevice physical_device,
246+
VkDevice logical_device,
247+
const uint32_t num_queues,
248+
const std::string& cache_data_path)
249+
: queue_usage_mutex_{},
250+
physical_device_(physical_device),
251+
queues_{},
252+
queue_usage_{},
253+
queue_mutexes_{},
254+
instance_(instance),
255+
device_(logical_device),
256+
shader_layout_cache_(device_.handle),
257+
shader_cache_(device_.handle),
258+
pipeline_layout_cache_(device_.handle),
259+
compute_pipeline_cache_(device_.handle, cache_data_path),
260+
sampler_cache_(device_.handle),
261+
vma_(instance_, physical_device_.handle, device_.handle),
262+
linear_tiling_3d_enabled_{
263+
test_linear_tiling_3d_image_support(device_.handle)},
264+
owns_device_{false} {
265+
std::vector<VkDeviceQueueCreateInfo> queue_create_infos;
266+
std::vector<std::pair<uint32_t, uint32_t>> queues_to_get;
267+
find_compute_queues(
268+
physical_device_, num_queues, queue_create_infos, queues_to_get);
269+
populate_queue_info(
270+
physical_device_, device_.handle, queues_to_get, queues_, queue_usage_);
271+
}
272+
273+
Adapter::~Adapter() {
274+
if (!owns_device_) {
275+
device_.handle = VK_NULL_HANDLE;
218276
}
219-
return;
220277
}
221278

222279
Adapter::Queue Adapter::request_queue() {

‎backends/vulkan/runtime/vk_api/Adapter.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,20 @@ class Adapter final {
5656
const uint32_t num_queues,
5757
const std::string& cache_data_path);
5858

59+
explicit Adapter(
60+
VkInstance instance,
61+
VkPhysicalDevice physical_device,
62+
VkDevice logical_device,
63+
const uint32_t num_queues,
64+
const std::string& cache_data_path);
65+
5966
Adapter(const Adapter&) = delete;
6067
Adapter& operator=(const Adapter&) = delete;
6168

6269
Adapter(Adapter&&) = delete;
6370
Adapter& operator=(Adapter&&) = delete;
6471

65-
~Adapter() = default;
72+
~Adapter();
6673

6774
struct Queue {
6875
uint32_t family_index;
@@ -94,6 +101,7 @@ class Adapter final {
94101
Allocator vma_;
95102
// Miscellaneous
96103
bool linear_tiling_3d_enabled_;
104+
bool owns_device_;
97105

98106
public:
99107
// Physical Device metadata

‎backends/vulkan/runtime/vk_api/Runtime.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
#include <iostream>
1515
#include <sstream>
1616

17+
#ifdef USE_VOLK_HEADER_ONLY
18+
// For volk.h, define this before including volk.h in exactly one CPP file.
19+
#define VOLK_IMPLEMENTATION
20+
#include <volk.h>
21+
#endif /* USE_VOLK_HEADER_ONLY */
22+
1723
namespace vkcompute {
1824
namespace vkapi {
1925

@@ -409,5 +415,20 @@ Runtime* runtime() {
409415
return p_runtime.get();
410416
}
411417

418+
Adapter* set_and_get_external_adapter(
419+
const VkInstance instance,
420+
const VkPhysicalDevice physical_device,
421+
const VkDevice logical_device) {
422+
static std::unique_ptr<Adapter> p_external_adapter = nullptr;
423+
424+
if (instance != VK_NULL_HANDLE && physical_device != VK_NULL_HANDLE &&
425+
logical_device != VK_NULL_HANDLE) {
426+
p_external_adapter = std::make_unique<Adapter>(
427+
instance, physical_device, logical_device, 1, set_and_get_pipeline_cache_data_path(""));
428+
}
429+
430+
return p_external_adapter.get();
431+
}
432+
412433
} // namespace vkapi
413434
} // namespace vkcompute

‎backends/vulkan/runtime/vk_api/Runtime.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,11 @@ std::string& set_and_get_pipeline_cache_data_path(const std::string& file_path);
106106
// a static local variable.
107107
Runtime* runtime();
108108

109+
// Used to share instance + devices between client code and ETVK
110+
Adapter* set_and_get_external_adapter(
111+
const VkInstance instance = VK_NULL_HANDLE,
112+
const VkPhysicalDevice physical_device = VK_NULL_HANDLE,
113+
const VkDevice logical_device = VK_NULL_HANDLE);
114+
109115
} // namespace vkapi
110116
} // namespace vkcompute

‎backends/vulkan/runtime/vk_api/Types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#include <cstddef>
1818
#include <cstdint>
1919

20+
// X11 headers via volk define Bool, so we need to undef it
21+
#if defined(__linux__)
22+
#undef Bool
23+
#endif
24+
2025
#ifdef USE_VULKAN_FP16_INFERENCE
2126
#define VK_FORMAT_FLOAT4 VK_FORMAT_R16G16B16A16_SFLOAT
2227
#else

‎backends/vulkan/targets.bzl

Lines changed: 80 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@fbsource//tools/target_determinator/macros:ci.bzl", "ci")
22
load("@fbcode_macros//build_defs:native_rules.bzl", "buck_genrule")
33
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
4-
load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "CXX", "FBCODE")
4+
load("@fbsource//tools/build_defs:platform_defs.bzl", "ANDROID", "CXX", "FBCODE", "APPLE")
55

66

77
def get_vulkan_compiler_flags():
@@ -13,17 +13,66 @@ def get_vulkan_compiler_flags():
1313
"ovr_config//os:windows": [],
1414
})
1515

16+
def get_vulkan_preprocessor_flags(no_volk, is_fbcode):
17+
VK_API_PREPROCESSOR_FLAGS = []
18+
19+
default_flags = []
20+
android_flags = []
21+
22+
if not no_volk:
23+
for flags in [default_flags, android_flags]:
24+
flags.append("-DUSE_VULKAN_WRAPPER")
25+
flags.append("-DUSE_VULKAN_VOLK")
26+
flags.append("-DUSE_VOLK_HEADER_ONLY")
27+
android_flags.append("-DVK_ANDROID_external_memory_android_hardware_buffer")
28+
29+
if not is_fbcode:
30+
link_moltenvk = no_volk and read_config("etvk", "link_moltenvk", "1") == "1"
31+
mac_flags = default_flags
32+
if link_moltenvk:
33+
mac_flags = []
34+
35+
VK_API_PREPROCESSOR_FLAGS += select({
36+
"DEFAULT": default_flags,
37+
"ovr_config//os:android": android_flags,
38+
"ovr_config//os:macos": mac_flags,
39+
}) + select({
40+
"//third-party/cuda:windows-cuda-11": [
41+
"-DVK_USE_PLATFORM_WIN32_KHR",
42+
],
43+
"DEFAULT": [],
44+
"ovr_config//os:android": [
45+
"-DVK_USE_PLATFORM_ANDROID_KHR",
46+
],
47+
"ovr_config//os:linux": [
48+
"-DVK_USE_PLATFORM_XLIB_KHR",
49+
],
50+
"ovr_config//os:macos": [
51+
"-DVK_USE_PLATFORM_MACOS_MVK",
52+
],
53+
"ovr_config//os:windows": [
54+
"-DVK_USE_PLATFORM_WIN32_KHR",
55+
],
56+
})
57+
58+
etvk_default_cache_path = read_config("etvk", "default_cache_path", "")
59+
if etvk_default_cache_path != "":
60+
VK_API_PREPROCESSOR_FLAGS += ["-DETVK_DEFAULT_CACHE_PATH={}".format(etvk_default_cache_path)]
61+
62+
debug_mode = read_config("etvk", "debug", "0") == "1"
63+
if debug_mode:
64+
VK_API_PREPROCESSOR_FLAGS += ["-DVULKAN_DEBUG"]
65+
66+
return VK_API_PREPROCESSOR_FLAGS
67+
1668
def get_labels(no_volk):
1769
if no_volk:
1870
return ci.labels(ci.linux(ci.mode("fbsource//arvr/mode/android/mac/dbg")))
1971
else:
2072
return []
2173

22-
def get_platforms(no_volk):
23-
if no_volk:
24-
return [ANDROID]
25-
else:
26-
return [ANDROID, CXX]
74+
def get_platforms():
75+
return [ANDROID, APPLE, CXX]
2776

2877
def vulkan_spv_shader_lib(name, spv_filegroups, is_fbcode = False, no_volk = False):
2978
gen_vulkan_spv_target = "//xplat/executorch/backends/vulkan:gen_vulkan_spv_bin"
@@ -73,7 +122,7 @@ def vulkan_spv_shader_lib(name, spv_filegroups, is_fbcode = False, no_volk = Fal
73122
],
74123
compiler_flags = get_vulkan_compiler_flags(),
75124
labels = get_labels(no_volk),
76-
platforms = get_platforms(no_volk),
125+
platforms = get_platforms(),
77126
define_static_target = True,
78127
# Static initialization is used to register shaders to the global shader registry,
79128
# therefore link_whole must be True to make sure unused symbols are not discarded.
@@ -122,25 +171,20 @@ def define_common_targets(is_fbcode = False):
122171

123172
suffix = "_no_volk" if no_volk else ""
124173

125-
VK_API_PREPROCESSOR_FLAGS = []
126174
VK_API_DEPS = [
127175
"fbsource//third-party/VulkanMemoryAllocator/3.0.1:VulkanMemoryAllocator_xplat",
128176
]
129177

130178
default_deps = []
131179
android_deps = ["fbsource//third-party/toolchains:android"]
132-
default_flags = []
133-
android_flags = []
134180

135181
if no_volk:
136-
android_deps.append("fbsource//third-party/toolchains:vulkan")
182+
for deps in [default_deps, android_deps]:
183+
deps.append("fbsource//third-party/toolchains:vulkan")
184+
deps.append("fbsource//third-party/khronos:vulkan-headers")
137185
else:
138186
for deps in [default_deps, android_deps]:
139-
deps.append("fbsource//third-party/volk:volk")
140-
for flags in [default_flags, android_flags]:
141-
flags.append("-DUSE_VULKAN_WRAPPER")
142-
flags.append("-DUSE_VULKAN_VOLK")
143-
android_flags.append("-DVK_ANDROID_external_memory_android_hardware_buffer")
187+
deps.append("fbsource//third-party/volk:volk-header")
144188

145189
if is_fbcode:
146190
VK_API_DEPS += [
@@ -149,34 +193,23 @@ def define_common_targets(is_fbcode = False):
149193
"fbsource//third-party/swiftshader/lib/linux-x64:libvk_swiftshader_so",
150194
]
151195
else:
152-
link_moltenvk = read_config("etvk", "link_moltenvk", "1") == "1"
196+
link_moltenvk = no_volk and read_config("etvk", "link_moltenvk", "1") == "1"
153197
mac_deps = default_deps
154198
if link_moltenvk:
155199
mac_deps = [
156200
"//third-party/khronos:moltenVK_static"
157201
]
158-
mac_flags = default_flags
159-
if link_moltenvk:
160-
mac_flags = []
161202

162203
VK_API_DEPS += select({
163204
"DEFAULT": default_deps,
164205
"ovr_config//os:android": android_deps,
165206
"ovr_config//os:macos": mac_deps,
207+
}) + select({
208+
"DEFAULT": [],
209+
"ovr_config//os:linux": [
210+
"//arvr/third-party/libX11:libX11",
211+
]
166212
})
167-
VK_API_PREPROCESSOR_FLAGS += select({
168-
"DEFAULT": default_flags,
169-
"ovr_config//os:android": android_flags,
170-
"ovr_config//os:macos": mac_flags,
171-
})
172-
173-
etvk_default_cache_path = read_config("etvk", "default_cache_path", "")
174-
if etvk_default_cache_path != "":
175-
VK_API_PREPROCESSOR_FLAGS += ["-DETVK_DEFAULT_CACHE_PATH={}".format(etvk_default_cache_path)]
176-
177-
debug_mode = read_config("etvk", "debug", "0") == "1"
178-
if debug_mode:
179-
VK_API_PREPROCESSOR_FLAGS += ["-DVULKAN_DEBUG"]
180213

181214
runtime.cxx_library(
182215
name = "vulkan_compute_api{}".format(suffix),
@@ -192,12 +225,22 @@ def define_common_targets(is_fbcode = False):
192225
"runtime/vk_api/**/*.h",
193226
]),
194227
labels = get_labels(no_volk),
195-
platforms = get_platforms(no_volk),
228+
platforms = get_platforms(),
196229
visibility = [
197230
"//executorch/backends/vulkan/...",
198231
"@EXECUTORCH_CLIENTS",
199232
],
200-
exported_preprocessor_flags = VK_API_PREPROCESSOR_FLAGS,
233+
fbobjc_frameworks = select({
234+
"DEFAULT": [],
235+
"ovr_config//os:macos": [
236+
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
237+
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
238+
"$SDKROOT/System/Library/Frameworks/AppKit.framework",
239+
"$SDKROOT/System/Library/Frameworks/Metal.framework",
240+
"$SDKROOT/System/Library/Frameworks/QuartzCore.framework",
241+
],
242+
}),
243+
exported_preprocessor_flags = get_vulkan_preprocessor_flags(no_volk, is_fbcode),
201244
exported_deps = VK_API_DEPS,
202245
)
203246

@@ -211,7 +254,7 @@ def define_common_targets(is_fbcode = False):
211254
"runtime/graph/**/*.h",
212255
]),
213256
labels = get_labels(no_volk),
214-
platforms = get_platforms(no_volk),
257+
platforms = get_platforms(),
215258
visibility = [
216259
"//executorch/backends/...",
217260
"//executorch/extension/pybindings/...",
@@ -249,7 +292,7 @@ def define_common_targets(is_fbcode = False):
249292
"runtime/*.h",
250293
]),
251294
labels = get_labels(no_volk),
252-
platforms = get_platforms(no_volk),
295+
platforms = get_platforms(),
253296
visibility = [
254297
"//executorch/backends/...",
255298
"//executorch/extension/pybindings/...",

‎backends/vulkan/test/compute_api_tests.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def define_compute_api_test_targets():
3232
],
3333
apple_sdks = MACOSX,
3434
labels = get_labels(no_volk),
35-
platforms = get_platforms(no_volk),
35+
platforms = get_platforms(),
3636
visibility = ["PUBLIC"],
3737
deps = [
3838
":test_shader_lib{}".format(suffix),

‎extension/aten_util/make_aten_functor_from_et_functor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#include <executorch/extension/kernel_util/type_list.h>
2323
#include <executorch/extension/tensor/tensor.h>
2424
#include <executorch/runtime/core/evalue.h>
25+
26+
// X11 headers via volk define Complex, so we need to undef it
27+
#if defined(__linux__)
28+
#undef Complex
29+
#endif
30+
2531
#include <torch/torch.h>
2632

2733
namespace executorch {

‎runtime/core/tag.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <executorch/runtime/platform/compiler.h>
1313
#include <cstdint>
1414

15+
// X11 headers via volk define None, so we need to undef it
16+
#if defined(__linux__)
17+
#undef None
18+
#endif
19+
1520
namespace executorch {
1621
namespace runtime {
1722

0 commit comments

Comments
 (0)
Please sign in to comment.