1 #include <samchon/protocol/master/ParallelSystemArray.hpp> 3 #include <samchon/protocol/master/ParallelSystem.hpp> 4 #include <samchon/protocol/master/PRMasterHistoryArray.hpp> 5 #include <samchon/protocol/master/PRMasterHistory.hpp> 8 #include <samchon/protocol/Invoke.hpp> 18 ParallelSystemArray::ParallelSystemArray()
23 ParallelSystemArray::~ParallelSystemArray()
39 sendPieceData(invoke, 0, totalSize);
42 void ParallelSystemArray::sendPieceData(shared_ptr<Invoke> invoke,
size_t index,
size_t totalSize)
44 if (invoke->has(
"invoke_history_uid") ==
false)
47 vector<thread> threadArray(size());
50 historyArray->emplace_back(history);
52 size_t pieceIndex = index;
54 for (
size_t i = 0; i < size(); i++)
57 size_t pieceSize = (size_t)(totalSize / (
double)size() * at(i)->performance);
59 if (i == size() - 1 && pieceIndex + pieceSize < totalSize)
60 pieceSize = totalSize - pieceIndex;
63 if (at(i)->systemArray ==
nullptr)
64 at(i)->systemArray =
this;
70 &ParallelSystem::sendPieceData, at(i).
get(),
71 history, invoke, pieceIndex, pieceSize
74 pieceIndex += pieceSize;
76 for (
size_t i = 0; i < threadArray.size(); i++)
77 threadArray[i].join();
84 double avgElapsedTime = 0.0;
86 for (
size_t i = 0; i < historyArray.size(); i++)
87 avgElapsedTime += historyArray[i]->calcAverageElapsedTime();
89 for (
size_t i = 0; i < historyArray.size(); i++)
99 double avgPerformance = 0.0;
101 for (
size_t i = 0; i < size(); i++)
102 avgPerformance += at(i)->performance / (double)size();
104 for (
size_t i = 0; i < size(); i++)
105 at(i)->performance /= avgPerformance;
A history log of an Invoke message on a master.
Package for external system, within the framework of master.
An array of parallel system drivers.
A network driver for a parallel system.
auto calcAverageElapsedTime() const -> double
Calculate average of elapsed time for each segmentation.
An array of invoke histories of master.
ParallelSystem * system
A system the history is belonged to.
Package of network protocol and libraries.
A reported history of an Invoke message.
Standard message of network I/O.
library::CriticalVector< PRInvokeHistory * > historyArray
An array of histories which are generated in each system.
A parameter of an Invoke.
double performance
A performance index.