CCI: optional thread-safe broker and parameter access#345
Open
markfoodyburton wants to merge 2 commits into
Open
CCI: optional thread-safe broker and parameter access#345markfoodyburton wants to merge 2 commits into
markfoodyburton wants to merge 2 commits into
Conversation
Thread safety (compile-time option -DCCI_ENABLE_THREAD_SAFETY=ON): Add shared_mutex to consuming_broker for concurrent read access. Add recursive_mutex to cci_param_untyped handle list. Add mutex to cci_value impl_pool. Make oncall/fast_read/fast_write atomic. All changes gated by CCI_THREAD_SAFE define (PUBLIC, propagated to linking code). Zero overhead when disabled. Originator thread awareness: current_originator_object() now returns NULL on non-SystemC threads. The SystemC thread ID is captured on first originator construction (during elaboration). On other threads, sc_get_current_object() is not called — the originator behaves as if outside the SystemC hierarchy. Named originators work from any thread; unnamed default originators still require SystemC context. cmake: try CONFIG mode before Find module for SystemC discovery. Test: ex20_Thread_Safety — concurrent broker access from multiple threads with custom originators and performance benchmarks. Only built when CCI_ENABLE_THREAD_SAFETY=ON. All 24 existing tests pass. Signed-off-by: Mark Burton <mburton@qti.qualcomm.com>
When the default cci_originator() constructor is called outside the SystemC hierarchy (including from a non-SystemC thread), silently create an originator with the default name (CCI_UNKNOWN_ORIGINATOR_STRING_) instead of reporting a fatal error. This enables cci_get_broker() and other CCI APIs that construct default originators to work from any context without requiring an explicit named originator. Signed-off-by: Mark Burton <mburton@qti.qualcomm.com>
markfoodyburton
force-pushed
the
mburton/thread_safety
branch
from
April 22, 2026 17:56
1f7747e to
495cb21
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add compile-time option CCI_ENABLE_THREAD_SAFETY (OFF by default) that enables thread-safe access to the CCI broker, parameters, and value pool. When enabled, defines CCI_THREAD_SAFE as a PUBLIC compile definition so all linking code sees it consistently.
Thread-safety changes (all gated by #ifdef CCI_THREAD_SAFE):
Broker (consuming_broker):
Parameter handles (cci_param_untyped):
Parameter callbacks (cci_param_typed):
Value pool (cci_value.cpp):
Build system:
Test:
Performance (100K ops, -O3, 4 threads vs single-threaded):