Skip to content

[Backport 3.10] Reduce memory usage in pulse sequencing (#336) #338

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

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions include/Utils/SymbolCacheAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ namespace qssc::utils {
// .addToCache<SequenceOp>();
//
// This analysis is intended to be used with MLIR's getAnalysis
// framework. It has been designed to reused the chached value
// framework. It has been designed to reuse the cached value
// and will not be invalidated automatically with each pass.
// If a pass manipulates the symbols that are cached with this
// analysis then it should use the addCallee method to update the
// map or call invalidate after appying updates.
// map or call invalidate after applying updates.
// Note this analysis should always be used by reference or
// via a pointer to ensure that updates are applied to the maps
// stored by the MLIR analysis framework.
Expand Down Expand Up @@ -95,6 +95,8 @@ class SymbolCacheAnalysis {

op->walk([&](CalleeOp op) {
symbolOpsMap[op.getSymName()] = op.getOperation();
// Don't recurse symbols
return mlir::WalkResult::skip();
});
cachedTypes.insert(typeName);
invalid = false;
Expand Down Expand Up @@ -193,7 +195,7 @@ class SymbolCacheAnalysis {

private:
llvm::StringMap<mlir::Operation *> symbolOpsMap;
std::unordered_map<mlir::Operation *, mlir::Operation *> callMap;
llvm::DenseMap<mlir::Operation *, mlir::Operation *> callMap;
std::unordered_set<std::string> cachedTypes;
mlir::Operation *topOp{nullptr};
bool invalid{true};
Expand Down
3 changes: 2 additions & 1 deletion lib/Dialect/QUIR/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ auto getMainFunction(Operation *moduleOperation) -> Operation * {
mainFunc = funcOp.getOperation();
return WalkResult::interrupt();
}
return WalkResult::advance();
// Don't process nested values
return WalkResult::skip();
});
if (!mainFunc)
llvm::errs() << "Error: Main function not found!\n";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
features:
- |
Symbol cache now uses llvm::DenseMap for performance reasons.
Loading