Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lang] Accelerate compilation by improving key generation #8604

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading