Skip to content

Commit

Permalink
Avoid double prof exec init in hier childs
Browse files Browse the repository at this point in the history
Signed-off-by: Bartłomiej Chmiel <[email protected]>
  • Loading branch information
b-chmiel committed Dec 20, 2024
1 parent 758def9 commit 1f9f891
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions bin/verilator_gantt
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def report_sections():
scope = scope[1].setdefault(item, [0, {}, 0])
scope[2] += 1
dt = time - prevTime
assert dt > 0
scope = sectionTree
for item in prevStack:
scope = scope[1].setdefault(item, [0, {}, 0])
Expand Down
3 changes: 2 additions & 1 deletion src/V3EmitCModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ class EmitCModel final : public EmitCFunc {
puts(topModNameProtected + "__" + protect("_eval_settle") + "(&(vlSymsp->TOP));\n");
puts("}\n");

if (v3Global.opt.profExec()) puts("vlSymsp->__Vm_executionProfilerp->configure();\n");
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
puts("vlSymsp->__Vm_executionProfilerp->configure();\n");

puts("VL_DEBUG_IF(VL_DBG_MSGF(\"+ Eval\\n\"););\n");
puts(topModNameProtected + "__" + protect("_eval") + "(&(vlSymsp->TOP));\n");
Expand Down
4 changes: 2 additions & 2 deletions src/V3Order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ AstCFunc* V3Order::order(AstNetlist* netlistp, //
return resp;
}();

if (v3Global.opt.profExec()) {
if (v3Global.opt.profExec() && !v3Global.opt.hierChild()) {
funcp->addStmtsp(new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPush(\"func "
+ tag + "\");\n"});
}
Expand Down Expand Up @@ -152,7 +152,7 @@ AstCFunc* V3Order::order(AstNetlist* netlistp, //
// Dispose of the remnants of the inputs
for (auto* const lbsp : logic) lbsp->deleteActives();

if (v3Global.opt.profExec()) {
if (v3Global.opt.profExec() && !v3Global.opt.hierChild()) {
funcp->addStmtsp(new AstCStmt{flp, "VL_EXEC_TRACE_ADD_RECORD(vlSymsp).sectionPop();\n"});
}

Expand Down
18 changes: 12 additions & 6 deletions src/V3Sched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ EvalLoop createEvalLoop(
AstNodeStmt* stmtps = nullptr;

// Prof-exec section push
if (v3Global.opt.profExec()) stmtps = profExecSectionPush(flp, "loop " + tag);
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
stmtps = profExecSectionPush(flp, "loop " + tag);

const auto addVar = [&](const std::string& name, int width, uint32_t initVal) {
AstVarScope* const vscp = scopeTopp->createTemp("__V" + tag + name, width);
Expand Down Expand Up @@ -273,7 +274,8 @@ EvalLoop createEvalLoop(
}

// Prof-exec section pop
if (v3Global.opt.profExec()) stmtps->addNext(profExecSectionPop(flp));
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
stmtps->addNext(profExecSectionPop(flp));

return {firstIterFlagp, stmtps};
}
Expand Down Expand Up @@ -630,7 +632,8 @@ const TriggerKit createTriggers(AstNetlist* netlistp, AstCFunc* const initFuncp,

// Create the trigger computation function
AstCFunc* const funcp = makeSubFunction(netlistp, "_eval_triggers__" + name, slow);
if (v3Global.opt.profExec()) funcp->addStmtsp(profExecSectionPush(flp, "trig " + name));
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
funcp->addStmtsp(profExecSectionPush(flp, "trig " + name));

// Create the trigger dump function (for debugging, always 'slow')
AstCFunc* const dumpp = makeSubFunction(netlistp, "_dump_triggers__" + name, true);
Expand Down Expand Up @@ -781,7 +784,8 @@ const TriggerKit createTriggers(AstNetlist* netlistp, AstCFunc* const initFuncp,
add("#endif\n");
}

if (v3Global.opt.profExec()) funcp->addStmtsp(profExecSectionPop(flp));
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
funcp->addStmtsp(profExecSectionPop(flp));

// The debug code might leak signal names, so simply delete it when using --protect-ids
if (v3Global.opt.protectIds()) dumpp->stmtsp()->unlinkFrBackWithNext()->deleteTree();
Expand Down Expand Up @@ -1110,7 +1114,8 @@ void createEval(AstNetlist* netlistp, //
AstCFunc* const funcp = makeTopFunction(netlistp, "_eval", false);
netlistp->evalp(funcp);

if (v3Global.opt.profExec()) funcp->addStmtsp(profExecSectionPush(flp, "eval"));
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
funcp->addStmtsp(profExecSectionPush(flp, "eval"));

// Start with the ico loop, if any
if (icoLoop) funcp->addStmtsp(icoLoop);
Expand All @@ -1121,7 +1126,8 @@ void createEval(AstNetlist* netlistp, //
// Add the Postponed eval call
if (postponedFuncp) funcp->addStmtsp(callVoidFunc(postponedFuncp));

if (v3Global.opt.profExec()) funcp->addStmtsp(profExecSectionPop(flp));
if (v3Global.opt.profExec() && !v3Global.opt.hierChild())
funcp->addStmtsp(profExecSectionPop(flp));
}

} // namespace
Expand Down

0 comments on commit 1f9f891

Please sign in to comment.