|
ndmspc
v1.2.0-0.1.rc3
|
Executes a function over all points in an N-dimensional space, optionally in parallel. More...
#include <NDimensionalExecutor.h>
Classes | |
| struct | IpcSession |
Public Member Functions | |
| NDimensionalExecutor (const std::vector< int > &minBounds, const std::vector< int > &maxBounds) | |
| Constructor from min/max bounds for each dimension. More... | |
| NDimensionalExecutor (THnSparse *hist, bool onlyfilled=false) | |
| Constructor from THnSparse histogram. More... | |
| void | SetBounds (const std::vector< int > &minBounds, const std::vector< int > &maxBounds) |
| void | Execute (const std::function< void(const std::vector< int > &coords)> &func) |
| Execute a function over all coordinates in the N-dimensional space. More... | |
| template<typename TObject > | |
| void | ExecuteParallel (const std::function< void(const std::vector< int > &coords, TObject &thread_object)> &func, std::vector< TObject > &thread_objects) |
| Execute a function in parallel over all coordinates, using thread-local objects. More... | |
| size_t | ExecuteParallelProcessIpc (std::vector< NThreadData * > &workerObjects, size_t processCount) |
| Execute fixed-contract processing in multiple child processes over IPC. More... | |
| void | StartProcessIpc (std::vector< NThreadData * > &workerObjects, size_t processCount, const std::string &tcpBindEndpoint="", const std::string &jobDir="", const std::string &treeName="ngnt", const std::string ¯oList="", const std::string &tmpDir="", const std::string &tmpResultsDir="") |
| size_t | ExecuteCurrentBoundsProcessIpc (const std::string &definitionName="", const std::vector< Long64_t > *definitionIds=nullptr, const std::function< void(size_t, size_t)> &progressCallback=nullptr) |
| void | FinishProcessIpc (bool abort=false) |
| std::set< size_t > | GetRegisteredWorkerIndices () const |
| size_t | Dimensions () const |
| Returns the number of dimensions. More... | |
| const std::vector< int > & | GetMinBounds () const |
| Returns the minimum bounds for each dimension. More... | |
| const std::vector< int > & | GetMaxBounds () const |
| Returns the maximum bounds for each dimension. More... | |
Private Member Functions | |
| bool | Increment () |
| Increment the current coordinates to the next point in the N-dimensional space. More... | |
| bool | InitTcpWorker (const std::string &identity) |
| Sends INIT to a newly-connected TCP worker, waits for ACK, and registers it in identityToWorker / workerIdentityVec. | |
| bool | HandleBootstrap (const std::string &identity) |
| Handles a BOOTSTRAP message from a worker: assigns the next sequential index and replies with a CONFIG frame containing the macro list and env vars. | |
Private Attributes | |
| size_t | fNumDimensions |
| Number of dimensions. | |
| std::vector< int > | fMinBounds |
| Minimum bounds for each dimension. | |
| std::vector< int > | fMaxBounds |
| Maximum bounds for each dimension. | |
| std::vector< int > | fCurrentCoords |
| Current coordinates during iteration. | |
| std::unique_ptr< IpcSession > | fIpcSession |
| std::set< size_t > | fRegisteredWorkerIndices |
| Worker indices that completed registration (TCP mode) | |
Executes a function over all points in an N-dimensional space, optionally in parallel.
Definition at line 32 of file NDimensionalExecutor.h.
| Ndmspc::NDimensionalExecutor::NDimensionalExecutor | ( | const std::vector< int > & | minBounds, |
| const std::vector< int > & | maxBounds | ||
| ) |
Constructor from min/max bounds for each dimension.
| minBounds | Minimum bounds for each dimension. |
| maxBounds | Maximum bounds for each dimension. |
Constructor
Definition at line 116 of file NDimensionalExecutor.cxx.
References fCurrentCoords, fMaxBounds, fMinBounds, and fNumDimensions.
| Ndmspc::NDimensionalExecutor::NDimensionalExecutor | ( | THnSparse * | hist, |
| bool | onlyfilled = false |
||
| ) |
Constructor from THnSparse histogram.
| hist | Pointer to THnSparse histogram. |
| onlyfilled | If true, iterate only filled bins. |
Constructor with THnSparse input
Definition at line 169 of file NDimensionalExecutor.cxx.
References fCurrentCoords, fMaxBounds, fMinBounds, and fNumDimensions.
|
inline |
Returns the number of dimensions.
Definition at line 90 of file NDimensionalExecutor.h.
References fNumDimensions.
| void Ndmspc::NDimensionalExecutor::Execute | ( | const std::function< void(const std::vector< int > &coords)> & | func | ) |
Execute a function over all coordinates in the N-dimensional space.
| func | Function to execute, taking coordinates as argument. |
Sequential Execution
Definition at line 201 of file NDimensionalExecutor.cxx.
References fCurrentCoords, fMinBounds, fNumDimensions, and Increment().
Referenced by Ndmspc::NBinningDef::RefreshContentFromIds(), Ndmspc::NBinningDef::RefreshIdsFromContent(), and Ndmspc::NGnNavigator::Reshape().
| template void Ndmspc::NDimensionalExecutor::ExecuteParallel< NGnThreadData > | ( | const std::function< void(const std::vector< int > &coords, TObject &thread_object)> & | func, |
| std::vector< TObject > & | thread_objects | ||
| ) |
Execute a function in parallel over all coordinates, using thread-local objects.
Execute a function in parallel over all coordinates, using thread-local objects. Handles task distribution, synchronization, and exception propagation.
| TObject | Type of thread-local object. |
| func | Function to execute, taking coordinates and thread-local object. |
| thread_objects | Vector of thread-local objects, one per thread. |
| std::exception | If any worker thread throws, the first exception is rethrown after joining. |
Definition at line 224 of file NDimensionalExecutor.cxx.
References fCurrentCoords, fMinBounds, fNumDimensions, Ndmspc::NThreadData::GetAssignedIndex(), Increment(), and Ndmspc::NLogger::SetThreadName().
Referenced by Ndmspc::NGnTree::Process().
| size_t Ndmspc::NDimensionalExecutor::ExecuteParallelProcessIpc | ( | std::vector< NThreadData * > & | workerObjects, |
| size_t | processCount | ||
| ) |
Execute fixed-contract processing in multiple child processes over IPC.
| workerObjects | Worker objects (NThreadData-derived) used by child processes. |
| processCount | Number of worker processes to use. |
Definition at line 394 of file NDimensionalExecutor.cxx.
|
inline |
Returns the maximum bounds for each dimension.
Definition at line 102 of file NDimensionalExecutor.h.
References fMaxBounds.
|
inline |
Returns the minimum bounds for each dimension.
Definition at line 96 of file NDimensionalExecutor.h.
References fMinBounds.
|
private |
Increment the current coordinates to the next point in the N-dimensional space.
Definition at line 104 of file NDimensionalExecutor.cxx.
References fCurrentCoords, fMaxBounds, fMinBounds, and fNumDimensions.
Referenced by Execute(), and ExecuteParallel().