Skip to content

Commit 17fc725

Browse files
committed
Update on "[ET-VK] Support setting cache_data_path at run time"
Differential Revision: [D75918105](https://our.internmc.facebook.com/intern/diff/D75918105/) [ghstack-poisoned]
2 parents 53858c2 + 021e6ea commit 17fc725

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

backends/vulkan/runtime/vk_api/Runtime.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,24 @@ uint32_t Runtime::create_adapter(const Selector& selector) {
377377
return adapter_i;
378378
}
379379

380-
Runtime* runtime(const std::string& cache_data_path) {
380+
std::string& set_and_get_pipeline_cache_data_path(
381+
const std::string& file_path) {
382+
// The global cache data path is declared as a static local variable for the
383+
// same reasons as the global runtime below.
384+
static std::string global_cache_data_path = "";
385+
if (file_path.size() > 0) {
386+
global_cache_data_path = file_path;
387+
}
388+
return global_cache_data_path;
389+
}
390+
391+
Runtime* runtime() {
381392
// The global vulkan runtime is declared as a static local variable within a
382393
// non-static function to ensure it has external linkage. If it were a global
383394
// static variable there would be one copy per translation unit that includes
384395
// Runtime.h as it would have internal linkage.
385396
static const std::unique_ptr<Runtime> p_runtime =
386-
init_global_vulkan_runtime(cache_data_path);
397+
init_global_vulkan_runtime(set_and_get_pipeline_cache_data_path(""));
387398

388399
VK_CHECK_COND(
389400
p_runtime,

backends/vulkan/runtime/vk_api/Runtime.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ class Runtime final {
100100
uint32_t create_adapter(const Selector&);
101101
};
102102

103+
std::string& set_and_get_pipeline_cache_data_path(const std::string& file_path);
104+
103105
// The global runtime is retrieved using this function, where it is declared as
104106
// a static local variable.
105-
Runtime* runtime(const std::string& cache_data_path = "");
107+
Runtime* runtime();
106108

107109
} // namespace vkapi
108110
} // namespace vkcompute

0 commit comments

Comments
 (0)