18#include "SubTrace.hpp"
27 const otf2::chrono::duration &runtime,
28 const otf2::chrono::duration &startTime) :
29 slots_(std::move(slots)),
30 communications_(communications),
31 collectiveCommunications_(collectiveCommunications),
33 startTime_(startTime) {}
38 collectiveCommunications_(),
64using TimeAccessor = std::function<otf2::chrono::duration(T
const &)>;
74 const TimeAccessor<Communication *> communicationStart = [](
75 const Communication *e) {
return e->getStartEvent()->getStartTime(); };
76 const TimeAccessor<Communication *> communicationEnd = [](
const Communication *e) {
return e->getEndEvent()->getEndTime(); };
80static Range<T> subRange(
Range<T> r, otf2::chrono::duration from, otf2::chrono::duration to, TimeAccessor<T> getStart,
81 TimeAccessor<T> getEnd) {
82 std::vector<T> newVec;
83 std::copy_if(r.
begin(), r.
end(), std::back_inserter(newVec), [from, to, getStart, getEnd](T x) {
84 return getStart(x) < to && getEnd(x) > from;
94 std::map<otf2::definition::location_group *, Range<Slot *>,
LocationGroupCmp> newSlots;
96 Range<Slot *> slots = subRange(item.second, from, to, accessors::slotStart, accessors::slotEnd);
97 std::sort(slots.
begin(), slots.
end(), [](
const Slot* lhs,
const Slot* rhs) {return lhs->startTime < rhs->startTime;});
98 newSlots.insert({item.first, slots});
100 auto newCommunications = subRange(
getCommunications(), from, to, accessors::communicationStart,
101 accessors::communicationEnd);
105 accessors::communicationEventStart,
106 accessors::communicationEventEnd);
108 auto trace =
new SubTrace(newSlots, newCommunications, newCollectiveCommunications, to - from, from);
otf2::chrono::duration getEndTime() const override=0
otf2::chrono::duration getStartTime() const override=0
Class representing any (successful or unsuccessful) communication.
A custom range implementation around std::vector<T>s.
A Slot represents a visual slot to be rendered in the UI. It contains the information of a location.
types::TraceTime endTime
End time of the slot relative to the trace start time.
otf2::chrono::duration startTime
Start time of the slot relative to the trace start time.
std::map< otf2::definition::location_group *, Range< Slot * >, LocationGroupCmp > slots_
Trace * subtrace(otf2::chrono::duration from, otf2::chrono::duration to) override
Creates a subtrace of the current trace.
Range< CollectiveCommunicationEvent * > collectiveCommunications_
types::TraceTime getEndTime() const override
Returns the end time of the current object.
otf2::chrono::duration startTime_
otf2::chrono::duration getStartTime() const override
Returns the start time of the current object.
Range< Communication * > getCommunications() override
Returns communication objects of the current trace.
std::map< otf2::definition::location_group *, Range< Slot * >, LocationGroupCmp > getSlots() const override
Returns a map of slots of the current trace.
otf2::chrono::duration runtime_
Range< CollectiveCommunicationEvent * > getCollectiveCommunications() override
Returns communication objects of the current trace.
types::TraceTime getDuration() const override
Returns the duration of the current object.
Range< Communication * > communications_
otf2::chrono::duration getRuntime() const override
Returns the runtime of the current trace.
Abstract base class for a trace.
A comparator for otf2::definition::location_group objects.