Skip to content

Commit

Permalink
[lang] Accelerate compilation by improving key generation (#8604)
Browse files Browse the repository at this point in the history
  • Loading branch information
erizmr authored Dec 19, 2024
1 parent 4218a45 commit e038020
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion taichi/analysis/gen_offline_cache_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,14 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor {
// Note: The result of serializing snode_tree_roots_ is not parsable now
emit(static_cast<std::size_t>(snode_tree_roots_.size()));
for (const auto *snode : snode_tree_roots_) {
auto key = get_hashed_offline_cache_key_of_snode(snode);
std::string key;
if (snode_key_cache_.find(snode) == snode_key_cache_.end()) {
key = get_hashed_offline_cache_key_of_snode(snode);
snode_key_cache_[snode] = key;
} else {
key = snode_key_cache_[snode];
}
snode_key_cache_[snode] = key;
emit_bytes(key.c_str(), key.size());
}

Expand Down Expand Up @@ -655,6 +662,7 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor {

std::ostream *os_{nullptr};
std::vector<const SNode *> snode_tree_roots_;
std::unordered_map<const SNode *, std::string> snode_key_cache_;
std::map<Function *, std::size_t> real_funcs_;
std::vector<char> string_pool_;
};
Expand Down

0 comments on commit e038020

Please sign in to comment.