Ejemplo n.º 1
0
  /**
   * @return true if we need switch code for this graph, otherwise we can just use the dynamic
   *     network because there are no overlapping routes and no splitters or joiners
   */
  public static boolean needSimulator(SpdStaticStreamGraph ssg) {
    // check if there are any overlapping routes...
    if (((SpdStreamGraph) ssg.getStreamGraph()).getLayout().getIntermediateTiles().size() > 0)
      return true;

    // check if there are any splitters...
    Iterator it = ssg.getFlatNodes().iterator();
    while (it.hasNext()) {
      FlatNode node = (FlatNode) it.next();
      if (node.isJoiner() || node.isSplitter()) return true;
    }
    // all's good!
    return false;
  }
Ejemplo n.º 2
0
  public void visitNode(FlatNode node) {
    System.out.println("Creating SliceNodes: " + node);
    OutputSliceNode output = new OutputSliceNode();
    InputSliceNode input = new InputSliceNode();
    FilterContent content;
    int mult = 1;

    if (node.isFilter()) {
      if (node.contents instanceof SIRFileWriter) {
        content = new FileOutputContent((SIRFileWriter) node.contents);
      } else if (node.contents instanceof SIRFileReader) {
        content = new FileInputContent((SIRFileReader) node.contents);
      } else content = new FilterContent(node.getFilter());

    } else if (node.isSplitter()) {
      CType type = CommonUtils.getOutputType(node);
      SIRIdentity id = new SIRIdentity(type);
      RenameAll.renameAllFilters(id);
      content = new FilterContent(id);
      if (!node.isDuplicateSplitter()) mult = node.getTotalOutgoingWeights();

    } else {
      // joiner
      CType type = CommonUtils.getOutputType(node);
      SIRIdentity id = new SIRIdentity(type);
      RenameAll.renameAllFilters(id);
      content = new FilterContent(id);
      mult = node.getTotalIncomingWeights();
    }
    if (exeCounts[0].containsKey(node.contents))
      content.setInitMult(mult * ((int[]) exeCounts[0].get(node.contents))[0]);
    else content.setInitMult(0);

    content.setSteadyMult(mult * ((int[]) exeCounts[1].get(node.contents))[0]);

    FilterSliceNode filterNode = new FilterSliceNode(content);
    if (node.isSplitter() || node.isJoiner()) generatedIds.add(filterNode);

    inputNodes.put(node.contents, input);
    outputNodes.put(node.contents, output);
    filterNodes.put(node.contents, filterNode);
  }