Filter.fillScheduleFields(scheduler);
    public void run(String args[])    {        boolean scheduledRun = true;        boolean printGraph = true;        boolean doRun = true;        boolean singeappsched = false;        boolean printSDEP = false;        String sdepTOPString = null, sdepBOTTOMString = null;        int nIters = -1;        // read the args:        if (args != null)        {            int length = args.length;            int index;            for (index = 0; index < length; index++)            {                if (args[index].equals("-nosched"))                {                    scheduledRun = false;                }                else if (args[index].equals("-printgraph"))                {                    printGraph = true;                }                else if (args[index].equals("-i"))                {                    index++;                    nIters = Integer.valueOf(args[index]).intValue();                }                else if (args[index].equals("-marksteady"))                {                    marksteady = true;                }                else if (args[index].equals("-printsched"))                {                    printsched = true;                }                else if (args[index].equals("-printreps"))                {                    printreps = true;                }                else if (args[index].equals("-norun"))                {                    doRun = false;                }                else if (args[index].equals("-singeappsched"))                {                    singeappsched = true;                }                else if (args[index].equals("-finegrained"))                {                    finegrained = true;                }                else if (args[index].equals("-printsdep"))                {                    printSDEP = true;                    sdepTOPString = args[index + 1];                    sdepBOTTOMString = args[index + 2];                    index += 2;                }                else                {                    ERROR("Unrecognized argument: " + args[index] + ".");                }            }        }        setupOperator();        if (getInputChannel() != null)            throw new IllegalArgumentException(            "The toplevel stream can't have any input or output channels,\n"            + "but in this program there is an input to the first filter.");        if (getOutputChannel() != null)            throw new IllegalArgumentException(            "The toplevel stream can't have any input or output channels,\n"            + "but in this program there is an output of the last filter.");        if (finegrained)        {            streamit.library.iriter.SplitJoinIter.fineGrained = true;            streamit.library.Splitter.finegrained = true;            streamit.library.Joiner.finegrained = true;        }        // setup the scheduler        if (printGraph)        {            Iterator selfIter = new streamit.library.iriter.Iterator(this);            new PrintGraph().printProgram(selfIter);        }        // compute latency from top to bottom        if (printSDEP)            try            {                Stream top = getStreamFromString(sdepTOPString);                Stream bottom = getStreamFromString(sdepBOTTOMString);                Iterator selfIter =                    new streamit.library.iriter.Iterator(this);                streamit.scheduler2.constrained.Scheduler sched =                    new streamit.scheduler2.constrained.Scheduler(selfIter);                streamit.scheduler2.SDEPData sdep =                    sched.computeSDEP(                        new streamit.library.iriter.Iterator(top),                        new streamit.library.iriter.Iterator(bottom));                System.out.println("Init SDEP:");                System.out.println("Upstream Downstream");                for (int n = 0; n < sdep.getNumDstInitPhases(); n++)                {                    System.out.println(                        "  "                            + sdep.getSrcPhase4DstPhase(n)                            + "         "                            + n);                }                System.out.println(                    "Total: "                        + sdep.getNumSrcInitPhases()                        + " "                        + sdep.getNumDstInitPhases()                        + "\n");                System.out.println("Steady SDEP:");                System.out.println("Upstream Downstream");                for (int n = 0; n < sdep.getNumDstSteadyPhases(); n++)                {                    System.out.println(                        "  "                            + (sdep                                .getSrcPhase4DstPhase(                                    n + sdep.getNumDstInitPhases()))                            + "         "                            + (n + sdep.getNumDstInitPhases()));                }                System.out.println(                    "Total: "                        + sdep.getNumSrcSteadyPhases()                        + " "                        + sdep.getNumDstSteadyPhases()                        + "\n");            }            catch (NoPathException x)            {                ERROR(x);            }        // setup the scheduler        if (scheduledRun)        {            Iterator selfIter = new streamit.library.iriter.Iterator(this);            streamit.scheduler2.Scheduler scheduler;            if (singeappsched)                scheduler =                    new streamit.scheduler2.singleappearance.Scheduler(                        selfIter);            else                scheduler =                    new streamit.scheduler2.minlatency.Scheduler(selfIter);            /*scheduler =                new streamit.scheduler2.constrained.Scheduler(selfIter);*/            scheduler.computeSchedule();            scheduler.computeBufferUse();            Schedule initSched = scheduler.getOptimizedInitSchedule();            Schedule steadySched = scheduler.getOptimizedSteadySchedule();            // setup the buffer lengths for the stream setup here:            setupBufferLengths(scheduler);            totalSize = this.computeSize(initSched, true);            totalSize += this.computeSize(steadySched, true);            int mlSize = totalSize;            int mlBuffer = totalBuffer;            if (printsched)            {                scheduler.printOptimizedSchedule();                System.out.println("!ml sched size = " + mlSize);                System.out.println("!ml buff size = " + mlBuffer);            }	    // print number of steady state executions for every leaf	    // of schedule	    if (printreps) {		scheduler.printReps();	    }            if (!doRun)                System.exit(0);            // run the init schedule:            if (nIters != 0)                runSchedule(initSched, 1);            //nIters = 0;            // and run the steady schedule forever:            while (nIters != 0)            {                runSchedule(steadySched, 1);                if (marksteady)                    System.out.print("*");                if (nIters > 0)                    nIters--;            }        }        else        {            if (!doRun)                System.exit(0);            while (true)            {                runSinks();                drainChannels();            }        }    }