Beispiel #1
0
        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]);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        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]);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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;
        }