if ( doCacheOptimization ) {
if ( doCacheOptimization && KjcOptions.peekratio != 1024) {
    public static void run(SIRStream str,			   JInterfaceDeclaration[] 			   interfaces,			   SIRInterfaceTable[]			   interfaceTables,			   SIRStructure[]			   structs) {	HashMap[] exec_counts1;	HashMap[] exec_counts2;	boolean doCacheOptimization = KjcOptions.cacheopt;	int code_cache = 16000;	int data_cache = 16000;	System.out.println("Entry to Cluster Backend");	System.out.println("  --cluster parameter is: "+KjcOptions.cluster);	System.out.println("  peekratio is: "+KjcOptions.peekratio);	System.out.println("  rename1 is: "+KjcOptions.rename1);	System.out.println("  rename2 is: "+KjcOptions.rename2);	structures = structs;		// set number of columns/rows 	//RawBackend.rawRows = KjcOptions.raw;	//if(KjcOptions.rawcol>-1)	//    RawBackend.rawColumns = KjcOptions.rawcol;	//else	//    RawBackend.rawColumns = KjcOptions.raw;	//simulator = new FineGrainSimulator();	//this must be run now, FlatIRToC relies on it!!!	RenameAll.renameAllFilters(str);		// move field initializations into init function	System.out.print("Moving initializers into init functions... ");	FieldInitMover.moveStreamInitialAssignments(str,	      FieldInitMover.IGNORE_ARRAY_INITIALIZERS);	System.out.println("done.");		// propagate constants and unroll loop	System.out.print("Running Constant Prop and Unroll...");	Unroller.setLimitNoTapeLoops(true, 4);	ConstantProp.propagateAndUnroll(str);	System.out.println(" done.");        // add initPath functions        EnqueueToInitPath.doInitPath(str);	// construct stream hierarchy from SIRInitStatements	ConstructSIRTree.doit(str);	if (Flattener.hasDynamicRates(str)) {	    System.err.println("Failure: Dynamic rates are not yet supported in the cluster backend.");	    System.exit(1);	}	//SIRPrinter printer1 = new SIRPrinter();	//str.accept(printer1);	//printer1.close();	//VarDecl Raise to move array assignments up	new VarDeclRaiser().raiseVars(str);        // do constant propagation on fields	System.out.print("Running Constant Field Propagation...");	FieldProp.doPropagate(str);	System.out.println(" done.");	//System.out.println("Analyzing Branches..");	//new BlockFlattener().flattenBlocks(str);	//new BranchAnalyzer().analyzeBranches(str);	SIRPortal.findMessageStatements(str);	// optimize so that IncreaseFilterMult has accurate estimates	// of code size	Optimizer.optimize(str); 	Estimator.estimate(str);	Lifter.liftAggressiveSync(str);	//StreamItDot.printGraph(str, "before-partition.dot");	// gather application-characterization statistics	if (KjcOptions.stats) {	    StatisticsGathering.doit(str);	}	str = Flattener.doLinearAnalysis(str);	str = Flattener.doStateSpaceAnalysis(str);	// Calculate SIRSchedule before increasing multiplicity	StreamItDot.printGraph(str, "before-peekmult.dot");	exec_counts1 = SIRScheduler.getExecutionCounts(str);	// Increasing filter Multiplicity	if ( doCacheOptimization ) {	    IncreaseFilterMult.inc(str, 1, code_cache);	    //}	/* for cluster backend, fusion means to fuse segments on same cluster	if (KjcOptions.fusion) {	    System.out.println("Running FuseAll...");	    str = FuseAll.fuse(str);	    Lifter.lift(str);	    System.out.println("Done FuseAll...");	}	*/	Optimizer.optimize(str);	Estimator.estimate(str);	int threads = KjcOptions.cluster;	HashMap partitionMap = new HashMap();	if ( doCacheOptimization ) {	    boolean decreased;	    str = new CachePartitioner(str, WorkEstimate.getWorkEstimate(str), 0, code_cache, data_cache).calcPartitions(partitionMap);	    decreased = IncreaseFilterMult.decreaseMult(partitionMap);	    if (decreased) {		// Repartition second time		str = new CachePartitioner(str, WorkEstimate.getWorkEstimate(str), 0, code_cache, data_cache).calcPartitions(partitionMap);		decreased = IncreaseFilterMult.decreaseMult(partitionMap);	    }	}	// Calculate SIRSchedule after increasing multiplicity	StreamItDot.printGraph(str, "after-peekmult.dot");	exec_counts2 = SIRScheduler.getExecutionCounts(str);	//exec_counts2 = SIRScheduler.getExecutionCounts(str);	//find out how what is the schedule multiplicity due to	//peek scaling	HashMap steady1 = exec_counts1[1];	HashMap steady2 = exec_counts2[1];		int implicit_mult =	    IncreaseFilterMult.scheduleMultAfterScaling(steady1, steady2);	System.out.println("Implicit schedule mult increase due to peek scaling is: "+implicit_mult);	System.err.println("Running Partitioning... target number of threads: "+threads);	StreamItDot.printGraph(str, "before-partition.dot");	// actually fuse components if fusion flag is enabled	if (KjcOptions.fusion) {	    // turn on dynamic programming if no other partitioning is turned on	    if (!KjcOptions.partition_greedy && !KjcOptions.partition_greedier) {		KjcOptions.partition_dp = true;	    }	    	    if ( doCacheOptimization ) {		str = CachePartitioner.doit(str, code_cache, data_cache);	    } else {				str = Partitioner.doit(str, 0, threads, false, false);	    }	    /*	    if (str instanceof SIRContainer) {		((SIRContainer)str).reclaimChildren();	    }	    */	} 	//HashMap partitionMap = new HashMap();	partitionMap.clear();	if ( doCacheOptimization ) {	    str = new CachePartitioner(str, WorkEstimate.getWorkEstimate(str), 0, code_cache, data_cache).calcPartitions(partitionMap);	} else {	    // Fix up a bug that might be caused by previous 	    // pass of partitioner	    str.setParent(null); 	    str = new DynamicProgPartitioner(str, WorkEstimate.getWorkEstimate(str), threads, false, false).calcPartitions(partitionMap);		}		System.err.println("Done Partitioning...");	Unroller.setLimitNoTapeLoops(false, 0);	if (KjcOptions.sjtopipe) {	    SJToPipe.doit(str);	}	StreamItDot.printGraph(str, "after-partition.dot");	//VarDecl Raise to move array assignments up	new VarDeclRaiser().raiseVars(str);		//VarDecl Raise to move peek index up so	//constant prop propagates the peek buffer index	new VarDeclRaiser().raiseVars(str);	// optionally print a version of the source code that we're	// sending to the scheduler	if (KjcOptions.print_partitioned_source) {	    new streamit.scheduler2.print.PrintProgram().printProgram(IterFactory.createFactory().createIter(str)); 	}	//run constrained scheduler       	System.out.print("Constrained Scheduler Begin...");	//topStreamIter = IterFactory.createFactory().createIter(str);	topStreamIter = IterFactory.createFineGrainedFactory().createIter(str);	//new streamit.scheduler2.print.PrintGraph().printProgram(topStreamIter);	//new streamit.scheduler2.print.PrintProgram().printProgram(topStreamIter);	if (KjcOptions.debug) {	    debugOutput(str);	}       	System.out.println(" done.");	// end constrained scheduler       	System.out.println("Flattener Begin...");	executionCounts = SIRScheduler.getExecutionCounts(str);	PartitionDot.printScheduleGraph(str, "schedule.dot", executionCounts);	GraphFlattener graphFlattener = new GraphFlattener(str);	//graphFlattener.dumpGraph("flatgraph.dot");	System.out.println("Flattener End.");	//create the execution counts for other passes	createExecutionCounts(str, graphFlattener);	////////////////////////////////////////////////	// the cluster specific code begins here	NodeEnumerator.reset();	graphFlattener.top.accept(new NodeEnumerator(), new HashSet(), true);	graphFlattener.top.accept(new RegisterStreams(), new HashSet(), true);	DiscoverSchedule d_sched = new DiscoverSchedule();	graphFlattener.top.accept(d_sched, new HashSet(), true);	d_sched.findPhases();	if (KjcOptions.removeglobals) {	    RemoveGlobals.doit(graphFlattener.top);	}	StructureIncludeFile.doit(structures, graphFlattener.top);	/// start output portals	SIRPortal portals[] = SIRPortal.getPortals();	LatencyConstraints.detectConstraints(topStreamIter, portals);		/// end output portals		//VarDecl Raise to move array assignments down?	new VarDeclRaiser().raiseVars(str);	// creating filter2Node	filter2Node = new HashMap();	graphFlattener.top.accept(new ClusterBackend(), null, true); 	//generating code for partitioned nodes	//ClusterExecutionCode.doit(graphFlattener.top);	System.out.println("Cluster Code begin...");	ClusterFusion.setPartitionMap(partitionMap);	if (KjcOptions.fusion) {	    graphFlattener.top.accept(new ClusterFusion(), new HashSet(), true);	}	ClusterCode.setPartitionMap(partitionMap);	ClusterCode.generateCode(graphFlattener.top);	FusionCode.generateFusionHeader();	FusionCode.generateFusionFile(d_sched, implicit_mult);	ClusterCode.generateMasterFile();	ClusterCode.generateMakeFile();	ClusterCode.generateConfigFile();	ClusterCode.generateSetupFile();	System.out.println("Cluster Code End.");		/*	//generate the makefiles	System.out.println("Creating Makefile.");	MakefileGenerator.createMakefile();	*/	System.out.println("Exiting");	System.exit(0);    }    /**     * Just some debugging output.     */    private static void debugOutput(SIRStream str) {	streamit.scheduler2.constrained.Scheduler cscheduler =	    new streamit.scheduler2.constrained.Scheduler(topStreamIter);	//cscheduler.computeSchedule(); //"Not Implemented"	if (!(str instanceof SIRPipeline)) return;		int pipe_size = ((SIRPipeline)str).size();		SIRFilter first = (SIRFilter)((SIRPipeline)str).get(0);	SIRFilter last = (SIRFilter)((SIRPipeline)str).get(pipe_size-1);	streamit.scheduler2.iriter.Iterator firstIter = 	    IterFactory.createFactory().createIter(first);	streamit.scheduler2.iriter.Iterator lastIter = 	    IterFactory.createFactory().createIter(last);		streamit.scheduler2.SDEPData sdep;	try {	    sdep = cscheduler.computeSDEP(firstIter, lastIter);	    System.out.println("\n");	    System.out.println("Source --> Sink Dependency:\n");	    System.out.println("  Source Init Phases: "+sdep.getNumSrcInitPhases());	    System.out.println("  Destn. Init Phases: "+sdep.getNumDstInitPhases());	    System.out.println("  Source Steady Phases: "+sdep.getNumSrcSteadyPhases());	    System.out.println("  Destn. Steady Phases: "+sdep.getNumDstSteadyPhases());	    	    	    /*	    for (int t = 0; t < 20; t++) {		int phase = sdep.getSrcPhase4DstPhase(t);		int phaserev = sdep.getDstPhase4SrcPhase(t);		System.out.println("sdep ["+t+"] = "+phase+				   " reverse_sdep["+t+"] = "+phaserev);	    }	    */	} catch (streamit.scheduler2.constrained.NoPathException ex) {	}	DoSchedules.findSchedules(topStreamIter, firstIter, str);    }