Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

mcmmodel: explicitly determine channel types

  • Loading branch information...
commit 6f37130ce86630b00a3f94a2de3ad4362938c63f 1 parent 948f557
Sven van Haastregt authored

Showing 1 changed file with 35 additions and 20 deletions. Show diff stats Hide diff stats

  1. +35 20 mcmmodel.cc
55 mcmmodel.cc
@@ -23,6 +23,13 @@
23 23
24 24 using namespace pdg_helper;
25 25
  26 +// Classification of an edge in MCM model
  27 +enum McmChannelType {
  28 + FEEDFORWARD, // Connects an SCC to another SCC
  29 + FEEDBACK, // Connects two processes in the same SCC
  30 + SELFLOOP // Connects process to itself
  31 +};
  32 +
26 33 //// MCM Model Dumper class
27 34 class McmModelDumper {
28 35 public:
@@ -31,7 +38,7 @@ class McmModelDumper {
31 38 void dump(std::ostream &strm);
32 39
33 40 private:
34   - void determineBackedgeBitmap(std::vector<bool> &depsBitmap);
  41 + void determineChannelTypes(std::vector<McmChannelType> &channelTypes);
35 42 void writePort(pdg::dependence const *dep, std::string name, std::string type, std::ostream &strm);
36 43 void writeChannel(std::ostream &strm);
37 44 int getDependenceCardinality(pdg::dependence const *dep);
@@ -62,23 +69,22 @@ McmModelDumper::~McmModelDumper() {
62 69 }
63 70
64 71
65   -// Returns a bitmap containing for each dependence whether we should add a backedge or not.
66   -// We only add backedges for feed-forward dependences.
67   -void McmModelDumper::determineBackedgeBitmap(std::vector<bool> &depsBitmap) {
68   - depsBitmap.clear();
  72 +// Returns a vector containing for each dependence the type of the channel in the SDF graph.
  73 +void McmModelDumper::determineChannelTypes(std::vector<McmChannelType> &channelTypes) {
  74 + channelTypes.clear();
69 75 for (unsigned int j = 0; j < pdg->dependences.size(); j++) {
70 76 pdg::dependence *dep = pdg->dependences[j];
71   - bool addEdge = true;
  77 + McmChannelType type = FEEDFORWARD;
72 78
73   - // Don't add backedge for selfloops
74   - if (dep->from == dep->to)
75   - addEdge = false;
76   -
77   - // Don't add backedge if it's inside an SCC
78   - if (this->pdgHelper->isInSCC(dep))
79   - addEdge = false;
  79 + if (dep->from == dep->to) {
  80 + type = SELFLOOP;
  81 + }
  82 + else if (this->pdgHelper->isInSCC(dep)) {
  83 + type = FEEDBACK;
  84 + }
80 85
81   - depsBitmap.push_back(addEdge);
  86 + channelTypes.push_back(type);
  87 + fprintf(stderr, "%2d -> %2d: %d\n", dep->from->nr, dep->to->nr, type);
82 88 }
83 89 }
84 90
@@ -89,8 +95,8 @@ void McmModelDumper::dump(std::ostream& strm) {
89 95 std::ostringstream sdfProps;
90 96 std::ostringstream selfLoopChannels;
91 97
92   - std::vector<bool> addBackedge;
93   - determineBackedgeBitmap(addBackedge);
  98 + std::vector<McmChannelType> channelTypes;
  99 + determineChannelTypes(channelTypes);
94 100
95 101 strm << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
96 102 << "<sdf3 type=\"sdf\" version=\"1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.es.ele.tue.nl/sdf3/xsd/sdf3-sdf.xsd\">\n"
@@ -130,7 +136,7 @@ void McmModelDumper::dump(std::ostream& strm) {
130 136 pdg::dependence *dep = pdg->dependences[j];
131 137
132 138 // Skip if we don't want a backedge
133   - if (addBackedge[j] == false)
  139 + if (channelTypes[j] != FEEDFORWARD)
134 140 continue;
135 141
136 142 if (dep->from == node) {
@@ -166,7 +172,16 @@ void McmModelDumper::dump(std::ostream& strm) {
166 172
167 173 if (dep->reordering == 0 && dep->value_size) {
168 174 // FIFO with integer (non-parametric) size
169   - channelSize = (1+dep->value_size->v) * getDependenceCardinality(dep);
  175 + if (channelTypes[i] == SELFLOOP) {
  176 + channelSize = dep->value_size->v * getDependenceCardinality(dep);
  177 + }
  178 + else if (channelTypes[i] == FEEDFORWARD) {
  179 + channelSize = (1+dep->value_size->v) * getDependenceCardinality(dep);
  180 + }
  181 + else if (channelTypes[i] == FEEDBACK) {
  182 + channelSize = -1;
  183 + fprintf(stderr, "Feedback edges detected, please update the initial tokens manually!\n");
  184 + }
170 185 }
171 186 else {
172 187 // Assume worst-case
@@ -181,10 +196,10 @@ void McmModelDumper::dump(std::ostream& strm) {
181 196 << "srcPort='" << getPortName(i, "out") << "' "
182 197 << "dstActor='" << dep->to->name->s << "' "
183 198 << "dstPort='" << getPortName(i, "in") << "' "
184   - << "initialTokens='" << (dep->from==dep->to ? channelSize : 0) << "' "
  199 + << "initialTokens='" << (channelTypes[i]==FEEDFORWARD ? 0 : channelSize) << "' "
185 200 << "/>\n";
186 201
187   - if (addBackedge[i]) {
  202 + if (channelTypes[i] == FEEDFORWARD) {
188 203 // Corresponding backedge
189 204 snprintf(channelName, sizeof(channelName), "BE_%d", i);
190 205 strm << " <channel name='" << channelName << "' "

0 comments on commit 6f37130

Please sign in to comment.
Something went wrong with that request. Please try again.