From c5da072ff680dd64eca10f18bd8e97f6a1643073 Mon Sep 17 00:00:00 2001 From: Yutetsu TAKATSUKASA Date: Mon, 5 Oct 2020 08:20:49 +0900 Subject: [PATCH] Fix performance degradation when --threads is used with --hierarchical (Issue #2562) #2581 --- src/V3HierBlock.cpp | 6 ++++++ src/V3Options.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/V3HierBlock.cpp b/src/V3HierBlock.cpp index fd0606ab0..0f460f46d 100644 --- a/src/V3HierBlock.cpp +++ b/src/V3HierBlock.cpp @@ -228,6 +228,9 @@ void V3HierBlock::writeCommandArgsFile(bool forCMake) const { ++child) { *of << (*child)->hierBlockArgs().front() << "\n"; } + // Hierarchical blocks should not use multi-threading, + // but needs to be thread safe when top is multi-threaded. + if (v3Global.opt.threads() > 0) { *of << "--threads 1\n"; } *of << v3Global.opt.allArgsStringForHierBlock(false) << "\n"; } @@ -426,6 +429,9 @@ void V3HierBlockPlan::writeCommandArgsFiles(bool forCMake) const { *of << "--protect-lib " << v3Global.opt.protectLib() << "\n"; *of << "--protect-key " << v3Global.opt.protectKeyDefaulted() << "\n"; } + if (v3Global.opt.threads() > 0) { + *of << "--threads " << cvtToStr(v3Global.opt.threads()) << "\n"; + } *of << (v3Global.opt.systemC() ? "--sc" : "--cc") << "\n"; *of << v3Global.opt.allArgsStringForHierBlock(true) << "\n"; } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 141593820..9caff20c6 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -504,7 +504,7 @@ string V3Options::filePathCheckOneDir(const string& modname, const string& dirna int V3Options::stripOptionsForChildRun(const string& opt, bool forTop) const { if (opt == "Mdir" || opt == "clk" || opt == "f" || opt == "j" || opt == "l2-name" || opt == "mod-prefix" || opt == "prefix" || opt == "protect-lib" || opt == "protect-key" - || opt == "top-module" || opt == "v") { + || opt == "threads" || opt == "top-module" || opt == "v") { return 2; } if (opt == "build" || (!forTop && (opt == "cc" || opt == "exe" || opt == "sc"))