Motiv
Marvelous OTF2 Traces Interactive Visualizer
Loading...
Searching...
No Matches
Filetrace.cpp
1/*
2 * Marvelous OTF2 Traces Interactive Visualizer (MOTIV)
3 * Copyright (C) 2023 Florian Gallrein, Björn Gehrke
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#include "Filetrace.hpp"
19#include "Range.hpp"
20#include "src/utils.hpp"
21
22FileTrace::FileTrace(std::vector<Slot *> &slotss,
23 std::vector<Communication *> &communications,
24 std::vector<CollectiveCommunicationEvent *> &collectiveCommunications,
25 otf2::chrono::duration runtime) :
26 slotsVec_(slotss),
27 communications_(communications),
28 collectiveCommunications_(collectiveCommunications) {
29 runtime_ = runtime;
30 startTime_ = otf2::chrono::duration(0);
31
32 slots_ = groupBy<Slot *, otf2::definition::location_group *, LocationGroupCmp>(
33 Range(slotsVec_),
34 [](const Slot *s) {
35 return new otf2::definition::location_group(s->location->location_group());
36 },
37 [](const Slot *l, const Slot *r) {
38 auto groupL = l->location->location_group();
39 auto groupR = r->location->location_group();
40
41 if (groupL.ref() == groupR.ref()) {
42 return l->startTime < r->startTime;
43 }
44
45 return groupL.ref() < groupR.ref();
46 });
47}
48
49std::map<otf2::definition::location_group *, Range<Slot *>, LocationGroupCmp> FileTrace::getSlots() const {
50 return slots_;
51}
52
54 return Range(communications_);
55}
56
58 return Range(collectiveCommunications_);
59}
60
61FileTrace::~FileTrace() {
62 for (const auto &communication: this->collectiveCommunications_) {
63 delete communication;
64 }
65
66 for (const auto &communication: this->communications_) {
67 delete communication;
68 }
69
70 for (const auto &locationGroupSlotPair: this->slots_) {
71 delete locationGroupSlotPair.first;
72
73 for (const auto &slot: locationGroupSlotPair.second) {
74 delete slot;
75 }
76 }
77}
std::map< otf2::definition::location_group *, Range< Slot * >, LocationGroupCmp > getSlots() const override
Returns a map of slots of the current trace.
Definition: Filetrace.cpp:49
Range< Communication * > getCommunications() override
Returns communication objects of the current trace.
Definition: Filetrace.cpp:53
FileTrace(std::vector< Slot * > &slotss, std::vector< Communication * > &communications, std::vector< CollectiveCommunicationEvent * > &collectiveCommunications, otf2::chrono::duration runtime)
Definition: Filetrace.cpp:22
Range< CollectiveCommunicationEvent * > getCollectiveCommunications() override
Returns collective communication events of the current trace.
Definition: Filetrace.cpp:57
A custom range implementation around std::vector<T>s.
Definition: Range.hpp:37
A Slot represents a visual slot to be rendered in the UI. It contains the information of a location.
Definition: Slot.hpp:37
otf2::chrono::duration startTime
Start time of the slot relative to the trace start time.
Definition: Slot.hpp:55
otf2::definition::location * location
Location of the slot (thread) containing the location group (MPI rank)
Definition: Slot.hpp:65
std::map< otf2::definition::location_group *, Range< Slot * >, LocationGroupCmp > slots_
Definition: SubTrace.hpp:76
otf2::chrono::duration startTime_
Definition: SubTrace.hpp:96
otf2::chrono::duration runtime_
Definition: SubTrace.hpp:91
A comparator for otf2::definition::location_group objects.
Definition: Trace.hpp:34