|
ndmspc v1.2.0-0.1.rc7
|
Thread-local data object for NDMSPC processing. More...
#include <NGnThreadData.h>
Public Member Functions | |
| NGnThreadData () | |
| Constructor. | |
| virtual | ~NGnThreadData () |
| Destructor. | |
| bool | Init (size_t id, NGnProcessFuncPtr func, NGnBeginFuncPtr beginFunc, NGnEndFuncPtr endFunc, NGnTree *ngnt, NBinning *binningIn, NGnTree *input=nullptr, const std::string &filename="", const std::string &treename="ngnt") |
| Initialize thread data for processing. | |
| void | SetProcessFunc (NGnProcessFuncPtr func) |
| Set the processing function pointer. | |
| bool | InitStorage (NStorageTree *ts, const std::string &filename="", const std::string &treename="ngnt") |
| Initialize storage tree for thread data. | |
| NGnTree * | GetHnSparseBase () const |
| Get pointer to base NGnTree object. | |
| Long64_t | GetNProcessed () const |
| Get number of processed entries. | |
| void | SetNProcessed (Long64_t n) |
| Set number of processed entries. | |
| void | SetCfg (const json &cfg) |
| Set configuration JSON object. | |
| json | GetCfg () const |
| Get configuration JSON object. | |
| void | SetResultsFilename (const std::string &filename) |
| Set the results filename for TCP mode (shared filesystem path). | |
| const std::string & | GetResultsFilename () const |
| Get the results filename for TCP mode. | |
| bool | IsPureCopy () const |
| Checks if the object is a pure copy. | |
| void | SetIsPureCopy (bool val) |
| Sets the pure copy status of the object. | |
| virtual void | Process (const std::vector< int > &coords) |
| Process coordinates (virtual). | |
| void | SetCurrentDefinitionName (const std::string &name) |
| void | SyncCurrentDefinitionIds (const std::vector< Long64_t > &ids) |
| void | ExecuteBeginFunction () |
| void | ExecuteEndFunction () |
| void | FlushDeferredDeletes () |
| Delete deferred ROOT objects, skipping TCanvas/TPad (leaked safely). | |
| virtual Long64_t | Merge (TCollection *list) |
| Merge thread data from a collection (virtual). | |
| void | SetItemCount (long long itemCount) |
| Setters for data members. | |
| void | SetCoordSum (long long coordSum) |
| Set the sum of coordinates processed by the thread. | |
| void | SetThreadId (std::thread::id threadId) |
| Set the thread's unique identifier. | |
| void | SetIdSet (bool idSet) |
| Set whether the thread ID has been assigned. | |
| void | SetAssignedIndex (size_t assignedIndex) |
| Set the assigned index for the thread. | |
| void | SetResourceMonitor (NResourceMonitor *monitor) |
| Sets the resource monitor for this thread data. | |
| long long | GetItemCount () const |
| Getters for data members. | |
| long long | GetCoordSum () const |
| Get the sum of coordinates processed by the thread. | |
| std::thread::id | GetThreadId () const |
| Get the thread's unique identifier. | |
| bool | GetIdSet () const |
| Check if the thread ID has been assigned. | |
| size_t | GetAssignedIndex () const |
| Get the assigned index for the thread. | |
| NResourceMonitor * | GetResourceMonitor () const |
| Gets the resource monitor associated with this thread data. | |
| virtual void | Print (Option_t *option="") const |
| Print method override. | |
Static Public Attributes | |
| static std::mutex | fSharedMutex |
| Shared mutex for thread-safe operations. | |
Protected Attributes | |
| NResourceMonitor * | fResourceMonitor {nullptr} |
| Pointer to resource monitor. | |
Private Attributes | |
| NGnProcessFuncPtr | fProcessFunc {nullptr} |
| Function pointer to the processing function. | |
| NGnBeginFuncPtr | fBeginFunc {nullptr} |
| Function pointer to the begin function. | |
| NGnEndFuncPtr | fEndFunc {nullptr} |
| Function pointer to the end function. | |
| NGnTree * | fHnSparseBase {nullptr} |
| Pointer to the base class. | |
| Long64_t | fNProcessed {0} |
| Number of processed entries. | |
| NBinning * | fBiningSource {nullptr} |
| Pointer to the source binning (from the original NGnTree) | |
| json | fCfg {} |
| Configuration object. | |
| bool | fIsPureCopy {false} |
| Flag indicating pure copy mode. | |
| std::string | fResultsFilename {} |
| Shared-FS path to copy result to after Close(true) (TCP mode) | |
| std::unordered_set< Long64_t > | fProcessedBinIds {} |
| Set of already-processed global bin IDs (duplicate guard) | |
| std::vector< TObject * > | fDeferredDeletes |
| Objects deferred for single-threaded deletion. | |
| long long | fItemCount = 0 |
| Number of items processed. | |
| long long | fCoordSum = 0 |
| Sum of coordinates. | |
| std::thread::id | fThreadId |
| Thread ID. | |
| bool | fIdSet = false |
| Flag to indicate if the thread ID is set. | |
| size_t | fAssignedIndex = 0 |
| Index assigned to this object. | |
Thread-local data object for NDMSPC processing.
Manages per-thread processing function, input/output trees, binning, configuration, and processed entry count. Supports initialization, storage setup, processing, and merging.
Definition at line 20 of file NGnThreadData.h.
| Ndmspc::NGnThreadData::NGnThreadData | ( | ) |
Constructor.
Definition at line 17 of file NGnThreadData.cxx.
References Ndmspc::NThreadData::NThreadData().
Referenced by Merge().
|
virtual |
Destructor.
Definition at line 18 of file NGnThreadData.cxx.
| void Ndmspc::NGnThreadData::ExecuteBeginFunction | ( | ) |
Definition at line 507 of file NGnThreadData.cxx.
| void Ndmspc::NGnThreadData::ExecuteEndFunction | ( | ) |
Definition at line 514 of file NGnThreadData.cxx.
| void Ndmspc::NGnThreadData::FlushDeferredDeletes | ( | ) |
Delete deferred ROOT objects, skipping TCanvas/TPad (leaked safely).
Definition at line 521 of file NGnThreadData.cxx.
References fDeferredDeletes, Ndmspc::NThreadData::GetAssignedIndex(), and Ndmspc::NUtils::SafeDeleteObjects().
|
inlineinherited |
Get the assigned index for the thread.
Definition at line 96 of file NThreadData.h.
References fAssignedIndex.
Referenced by Ndmspc::NDimensionalExecutor::ExecuteParallel(), Ndmspc::NGnThreadData::FlushDeferredDeletes(), Ndmspc::NGnThreadData::Merge(), and Ndmspc::NGnThreadData::Process().
|
inline |
Get configuration JSON object.
Definition at line 90 of file NGnThreadData.h.
References fCfg.
|
inlineinherited |
Get the sum of coordinates processed by the thread.
Definition at line 78 of file NThreadData.h.
References fCoordSum.
|
inline |
Get pointer to base NGnTree object.
Definition at line 66 of file NGnThreadData.h.
References fHnSparseBase.
Referenced by Merge(), and Ndmspc::NGnTree::Process().
|
inlineinherited |
Check if the thread ID has been assigned.
Definition at line 90 of file NThreadData.h.
References fIdSet.
|
inlineinherited |
Getters for data members.
Get the number of items processed by the thread.
Definition at line 72 of file NThreadData.h.
References fItemCount.
|
inline |
Get number of processed entries.
Definition at line 72 of file NGnThreadData.h.
References fNProcessed.
Referenced by Merge().
|
inlineinherited |
Gets the resource monitor associated with this thread data.
Returns a pointer to the NResourceMonitor instance currently associated with this thread data. The caller does not take ownership of the returned pointer.
Definition at line 108 of file NThreadData.h.
References fResourceMonitor.
|
inline |
Get the results filename for TCP mode.
Definition at line 105 of file NGnThreadData.h.
References fResultsFilename.
Referenced by Merge().
|
inlineinherited |
Get the thread's unique identifier.
Definition at line 84 of file NThreadData.h.
References fThreadId.
| bool Ndmspc::NGnThreadData::Init | ( | size_t | id, |
| NGnProcessFuncPtr | func, | ||
| NGnBeginFuncPtr | beginFunc, | ||
| NGnEndFuncPtr | endFunc, | ||
| NGnTree * | ngnt, | ||
| NBinning * | binningIn, | ||
| NGnTree * | input = nullptr, | ||
| const std::string & | filename = "", | ||
| const std::string & | treename = "ngnt" ) |
Initialize thread data for processing.
| id | Thread ID. |
| func | Processing function pointer. |
| ngnt | Pointer to NGnTree object. |
| binningIn | Pointer to NBinning object. |
| input | Optional input NGnTree pointer. |
| filename | Optional file name. |
| treename | Optional tree name (default: "ngnt"). |
Initialize thread data
Definition at line 19 of file NGnThreadData.cxx.
References Ndmspc::NStorageTree::AddBranch(), Ndmspc::NStorageTree::Clear(), fBeginFunc, fBiningSource, fEndFunc, fHnSparseBase, fIsPureCopy, fProcessFunc, Ndmspc::NStorageTree::GetBranch(), Ndmspc::NStorageTree::GetBrancheNames(), Ndmspc::NStorageTree::GetBranchesMap(), Ndmspc::NBinningDef::GetContent(), Ndmspc::NStorageTree::GetFileName(), Ndmspc::NBinningDef::GetIds(), Ndmspc::NGnTree::GetParameters(), Ndmspc::NGnTree::GetStorageTree(), Ndmspc::NStorageTree::InitTree(), Ndmspc::NGnTree::IsPureCopy(), Ndmspc::NUtils::Join(), Ndmspc::NGnTree::Open(), Ndmspc::NTreeBranch::SetAddress(), Ndmspc::NThreadData::SetAssignedIndex(), and Ndmspc::NThreadData::SetThreadId().
Referenced by Ndmspc::NGnTree::Process().
| bool Ndmspc::NGnThreadData::InitStorage | ( | NStorageTree * | ts, |
| const std::string & | filename = "", | ||
| const std::string & | treename = "ngnt" ) |
Initialize storage tree for thread data.
| ts | Pointer to NStorageTree. |
| filename | Optional file name. |
| treename | Optional tree name (default: "ngnt"). |
|
inline |
Checks if the object is a pure copy.
Definition at line 111 of file NGnThreadData.h.
References fIsPureCopy.
|
virtual |
Merge thread data from a collection (virtual).
| list | Pointer to TCollection. |
Merge function
Definition at line 323 of file NGnThreadData.cxx.
References fBiningSource, fHnSparseBase, Ndmspc::NThreadData::GetAssignedIndex(), Ndmspc::NBinningDef::GetContent(), Ndmspc::NBinningPoint::GetCoords(), Ndmspc::NUtils::GetCoordsString(), Ndmspc::NStorageTree::GetFileName(), GetHnSparseBase(), Ndmspc::NBinningDef::GetIds(), GetNProcessed(), Ndmspc::NGnTree::GetOutputs(), GetResultsFilename(), Ndmspc::NGnTree::GetStorageTree(), NGnThreadData(), and Ndmspc::NGnTree::Open().
Referenced by Ndmspc::NGnTree::Process().
|
virtualinherited |
Print method override.
| option | Print options. |
Definition at line 43 of file NThreadData.cxx.
References fAssignedIndex, fCoordSum, fItemCount, and fThreadId.
|
virtual |
Process coordinates (virtual).
| coords | Vector of coordinates. |
Process method This method is called for each set of coordinates It initializes the NHnSparseTree if not already done
Reimplemented from Ndmspc::NThreadData.
Definition at line 137 of file NGnThreadData.cxx.
References Ndmspc::NUtils::ArrayToVector(), fBiningSource, fCfg, fDeferredDeletes, fHnSparseBase, Ndmspc::NStorageTree::Fill(), fIsPureCopy, fNProcessed, fProcessedBinIds, fProcessFunc, Ndmspc::NThreadData::fResourceMonitor, Ndmspc::NThreadData::GetAssignedIndex(), Ndmspc::NStorageTree::GetBranch(), Ndmspc::NBinningPoint::GetCfg(), Ndmspc::NBinningDef::GetContent(), Ndmspc::NBinningPoint::GetCoords(), Ndmspc::NUtils::GetCoordsString(), Ndmspc::NBinningPoint::GetNDimensionsContent(), Ndmspc::NBinningPoint::GetStorageCoords(), Ndmspc::NBinningPoint::RecalculateStorageCoords(), Ndmspc::NTreeBranch::SetAddress(), Ndmspc::NBinningPoint::SetCfg(), Ndmspc::NBinningPoint::SetInput(), and Ndmspc::NBinningPoint::SetTreeStorage().
|
inlineinherited |
Set the assigned index for the thread.
| assignedIndex | Index assigned to the thread. |
Definition at line 53 of file NThreadData.h.
References fAssignedIndex.
Referenced by Ndmspc::NGnThreadData::Init().
|
inline |
Set configuration JSON object.
| cfg | JSON configuration. |
Definition at line 84 of file NGnThreadData.h.
References fCfg.
Referenced by Ndmspc::NGnTree::Process().
|
inlineinherited |
Set the sum of coordinates processed by the thread.
| coordSum | Sum of coordinates. |
Definition at line 35 of file NThreadData.h.
References fCoordSum.
| void Ndmspc::NGnThreadData::SetCurrentDefinitionName | ( | const std::string & | name | ) |
Definition at line 293 of file NGnThreadData.cxx.
|
inlineinherited |
Set whether the thread ID has been assigned.
| idSet | True if ID is set, false otherwise. |
Definition at line 47 of file NThreadData.h.
References fIdSet.
|
inline |
Sets the pure copy status of the object.
| val | Boolean value to set the pure copy status. |
Definition at line 117 of file NGnThreadData.h.
References fIsPureCopy.
|
inlineinherited |
Setters for data members.
Set the number of items processed by the thread.
| itemCount | Number of items. |
Definition at line 29 of file NThreadData.h.
References fItemCount.
|
inline |
Set number of processed entries.
| n | Number of processed entries. |
Definition at line 78 of file NGnThreadData.h.
References fNProcessed.
|
inline |
Set the processing function pointer.
| func | Function pointer to set. |
Definition at line 51 of file NGnThreadData.h.
References fProcessFunc.
|
inlineinherited |
Sets the resource monitor for this thread data.
This function assigns the given NResourceMonitor pointer to the internal resource monitor member. Ownership of the pointer is not transferred; the caller is responsible for managing the lifetime of the monitor object.
| monitor | Pointer to an NResourceMonitor instance to be associated with this thread data. |
Definition at line 64 of file NThreadData.h.
References fResourceMonitor.
|
inline |
Set the results filename for TCP mode (shared filesystem path).
When set, TaskLoop will copy the locally-written file to this path after Close(true) before sending DONE to the supervisor.
| filename | Shared-filesystem path where results should be deposited. |
Definition at line 99 of file NGnThreadData.h.
References fResultsFilename.
Referenced by Ndmspc::NGnTree::Process().
|
inlineinherited |
Set the thread's unique identifier.
| threadId | Thread ID. |
Definition at line 41 of file NThreadData.h.
References fThreadId.
Referenced by Ndmspc::NGnThreadData::Init().
| void Ndmspc::NGnThreadData::SyncCurrentDefinitionIds | ( | const std::vector< Long64_t > & | ids | ) |
Definition at line 303 of file NGnThreadData.cxx.
|
privateinherited |
Index assigned to this object.
Definition at line 140 of file NThreadData.h.
Referenced by GetAssignedIndex(), NThreadData(), Print(), and SetAssignedIndex().
|
private |
Function pointer to the begin function.
Definition at line 145 of file NGnThreadData.h.
Referenced by Init().
|
private |
|
private |
Configuration object.
Definition at line 150 of file NGnThreadData.h.
|
privateinherited |
Sum of coordinates.
Definition at line 137 of file NThreadData.h.
Referenced by GetCoordSum(), NThreadData(), Print(), Process(), and SetCoordSum().
|
private |
Objects deferred for single-threaded deletion.
Definition at line 154 of file NGnThreadData.h.
Referenced by FlushDeferredDeletes(), and Process().
|
private |
Function pointer to the end function.
Definition at line 146 of file NGnThreadData.h.
Referenced by Init().
|
private |
Pointer to the base class.
Definition at line 147 of file NGnThreadData.h.
Referenced by GetHnSparseBase(), Init(), Merge(), and Process().
|
privateinherited |
Flag to indicate if the thread ID is set.
Definition at line 139 of file NThreadData.h.
Referenced by GetIdSet(), NThreadData(), Process(), and SetIdSet().
|
private |
Flag indicating pure copy mode.
Definition at line 151 of file NGnThreadData.h.
Referenced by Init(), IsPureCopy(), Process(), and SetIsPureCopy().
|
privateinherited |
Number of items processed.
Definition at line 136 of file NThreadData.h.
Referenced by GetItemCount(), NThreadData(), Print(), Process(), and SetItemCount().
|
private |
Number of processed entries.
Definition at line 148 of file NGnThreadData.h.
Referenced by GetNProcessed(), Process(), and SetNProcessed().
|
private |
Set of already-processed global bin IDs (duplicate guard)
Definition at line 153 of file NGnThreadData.h.
Referenced by Process().
|
private |
Function pointer to the processing function.
Definition at line 144 of file NGnThreadData.h.
Referenced by Init(), Process(), and SetProcessFunc().
|
protectedinherited |
Pointer to resource monitor.
Definition at line 133 of file NThreadData.h.
Referenced by GetResourceMonitor(), Ndmspc::NGnThreadData::Process(), and SetResourceMonitor().
|
private |
Shared-FS path to copy result to after Close(true) (TCP mode)
Definition at line 152 of file NGnThreadData.h.
Referenced by GetResultsFilename(), and SetResultsFilename().
|
staticinherited |
Shared mutex for thread-safe operations.
Definition at line 98 of file NThreadData.h.
|
privateinherited |
Thread ID.
Definition at line 138 of file NThreadData.h.
Referenced by GetThreadId(), NThreadData(), Print(), Process(), and SetThreadId().