Thread pool rewrite (#5161)

Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
Signed-off-by: Bartłomiej Chmiel <bchmiel@antmicro.com>
Signed-off-by: Arkadiusz Kozdra <akozdra@antmicro.com>
Co-authored-by: Krzysztof Bieganski <kbieganski@antmicro.com>
Co-authored-by: Arkadiusz Kozdra <akozdra@antmicro.com>
Co-authored-by: Wilson Snyder <wsnyder@wsnyder.org>
This commit is contained in:
Bartłomiej Chmiel 2024-08-23 14:36:49 +02:00 committed by GitHub
parent eb8bbcda05
commit ffe76717c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
117 changed files with 1188 additions and 1845 deletions

View File

@ -221,19 +221,6 @@ public:
void unlock() VL_RELEASE() VL_MT_SAFE { m_mutex.unlock(); }
/// Try to acquire mutex. Returns true on success, and false on failure.
bool try_lock() VL_TRY_ACQUIRE(true) VL_MT_SAFE { return m_mutex.try_lock(); }
/// Acquire/lock mutex and check for stop request
/// It tries to lock the mutex and if it fails, it check if stop request was send.
/// It returns after locking mutex.
/// This function should be extracted to V3ThreadPool, but due to clang thread-safety
/// limitations it needs to be placed here.
void lockCheckStopRequest(std::function<void()> checkStopRequestFunction)
VL_ACQUIRE() VL_MT_SAFE {
while (true) {
checkStopRequestFunction();
if (m_mutex.try_lock()) return;
VL_CPU_RELAX();
}
}
};
/// Lock guard for mutex (ala std::unique_lock), wrapped to allow -fthread_safety checks

View File

@ -200,6 +200,11 @@
// Comment tag that Function is pure (and thus also VL_MT_SAFE)
#define VL_PURE VL_CLANG_ATTR(annotate("PURE"))
// Annotated function can be called only in MT_DISABLED context, i.e. either in a code unit
// compiled with VL_MT_DISABLED_CODE_UNIT preprocessor definition, or in the main thread.
#define VL_MT_DISABLED \
VL_CLANG_ATTR(annotate("MT_DISABLED")) \
VL_EXCLUDES(VlOs::MtScopeMutex::s_haveThreadScope)
// Comment tag that function is threadsafe
#define VL_MT_SAFE VL_CLANG_ATTR(annotate("MT_SAFE"))
// Comment tag that function is threadsafe, only if
@ -216,7 +221,7 @@
// protected to make sure single-caller
#define VL_MT_UNSAFE_ONE VL_CLANG_ATTR(annotate("MT_UNSAFE_ONE"))
// Comment tag that function is entry point of parallelization
#define VL_MT_START VL_CLANG_ATTR(annotate("MT_START"))
#define VL_MT_START VL_CLANG_ATTR(annotate("MT_START")) VL_REQUIRES(VlOs::MtScopeMutex::s_haveThreadScope)
#ifndef VL_NO_LEGACY
# define VL_ULL(c) (c##ULL) // Add appropriate suffix to 64-bit constant (deprecated)
@ -653,6 +658,14 @@ public:
return (m_start == 0.0) ? 0.0 : gettime() - m_start;
}
};
// Used by clang's -fthread-safety, ensures that only one instance of V3ThreadScope
// is created at a time
class VL_CAPABILITY("mutex") MtScopeMutex final {
public:
static MtScopeMutex s_haveThreadScope;
};
} //namespace VlOs
//=========================================================================

View File

@ -752,15 +752,15 @@ class CallAnnotationsValidator:
# Implicitly mark definitions in VL_MT_DISABLED_CODE_UNIT .cpp files as
# VL_MT_DISABLED. Existence of the annotation on declarations in .h
# files is verified below.
# Also sets VL_REQUIRES, as this annotation is added together with
# Also sets VL_EXCLUDES, as this annotation is added together with
# explicit VL_MT_DISABLED.
if self.is_mt_disabled_code_unit():
if node.location.file.name == self._main_source_file:
annotations.mt_disabled = True
annotations.requires = True
annotations.excludes = True
if refd.location.file.name == self._main_source_file:
def_annotations.mt_disabled = True
def_annotations.requires = True
def_annotations.excludes = True
if not (def_annotations.is_empty() or def_annotations == annotations):
# Use definition's annotations for the diagnostic

