A thread-safe vector to keep track of the status across threads, for example during gather operations. More...
#include <per_thread_bool_indicator.h>
Public Member Functions | |
| PerThreadBoolIndicator () | |
| BoolIndicatorUInt64 & | operator[] (const size_t tid) |
| void | set_true (const size_t tid) |
| void | set_false (const size_t tid) |
| void | logical_and (const size_t tid, const bool status) |
| void | initialize (const size_t num_threads, const bool status) |
| Resize to the given number of threads and set all elements to false. | |
| bool | all_false () const |
| Waits for all threads and returns whether all elements are false. | |
| bool | all_true () const |
| Waits for all threads and returns whether all elements are true. | |
| bool | any_false () const |
| Waits for all threads and returns whether any elements are false. | |
| bool | any_true () const |
| Waits for all threads and returns whether any elements are true. | |
Private Attributes | |
| std::vector< BoolIndicatorUInt64 > | per_thread_status_ |
| int | size_ { 0 } |
| std::atomic< int > | are_true_ { 0 } |
| Number of per-thread indicators currently true. | |
A thread-safe vector to keep track of the status across threads, for example during gather operations.
Uses a vector of integers instead of a vector of bools to guarantee thread safety. See issue #1394.
|
inline |
| bool nest::PerThreadBoolIndicator::all_false | ( | ) | const |
Waits for all threads and returns whether all elements are false.
References are_true_, nest::KernelManager::get_omp_synchronization_construction_stopwatch(), nest::kernel(), nest::Stopwatch< detailed_timer, threaded_timer >::start(), and nest::Stopwatch< detailed_timer, threaded_timer >::stop().
Referenced by nest::EventDeliveryManager::gather_target_data(), and nest::EventDeliveryManager::gather_target_data_compressed().
| bool nest::PerThreadBoolIndicator::all_true | ( | ) | const |
Waits for all threads and returns whether all elements are true.
References are_true_, nest::KernelManager::get_omp_synchronization_construction_stopwatch(), nest::kernel(), size_, nest::Stopwatch< detailed_timer, threaded_timer >::start(), and nest::Stopwatch< detailed_timer, threaded_timer >::stop().
Referenced by nest::EventDeliveryManager::gather_target_data(), nest::EventDeliveryManager::gather_target_data_compressed(), and nest::SourceTable::is_cleared().
| bool nest::PerThreadBoolIndicator::any_false | ( | ) | const |
Waits for all threads and returns whether any elements are false.
References are_true_, nest::KernelManager::get_omp_synchronization_construction_stopwatch(), nest::kernel(), size_, nest::Stopwatch< detailed_timer, threaded_timer >::start(), and nest::Stopwatch< detailed_timer, threaded_timer >::stop().
Referenced by nest::EventDeliveryManager::gather_target_data(), and nest::EventDeliveryManager::gather_target_data_compressed().
| bool nest::PerThreadBoolIndicator::any_true | ( | ) | const |
Waits for all threads and returns whether any elements are true.
References are_true_, nest::KernelManager::get_omp_synchronization_construction_stopwatch(), nest::kernel(), nest::Stopwatch< detailed_timer, threaded_timer >::start(), and nest::Stopwatch< detailed_timer, threaded_timer >::stop().
| void nest::PerThreadBoolIndicator::initialize | ( | const size_t | num_threads, |
| const bool | status | ||
| ) |
Resize to the given number of threads and set all elements to false.
References are_true_, nest::VPManager::assert_single_threaded(), nest::kernel(), per_thread_status_, size_, and nest::KernelManager::vp_manager.
Referenced by nest::SourceTable::initialize(), nest::ConnectionManager::initialize(), and nest::EventDeliveryManager::initialize().
|
inline |
References are_true_, and per_thread_status_.
Referenced by nest::EventDeliveryManager::gather_target_data(), and nest::EventDeliveryManager::gather_target_data_compressed().
| BoolIndicatorUInt64 & nest::PerThreadBoolIndicator::operator[] | ( | const size_t | tid | ) |
References per_thread_status_.
|
inline |
References are_true_, and per_thread_status_.
Referenced by nest::EventDeliveryManager::gather_target_data(), nest::EventDeliveryManager::gather_target_data_compressed(), and nest::SourceTable::restore_entry_point().
|
inline |
References are_true_, and per_thread_status_.
Referenced by nest::SourceTable::clear(), nest::ConnectionManager::connect_(), nest::EventDeliveryManager::gather_target_data(), nest::EventDeliveryManager::gather_target_data_compressed(), and nest::SourceTable::save_entry_point().
|
private |
Number of per-thread indicators currently true.
are_true_ == 0 -> all are false are_true_ == size_ -> all are true 0 < are_true_ < size_ -> some true, some false
Referenced by all_false(), all_true(), any_false(), any_true(), initialize(), logical_and(), set_false(), and set_true().
|
private |
Referenced by initialize(), logical_and(), operator[](), set_false(), and set_true().
|
private |
Referenced by all_true(), any_false(), and initialize().