Support multi-thread hierarchical simulation (#2583) (#5871)

This commit is contained in:
Bartłomiej Chmiel
2025-03-24 18:39:29 -04:00
committed by GitHub
parent 7521c2c644
commit fabded95df
22 changed files with 505 additions and 142 deletions
+30
View File
@@ -1737,6 +1737,34 @@ private:
VL_UNCOPYABLE(DpiImportCallVisitor);
};
//######################################################################
// DpiThreadsVisitor
// Get number of threads occupied by this mtask
class DpiThreadsVisitor final : public VNVisitorConst {
int m_threads = 1; // Max number of threads used by this mtask
// METHODS
void visit(AstCFunc* nodep) override {
m_threads = std::max(m_threads, V3Config::getHierWorkers(nodep->cname()));
iterateChildrenConst(nodep);
}
void visit(AstNodeCCall* nodep) override {
iterateChildrenConst(nodep);
iterateConst(nodep->funcp());
}
void visit(AstNode* nodep) override { iterateChildrenConst(nodep); }
public:
// CONSTRUCTORS
explicit DpiThreadsVisitor(AstMTaskBody* nodep) { iterateConst(nodep); }
int threads() const { return m_threads; }
~DpiThreadsVisitor() override = default;
private:
VL_UNCOPYABLE(DpiThreadsVisitor);
};
//######################################################################
// FixDataHazards
@@ -2451,6 +2479,8 @@ AstExecGraph* V3Order::createParallel(OrderGraph& orderGraph, const std::string&
// Create the ExecMTask
ExecMTask* const execMTaskp = new ExecMTask{depGraphp, bodyp};
if (!v3Global.opt.hierBlocks().empty())
execMTaskp->threads(DpiThreadsVisitor{bodyp}.threads());
const bool newEntry = logicMTaskToExecMTask.emplace(mTaskp, execMTaskp).second;
UASSERT_OBJ(newEntry, mTaskp, "LogicMTasks should be processed in dependencyorder");
UINFO(3, "Final '" << tag << "' LogicMTask " << mTaskp->id() << " maps to ExecMTask"