View File

@ -163,7 +163,6 @@ set(HEADERS
V3Table.h
V3Task.h
V3ThreadPool.h
V3ThreadSafety.h
V3Timing.h
V3Trace.h
V3TraceDecl.h

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -21,7 +21,6 @@
#include "verilatedos.h"
#include "V3Ast.h"
#include "V3ThreadSafety.h"
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -2182,7 +2182,7 @@ public:
virtual void tag(const string& text) {}
virtual string tag() const { return ""; }
virtual string verilogKwd() const { return ""; }
string nameProtect() const; // Name with --protect-id applied
string nameProtect() const VL_MT_STABLE; // Name with --protect-id applied
string origNameProtect() const; // origName with --protect-id applied
string shortName() const; // Name with __PVT__ removed for concatenating scopes
static string dedotName(const string& namein); // Name with dots removed

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
class AstNode;
class AstForeach;

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3CCtors final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3CUse final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
class AstNodeCase;

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3Common final {

View File

@ -21,7 +21,6 @@
#include "verilatedos.h"
#include "V3Ast.h"
#include "V3ThreadSafety.h"
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -38,7 +38,6 @@
#include "V3Global.h"
#include "V3Hash.h"
#include "V3List.h"
#include "V3ThreadSafety.h"
#include "V3Dfg__gen_forward_class_decls.h" // From ./astgen

View File

@ -21,7 +21,6 @@
#include "verilatedos.h"
#include "V3Ast.h"
#include "V3ThreadSafety.h"
//============================================================================

View File

@ -18,10 +18,10 @@
#define VERILATOR_V3DFGPASSES_H_
#include "config_build.h"
#include "verilatedos.h"
#include "V3DfgPatternStats.h"
#include "V3DfgPeephole.h"
#include "V3ThreadSafety.h"
class AstModule;
class DfgGraph;

View File

@ -18,8 +18,7 @@
#define VERILATOR_V3DFGPEEPHOLE_H_
#include "config_build.h"
#include "V3ThreadSafety.h"
#include "verilatedos.h"
#include <V3Stats.h>

View File

@ -26,7 +26,6 @@
#include "V3Ast.h"
#include "V3Error.h"
#include "V3Hasher.h"
#include "V3ThreadSafety.h"
#include <map>
#include <memory>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3EmitC final {

View File

@ -22,7 +22,6 @@
#include "V3Ast.h"
#include "V3File.h"
#include "V3ThreadSafety.h"
#include <cmath>
#include <cstdarg>

View File

@ -23,7 +23,6 @@
#include "V3EmitCConstInit.h"
#include "V3Global.h"
#include "V3MemberMap.h"
#include "V3ThreadSafety.h"
#include <algorithm>
#include <map>

View File

@ -143,7 +143,7 @@ class EmitCGatherDependencies final : VNVisitorConst {
}
public:
static const std::set<std::string> gather(AstCFunc* cfuncp) {
static const std::set<std::string> gather(AstCFunc* cfuncp) VL_MT_STABLE {
const EmitCGatherDependencies visitor{cfuncp};
return std::move(visitor.m_dependencies);
}
@ -562,7 +562,8 @@ class EmitCImp final : EmitCFunc {
~EmitCImp() override = default;
public:
static void main(const AstNodeModule* modp, bool slow, std::deque<AstCFile*>& cfilesr) {
static void main(const AstNodeModule* modp, bool slow,
std::deque<AstCFile*>& cfilesr) VL_MT_STABLE {
EmitCImp{modp, slow, cfilesr};
}
};
@ -977,7 +978,7 @@ void V3EmitC::emitcImp() {
// Make parent module pointers available.
const EmitCParentModule emitCParentModule;
std::list<std::deque<AstCFile*>> cfiles;
std::list<std::future<void>> futures;
V3ThreadScope threadScope;
// Process each module in turn
for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) {
@ -985,29 +986,29 @@ void V3EmitC::emitcImp() {
const AstNodeModule* const modp = VN_AS(nodep, NodeModule);
cfiles.emplace_back();
auto& slowCfilesr = cfiles.back();
futures.push_back(V3ThreadPool::s().enqueue(
[modp, &slowCfilesr]() { EmitCImp::main(modp, /* slow: */ true, slowCfilesr); }));
threadScope.enqueue(
[modp, &slowCfilesr] { EmitCImp::main(modp, /* slow: */ true, slowCfilesr); });
cfiles.emplace_back();
auto& fastCfilesr = cfiles.back();
futures.push_back(V3ThreadPool::s().enqueue(
[modp, &fastCfilesr]() { EmitCImp::main(modp, /* slow: */ false, fastCfilesr); }));
threadScope.enqueue(
[modp, &fastCfilesr] { EmitCImp::main(modp, /* slow: */ false, fastCfilesr); });
}
// Emit trace routines (currently they can only exist in the top module)
if (v3Global.opt.trace() && !v3Global.opt.lintOnly()) {
cfiles.emplace_back();
auto& slowCfilesr = cfiles.back();
futures.push_back(V3ThreadPool::s().enqueue([&slowCfilesr]() {
threadScope.enqueue([&slowCfilesr] {
EmitCTrace::main(v3Global.rootp()->topModulep(), /* slow: */ true, slowCfilesr);
}));
});
cfiles.emplace_back();
auto& fastCfilesr = cfiles.back();
futures.push_back(V3ThreadPool::s().enqueue([&fastCfilesr]() {
threadScope.enqueue([&fastCfilesr] {
EmitCTrace::main(v3Global.rootp()->topModulep(), /* slow: */ false, fastCfilesr);
}));
});
}
// Wait for futures
V3ThreadPool::waitForFutures(futures);
threadScope.wait();
for (const auto& collr : cfiles) {
for (const auto cfilep : collr) v3Global.rootp()->addFilesp(cfilep);
}

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3EmitCMain final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3EmitCMake final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class V3HierBlockPlan;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNode;
class AstSenTree;

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3EmitXml final {

View File

@ -23,6 +23,7 @@
# include "V3Stats.h"
VL_DEFINE_DEBUG_FUNCTIONS;
#endif
#include <thread>
// clang-format on
//======================================================================
@ -88,7 +89,18 @@ void V3ErrorGuarded::vlAbortOrExit() VL_REQUIRES(m_mutex) {
if (V3Error::debugDefault()) {
std::cerr << msgPrefix() << "Aborting since under --debug" << endl;
V3Error::vlAbort();
} else {
}
#ifndef V3ERROR_NO_GLOBAL_
else if (v3Global.opt.verilateJobs() > 1
&& v3Global.mainThreadId() != std::this_thread::get_id()) {
VL_GCOV_DUMP(); // No static destructors are called, thus must be called manually.
// Exit without triggering any global destructors.
// Used to prevent detached V3ThreadPool jobs accessing destroyed static objects.
::_exit(1);
}
#endif
else {
std::exit(1);
}
}
@ -209,7 +221,6 @@ void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra)
#ifndef V3ERROR_NO_GLOBAL_
if (dumpTreeLevel() || dumpTreeJsonLevel() || debug()) {
V3Broken::allowMidvisitorCheck(true);
const V3ThreadPool::ScopedExclusiveAccess exclusiveAccess;
if (dumpTreeLevel()) {
v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("final.tree", 990));
}
@ -222,8 +233,6 @@ void V3ErrorGuarded::v3errorEnd(std::ostringstream& sstr, const string& extra)
V3Stats::statsFinalAll(v3Global.rootp());
V3Stats::statsReport();
}
// Abort in exclusive access to make sure other threads
// don't change error code
vlAbortOrExit();
}
#endif
@ -276,27 +285,14 @@ void V3Error::vlAbort() {
VL_GCOV_DUMP();
std::abort();
}
void V3Error::v3errorAcquireLock(bool mtDisabledCodeUnit) VL_ACQUIRE(s().m_mutex) {
#if !defined(V3ERROR_NO_GLOBAL_)
if (!mtDisabledCodeUnit) {
V3Error::s().m_mutex.lockCheckStopRequest(
[]() -> void { V3ThreadPool::s().waitIfStopRequested(); });
} else {
V3Error::s().m_mutex.lock();
}
#else
std::ostringstream& V3Error::v3errorPrep(V3ErrorCode code) VL_ACQUIRE(s().m_mutex) {
V3Error::s().m_mutex.lock();
#endif
}
std::ostringstream& V3Error::v3errorPrep(V3ErrorCode code, bool mtDisabledCodeUnit)
VL_ACQUIRE(s().m_mutex) {
v3errorAcquireLock(mtDisabledCodeUnit);
s().v3errorPrep(code);
return v3errorStr();
}
std::ostringstream& V3Error::v3errorPrepFileLine(V3ErrorCode code, const char* file, int line,
bool mtDisabledCodeUnit) VL_ACQUIRE(s().m_mutex) {
v3errorPrep(code, mtDisabledCodeUnit) << file << ":" << std::dec << line << ": ";
std::ostringstream& V3Error::v3errorPrepFileLine(V3ErrorCode code, const char* file, int line)
VL_ACQUIRE(s().m_mutex) {
v3errorPrep(code) << file << ":" << std::dec << line << ": ";
return v3errorStr();
}
std::ostringstream& V3Error::v3errorStr() VL_REQUIRES(s().m_mutex) { return s().v3errorStr(); }

View File

@ -24,9 +24,6 @@
// Limited V3 headers here - this is a base class for Vlc etc
#include "V3String.h"
#ifndef VL_MT_DISABLED_CODE_UNIT
#include "V3ThreadPool.h"
#endif
#include <array>
#include <bitset>
@ -531,11 +528,8 @@ public:
// Internals for v3error()/v3fatal() macros only
// Error end takes the string stream to output, be careful to seek() as needed
static void v3errorAcquireLock(bool checkStopRequest) VL_ACQUIRE(s().m_mutex);
static std::ostringstream& v3errorPrep(V3ErrorCode code, bool mtDisabledCodeUnit)
VL_ACQUIRE(s().m_mutex);
static std::ostringstream& v3errorPrepFileLine(V3ErrorCode code, const char* file, int line,
bool mtDisabledCodeUnit)
static std::ostringstream& v3errorPrep(V3ErrorCode code) VL_ACQUIRE(s().m_mutex);
static std::ostringstream& v3errorPrepFileLine(V3ErrorCode code, const char* file, int line)
VL_ACQUIRE(s().m_mutex);
static std::ostringstream& v3errorStr() VL_REQUIRES(s().m_mutex);
// static, but often overridden in classes.
@ -563,12 +557,9 @@ void v3errorEndFatal(std::ostringstream& sstr)
// the comma operator (,) to guarantee the execution order here.
#define v3errorBuildMessage(prep, msg) \
(prep, static_cast<std::ostringstream&>(V3Error::v3errorStr() << msg))
#define v3warnCode(code, msg) \
v3errorEnd( \
v3errorBuildMessage(V3Error::v3errorPrep(code, VL_MT_DISABLED_CODE_UNIT_DEFINED), msg))
#define v3warnCode(code, msg) v3errorEnd(v3errorBuildMessage(V3Error::v3errorPrep(code), msg))
#define v3warnCodeFatal(code, msg) \
v3errorEndFatal( \
v3errorBuildMessage(V3Error::v3errorPrep(code, VL_MT_DISABLED_CODE_UNIT_DEFINED), msg))
v3errorEndFatal(v3errorBuildMessage(V3Error::v3errorPrep(code), msg))
#define v3warn(code, msg) v3warnCode(V3ErrorCode::code, msg)
#define v3info(msg) v3warnCode(V3ErrorCode::EC_INFO, msg)
#define v3error(msg) v3warnCode(V3ErrorCode::EC_ERROR, msg)
@ -578,13 +569,10 @@ void v3errorEndFatal(std::ostringstream& sstr)
// Use this instead of fatal() to mention the source code line.
#define v3fatalSrc(msg) \
v3errorEndFatal(v3errorBuildMessage( \
V3Error::v3errorPrepFileLine(V3ErrorCode::EC_FATALSRC, __FILE__, __LINE__, \
VL_MT_DISABLED_CODE_UNIT_DEFINED), \
msg))
V3Error::v3errorPrepFileLine(V3ErrorCode::EC_FATALSRC, __FILE__, __LINE__), msg))
// Use this when normal v3fatal is called in static method that overrides fileline.
#define v3fatalStatic(msg) \
::v3errorEndFatal(v3errorBuildMessage( \
V3Error::v3errorPrep(V3ErrorCode::EC_FATAL, VL_MT_DISABLED_CODE_UNIT_DEFINED), msg))
::v3errorEndFatal(v3errorBuildMessage(V3Error::v3errorPrep(V3ErrorCode::EC_FATAL), msg))
#define UINFO(level, stmsg) \
do { \

View File

@ -21,7 +21,6 @@
#include "verilatedos.h"
#include "V3Graph.h"
#include "V3ThreadSafety.h"
class AstNetlist;
class AstMTaskBody;

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -21,8 +21,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -21,8 +21,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -26,6 +26,7 @@
#include "V3Parse.h"
#include "V3ParseSym.h"
#include "V3Stats.h"
#include "V3ThreadPool.h"
VL_DEFINE_DEBUG_FUNCTIONS;
@ -39,6 +40,7 @@ void V3Global::boot() {
void V3Global::shutdown() {
VL_DO_CLEAR(delete m_hierPlanp, m_hierPlanp = nullptr); // delete nullptr is safe
VL_DO_CLEAR(delete m_threadPoolp, m_threadPoolp = nullptr); // delete nullptr is safe
#ifdef VL_LEAK_CHECKS
if (m_rootp) VL_DO_CLEAR(m_rootp->deleteTree(), m_rootp = nullptr);
#endif

View File

@ -30,14 +30,15 @@
#include "V3FileLine.h"
#include "V3Mutex.h"
#include "V3Options.h"
#include "V3ThreadSafety.h"
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
class AstNetlist;
class V3HierBlockPlan;
class V3ThreadPool;
//======================================================================
// Restorer
@ -101,6 +102,8 @@ class V3Global final {
// created by makeInitNetlist(} so static constructors run first
V3HierBlockPlan* m_hierPlanp = nullptr; // Hierarchical Verilation plan,
// nullptr unless hier_block, set via hierPlanp(V3HierBlockPlan*}
V3ThreadPool* m_threadPoolp = nullptr; // Thread Pool,
// nullptr unless 'verilatedJobs' is known, set via threadPoolp(V3ThreadPool*)
VWidthMinUsage m_widthMinUsage
= VWidthMinUsage::LINT_WIDTH; // What AstNode::widthMin() is used for
@ -131,6 +134,9 @@ class V3Global final {
// Names of fields that were dumped by dumpJsonPtr()
std::unordered_set<std::string> m_jsonPtrNames;
// Id of the main thread
const std::thread::id m_mainThreadId = std::this_thread::get_id();
public:
// Options
V3Options opt; // All options; let user see them directly
@ -142,6 +148,11 @@ public:
// ACCESSORS (general)
AstNetlist* rootp() const VL_MT_SAFE { return m_rootp; }
V3ThreadPool* threadPoolp() const VL_PURE { return m_threadPoolp; }
void threadPoolp(V3ThreadPool* threadPoolp) {
UASSERT(!m_threadPoolp, "attempted to create multiple threadPool singletons");
m_threadPoolp = threadPoolp;
}
VWidthMinUsage widthMinUsage() const VL_PURE { return m_widthMinUsage; }
bool assertDTypesResolved() const { return m_assertDTypesResolved; }
bool assertScoped() const { return m_assertScoped; }
@ -196,6 +207,7 @@ public:
void ptrNamesDumpJson(std::ostream& os);
void idPtrMapDumpJson(std::ostream& os);
const std::string& ptrToId(const void* p);
std::thread::id mainThreadId() const { return m_mainThreadId; }
};
extern V3Global v3Global;

View File

@ -23,7 +23,6 @@
#include "V3Error.h"
#include "V3List.h"
#include "V3Rtti.h"
#include "V3ThreadSafety.h"
#include <algorithm>
#include <functional>

View File

@ -20,7 +20,6 @@
#include "V3Error.h"
#include "V3Graph.h"
#include "V3GraphAlg.h"
#include "V3ThreadSafety.h"
//######################################################################

View File

@ -20,7 +20,6 @@
#include "verilatedos.h"
#include "V3Options.h"
#include "V3ThreadSafety.h"
#include <map>
#include <set>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstAssignW;
class AstCell;
class AstNetlist;

View File

@ -21,8 +21,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNode;
class V3InstrCount final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
class VInFilter;
class V3ParseSym;

View File

@ -22,7 +22,6 @@
#include "V3Ast.h"
#include "V3Error.h"
#include "V3ThreadSafety.h"
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
class AstNode;

View File

@ -22,7 +22,6 @@
#include "V3Ast.h"
#include "V3Error.h"
#include "V3ThreadSafety.h"
#include <vector>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -111,21 +111,6 @@ public:
void assumeLocked() VL_ASSERT_CAPABILITY(this) VL_MT_SAFE {}
/// Pretend that the mutex is being unlocked. Purely for Clang thread safety analyzer.
void pretendUnlock() VL_RELEASE() VL_MT_SAFE {}
/// Acquire/lock mutex and check for stop request
/// It tries to lock the mutex and if it fails, it check if stop request was send.
/// It returns after locking mutex.
/// This function should be extracted to V3ThreadPool, but due to clang thread-safety
/// limitations it needs to be placed here.
void lockCheckStopRequest(std::function<void()> checkStopRequestFunction)
VL_ACQUIRE() VL_MT_SAFE {
if (V3MutexConfig::s().enable()) {
while (true) {
checkStopRequestFunction();
if (m_mutex.try_lock()) return;
VL_CPU_RELAX();
}
}
}
};
/// Lock guard for mutex (ala std::unique_lock), wrapped to allow -fthread_safety checks

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
#include <functional>
#include <memory>
#include <string>

View File

@ -22,7 +22,6 @@
#include "V3Error.h"
#include "V3LangCode.h"
#include "V3ThreadSafety.h"
#include <map>
#include <set>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
#include <functional>
#include <unordered_map>
#include <vector>

View File

@ -22,7 +22,6 @@
#include "V3Order.h"
#include "V3OrderGraph.h"
#include "V3ThreadSafety.h"
#include <string>
#include <unordered_map>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -22,7 +22,6 @@
#include "V3Error.h"
#include "V3Global.h"
#include "V3ThreadSafety.h"
class AstNetlist;
class VInFilter;

View File

@ -25,7 +25,6 @@
#include "V3Global.h"
#include "V3Parse.h"
#include "V3ParseSym.h"
#include "V3ThreadSafety.h"
#include <algorithm>
#include <deque>

View File

@ -35,7 +35,6 @@
#include "V3Options.h"
#include "V3StdFuture.h"
#include "V3String.h"
#include "V3ThreadSafety.h"
#include <algorithm>

View File

@ -37,7 +37,6 @@
#include "V3Options.h"
#include "V3StdFuture.h"
#include "V3String.h"
#include "V3ThreadSafety.h"
#include <algorithm>
#include <map>

View File

@ -23,7 +23,6 @@
#include "V3Error.h"
#include "V3FileLine.h"
#include "V3Global.h"
#include "V3ThreadSafety.h"
#include <iostream>
#include <list>

View File

@ -22,7 +22,6 @@
#include "V3Error.h"
#include "V3FileLine.h"
#include "V3ThreadSafety.h"
class V3ParseImp;
class VInFilter;

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class V3ProtectLib final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstClass;
class AstFunc;
class AstNetlist;

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -21,7 +21,6 @@
#include "verilatedos.h"
#include "V3Ast.h"
#include "V3ThreadSafety.h"
#include <functional>
#include <unordered_map>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -22,7 +22,6 @@
#include "V3Error.h"
#include "V3PairingHeap.h"
#include "V3ThreadSafety.h"
//===============================================================================================
// V3Scoreboard is essentially a heap that can be hinted that some elements have changed keys, at

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -17,9 +17,9 @@
#ifndef VERILATOR_V3SPLITVAR_H_
#define VERILATOR_V3SPLITVAR_H_
//============================================================================
#include "verilatedos.h"
#include "V3ThreadSafety.h"
//============================================================================
class AstNetlist;
class AstVar;

View File

@ -21,8 +21,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNode;
class V3StackCount final {

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -22,7 +22,6 @@
#include "verilatedos.h"
#include "V3Error.h"
#include "V3ThreadSafety.h"
#include <vector>

View File

@ -20,8 +20,6 @@
#include "config_build.h"
#include "verilatedos.h"
#include "V3ThreadSafety.h"
class AstNetlist;
//============================================================================

View File

@ -22,7 +22,6 @@
#include "V3Ast.h"
#include "V3Error.h"
#include "V3ThreadSafety.h"
#include <utility>
#include <vector>

Some files were not shown because too many files have changed in this diff Show More