Skip to content

Commit

Permalink
[bug] Avoid redundant cache loading (#7741)
Browse files Browse the repository at this point in the history
Issue: #7002 

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at f2ee059</samp>

Improve kernel compilation manager efficiency by avoiding redundant
cache loading.
### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at f2ee059</samp>

* Add a check for existing kernel data to avoid redundant loading
([link](https://github.com/taichi-dev/taichi/pull/7741/files?diff=unified&w=0#diff-b7662dbf5bcf20f4b99048f4f2405316c0ba037c0722273522efaad72d256ef0L219-R228))
  • Loading branch information
PGZXB authored Apr 4, 2023
1 parent 01233a3 commit d919d75
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion taichi/compilation_manager/kernel_compilation_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ const CompiledKernelData *KernelCompilationManager::try_load_cached_kernel(
auto iter = kernels.find(kernel_key);
if (iter != kernels.end()) {
auto &k = iter->second;
if (auto loaded = load_ckd(kernel_key, arch)) {
if (k.compiled_kernel_data) {
TI_DEBUG("Create kernel '{}' from cache (key='{}')",
kernel_def.get_name(), kernel_key);
return k.compiled_kernel_data.get();
} else if (auto loaded = load_ckd(kernel_key, arch)) {
TI_DEBUG("Create kernel '{}' from cache (key='{}')",
kernel_def.get_name(), kernel_key);
TI_ASSERT(loaded->arch() == arch);
Expand Down

0 comments on commit d919d75

Please sign in to comment.