1 #ifndef N_DIMENSIONAL_EXECUTOR_H
2 #define N_DIMENSIONAL_EXECUTOR_H
12 #include <condition_variable>
21 #include <THnSparse.h>
23 #include "NThreadData.h"
50 void SetBounds(
const std::vector<int> & minBounds,
const std::vector<int> & maxBounds);
56 void Execute(
const std::function<
void(
const std::vector<int> & coords)> & func);
64 template <
typename TObject>
65 void ExecuteParallel(
const std::function<
void(
const std::vector<int> & coords, TObject & thread_object)> & func,
66 std::vector<TObject> & thread_objects);
75 void StartProcessIpc(std::vector<NThreadData *> & workerObjects,
size_t processCount,
76 const std::string & tcpBindEndpoint =
"",
const std::string & jobDir =
"",
77 const std::string & treeName =
"ngnt",
const std::string & macroList =
"",
78 const std::string & tmpDir =
"",
const std::string & tmpResultsDir =
"");
79 size_t ExecuteCurrentBoundsProcessIpc(
const std::string & definitionName =
"",
80 const std::vector<Long64_t> * definitionIds =
nullptr,
81 const std::function<
void(
size_t,
size_t)> & progressCallback =
nullptr);
82 void FinishProcessIpc(
bool abort =
false);
125 std::unique_ptr<IpcSession> fIpcSession;
Executes a function over all points in an N-dimensional space, optionally in parallel.
std::vector< int > fMinBounds
Minimum bounds for each dimension.
bool InitTcpWorker(const std::string &identity)
Sends INIT to a newly-connected TCP worker, waits for ACK, and registers it in identityToWorker / wor...
std::set< size_t > fRegisteredWorkerIndices
Worker indices that completed registration (TCP mode)
const std::vector< int > & GetMaxBounds() const
Returns the maximum bounds for each dimension.
std::vector< int > fMaxBounds
Maximum bounds for each dimension.
size_t ExecuteParallelProcessIpc(std::vector< NThreadData * > &workerObjects, size_t processCount)
Execute fixed-contract processing in multiple child processes over IPC.
bool HandleBootstrap(const std::string &identity)
Handles a BOOTSTRAP message from a worker: assigns the next sequential index and replies with a CONFI...
std::vector< int > fCurrentCoords
Current coordinates during iteration.
bool Increment()
Increment the current coordinates to the next point in the N-dimensional space.
NDimensionalExecutor(const std::vector< int > &minBounds, const std::vector< int > &maxBounds)
Constructor from min/max bounds for each dimension.
size_t Dimensions() const
Returns the number of dimensions.
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.
size_t fNumDimensions
Number of dimensions.
void Execute(const std::function< void(const std::vector< int > &coords)> &func)
Execute a function over all coordinates in the N-dimensional space.
const std::vector< int > & GetMinBounds() const
Returns the minimum bounds for each dimension.