Skip to content

Commit 3534640

Browse files
[Backport 3.10] Reduce memory usage in pulse sequencing (#336) (#338)
Builds on #335. Co-authored-by: Thomas Alexander <[email protected]>
1 parent d78b3dd commit 3534640

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

include/Utils/SymbolCacheAnalysis.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ namespace qssc::utils {
4949
// .addToCache<SequenceOp>();
5050
//
5151
// This analysis is intended to be used with MLIR's getAnalysis
52-
// framework. It has been designed to reused the chached value
52+
// framework. It has been designed to reuse the cached value
5353
// and will not be invalidated automatically with each pass.
5454
// If a pass manipulates the symbols that are cached with this
5555
// analysis then it should use the addCallee method to update the
56-
// map or call invalidate after appying updates.
56+
// map or call invalidate after applying updates.
5757
// Note this analysis should always be used by reference or
5858
// via a pointer to ensure that updates are applied to the maps
5959
// stored by the MLIR analysis framework.
@@ -95,6 +95,8 @@ class SymbolCacheAnalysis {
9595

9696
op->walk([&](CalleeOp op) {
9797
symbolOpsMap[op.getSymName()] = op.getOperation();
98+
// Don't recurse symbols
99+
return mlir::WalkResult::skip();
98100
});
99101
cachedTypes.insert(typeName);
100102
invalid = false;
@@ -193,7 +195,7 @@ class SymbolCacheAnalysis {
193195

194196
private:
195197
llvm::StringMap<mlir::Operation *> symbolOpsMap;
196-
std::unordered_map<mlir::Operation *, mlir::Operation *> callMap;
198+
llvm::DenseMap<mlir::Operation *, mlir::Operation *> callMap;
197199
std::unordered_set<std::string> cachedTypes;
198200
mlir::Operation *topOp{nullptr};
199201
bool invalid{true};

lib/Dialect/QUIR/Utils/Utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ auto getMainFunction(Operation *moduleOperation) -> Operation * {
9797
mainFunc = funcOp.getOperation();
9898
return WalkResult::interrupt();
9999
}
100-
return WalkResult::advance();
100+
// Don't process nested values
101+
return WalkResult::skip();
101102
});
102103
if (!mainFunc)
103104
llvm::errs() << "Error: Main function not found!\n";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
features:
3+
- |
4+
Symbol cache now uses llvm::DenseMap for performance reasons.

0 commit comments

Comments
 (0)