forked from Dr15Jones/root_serialization
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathReplicatedSharedSource.h
More file actions
53 lines (45 loc) · 1.57 KB
/
ReplicatedSharedSource.h
File metadata and controls
53 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#if !defined(ReplicatedSharedSource_h)
#define ReplicatedSharedSource_h
#include <vector>
#include <iostream>
#include "SharedSourceBase.h"
namespace cce::tf {
template<typename S>
class ReplicatedSharedSource : public SharedSourceBase {
public:
template<typename... Args>
ReplicatedSharedSource(unsigned iNLanes, unsigned long long iNEvents, Args&&... iArgs):
SharedSourceBase(iNEvents) {
sources_.reserve(iNLanes);
for(int i=0; i< iNLanes; ++i) {
sources_.emplace_back(std::forward<Args>(iArgs)...);
}
}
size_t numberOfDataProducts() const {return sources_[0].numberOfDataProducts();}
std::vector<DataProductRetriever>& dataProducts(unsigned int iLane, long iEventIndex) final {
return sources_[iLane].dataProducts();
}
EventIdentifier eventIdentifier(unsigned int iLane, long iEventIndex) final {
return sources_[iLane].eventIdentifier();
}
void printSummary() const {
std::chrono::microseconds sourceTime = accumulatedTime();
std::cout <<"\nSource time: "<<sourceTime.count()<<"us\n"<<std::endl;
}
std::chrono::microseconds accumulatedTime() const {
std::chrono::microseconds totalTime = std::chrono::microseconds::zero();
for(auto const& s: sources_) {
totalTime += s.accumulatedTime();
}
return totalTime;
}
private:
void readEventAsync(unsigned int iLane, long iEventIndex, OptionalTaskHolder iTask) final {
if(sources_[iLane].gotoEvent(iEventIndex)) {
iTask.runNow();
}
}
std::vector<S> sources_;
};
}
#endif