From 157e7da747093c13ea94ef6116a26ab626898daf Mon Sep 17 00:00:00 2001 From: jorgep31415 Date: Tue, 3 Jun 2025 17:25:12 -0700 Subject: [PATCH] [ET-VK] Allow clients to specify cache_data_path Differential Revision: [D75918105](https://our.internmc.facebook.com/intern/diff/D75918105/) [ghstack-poisoned] --- backends/vulkan/runtime/vk_api/Runtime.cpp | 7 +++---- backends/vulkan/runtime/vk_api/Runtime.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backends/vulkan/runtime/vk_api/Runtime.cpp b/backends/vulkan/runtime/vk_api/Runtime.cpp index 9b30aaacda8..f3515b26de3 100644 --- a/backends/vulkan/runtime/vk_api/Runtime.cpp +++ b/backends/vulkan/runtime/vk_api/Runtime.cpp @@ -258,7 +258,7 @@ uint32_t select_first(const std::vector& devices) { // Global runtime initialization // -std::unique_ptr init_global_vulkan_runtime() { +std::unique_ptr init_global_vulkan_runtime(const std::string& cache_data_path) { // Load Vulkan drivers #if defined(USE_VULKAN_VOLK) if (VK_SUCCESS != volkInitialize()) { @@ -278,7 +278,6 @@ std::unique_ptr init_global_vulkan_runtime() { #endif /* VULKAN_DEBUG */ const bool init_default_device = true; const uint32_t num_requested_queues = 1; // TODO: raise this value - const std::string cache_data_path = ""; // TODO: expose to client const RuntimeConfig default_config{ enable_validation_messages, @@ -377,13 +376,13 @@ uint32_t Runtime::create_adapter(const Selector& selector) { return adapter_i; } -Runtime* runtime() { +Runtime* runtime(const std::string& cache_data_path) { // The global vulkan runtime is declared as a static local variable within a // non-static function to ensure it has external linkage. If it were a global // static variable there would be one copy per translation unit that includes // Runtime.h as it would have internal linkage. static const std::unique_ptr p_runtime = - init_global_vulkan_runtime(); + init_global_vulkan_runtime(cache_data_path); VK_CHECK_COND( p_runtime, diff --git a/backends/vulkan/runtime/vk_api/Runtime.h b/backends/vulkan/runtime/vk_api/Runtime.h index 16f1400021c..30ac5527367 100644 --- a/backends/vulkan/runtime/vk_api/Runtime.h +++ b/backends/vulkan/runtime/vk_api/Runtime.h @@ -102,7 +102,7 @@ class Runtime final { // The global runtime is retrieved using this function, where it is declared as // a static local variable. -Runtime* runtime(); +Runtime* runtime(const std::string& cache_data_path = ""); } // namespace vkapi } // namespace vkcompute