|
ndmspc
v1.2.0-0.1.rc3
|
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. More... | |
| void | SetProcessFunc (NGnProcessFuncPtr func) |
| Set the processing function pointer. More... | |
| bool | InitStorage (NStorageTree *ts, const std::string &filename="", const std::string &treename="ngnt") |
| Initialize storage tree for thread data. More... | |
| NGnTree * | GetHnSparseBase () const |
| Get pointer to base NGnTree object. More... | |
| Long64_t | GetNProcessed () const |
| Get number of processed entries. More... | |
| void | SetNProcessed (Long64_t n) |
| Set number of processed entries. More... | |
| void | SetCfg (const json &cfg) |
| Set configuration JSON object. More... | |
| json | GetCfg () const |
| Get configuration JSON object. More... | |
| void | SetResultsFilename (const std::string &filename) |
| Set the results filename for TCP mode (shared filesystem path). More... | |
| const std::string & | GetResultsFilename () const |
| Get the results filename for TCP mode. More... | |
| bool | IsPureCopy () const |
| Checks if the object is a pure copy. More... | |
| void | SetIsPureCopy (bool val) |
| Sets the pure copy status of the object. More... | |
| virtual void | Process (const std::vector< int > &coords) |
| Process coordinates (virtual). More... | |
| 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). More... | |
| void | SetItemCount (long long itemCount) |
| Setters for data members. More... | |
| void | SetCoordSum (long long coordSum) |
| Set the sum of coordinates processed by the thread. More... | |
| void | SetThreadId (std::thread::id threadId) |
| Set the thread's unique identifier. More... | |
| void | SetIdSet (bool idSet) |
| Set whether the thread ID has been assigned. More... | |
| void | SetAssignedIndex (size_t assignedIndex) |
| Set the assigned index for the thread. More... | |
| void | SetResourceMonitor (NResourceMonitor *monitor) |
| Sets the resource monitor for this thread data. More... | |
| long long | GetItemCount () const |
| Getters for data members. More... | |
| long long | GetCoordSum () const |
| Get the sum of coordinates processed by the thread. More... | |
| std::thread::id | GetThreadId () const |
| Get the thread's unique identifier. More... | |
| bool | GetIdSet () const |
| Check if the thread ID has been assigned. More... | |
| size_t | GetAssignedIndex () const |
| Get the assigned index for the thread. More... | |
| NResourceMonitor * | GetResourceMonitor () const |
| Gets the resource monitor associated with this thread data. More... | |
| virtual void | Print (Option_t *option="") const |
| Print method override. More... | |
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::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 19 of file NGnThreadData.h.
|
inlineinherited |
Get the assigned index for the thread.
Definition at line 96 of file NThreadData.h.
References Ndmspc::NThreadData::fAssignedIndex.
Referenced by Ndmspc::NDimensionalExecutor::ExecuteParallel(), FlushDeferredDeletes(), Merge(), and Process().
|
inline |
Get configuration JSON object.
Definition at line 89 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 Ndmspc::NThreadData::fCoordSum.
|
inline |
Get pointer to base NGnTree object.
Definition at line 65 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 Ndmspc::NThreadData::fIdSet.
|
inlineinherited |
Getters for data members.
Get the number of items processed by the thread.
Definition at line 72 of file NThreadData.h.
References Ndmspc::NThreadData::fItemCount.
|
inline |
Get number of processed entries.
Definition at line 71 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 Ndmspc::NThreadData::fResourceMonitor.
|
inline |
Get the results filename for TCP mode.
Definition at line 104 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 Ndmspc::NThreadData::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::NGnTree::GetBinning(), Ndmspc::NStorageTree::GetBranch(), Ndmspc::NStorageTree::GetBrancheNames(), Ndmspc::NStorageTree::GetBranchesMap(), Ndmspc::NBinningDef::GetContent(), Ndmspc::NBinning::GetDefinition(), Ndmspc::NBinning::GetDefinitionNames(), Ndmspc::NStorageTree::GetFileName(), Ndmspc::NBinningDef::GetIds(), Ndmspc::NGnTree::GetParameters(), Ndmspc::NBinning::GetPoint(), Ndmspc::NGnTree::GetStorageTree(), Ndmspc::NStorageTree::InitTree(), Ndmspc::NGnTree::IsPureCopy(), Ndmspc::NUtils::Join(), Ndmspc::NGnTree::Open(), Ndmspc::NTreeBranch::SetAddress(), Ndmspc::NThreadData::SetAssignedIndex(), Ndmspc::NGnTree::SetInput(), Ndmspc::NBinningPoint::SetParameters(), Ndmspc::NThreadData::SetThreadId(), and Ndmspc::NBinningPoint::SetTreeStorage().
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 110 of file NGnThreadData.h.
References fIsPureCopy.
|
virtual |
Merge thread data from a collection (virtual).
| list | Pointer to TCollection. |
Merge function
Definition at line 325 of file NGnThreadData.cxx.
References Ndmspc::NGnTree::Close(), fBiningSource, fHnSparseBase, Ndmspc::NThreadData::GetAssignedIndex(), Ndmspc::NGnTree::GetBinning(), Ndmspc::NBinning::GetContent(), Ndmspc::NBinningDef::GetContent(), Ndmspc::NBinningPoint::GetCoords(), Ndmspc::NUtils::GetCoordsString(), Ndmspc::NBinning::GetDefinition(), Ndmspc::NBinning::GetDefinitionNames(), Ndmspc::NGnTree::GetEntry(), Ndmspc::NStorageTree::GetFileName(), GetHnSparseBase(), Ndmspc::NBinningDef::GetIds(), Ndmspc::NGnTree::GetInput(), GetNProcessed(), Ndmspc::NGnTree::GetOutput(), Ndmspc::NGnTree::GetOutputs(), Ndmspc::NBinning::GetPoint(), GetResultsFilename(), Ndmspc::NBinningPoint::GetStorageCoords(), Ndmspc::NGnTree::GetStorageTree(), Ndmspc::NStorageTree::Merge(), Ndmspc::NGnTree::Open(), Ndmspc::NBinningPoint::Reset(), Ndmspc::NStorageTree::SetBinning(), Ndmspc::NBinning::SetCurrentDefinitionName(), and Ndmspc::NStorageTree::SetEnabledBranches().
Referenced by Ndmspc::NGnTree::Process().
|
virtualinherited |
Print method override.
| option | Print options. |
Definition at line 43 of file NThreadData.cxx.
References Ndmspc::NThreadData::fAssignedIndex, Ndmspc::NThreadData::fCoordSum, Ndmspc::NThreadData::fItemCount, and Ndmspc::NThreadData::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(), Ndmspc::NResourceMonitor::End(), fBiningSource, fCfg, fDeferredDeletes, fHnSparseBase, Ndmspc::NResourceMonitor::Fill(), Ndmspc::NStorageTree::Fill(), fIsPureCopy, fNProcessed, fProcessFunc, Ndmspc::NThreadData::fResourceMonitor, Ndmspc::NThreadData::GetAssignedIndex(), Ndmspc::NGnTree::GetBinning(), Ndmspc::NStorageTree::GetBranch(), Ndmspc::NBinningPoint::GetCfg(), Ndmspc::NBinning::GetContent(), Ndmspc::NBinningDef::GetContent(), Ndmspc::NBinningPoint::GetCoords(), Ndmspc::NUtils::GetCoordsString(), Ndmspc::NBinning::GetDefinition(), Ndmspc::NResourceMonitor::GetHnSparse(), Ndmspc::NBinningDef::GetId(), Ndmspc::NBinningDef::GetIds(), Ndmspc::NGnTree::GetInput(), Ndmspc::NBinningPoint::GetNDimensionsContent(), Ndmspc::NGnTree::GetOutput(), Ndmspc::NBinning::GetPoint(), Ndmspc::NBinningPoint::GetStorageCoords(), Ndmspc::NGnTree::GetStorageTree(), Ndmspc::NResourceMonitor::Initialize(), Ndmspc::NBinningPoint::RecalculateStorageCoords(), Ndmspc::NTreeBranch::SetAddress(), Ndmspc::NBinningPoint::SetCfg(), Ndmspc::NBinningPoint::SetInput(), Ndmspc::NBinningPoint::SetTreeStorage(), and Ndmspc::NResourceMonitor::Start().
|
inlineinherited |
Set the assigned index for the thread.
| assignedIndex | Index assigned to the thread. |
Definition at line 53 of file NThreadData.h.
References Ndmspc::NThreadData::fAssignedIndex.
Referenced by Init().
|
inline |
Set configuration JSON object.
| cfg | JSON configuration. |
Definition at line 83 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 Ndmspc::NThreadData::fCoordSum.
|
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 Ndmspc::NThreadData::fIdSet.
|
inline |
Sets the pure copy status of the object.
| val | Boolean value to set the pure copy status. |
Definition at line 116 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 Ndmspc::NThreadData::fItemCount.
|
inline |
Set number of processed entries.
| n | Number of processed entries. |
Definition at line 77 of file NGnThreadData.h.
References fNProcessed.
|
inline |
Set the processing function pointer.
| func | Function pointer to set. |
Definition at line 50 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 Ndmspc::NThreadData::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 98 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 Ndmspc::NThreadData::fThreadId.
Referenced by Init().