print("    }\n"); print("    last = msg;\n");
print("    } else { last = msg; }\n");
    public void visitFilter(SIRFilter self,			    SIRFilterIter iter) {	filter = self;	selfID = NodeEnumerator.getSIROperatorId(self); // needed by the class	method_names = new HashSet();	JMethodDeclaration[] meth = self.getMethods();	for (int i = 0; i < meth.length; i++) {	    method_names.add(meth[i].getName());	}	HashSet sendsCreditsTo = LatencyConstraints.getOutgoingConstraints(self);	boolean restrictedExecution = LatencyConstraints.isRestricted(self); 	boolean sendsCredits = (sendsCreditsTo.size() > 0);	SIRPortal outgoing[] = SIRPortal.getPortalsWithSender(self);	SIRPortal incoming[] = SIRPortal.getPortalsWithReceiver(self);		Vector sends_to = new Vector();	Vector receives_from = new Vector();	FlatNode node = NodeEnumerator.getFlatNode(selfID);	System.out.println("flat node: "+node);		Integer init_int = (Integer)ClusterBackend.initExecutionCounts.get(node);	int init_counts;	if (init_int == null) {	    init_counts = 0;	} else {	    init_counts = init_int.intValue();	}	int steady_counts = ((Integer)ClusterBackend.steadyExecutionCounts.get(node)).intValue();	for (int t = 0; t < outgoing.length; t++) {	    SIRStream[] receivers = outgoing[t].getReceivers();	    for (int i = 0; i < receivers.length; i++) {		sends_to.add(receivers[i]);	    }	}		for (int t = 0; t < incoming.length; t++) {	    SIRPortalSender[] senders = incoming[t].getSenders();	    for (int i = 0; i < senders.length; i++) {		receives_from.add(senders[i].getStream());	    }	}		int pop_n, peek_n, push_n;	pop_n = self.getPopInt();	peek_n = self.getPeekInt();	push_n = self.getPushInt();	print("// peek: "+peek_n+" pop: "+pop_n+" push "+push_n+"\n"); 	print("// init counts: "+init_counts+" steady counts: "+steady_counts+"\n"); 	print("\n");	int data = DataEstimate.filterGlobalsSize(self);	CodeEstimate est = CodeEstimate.estimate(self);	//int code = CodeEstimate.estimateCode(self);	//int locals = CodeEstimate.estimateLocals(self);	int code = est.getCodeSize();	int locals = est.getLocalsSize();	System.out.println("[globals: "+data+" locals: "+locals+" code: "+code+"]");	ClusterCodeGenerator gen = new ClusterCodeGenerator(self, self.getFields());	Vector pre = gen.generatePreamble();	for (int i = 0; i < pre.size(); i++) {	    print(pre.elementAt(i).toString());	}	//  +=============================+	//  | Method Declarations         |	//  +=============================+	JMethodDeclaration work = self.getWork();	//visit methods of filter, print the declaration first	declOnly = true;	JMethodDeclaration[] methods = self.getMethods();	for (int i =0; i < methods.length; i++) {	    if (!methods[i].equals(work)) methods[i].accept(this);	}	print("\n");	print("inline void check_status__"+selfID+"();\n");	print("void check_messages__"+selfID+"();\n");	print("void handle_message__"+selfID+"(netsocket *sock);\n");	print("void send_credits__"+selfID+"();\n");	print("\n");	//  +=============================+	//  | Push / Pop                  |	//  +=============================+	CType input_type = self.getInputType();	CType output_type = self.getOutputType();	NetStream in = RegisterStreams.getFilterInStream(self);	NetStream out = RegisterStreams.getFilterOutStream(self);	int out_pop_buffer_size = 10240;	int out_pop_num_iters = 0;	if (push_n != 0) out_pop_num_iters = out_pop_buffer_size / push_n;	if (out != null) {	    //print(output_type.toString()+" "+out.pop_buffer()+"["+push_n+"];\n");	    //print("int "+out.pop_index()+" = "+push_n+";\n");	    print(output_type.toString()+" "+out.pop_buffer()+"["+out_pop_buffer_size+"];\n");	    print("int "+out.pop_index()+" = "+(out_pop_num_iters*push_n)+";\n");	    	    print("\n");	}	if (in != null) {	    FlatNode source_node = NodeEnumerator.getFlatNode(in.getSource());	    FlatNode my_node = NodeEnumerator.getFlatNode(selfID);	    //String pop_expr = null;	    FlatNode source_master = ClusterFusion.getLocalMaster(source_node);	    boolean source_fused = (source_master != null && source_master.equals(my_node)); 	    	    //if  { 	    //	pop_expr = in.pop_name();	    //} else {	    //	pop_expr = in.consumer_name()+".pop";	    //}	    int peek_buf_size = 1;	    while (peek_buf_size < peek_n) {		peek_buf_size *= 2;	    }	    print(input_type.toString()+" __pop_buf__"+selfID+"["+peek_buf_size+"];\n");	    print("int __head__"+selfID+";\n");	    print("int __tail__"+selfID+";\n");	    print("\n");	    int extra = peek_n - pop_n;	    	    //assert (extra >= 0);	    if (extra < 0) extra = 0;	    print("inline void __init_pop_buf__"+selfID+"() {\n");				    for (int i = 0; i < extra; i++) {					print("  __pop_buf__"+selfID+"["+i+"]=");				if (source_fused) { 		    print(in.pop_name()+"();\n");		} else {		    print(in.consumer_name()+".pop();\n");		}	    }	    print("  __tail__"+selfID+"=0;\n");	    print("  __head__"+selfID+"="+extra+";\n");				/*		if (source_fused) { 		    for (int y = 0; y < extra; y++) {			int index = y + pop_n;						print("  __pop_buf__"+selfID+"["+index+"] = "+in.pop_name()+"();\n");		    }		} else {		    if (pop_n < 8) {						for (int i = 0; i < extra; i++) {						    print("  __pop_buf__"+selfID+"["+(pop_n+i)+"] = "+in.consumer_name()+".pop();\n");			}					    } else {						print("  "+in.consumer_name()+".pop_items(&__pop_buf__"+selfID+"["+pop_n+"], "+extra+");\n");		    }		}		*/	    	    print("}\n");	    print("\n");	    print("void save_peek_buffer__"+selfID+"(object_write_buffer *buf) {\n");	    print("  int i = 0, offs = __tail__"+selfID+";\n");	    print("  while (offs != __head__"+selfID+") {\n");	    print("    buf->write(&__pop_buf__"+selfID+"[offs], sizeof("+input_type.toString()+"));\n    offs++;\n    offs&="+(peek_buf_size-1)+";\n    i++;\n");	    print("  }\n");	    //print("  printf(\"buf size: %d\\n\", i);\n"); 	    print("  assert(i == "+extra+");\n");	    print("}\n");	    print("\n");	    print("void load_peek_buffer__"+selfID+"(object_write_buffer *buf) {\n");	    print("  for (int i = 0; i < "+extra+"; i++) {\n");	    print("     buf->read(&__pop_buf__"+selfID+"[i] , sizeof("+input_type.toString()+"));\n");	    print("  }\n");	    print("  __tail__"+selfID+"=0;\n");	    print("  __head__"+selfID+"="+extra+";\n");	    print("}\n");	    print("\n");	    print("inline void __update_pop_buf__"+selfID+"() {\n");	    	    if (peek_n <= pop_n) {		// no peek beyond pop		for (int i = 0; i < pop_n; i++) {		    print("  __pop_buf__"+selfID+"["+i+"]=");		    		    if (source_fused) { 			print(in.pop_name()+"();");		    } else {			print(in.consumer_name()+".pop();");		    }		    print("\n");		}		print("  __tail__"+selfID+" = 0;\n");		print("  __head__"+selfID+" = "+pop_n+";\n");	    } else {		// peek beyond pop => circular buffer		for (int i = 0; i < pop_n; i++) {		    		    print("  __pop_buf__"+selfID+"[__head__"+selfID+"]=");		    		    if (source_fused) { 			print(in.pop_name()+"();");		    } else {			print(in.consumer_name()+".pop();");		    }		    		    print("__head__"+selfID+"++;");		    print("__head__"+selfID+"&="+(peek_buf_size-1)+";\n");		}	    }	    /*	    print("  __pop_index__"+selfID+" = 0;\n");	    int extra = peek_n - pop_n;	    for (int y = 0; y < extra; y++) {		int index = y + pop_n;		print("  __pop_buf__"+selfID+"["+y+"] = __pop_buf__"+selfID+"["+index+"];\n");	    }	    if (source_fused) {	    		for (int y = 0; y < pop_n; y++) {		    int index = y + extra;		    print("  __pop_buf__"+selfID+"["+index+"] = "+in.pop_name()+"();\n");		}	    } else {		if (pop_n < 8) {		    		    for (int i = 0; i < pop_n; i++) {						print("  __pop_buf__"+selfID+"["+(extra+i)+"] = "+in.consumer_name()+".pop();\n");		    }		} else {		    		    print("  "+in.consumer_name()+".pop_items(&__pop_buf__"+selfID+"["+extra+"], "+pop_n+");\n");		}	    }	    */	    	    print("}\n");	    print("\n");	    int s = in.getSource();	    int d = in.getDest();	    print("#ifdef __FUSED_"+s+"_"+d+"\n");	    	    // the filter is fused with its source 	    print("\n");	    print("  extern "+input_type.toString()+" BUFFER_"+s+"_"+d+"[];\n");	    print("  extern volatile int HEAD_"+s+"_"+d+";\n");	    print("  extern volatile int TAIL_"+s+"_"+d+";\n");	    //print("  extern int HEAD_"+s+"_"+d+";\n");	    //print("  extern int TAIL_"+s+"_"+d+";\n");	    print("\n");	    // pop from fusion buffer	    print("  inline "+input_type.toString()+" __pop__"+selfID+"() {\n");	    print("    "+input_type.toString()+" res=BUFFER_"+s+"_"+d+"[TAIL_"+s+"_"+d+"];\n");	    print("    TAIL_"+s+"_"+d+"++;\n");	    print("    #ifndef __NOMOD_"+s+"_"+d+"\n");	    print("    TAIL_"+s+"_"+d+"&=__BUF_SIZE_MASK_"+s+"_"+d+";\n");	    print("    #endif\n");	    print("    return res;\n");	    print("  }\n");	    print("\n");	    // peek from fusion buffer	    print("  inline "+input_type.toString()+" __peek__"+selfID+"(int offs) {\n");	    print("    #ifdef __NOMOD_"+s+"_"+d+"\n");	    print("    return BUFFER_"+s+"_"+d+"[TAIL_"+s+"_"+d+"+offs];\n");	    print("    #else\n");	    print("    return BUFFER_"+s+"_"+d+"[(TAIL_"+s+"_"+d+"+offs)&__BUF_SIZE_MASK_"+s+"_"+d+"];\n");	    print("    #endif\n");	    print("  }\n");	    print("\n");	    // the source is not fused	    print("#else //!__FUSED_"+s+"_"+d+"\n");	    print("\n");	    print("  inline "+input_type.toString()+" __pop__"+selfID+"() {\n");	    if (peek_n <= pop_n) {		print("    return __pop_buf__"+selfID+"[__tail__"+selfID+"++];\n");	    } else {		print("    "+input_type.toString()+" res=__pop_buf__"+selfID+"[__tail__"+selfID+"];");		print("__tail__"+selfID+"++;");		print("__tail__"+selfID+"&="+(peek_buf_size-1)+";\n");		print("    return res;\n");	    }	    //print("  return __pop_buf__"+selfID+"[__pop_index__"+selfID+"++];\n");	    print("  }\n");	    print("\n");	    print("  inline "+input_type.toString()+" __peek__"+selfID+"(int offs) {\n");	    if (peek_n <= pop_n) {		print("    return __pop_buf__"+selfID+"[(__tail__"+selfID+"+offs)];\n");	    } else {		print("    return __pop_buf__"+selfID+"[(__tail__"+selfID+"+offs)&"+(peek_buf_size-1)+"];\n");	    }	    //print("  return __pop_buf__"+selfID+"[__pop_index__"+selfID+" + offs];\n"); 	    print("  }\n");	    print("\n"); 	    print("#endif\n");	    print("\n");	} else {       	    print("inline "+input_type.toString()+" __init_pop_buf__"+selfID+"() {}\n");	    print("inline "+input_type.toString()+" __update_pop_buf__"+selfID+"() {}\n");	    print("void save_peek_buffer__"+selfID+"(object_write_buffer *buf) {}\n");	    print("void load_peek_buffer__"+selfID+"(object_write_buffer *buf) {}\n");	    print("\n");	}	if (out != null) {	    FlatNode dst_node = NodeEnumerator.getFlatNode(out.getDest());	    FlatNode my_node = NodeEnumerator.getFlatNode(selfID);	    String push_expr = null;	    FlatNode dst_master = ClusterFusion.getLocalMaster(dst_node);	    FlatNode my_master = ClusterFusion.getLocalMaster(my_node);	    int s = out.getSource();	    int d = out.getDest();	    	    // check if the destination node is fused	    	    print("#ifdef __FUSED_"+s+"_"+d+"\n");	    print("\n");	    print("  extern "+output_type.toString()+" BUFFER_"+s+"_"+d+"[];\n");	    print("  extern int HEAD_"+s+"_"+d+";\n");	    print("  extern int TAIL_"+s+"_"+d+";\n");	    print("\n");	    print("  inline void __push__"+selfID+"("+output_type.toString()+" data) {\n");	    print("    BUFFER_"+s+"_"+d+"[HEAD_"+s+"_"+d+"]=data;\n");	    print("    HEAD_"+s+"_"+d+"++;\n");	    print("    #ifndef __NOMOD_"+s+"_"+d+"\n");	    print("    HEAD_"+s+"_"+d+"&=__BUF_SIZE_MASK_"+s+"_"+d+";\n");	    print("    #endif\n");	    print("  }\n");	    print("\n");	    // if not fused use the producer's push function	    print("#else //!__FUSED_"+s+"_"+d+"\n");	    print("\n");	    print("  inline void __push__"+selfID+"("+output_type.toString()+" data) {\n");	    if (dst_master != null && dst_master.equals(my_node)) {       		print("  "+out.push_name()+"(data);\n");		    	    } else if (my_master != null && my_master.equals(dst_node)) {		print("  "+out.pop_buffer()+"["+out.pop_index()+"++] = data;\n");	    } else {		print("  "+out.producer_name()+".push(data);\n");	    }	    	    print("  }\n");	    print("\n");	    print("#endif");	    print("\n");	}	if (in != null) {	    print("void "+in.push_name()+"("+input_type.toString()+" data) {}\n");	    print("\n");	}	print("\n");	if (out != null) {	    	    //print("void "+ClusterExecutionCode.rawMain+"__"+selfID+"();\n");	    print("void "+self.getWork().getName()+"__"+selfID+"(int);\n\n");	    print(output_type.toString()+" "+out.pop_name()+"() {\n");	    print("  int _tmp;\n");	    	    /*	    print("  if ("+out.pop_index()+" == "+push_n+") {\n");	    print("    int tmp = __number_of_iterations_"+selfID+";\n");	    print("    __number_of_iterations_"+selfID+" = 1;\n");	    print("    "+out.pop_index()+" = 0;\n");            print("    "+ClusterExecutionCode.rawMain+"__"+selfID+"();\n");	    print("    __number_of_iterations_"+selfID+" = tmp - 1;\n");	    print("    "+out.pop_index()+" = 0;\n");	    */	    print("  if ("+out.pop_index()+" == "+(out_pop_num_iters*push_n)+") {\n");	    print("    "+out.pop_index()+" = 0;\n");	    print("    for (_tmp = 0; _tmp < "+out_pop_num_iters+"; _tmp++) {\n");	    print("      //check_status__"+selfID+"();\n");	    print("      check_messages__"+selfID+"();\n");	    print("      __update_pop_buf__"+selfID+"();\n");	    print("      "+self.getWork().getName()+"__"+selfID+"(1);\n");	    print("      //send_credits__"+selfID+"();\n");	    print("    }\n");	    print("    "+out.pop_index()+" = 0;\n");	    /*	    print("    int tmp = __number_of_iterations_"+selfID+";\n");	    print("    __number_of_iterations_"+selfID+" = "+out_pop_num_iters+";\n");	    print("    "+out.pop_index()+" = 0;\n");            print("    "+ClusterExecutionCode.rawMain+"__"+selfID+"();\n");	    print("    __number_of_iterations_"+selfID+" = tmp - "+out_pop_num_iters+";\n");	    print("    "+out.pop_index()+" = 0;\n");	    */	    print("  }\n");	    print("  return "+out.pop_buffer()+"["+out.pop_index()+"++];\n");	    	    print("}\n");	    print("\n");	}	//  +=============================+	//  | Method Bodies               |	//  +=============================+	declOnly = false;	for (int i =0; i < methods.length; i++) {	    if (!methods[i].equals(work)) methods[i].accept(this);	    //methods[i].accept(this);	}	//  +=============================+	//  | Work Function (int ____n)   |	//  +=============================+	       	JBlock block = new JBlock(null, new JStatement[0], null);	JVariableDefinition counter = 	    new JVariableDefinition(null, 				    0, 				    CStdType.Integer,				    "____n",				    new JIntLiteral(0));	/*	JVariableDefinition tmp = 	    new JVariableDefinition(null, 				    0, 				    CStdType.Integer,				    "____tmp",				    new JLocalVariableExpression(null, counter)); // int ____tmp = ____n;	*/	JVariableDefinition iter_counter = 	    new JVariableDefinition(null, 				    0, 				    CStdType.Integer,				    "__counter_"+selfID,				    null);		JStatement init = new JEmptyStatement(null, null);	//VariableDeclarationStatement(null, tmp, null);	JExpression decrExpr = 	    new JPostfixExpression(null, 				   Constants.OPE_POSTDEC, 				   new JLocalVariableExpression(null,								   counter));	JStatement decr = 	    new JExpressionStatement(null, decrExpr, null);	JExpression cond = 	    new JRelationalExpression(null,				      Constants.OPE_LT,				      new JIntLiteral(0),				      new JLocalVariableExpression(null,counter));	block.addStatement(new JForStatement(null, init, cond, decr, work.getBody(),					     null));	// __counter_X = __counter_X + ____n;	/*	block.addStatement(new JExpressionStatement(						    null,						    new JAssignmentExpression							(null,							 new JLocalVariableExpression							     (null, iter_counter),							 new JAddExpression(null,									    new JLocalVariableExpression										(null, iter_counter),									    new JLocalVariableExpression										(null, counter))),						    null));								       	*/			JFormalParameter param = new JFormalParameter(null, 0, CStdType.Integer, "____n", true);	JFormalParameter params[] = new JFormalParameter[1];	params[0] = param;	JMethodDeclaration work_n = 	    new JMethodDeclaration(null, 				   at.dms.kjc.Constants.ACC_PUBLIC,				   CStdType.Void,				   work.getName(),				   params,				   CClassType.EMPTY,				   block,				   null,				   null);	work_n.accept(this);		//  +=============================+	//  | Check Messages              |	//  +=============================+	print("\nvoid check_messages__"+selfID+"() {\n");	print("  message *msg, *last = NULL;\n");	if (restrictedExecution) {	    print("  while (__credit_"+selfID+" <= __counter_"+selfID+") {\n");	}		{	    Iterator i = receives_from.iterator();	    while (i.hasNext()) {		int src = NodeEnumerator.getSIROperatorId((SIRStream)i.next());		print("  if (__msg_sock_"+src+"_"+selfID+"in->data_available()) {\n    handle_message__"+selfID+"(__msg_sock_"+src+"_"+selfID+"in);\n  } // if\n");	    }	}	if (restrictedExecution) {	    print("  } // while \n");	}	print("  for (msg = __msg_stack_"+selfID+"; msg != NULL; msg = msg->next) {\n");	print("    if (msg->execute_at <= __counter_"+selfID+") {\n");	SIRPortal[] portals = SIRPortal.getPortalsWithReceiver(self);	/* there should be only one portal or none */	if (portals.length == 1) {	    	    CClass pclass = portals[0].getPortalType().getCClass();	    CMethod pmethods[] = pclass.getMethods();	    for (int i = 0 ; i < pmethods.length; i++) {		CMethod portal_method = pmethods[i];		CType portal_method_params[] = portal_method.getParameters();		String method_name = portal_method.getIdent();		int length = method_name.length();		if (!method_name.startsWith("<") && 		    !method_name.endsWith(">")) {		    print("      if (msg->method_id == "+i+") {\n");		    for (int t = 0; t < methods.length; t++) {		    			String thread_method_name = methods[t].getName();						if (thread_method_name.startsWith(method_name) &&			    thread_method_name.charAt(length) == '_' &&			    thread_method_name.charAt(length + 1) == '_') {			    			    int param_count = methods[t].getParameters().length;			    for (int a = 0; a < param_count; a++) {				if (portal_method_params[a].toString().equals("int")) {				    print("        int p"+a+" = msg->get_int_param();\n");				}				if (portal_method_params[a].toString().equals("float")) {				    print("        float p"+a+" = msg->get_float_param();\n");				}			    }			    print("        "+thread_method_name+"__"+selfID+"(");			    for (int a = 0; a < param_count; a++) {				if (a > 0) print(", ");				print("p"+a);			    }			    print(");\n");			}		    }		    print("      }\n");		}	    }	    	    print("      if (last != NULL) { \n");	    print("        last->next = msg->next;\n");	    print("      } else {\n");	    print("        __msg_stack_"+selfID+" = msg->next;\n");	    print("      }\n");	    print("      delete msg;\n");	}	print("    }\n");	print("    last = msg;\n"); 	print("  } // for \n");	print("}\n");		//  +=============================+	//  | Handle Message              |	//  +=============================+		print("\nvoid handle_message__"+selfID+"(netsocket *sock) {\n");	print("  int size = sock->read_int();\n");		if (restrictedExecution) {	    print("  if (size == -1) { // a credit message received\n");	    print("    __credit_"+selfID+" = sock->read_int();\n");	    print("    return;\n");	    print("  };\n");	}	print("  int index = sock->read_int();\n");	print("  int iteration = sock->read_int();\n");	print("  printf(\"Message receieved! thread: "+selfID+", method_index: %d excute at iteration: %d\\n\", index, iteration);\n");	print("  if (iteration > 0) {\n");	print("    message *msg = new message(size, index, iteration);\n");	print("    msg->read_params(sock);\n");	print("    __msg_stack_"+selfID+" = msg->push_on_stack(__msg_stack_"+selfID+");\n");	print("    return;\n");	print("  }\n");	//SIRPortal[] portals = SIRPortal.getPortalsWithReceiver(self);	/* there should be only one portal or none */	if (portals.length == 1) {	    	    CClass pclass = portals[0].getPortalType().getCClass();	    CMethod pmethods[] = pclass.getMethods();	    for (int i = 0 ; i < pmethods.length; i++) {		CMethod portal_method = pmethods[i];		CType portal_method_params[] = portal_method.getParameters();		String method_name = portal_method.getIdent();		int length = method_name.length();		if (!method_name.startsWith("<") && 		    !method_name.endsWith(">")) {		    print("  if (index == "+i+") {\n");		    for (int t = 0; t < methods.length; t++) {		    			String thread_method_name = methods[t].getName();						if (thread_method_name.startsWith(method_name) &&			    thread_method_name.charAt(length) == '_' &&			    thread_method_name.charAt(length + 1) == '_') {			    			    int param_count = methods[t].getParameters().length;			    for (int a = 0; a < param_count; a++) {				if (portal_method_params[a].toString().equals("int")) {				    print("    int p"+a+" = sock->read_int();\n");				}				if (portal_method_params[a].toString().equals("float")) {				    print("    float p"+a+" = sock->read_float();\n");				}			    }			    print("    "+thread_method_name+"__"+selfID+"(");			    for (int a = 0; a < param_count; a++) {				if (a > 0) print(", ");				print("p"+a);			    }			    print(");\n");			}		    }		    print("  }\n");		}	    }	}	print("}\n");		//  +=============================+	//  | Send Credits                |	//  +=============================+	Iterator constrIter;	constrIter = sendsCreditsTo.iterator();	while (constrIter.hasNext()) {	    LatencyConstraint constraint = (LatencyConstraint)constrIter.next();	    int receiver = NodeEnumerator.getSIROperatorId(constraint.getReceiver());	    int sourcePhase = constraint.getSourceSteadyExec();	    print("int __init_"+selfID+"_"+receiver+" = "+constraint.getSourceInit()+";\n");	    print("int __source_phase_"+selfID+"_"+receiver+" = "+sourcePhase+";\n");	    print("int __dest_phase_"+selfID+"_"+receiver+" = "+constraint.getDestSteadyExec()+";\n");	    print("int __current_"+selfID+"_"+receiver+" = 0;\n");	    print("int __dest_offset_"+selfID+"_"+receiver+" = 0;\n");	    print("int __dependency_"+selfID+"_"+receiver+"[] = {");	    int y;	    	    for (y = 0; y < sourcePhase - 1; y++) {		print(constraint.getDependencyData(y)+",");	    }	    print(constraint.getDependencyData(y)+"};\n");	    print("\n");	}		print("\ninline void send_credits__"+selfID+"() {\n");	print("  int tmp;\n");	    	//HashSet sendsCreditsTo = LatencyConstraints.getOutgoingConstraints(self);	//boolean restrictedExecution = LatencyConstraints.isRestricted(self); 	//boolean sendsCredits;	constrIter = sendsCreditsTo.iterator();	while (constrIter.hasNext()) {	    LatencyConstraint constraint = (LatencyConstraint)constrIter.next();	    int receiver = NodeEnumerator.getSIROperatorId(constraint.getReceiver());	    if (LatencyConstraints.isMessageDirectionDownstream(self, constraint.getReceiver())) {		// message and credit is sent downstream		print("  if (__counter_"+selfID+" > __init_"+selfID+"_"+receiver+") {\n");		print("    tmp = __dependency_"+selfID+"_"+receiver+"[__current_"+selfID+"_"+receiver+"];\n");		print("    if (tmp > 0) {\n");		print("      __msg_sock_"+selfID+"_"+receiver+"out->write_int(-1);\n");		print("      __msg_sock_"+selfID+"_"+receiver+"out->write_int(tmp + __dest_offset_"+selfID+"_"+receiver+");\n");		print("    }\n");		print("    __current_"+selfID+"_"+receiver+" = (__current_"+selfID+"_"+receiver+" + 1) % __source_phase_"+selfID+"_"+receiver+";\n");		print("    if (__current_"+selfID+"_"+receiver+" == 0) __dest_offset_"+selfID+"_"+receiver+" += __dest_phase_"+selfID+"_"+receiver+";\n");		print("  }\n");   	    } else {		// message and credit is sent upstream	    		print("  if (__counter_"+selfID+" == 0) {\n");		print("    __msg_sock_"+selfID+"_"+receiver+"out->write_int(-1);\n");		print("    __msg_sock_"+selfID+"_"+receiver+"out->write_int(__init_"+selfID+"_"+receiver+");\n");		print("  } else {\n");   		print("    tmp = __dependency_"+selfID+"_"+receiver+"[__current_"+selfID+"_"+receiver+"];\n");		print("    if (tmp > 0) {\n");		print("      __msg_sock_"+selfID+"_"+receiver+"out->write_int(-1);\n");		print("      __msg_sock_"+selfID+"_"+receiver+"out->write_int(tmp + __dest_offset_"+selfID+"_"+receiver+");\n");		print("    }\n");   		print("    __current_"+selfID+"_"+receiver+" = (__current_"+selfID+"_"+receiver+" + 1) % __source_phase_"+selfID+"_"+receiver+";\n");		print("    if (__current_"+selfID+"_"+receiver+" == 0) __dest_offset_"+selfID+"_"+receiver+" += __dest_phase_"+selfID+"_"+receiver+";\n");		print("  }\n");   	    	    }	}	print("}\n");	//  +=============================+	//  | Cluster Main                |	//  +=============================+	Vector run = gen.generateRunFunction(filter.getInit().getName()+"__"+selfID, filter.getWork().getName()+"__"+selfID);	for (int i = 0; i < run.size(); i++) {	    print(run.elementAt(i).toString());	}       	createFile(selfID);    }