Add stats on input size etc (#5017)

This commit is contained in:
Wilson Snyder
2024-03-24 09:14:31 -04:00
committed by GitHub
parent 9b729b80e0
commit 23f013f2d7
5 changed files with 22 additions and 2 deletions
+8 -1
View File
@@ -113,6 +113,7 @@ class EmitCSyms final : EmitCBaseVisitorConst {
int m_funcNum = 0; // CFunc split function number
V3OutCFile* m_ofpBase = nullptr; // Base (not split) C file
std::unordered_map<int, bool> m_usesVfinal; // Split method uses __Vfinal
VDouble0 m_statVarScopeBytes; // Statistic tracking
// METHODS
void emitSymHdr();
@@ -367,6 +368,10 @@ class EmitCSyms final : EmitCBaseVisitorConst {
iterateChildrenConst(nodep);
if (nodep->isSigUserRdPublic() && !m_cfuncp) m_modVars.emplace_back(m_modp, nodep);
}
void visit(AstVarScope* nodep) override {
iterateChildrenConst(nodep);
m_statVarScopeBytes += nodep->varp()->dtypep()->widthTotalBytes();
}
void visit(AstCoverDecl* nodep) override {
// Assign numbers to all bins, so we know how big of an array to use
if (!nodep->dataDeclNullp()) { // else duplicate we don't need code for
@@ -832,8 +837,10 @@ void EmitCSyms::emitSymImp() {
puts(" // Check resources\n");
uint64_t stackSize = V3StackCount::count(v3Global.rootp());
if (v3Global.opt.debugStackCheck()) stackSize += 1024 * 1024 * 1024;
V3Stats::addStat("Stack size prediction (bytes)", stackSize);
V3Stats::addStat("Size prediction, Stack (bytes)", stackSize);
puts(" Verilated::stackCheck(" + cvtToStr(stackSize) + ");\n");
V3Stats::addStat("Size prediction, Heap, from Var Scopes (bytes)", m_statVarScopeBytes);
V3Stats::addStat(V3Stats::STAT_MODEL_SIZE, stackSize + m_statVarScopeBytes);
}
if (v3Global.opt.profPgo()) {