Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 6081f15

Browse files
author
Theodoros Theodoridis
committed
Allow using a user-defined key in the compilation cache
1 parent ba396af commit 6081f15

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

include/tc/core/compilation_cache-inl.h

+11-2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ void Cache<CC>::clear() {
9595
static_cast<CC*>(this)->entries_.clear();
9696
}
9797

98+
namespace {
99+
std::string gpuKey() {
100+
if (not FLAGS_cache_custom_hw_key.empty()) {
101+
return FLAGS_cache_custom_hw_key;
102+
}
103+
return CudaGPUInfo::GPUInfo().GetCudaDeviceStr();
104+
}
105+
} // namespace
106+
98107
template <typename C, typename InputTy> // deduces whether C is const or
99108
// non-const
100109
auto CudaCache::searchKernelImpl(
@@ -104,7 +113,7 @@ auto CudaCache::searchKernelImpl(
104113
const std::vector<InputTy>& inputs,
105114
const std::vector<InputTy>& outputs)
106115
-> decltype(c.searchKernel(id, options, inputs, outputs)) {
107-
auto gpuStr = CudaGPUInfo::GPUInfo().GetCudaDeviceStr();
116+
auto gpuStr = gpuKey();
108117
auto it = std::find_if(
109118
c.entries_.begin(), c.entries_.end(), [&](const CachedEntry& c) {
110119
using tc::operator==;
@@ -134,7 +143,7 @@ auto OptionsCache::searchKernelImpl(
134143
const std::vector<const DLTensor*>& inputs,
135144
const std::vector<const DLTensor*>& outputs)
136145
-> decltype(c.searchKernel(id, inputs, outputs)) {
137-
auto gpuStr = CudaGPUInfo::GPUInfo().GetCudaDeviceStr();
146+
auto gpuStr = gpuKey();
138147
auto it = std::find_if(
139148
c.entries_.begin(), c.entries_.end(), [&](const CachedEntry& c) {
140149
using tc::operator==;

include/tc/core/flags.h

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ DECLARE_uint32(tuner_gen_restore_number);
5454
DECLARE_bool(tuner_gen_log_generations);
5555
DECLARE_uint64(tuner_min_launch_total_threads);
5656

57+
58+
DECLARE_string(cache_custom_hw_key);
59+
5760
// Misc
5861
DECLARE_int64(random_seed);
5962
DECLARE_bool(schedule_tree_verbose_validation);

src/core/flags.cc

+5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ DEFINE_int64(
111111
-1,
112112
"The number of best candidates to restore from the proto cache");
113113

114+
DEFINE_string(
115+
cache_custom_hw_key,
116+
"",
117+
"Replace the \"hardware description\" with a custom string when querying the cache.");
118+
114119
uint64_t initRandomSeed() {
115120
static std::mutex mut;
116121
static bool inited = false;

0 commit comments

Comments
 (0)