public void Compile(ProgramGraph graph, CompilerOutputInfo info) { if (!(info is ShaderOutputInfo)) { return; } ShaderOutputInfo outputInfo = info as ShaderOutputInfo; RegisterDict = new Dictionary <string, int>(); for (int i = 0; i < graph.getMaxDepth(); i++) { foreach (Vertex v in graph.getVerticesForLayer(i)) { foreach (NodeItem outputItem in v.Data.Items.Where(item => item.Output.Enabled)) { if (outputItem.OutputData is ShaderTypes.sampler2D) { ShaderTypes.sampler2D Sampler = (ShaderTypes.sampler2D)outputItem.OutputData; if (!RegisterDict.ContainsKey(Sampler.path)) { RegisterDict.Add(Sampler.path, RegisterDict.Count); } } } } } mCompiler = new HLSLCompiler(new Dictionary <object, string>(), RegisterDict); WritePostFxScript(outputInfo); if (mCompiler == null) { return; } mCompiler.Compile(graph, outputInfo); }
protected void CreateSingleLoop( ProgramGraph g, ValueNode ap, ValueNode bp, ValueNode s, ValueNode ap1, ValueNode bp1, ValueNode s1) { OperationNode[] o = new OperationNode[8]; o[0] = new AddOperationNode(); o[1] = new MulOperationNode(); o[2] = new LoadOperationNode(); o[3] = new AddOperationNode(); o[4] = new LoadOperationNode(); o[5] = new AddOperationNode(); o[6] = new ConstOperationNode(); o[7] = new ConstOperationNode(); foreach (OperationNode op in o) g.AddNode(op); ValueNode[] v = new ValueNode[7]; v[0] = new FloatRegisterNode(); v[1] = new FloatRegisterNode(); v[2] = new FloatRegisterNode(); v[3] = new IntRegisterNode(); v[4] = new IntRegisterNode(); v[5] = new IntConstantNode(4); v[6] = new IntConstantNode(4); foreach (ValueNode val in v) g.AddNode(val); g.AddEdge(v[0], o[0]); g.AddEdge(s, o[0]); g.AddEdge(o[0], s1); g.AddEdge(v[1], o[1]); g.AddEdge(v[2], o[1]); g.AddEdge(o[1], v[0]); g.AddEdge(ap, o[2]); g.AddEdge(o[2], v[1]); g.AddEdge(ap, o[3]); g.AddEdge(v[3], o[3]); g.AddEdge(o[3], ap1); g.AddEdge(bp, o[4]); g.AddEdge(o[4], v[2]); g.AddEdge(bp, o[5]); g.AddEdge(v[4], o[5]); g.AddEdge(o[5], bp1); g.AddEdge(v[5], o[6]); g.AddEdge(o[6], v[3]); g.AddEdge(v[6], o[7]); g.AddEdge(o[7], v[4]); }
public ProgramGraph CreateUnrolledProgramGraph(int k) { ProgramGraph g = new ProgramGraph(); ValueNode[] ap = new ValueNode[k + 1]; ValueNode[] bp = new ValueNode[k + 1]; ValueNode[] cp = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { ap[i] = new TestRegisterNode("a[" + i + "]", Datatype.AddressValue); bp[i] = new TestRegisterNode("b[" + i + "]", Datatype.AddressValue); cp[i] = new TestRegisterNode("c[" + i + "]", Datatype.AddressValue); g.AddNode(ap[i]); g.AddNode(bp[i]); g.AddNode(cp[i]); } ValueNode k0 = new TestRegisterNode("k0", Datatype.FloatValue); ValueNode k1 = new TestRegisterNode("k1", Datatype.FloatValue); g.AddNode(k0); g.AddNode(k1); for (int i = 0; i < k; i++) { CreateSingleLoop( g, ap[i], bp[i], cp[i], k0, k1, ap[i + 1], bp[i + 1], cp[i + 1]); } g.InitInputValues(); g.InitOutputValues(); g.OutputValues.Add(k0); g.OutputValues.Add(k1); g.CyclicDependencies[ap[0]] = ap[k]; g.CyclicDependencies[ap[k]] = ap[0]; g.CyclicDependencies[bp[0]] = bp[k]; g.CyclicDependencies[bp[k]] = bp[0]; g.CyclicDependencies[cp[0]] = cp[k]; g.CyclicDependencies[cp[k]] = cp[0]; return g; }
public GACodeGeneratorTester( IMachineDescriptionProvider mdp, IProgramGraphProvider pgp, int k, GAInstructionSelectorConfiguration isConfig, GASchedulerConfiguration scConfig, TextWriter textWriter, TextWriter dataWriter) { machineDescription = mdp.CreateMachineDescription(); programGraph = pgp.CreateUnrolledProgramGraph(k); codeGenerator = new GACodeGenerator(isConfig, scConfig); iSelector = codeGenerator.InstructionSelector; scheduler = codeGenerator.Scheduler; this.textWriter = textWriter; this.dataWriter = dataWriter; }
public void Compile(ProgramGraph graph, CompilerOutputInfo info) { currentDepth = 0; List <Vertex> inputVertices = graph.getVerticesForLayer(0); Vertex main = GetMainInput(inputVertices); if (main == null) { return; } InputDict = new Dictionary <object, string>(); outStream = new StreamWriter(info.outputPath + info.outputFilename + ".hlsl"); WriteInputHeaders(inputVertices); WriteFunctionHeader(main); for (int i = 0; i <= graph.getMaxDepth(); i++) { WriteLayer(graph.getVerticesForLayer(i)); } currentDepth--; WriteLine("}", IndentType.Decrease); outStream.Close(); }
public ProgramGraph CreateUnrolledProgramGraph(int k) { ProgramGraph g = new ProgramGraph(); ValueNode[] ap = new ValueNode[k + 1]; ValueNode[] bp = new ValueNode[k + 1]; ValueNode[] s = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { ap[i] = new TestRegisterNode("a[" + i + "]", Datatype.AddressValue); bp[i] = new TestRegisterNode("b[" + i + "]", Datatype.AddressValue); s[i] = new TestRegisterNode("s[" + i + "]", Datatype.FloatValue); g.AddNode(ap[i]); g.AddNode(bp[i]); g.AddNode(s[i]); } for (int i = 0; i < k; i++) CreateSingleLoop( g, ap[i], bp[i], s[i], ap[i + 1], bp[i + 1], s[i + 1]); }
protected void CreateSingleLoop( ProgramGraph g, ValueNode xp, ValueNode yp, ValueNode x, ValueNode y, ValueNode c0, ValueNode c1, ValueNode c2, ValueNode xp1, ValueNode yp1, ValueNode x1, ValueNode y1) { OperationNode[] o = new OperationNode[11]; o[0] = new StoreOperationNode(); o[1] = new AddOperationNode(); o[2] = new AddOperationNode(); o[3] = new ConstOperationNode(); o[4] = new AddOperationNode(); o[5] = new MulOperationNode(); o[6] = new MulOperationNode(); o[7] = new MulOperationNode(); o[8] = new LoadOperationNode(); o[9] = new AddOperationNode(); o[10] = new ConstOperationNode(); foreach (OperationNode op in o) g.AddNode(op); ValueNode[] v = new ValueNode[9]; v[0] = new FloatMemoryNode(null); v[1] = new IntRegisterNode(); v[2] = new FloatRegisterNode(); v[3] = new FloatRegisterNode(); v[4] = new IntConstantNode(4); v[5] = new FloatRegisterNode(); v[6] = new FloatRegisterNode(); v[7] = new IntRegisterNode(); v[8] = new IntConstantNode(4); foreach (ValueNode val in v) g.AddNode(val); g.AddEdge(y1, o[0]); g.AddEdge(yp, o[0]); g.AddEdge(o[0], v[0]); g.AddEdge(yp, o[1]); g.AddEdge(v[1], o[1]); g.AddEdge(o[1], yp1); g.AddEdge(v[2], o[2]); g.AddEdge(v[3], o[2]); g.AddEdge(o[2], y1); g.AddEdge(v[4], o[3]); g.AddEdge(o[3], v[1]); g.AddEdge(v[5], o[4]); g.AddEdge(v[6], o[4]); g.AddEdge(o[4], v[2]); g.AddEdge(c2, o[5]); g.AddEdge(y, o[5]); g.AddEdge(o[5], v[3]); g.AddEdge(c1, o[6]); g.AddEdge(x, o[6]); g.AddEdge(o[6], v[5]); g.AddEdge(c0, o[7]); g.AddEdge(x1, o[7]); g.AddEdge(o[7], v[6]); g.AddEdge(xp, o[8]); g.AddEdge(o[8], x1); g.AddEdge(xp, o[9]); g.AddEdge(v[7], o[9]); g.AddEdge(o[9], xp1); g.AddEdge(v[8], o[10]); g.AddEdge(o[10], v[7]); }
public ProgramGraph CreateUnrolledProgramGraph(int k) { ProgramGraph g = new ProgramGraph(); ValueNode[] xp = new ValueNode[k + 1]; ValueNode[] yp = new ValueNode[k + 1]; ValueNode[] y = new ValueNode[k + 1]; ValueNode[] x = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { xp[i] = new TestRegisterNode("xp[" + i + "]", Datatype.AddressValue); yp[i] = new TestRegisterNode("yp[" + i + "]", Datatype.AddressValue); y[i] = new TestRegisterNode("y[" + i + "]", Datatype.FloatValue); x[i] = new TestRegisterNode("x[" + i + "]", Datatype.FloatValue); g.AddNode(xp[i]); g.AddNode(yp[i]); g.AddNode(x[i]); g.AddNode(y[i]); } ValueNode pc0 = new FloatMemoryNode("c0"); ValueNode pc1 = new FloatMemoryNode("c1"); ValueNode pc2 = new FloatMemoryNode("c2"); OperationNode lc0 = new LoadOperationNode(); OperationNode lc1 = new LoadOperationNode(); OperationNode lc2 = new LoadOperationNode(); ValueNode c0 = new FloatRegisterNode(); ValueNode c1 = new FloatRegisterNode(); ValueNode c2 = new FloatRegisterNode(); g.AddNode(pc0); g.AddNode(pc1); g.AddNode(pc2); g.AddNode(lc0); g.AddNode(lc1); g.AddNode(lc2); g.AddNode(c0); g.AddNode(c1); g.AddNode(c2); g.AddEdge(pc0, lc0); g.AddEdge(lc0, c0); g.AddEdge(pc1, lc1); g.AddEdge(lc1, c1); g.AddEdge(pc2, lc2); g.AddEdge(lc2, c2); for (int i = 0; i < k; i++) { CreateSingleLoop( g, xp[i], yp[i], x[i], y[i], c0, c1, c2, xp[i + 1], yp[i + 1], x[i + 1], y[i + 1]); } g.InitInputValues(); g.InitOutputValues(); g.OutputValues.Add(x[k]); g.OutputValues.Add(y[k]); x[k].OutputFlag = true; y[k].OutputFlag = true; g.CyclicDependencies[xp[0]] = xp[k]; g.CyclicDependencies[xp[k]] = xp[0]; g.CyclicDependencies[yp[0]] = yp[k]; g.CyclicDependencies[yp[k]] = yp[0]; g.CyclicDependencies[y[0]] = y[k]; g.CyclicDependencies[y[k]] = y[0]; g.CyclicDependencies[x[0]] = x[k]; g.CyclicDependencies[x[k]] = x[0]; return g; }
protected void CreateSingleFilterLoop( ProgramGraph g, ValueNode x, ValueNode x0, ValueNode x1, ValueNode c0, ValueNode c1, ValueNode c2, ValueNode c3, ValueNode c4, ValueNode z0, ValueNode z1, ValueNode y) { OperationNode[] o = new OperationNode[13]; o[0] = new AddOperationNode(); o[1] = new MulOperationNode(); o[2] = new AddOperationNode(); o[3] = new AddOperationNode(); o[4] = new MulOperationNode(); o[5] = new AddOperationNode(); o[6] = new AddOperationNode(); o[7] = new AddOperationNode(); o[8] = new MulOperationNode(); o[9] = new MulOperationNode(); o[10] = new MulOperationNode(); o[11] = new AddOperationNode(); o[12] = new AddOperationNode(); foreach (OperationNode opNode in o) g.AddNode(opNode); ValueNode[] v = new ValueNode[10]; for (int i = 0; i < v.Length; i++) v[i] = new FloatRegisterNode(); foreach (ValueNode vNode in v) g.AddNode(vNode); g.AddEdge(x, o[0]); g.AddEdge(x0, o[0]); g.AddEdge(o[0], v[0]); g.AddEdge(c0, o[1]); g.AddEdge(v[0], o[1]); g.AddEdge(o[1], v[1]); g.AddEdge(x, o[2]); g.AddEdge(v[1], o[2]); g.AddEdge(o[2], v[2]); g.AddEdge(v[2], o[3]); g.AddEdge(x1, o[3]); g.AddEdge(o[3], v[3]); g.AddEdge(c1, o[4]); g.AddEdge(v[3], o[4]); g.AddEdge(o[4], v[4]); g.AddEdge(v[2], o[5]); g.AddEdge(v[4], o[5]); g.AddEdge(o[5], z1); g.AddEdge(v[1], o[6]); g.AddEdge(x0, o[6]); g.AddEdge(o[6], v[5]); g.AddEdge(v[4], o[7]); g.AddEdge(x1, o[7]); g.AddEdge(o[7], z0); g.AddEdge(v[5], o[8]); g.AddEdge(c2, o[8]); g.AddEdge(o[8], v[6]); g.AddEdge(z0, o[9]); g.AddEdge(c3, o[9]); g.AddEdge(o[9], v[7]); g.AddEdge(z1, o[10]); g.AddEdge(c4, o[10]); g.AddEdge(o[10], v[9]); g.AddEdge(v[6], o[11]); g.AddEdge(v[7], o[11]); g.AddEdge(o[11], v[8]); g.AddEdge(v[8], o[12]); g.AddEdge(v[9], o[12]); g.AddEdge(o[12], y); }
public ProgramGraph CreateUnrolledProgramGraph(int k) { ProgramGraph g = new ProgramGraph(); ValueNode[] px = new ValueNode[k + 1]; ValueNode[] py = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { px[i] = new TestRegisterNode("x[" + i + "]", Datatype.AddressValue); py[i] = new TestRegisterNode("y[" + i + "]", Datatype.AddressValue); g.AddNode(px[i]); g.AddNode(py[i]); } ValueNode[] x = new ValueNode[k]; ValueNode[] y = new ValueNode[k]; for (int i = 0; i < k; i++) { x[i] = new FloatRegisterNode(); y[i] = new FloatRegisterNode(); g.AddNode(x[i]); g.AddNode(y[i]); } ValueNode[] x0 = new ValueNode[k + 1]; ValueNode[] x1 = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { x0[i] = new TestRegisterNode("x0[" + i + "]", Datatype.FloatValue); x1[i] = new TestRegisterNode("x1[" + i + "]", Datatype.FloatValue); g.AddNode(x0[i]); g.AddNode(x1[i]); } ValueNode pc0 = new FloatMemoryNode("c0"); ValueNode pc1 = new FloatMemoryNode("c1"); ValueNode pc2 = new FloatMemoryNode("c2"); ValueNode pc3 = new FloatMemoryNode("c3"); ValueNode pc4 = new FloatMemoryNode("c4"); OperationNode lc0 = new LoadOperationNode(); OperationNode lc1 = new LoadOperationNode(); OperationNode lc2 = new LoadOperationNode(); OperationNode lc3 = new LoadOperationNode(); OperationNode lc4 = new LoadOperationNode(); ValueNode c0 = new FloatRegisterNode(); ValueNode c1 = new FloatRegisterNode(); ValueNode c2 = new FloatRegisterNode(); ValueNode c3 = new FloatRegisterNode(); ValueNode c4 = new FloatRegisterNode(); g.AddNode(pc0); g.AddNode(pc1); g.AddNode(pc2); g.AddNode(pc3); g.AddNode(pc4); g.AddNode(lc0); g.AddNode(lc1); g.AddNode(lc2); g.AddNode(lc3); g.AddNode(lc4); g.AddNode(c0); g.AddNode(c1); g.AddNode(c2); g.AddNode(c3); g.AddNode(c4); g.AddEdge(pc0, lc0); g.AddEdge(lc0, c0); g.AddEdge(pc1, lc1); g.AddEdge(lc1, c1); g.AddEdge(pc2, lc2); g.AddEdge(lc2, c2); g.AddEdge(pc3, lc3); g.AddEdge(lc3, c3); g.AddEdge(pc4, lc4); g.AddEdge(lc4, c4); for (int i = 0; i < k; i++) { CreateLoadIncGraph( g, x[i], px[i], px[i + 1], 4); CreateStoreIncGraph( g, y[i], py[i], py[i + 1], 4); CreateSingleFilterLoop( g, x[i], x0[i], x1[i], c0, c1, c2, c3, c4, x0[i + 1], x1[i + 1], y[i]); } g.InitInputValues(); g.InitOutputValues(); g.CyclicDependencies[x0[0]] = x0[k]; g.CyclicDependencies[x0[k]] = x0[0]; g.CyclicDependencies[x1[0]] = x1[k]; g.CyclicDependencies[x1[k]] = x1[0]; g.CyclicDependencies[px[0]] = px[k]; g.CyclicDependencies[px[k]] = px[0]; g.CyclicDependencies[py[0]] = py[k]; g.CyclicDependencies[py[k]] = py[0]; return g; }
protected void CreateSingleLoop( ProgramGraph g, ValueNode ap, ValueNode bp, ValueNode cp, ValueNode k0, ValueNode k1, ValueNode ap1, ValueNode bp1, ValueNode cp1) { OperationNode[] o = new OperationNode[12]; o[0] = new AddOperationNode(); o[1] = new MulOperationNode(); o[2] = new MulOperationNode(); o[3] = new LoadOperationNode(); o[4] = new AddOperationNode(); o[5] = new LoadOperationNode(); o[6] = new AddOperationNode(); o[7] = new ConstOperationNode(); o[8] = new ConstOperationNode(); o[9] = new StoreOperationNode(); o[10] = new AddOperationNode(); o[11] = new ConstOperationNode(); foreach (OperationNode op in o) g.AddNode(op); ValueNode[] v = new ValueNode[12]; v[0] = new FloatRegisterNode(); v[1] = new FloatRegisterNode(); v[2] = new FloatRegisterNode(); v[3] = new FloatRegisterNode(); v[4] = new IntRegisterNode(); v[5] = new IntRegisterNode(); v[6] = new IntConstantNode(4); v[7] = new IntConstantNode(4); v[8] = new FloatRegisterNode(); v[9] = new FloatMemoryNode(null); v[10] = new IntRegisterNode(); v[11] = new IntConstantNode(4); foreach (ValueNode val in v) g.AddNode(val); g.AddEdge(v[0], o[0]); g.AddEdge(v[1], o[0]); g.AddEdge(o[0], v[8]); g.AddEdge(v[2], o[1]); g.AddEdge(k0, o[1]); g.AddEdge(o[1], v[0]); g.AddEdge(v[3], o[2]); g.AddEdge(k1, o[2]); g.AddEdge(o[2], v[1]); g.AddEdge(ap, o[3]); g.AddEdge(o[3], v[2]); g.AddEdge(ap, o[4]); g.AddEdge(v[4], o[4]); g.AddEdge(o[4], ap1); g.AddEdge(bp, o[5]); g.AddEdge(o[5], v[3]); g.AddEdge(bp, o[6]); g.AddEdge(v[5], o[6]); g.AddEdge(o[6], bp1); g.AddEdge(v[6], o[7]); g.AddEdge(o[7], v[4]); g.AddEdge(v[7], o[8]); g.AddEdge(o[8], v[5]); g.AddEdge(v[8], o[9]); g.AddEdge(cp, o[9]); g.AddEdge(o[9], v[9]); g.AddEdge(cp, o[10]); g.AddEdge(v[10], o[10]); g.AddEdge(o[10], cp1); g.AddEdge(v[11], o[11]); g.AddEdge(o[11], v[10]); }
/// <summary> /// Populates the loop information. /// </summary> /// <param name="program">The given program.</param> private static void PopulateLoopInformation(Program program) { ProgramGraph graph = new ProgramGraph(program); BackEdges = graph.BackEdges; LoopBarriers = new Dictionary <BackEdge, List <Barrier> >(); foreach (BackEdge edge in graph.BackEdges) { List <ProgramNode> loopNodes = graph.GetLoopNodes(edge); List <Block> loopBlocks = loopNodes.Select(x => x.Block).ToList(); IEnumerable <Barrier> barriers = Barriers.Values.Where(x => loopBlocks.Contains(x.Block)); LoopBarriers.Add(edge, barriers.ToList()); } foreach (Barrier barrier in Barriers.Values) { barrier.LoopDepth = LoopBarriers.Where(x => x.Value.Contains(barrier)).Count(); } // consider barriers instrumented in the header node as a part of the loop // these barriers will not have a loop depth since they are outside the loop foreach (BackEdge edge in graph.BackEdges) { foreach (ProgramNode predecessor in edge.Destination.Predecessors) { // ignore the other end of the back-edge if (predecessor == edge.Source) { continue; } // identify the last thread-level and grid-level barrier in the predecessor int?thread = null, grid = null; int location = predecessor.Block.Cmds.Count - 1; while (location >= 0) { if (predecessor.Block.Cmds[location] is CallCmd) { CallCmd command = predecessor.Block.Cmds[location] as CallCmd; if (thread == null && command.callee.Contains("$bugle_barrier")) { thread = location; } if (grid == null && command.callee.Contains("bugle_grid_barrier")) { grid = location; } } if (thread != null && grid != null) { break; } location = location - 1; } if (thread != null) { CallCmd command = predecessor.Block.Cmds[thread.Value] as CallCmd; Barrier barrier = Barriers.Where(x => x.Value.Call == command).Select(x => x.Value).FirstOrDefault(); if (barrier != null && !LoopBarriers[edge].Contains(barrier)) { LoopBarriers[edge].Add(barrier); } } if (grid != null) { CallCmd command = predecessor.Block.Cmds[grid.Value] as CallCmd; Barrier barrier = Barriers.Where(x => x.Value.Call == command).Select(x => x.Value).FirstOrDefault(); if (barrier != null && !LoopBarriers[edge].Contains(barrier)) { LoopBarriers[edge].Add(barrier); } } } } }
public ProgramGraph CreateUnrolledProgramGraph(int k) { ProgramGraph g = new ProgramGraph(); ValueNode[] ap = new ValueNode[k + 1]; ValueNode[] bp = new ValueNode[k + 1]; ValueNode[] s = new ValueNode[k + 1]; ValueNode[] cp = new ValueNode[k + 1]; ValueNode[] dp = new ValueNode[k + 1]; ValueNode[] t = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { ap[i] = new TestRegisterNode("a[" + i + "]", Datatype.AddressValue); bp[i] = new TestRegisterNode("b[" + i + "]", Datatype.AddressValue); s[i] = new TestRegisterNode("s[" + i + "]", Datatype.FloatValue); g.AddNode(ap[i]); g.AddNode(bp[i]); g.AddNode(s[i]); cp[i] = new TestRegisterNode("c[" + i + "]", Datatype.AddressValue); dp[i] = new TestRegisterNode("d[" + i + "]", Datatype.AddressValue); t[i] = new TestRegisterNode("t[" + i + "]", Datatype.FloatValue); g.AddNode(cp[i]); g.AddNode(dp[i]); g.AddNode(t[i]); } for (int i = 0; i < k; i++) { CreateSingleLoop( g, ap[i], bp[i], s[i], ap[i + 1], bp[i + 1], s[i + 1]); CreateSingleLoop( g, cp[i], dp[i], t[i], cp[i + 1], dp[i + 1], t[i + 1]); } g.InitInputValues(); g.InitOutputValues(); g.CyclicDependencies[s[0]] = s[k]; g.CyclicDependencies[s[k]] = s[0]; g.CyclicDependencies[ap[0]] = ap[k]; g.CyclicDependencies[ap[k]] = ap[0]; g.CyclicDependencies[bp[0]] = bp[k]; g.CyclicDependencies[bp[k]] = bp[0]; g.CyclicDependencies[t[0]] = t[k]; g.CyclicDependencies[t[k]] = t[0]; g.CyclicDependencies[cp[0]] = cp[k]; g.CyclicDependencies[cp[k]] = cp[0]; g.CyclicDependencies[dp[0]] = dp[k]; g.CyclicDependencies[dp[k]] = dp[0]; return g; }
public ProgramGraph CreateUnrolledProgramGraph(int k) { ProgramGraph g = new ProgramGraph(); ValueNode[] px = new ValueNode[k]; ValueNode[] x = new ValueNode[k]; ValueNode[] py = new ValueNode[k]; ValueNode[] my = new ValueNode[k]; ValueNode[] y = new ValueNode[k]; OperationNode[] lx = new OperationNode[k]; OperationNode[] sy = new OperationNode[k]; for (int i = 0; i < k; i++) { px[i] = new FloatMemoryNode("x[" + i + "]"); lx[i] = new LoadOperationNode(); x[i] = new FloatRegisterNode(); g.AddNode(px[i]); g.AddNode(lx[i]); g.AddNode(x[i]); g.AddEdge(px[i], lx[i]); g.AddEdge(lx[i], x[i]); y[i] = new FloatRegisterNode(); py[i] = new FloatMemoryNode("y[" + i + "]"); sy[i] = new StoreOperationNode(); my[i] = new FloatMemoryNode(null); g.AddNode(y[i]); g.AddNode(py[i]); g.AddNode(sy[i]); g.AddNode(my[i]); g.AddEdge(y[i], sy[i]); g.AddEdge(py[i], sy[i]); g.AddEdge(sy[i], my[i]); } ValueNode[] x0 = new ValueNode[k + 1]; ValueNode[] x1 = new ValueNode[k + 1]; for (int i = 0; i < k + 1; i++) { x0[i] = new FloatRegisterNode(); x1[i] = new FloatRegisterNode(); g.AddNode(x0[i]); g.AddNode(x1[i]); } ValueNode px00 = new FloatMemoryNode("x0[0]"); ValueNode px10 = new FloatMemoryNode("x1[0]"); OperationNode lx00 = new LoadOperationNode(); OperationNode lx10 = new LoadOperationNode(); g.AddNode(px00); g.AddNode(px10); g.AddNode(lx00); g.AddNode(lx10); g.AddEdge(px00, lx00); g.AddEdge(lx00, x0[0]); g.AddEdge(px10, lx10); g.AddEdge(lx10, x1[0]); ValueNode px0k = new FloatMemoryNode("x0[" + k + "]"); ValueNode px1k = new FloatMemoryNode("x1[" + k + "]"); ValueNode mx0k = new FloatMemoryNode(null); ValueNode mx1k = new FloatMemoryNode(null); OperationNode sx0k = new StoreOperationNode(); OperationNode sx1k = new StoreOperationNode(); g.AddNode(px0k); g.AddNode(px1k); g.AddNode(mx0k); g.AddNode(mx1k); g.AddNode(sx0k); g.AddNode(sx1k); g.AddEdge(x0[k], sx0k); g.AddEdge(px0k, sx0k); g.AddEdge(sx0k, mx0k); g.AddEdge(x1[k], sx1k); g.AddEdge(px1k, sx1k); g.AddEdge(sx1k, mx1k); ValueNode pc0 = new FloatMemoryNode("c0"); ValueNode pc1 = new FloatMemoryNode("c1"); ValueNode pc2 = new FloatMemoryNode("c2"); ValueNode pc3 = new FloatMemoryNode("c3"); ValueNode pc4 = new FloatMemoryNode("c4"); OperationNode lc0 = new LoadOperationNode(); OperationNode lc1 = new LoadOperationNode(); OperationNode lc2 = new LoadOperationNode(); OperationNode lc3 = new LoadOperationNode(); OperationNode lc4 = new LoadOperationNode(); ValueNode c0 = new FloatRegisterNode(); ValueNode c1 = new FloatRegisterNode(); ValueNode c2 = new FloatRegisterNode(); ValueNode c3 = new FloatRegisterNode(); ValueNode c4 = new FloatRegisterNode(); g.AddNode(pc0); g.AddNode(pc1); g.AddNode(pc2); g.AddNode(pc3); g.AddNode(pc4); g.AddNode(lc0); g.AddNode(lc1); g.AddNode(lc2); g.AddNode(lc3); g.AddNode(lc4); g.AddNode(c0); g.AddNode(c1); g.AddNode(c2); g.AddNode(c3); g.AddNode(c4); g.AddEdge(pc0, lc0); g.AddEdge(lc0, c0); g.AddEdge(pc1, lc1); g.AddEdge(lc1, c1); g.AddEdge(pc2, lc2); g.AddEdge(lc2, c2); g.AddEdge(pc3, lc3); g.AddEdge(lc3, c3); g.AddEdge(pc4, lc4); g.AddEdge(lc4, c4); for (int i = 0; i < k; i++) { CreateSingleFilterLoop( g, x[i], x0[i], x1[i], c0, c1, c2, c3, c4, x0[i + 1], x1[i + 1], y[i]); } g.InitInputValues(); g.InitOutputValues(); return g; }
/// <summary> /// Initilaizes an instance of <see cref="GraphAnalyzer"/>. /// </summary> /// <param name="program">The boogie program.</param> public GraphAnalyzer(Microsoft.Boogie.Program program) { Graph = new ProgramGraph(program); }