System.out.println("REMAINING ITEMS: " + filterInfo.remaining);
SpaceTimeBackend.println("REMAINING ITEMS: " + filterInfo.remaining);
    private static void createCommunicationCode(FilterTraceNode node, Trace parent,                                             FilterInfo filterInfo, boolean init, boolean primePump,                                             boolean linear, RawTile tile, RawChip rawChip) {        int mult, sentItems = 0;        // don't cache align if the only source is a file reader        boolean cacheAlignSource = true;        // should we generate switch receive code        boolean switchReceiveCode = true;        if (node.getPrevious() instanceof InputTraceNode) {            IntraTraceBuffer buf =                 IntraTraceBuffer.getBuffer((InputTraceNode) node.getPrevious(), node);            //don't worry about handling non-cache-sized transfers if the            //source is a file reader, use the upstream non-redundant buffer            //for this because it is the one that is connect to the file reader            if (((InputTraceNode)node.getPrevious()).onlyFileInput())                cacheAlignSource = false;                        //don't generate switch code for receiving if this filter is the            //first in a trace and it gets its input from the dynamic network            if (buf != null && !buf.isStaticNet())                switchReceiveCode = false;        }        //should we generate switch send code??        boolean switchSendCode = true;        //shoud we cache align the sending code               boolean cacheAlignDest = true;        if (node.getNext() instanceof OutputTraceNode) {            OutputTraceNode output = (OutputTraceNode) node.getNext();            //don't cache align the dest if the true dest is a file writer            //that is not split            if (output.onlyWritingToAFile())                cacheAlignDest = false;                        //don't generate switch code for sending if the buffer is             //allocated to use the gdn            if (!IntraTraceBuffer.getBuffer(node, output).isStaticNet())                switchSendCode = false;        }                mult = filterInfo.getMult(init, primePump);        // should we compress the switch code??        boolean switchCompression = SWITCH_COMP && mult > SC_THRESHOLD && !init;        if (!(init || primePump || !linear)) { // Linear switch code in            // steadystate            /*             * if(primePump) { int bufferSize; FilterContent             * content=filterInfo.traceNode.getFilter(); final int             * pos=content.getPos(); final int peek=content.getPeek(); final int             * pop = content.getPopCount(); int index=content.getTotal()-pos-1;             * if(index==0) //If first tile bufferSize=filterInfo.remaining;             * else { //Find first tile TraceNode curNode=node; for(int             * i=index;i>0;i--) curNode=curNode.getPrevious(); FilterInfo             * parentInfo=FilterInfo.getFilterInfo((FilterTraceNode)curNode);             * bufferSize=parentInfo.remaining; } if(filterInfo.initMult>0)             * bufferSize+=peek-pop;             * createInitLinearSwitchCode(node,filterInfo,mult,bufferSize,tile,rawChip); }             * else             */            createLinearSwitchCode(node, filterInfo, mult, tile, rawChip);            sentItems += mult;        } else if (switchCompression) {            assert mult > 1;            sentItems = filterInfo.push * mult;            filterSwitchCodeCompressed(mult, node, filterInfo, init, primePump,                                       tile, rawChip, switchSendCode, switchReceiveCode);        } else {            for (int i = 0; i < mult; i++) {                // append the receive code but only if we are using the static net                                if (switchReceiveCode)                    createReceiveCode(i, node, filterInfo, init, primePump, tile,                            rawChip, false);                // append the send code, but only if we are using the static net                if (switchSendCode)                    sentItems += createSendCode(i, node, filterInfo, init,                                            primePump, tile, rawChip, false);            }        }                if (init)            System.out.println("REMAINING ITEMS: " + filterInfo.remaining);        // now we must take care of the generating switch code for the remaining items         // on the input tape after the initialization phase if the upstream filter         // produces more than we consume in init         if (init && filterInfo.remaining > 0 && switchReceiveCode) {            appendReceiveInstructions(node, filterInfo.remaining                                      * Util.getTypeSize(node.getFilter().getInputType()),                                      filterInfo, init, false, tile, rawChip);        }        // we must add some switch instructions to account for the fact        // that we must transfer cacheline sized chunks in the streaming dram        // do it for the init and the steady state, primepump                // generate code to fill the remainder of the cache line        if (/*!KjcOptions.magicdram && */ node.getNext().isOutputTrace()            && cacheAlignDest && switchSendCode) {            //perform the filling in the switch if we are using the static net            fillCacheLineStatic(rawChip, node, init, primePump, sentItems);        }                // because all dram transfers must be multiples of cacheline        // generate code to disregard the remainder of the transfer        if (/*!KjcOptions.magicdram && */ node.getPrevious().isInputTrace()            && cacheAlignSource && switchReceiveCode) {            //perform the disregarding in the switch if we are static            handleUnneededInputStatic(rawChip, node, init, primePump,                     filterInfo.totalItemsReceived(init, primePump));                                       }    }