Project
Loading...
Searching...
No Matches
GraphvizHelpers.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "GraphvizHelpers.h"
13#include <map>
14#include <iostream>
15#include <string>
16
17namespace o2::framework
18{
19
20namespace
21{
22std::string quote(std::string const& s) { return R"(")" + s + R"(")"; }
23} // namespace
24
26void GraphvizHelpers::dumpDataProcessorSpec2Graphviz(std::ostream& out, const std::vector<DataProcessorSpec>& specs,
27 std::vector<std::pair<int, int>> const& edges)
28{
29 out << "digraph structs {\n";
30 out << " node[shape=record]\n";
31 for (auto& spec : specs) {
32 std::string labels = " xlabel=\"";
33 for (auto& label : spec.labels) {
34 labels += labels == " xlabel=\"" ? "" : ",";
35 labels += label.value;
36 }
37 labels += "\"";
38 out << fmt::format(" \"{}\" [label=\"{}\"{}];\n", spec.name, spec.name, labels != " xlabel=\"\"" ? labels : "");
39 }
40 for (auto& e : edges) {
41 out << fmt::format(" \"{}\" -> \"{}\"\n", specs[e.first].name, specs[e.second].name);
42 }
43 out << "}\n";
44}
45
47void GraphvizHelpers::dumpDeviceSpec2Graphviz(std::ostream& out, const std::vector<DeviceSpec>& specs)
48{
49 out << R"GRAPHVIZ(digraph structs {
50 node[shape=record]
51)GRAPHVIZ";
52 std::map<std::string, std::string> outputChannel2Device;
53 std::map<std::string, unsigned int> outputChannel2Port;
54
55 for (auto& spec : specs) {
56 auto id = spec.id;
57 out << " " << quote(id) << R"( [label="{{)";
58 bool firstInput = true;
59 for (auto&& input : spec.inputChannels) {
60 if (firstInput == false) {
61 out << "|";
62 }
63 firstInput = false;
64 out << "<" << input.name << ">" << input.name;
65 }
66 out << "}|";
67 auto totalChannels = spec.inputChannels.size() +
68 spec.outputChannels.size();
69 out << id << "(" << totalChannels << ")";
70 out << "|{";
71 bool firstOutput = true;
72 for (auto&& output : spec.outputChannels) {
73 outputChannel2Device.insert(std::make_pair(output.name, id));
74 outputChannel2Port.insert(std::make_pair(output.name, output.port));
75 if (firstOutput == false) {
76 out << "|";
77 }
78 firstOutput = false;
79 out << "<" << output.name << ">" << output.name;
80 }
81 out << R"(}}"];)"
82 << "\n";
83 }
84 for (auto& spec : specs) {
85 for (auto& input : spec.inputChannels) {
86 // input and output name are now the same
87 auto outputName = input.name;
88 out << " " << quote(outputChannel2Device[outputName]) << ":" << quote(outputName) << "-> " << quote(spec.id)
89 << ":" << quote(input.name) << R"( [label=")" << input.port << R"(")"
90 << "]\n";
91 }
92 }
93 out << "}\n";
94}
95
96} // namespace o2::framework
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
std::vector< o2::MCCompLabel > labels
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
std::vector< SidecarEdge > edges
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
Defining ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
static void dumpDeviceSpec2Graphviz(std::ostream &, const Devices &specs)
Helper to dump a set of devices as a graphviz file.
static void dumpDataProcessorSpec2Graphviz(std::ostream &, const WorkflowSpec &specs, std::vector< std::pair< int, int > > const &edges={})
Helper to dump a workflow as a graphviz file.