⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbio.cc

📁 C语言前端编译器,yacc/lex编写,可自行修改代码.
💻 CC
📖 第 1 页 / 共 2 页
字号:

//--------------------------------------------------
// DEBUG PRINTOUT
//--------------------------------------------------
//MAP (x, function_.size()) {
//set bob = function_[x].vars_touched();
//cout << function_[x].name() << ": " << bob  << endl;
//}

	//--------------------------------------------------
	// Determine arc length based on variables' sizes 
	// and func return values
	//--------------------------------------------------
	long base_out_size = 0;
	MAP (x, fg_.size()) {
		MAP (y, fg_[x].size_vertex()) {
			// Get base size if node has a function return value.
			base_out_size = determine_node_function_out_size(x, y);
//			cout << function_[x].name() << " node:" << y << " ";

			// For each edge, determine it's edge size based on the
			// sum of the common variables' sizes.
			MAP (z, fg_[x].vertex(y)->size_out()) {
				long arc_num = fg_[x].vertex(y)->out(z);
				set<long> i_set = fg_[x](fg_[x].vertex(y)->out(z)).vars();

				long arc_out_size = base_out_size;
				set<long>::iterator i;
				for (i = i_set.begin(); i != i_set.end(); i++) {
					long var_index = *i;
					long tmp_size = variable_[var_index].total_size();
					if ((tmp_size >= 0) && (arc_out_size != -1)) {
						arc_out_size += tmp_size;
					} else {
						arc_out_size = -1;
					}
//cout << variable_[var_index].name() << " ";
				}
//cout << endl;
				i_set.clear();
				fg_[x](arc_num).set_val(arc_out_size);

			}
		}
	}
}

// If node isn't a loop/cond, it might contain a return value
// to be passed to other nodes.  If so, determine that size.
long DB::determine_node_function_out_size (long f, long n)
{
	//--------------------------------------------------
	// loops and cond nodes don't return values...
	//--------------------------------------------------
	if (fg_[f][n].is_loop_or_cond_node()) {
		return 0;
	}

	//--------------------------------------------------
	// Determine func call return size (if there is one)
	//--------------------------------------------------
	long sz = 0;
	RVector<long> func = fg_[f][n].func();

//	cout << function_[f].name() << " node: " << n << ":  ";

	MAP (x, func.size()) {
//		cout << function_[func[x]].name() << " ";
		string type = function_[func[x]].type();
		long tmp_size = type_map_lookup(type);

		// If data type size is known, add that to the size.
		if ((tmp_size >= 0) && (sz != -1)) {
			sz += type_map_lookup(type);
		} else {
//KSV WARNING, this might be best as set to pointer size
			sz = -1;
		}
//		cout << sz;
	}
//	cout << endl;

	return sz;
}

// Print task graph.
void DB::print_task_graphs() 
{
	ofstream out;
	string filename = ArgPack::ap().get_fname() + ".tg";
	out.open(filename.c_str());

	out << "#  " << filename << " Task Graphs:" << endl;
	out << "#  (Automatically generated file)" << endl << endl;

	MAP (x, fg_.size()) {
		out << "#  " << fg_[x].name() << endl;
		if (fg_[x].name() == "main") {
			out << "@Task Graph " << x << "  {" <<endl;
		} else {
			out << "@SubTask Graph " << x << "  {" <<endl;
		}
//		out << "SE: " << fg_[x].statement_nodes() << endl;
//		out << "LC: " << fg_[x].loop_or_cond_nodes() << endl;
//		out << "FC: " << fg_[x].func_call_nodes() << endl;

		// Print nodes
		MAP (y, fg_[x].size_vertex()) {
			out << "   TASK t" << x << "_" << y;
			out << "   SIZE " << fg_[x][y].time_unit() 
//				<< "    " << fg_[x][y].start()
				<< endl;
			
		}
		out << endl << endl;
		// Print edges
		MAP (y, fg_[x].size_edge()) {
			out << "   ARC a" << x << "_" << y;
			out << "\t FROM t" << x << "_" << fg_[x].edge(y)->from();
			out << "\t TO t" << x << "_" << fg_[x].edge(y)->to();
			out << "\t SIZE " << fg_[x](y).val();

			if (ArgPack::ap().display_arc_variables()) {
				set<long> v = fg_[x](y).vars();
				set<long>::iterator i;
				for (i = v.begin(); i != v.end(); i++) {
					long tmp = *i;
					out << "\t " << variable_[tmp].name();
				}
			}
			out << endl;
		}


		out << "}\n" << endl;
	}
	out.close();
}

// Print task graph in "Standard" format.  This format is 
// compatible with MOCSYN by Robert Dick.
void DB::print_standard_task_graphs()
{
	ofstream out;
	string filename = ArgPack::ap().get_fname() + ".std_tg";
	out.open(filename.c_str());

	out << "#  Task graph for --  " << filename << ":" << endl;
	out << "#  (Automatically generated file)" << endl << endl;
	out << "@HYPERPERIOD 1" << endl << endl;

	string main_string = "main";
	RVector<long> fn_list = call_graph_.top_sort (func_map_[main_string]);
	RVector<TimeUnit> task_type;
	RVector<long> arc_type;

	//-----------------------------------------
	// Communication quantities for arc lengths
	//-----------------------------------------
	MAP (x, fn_list.size()) {
		long curr_func = fn_list[x];
		MAP (y, fg_[curr_func].size_edge()) {
			arc_type.push_back (fg_[curr_func](y).val());
			if (arc_type[arc_type.size() - 1] < 0) {
				cerr << "Edge with negative value.  "
					<< "Probably caused by pointer."  << endl;
				Rabort();
			}
		}
	}
	out << "@COMMUN_QUANT 0 {" << endl;
	MAP (x, arc_type.size()) {
		out << x << "\t" << arc_type[x] << endl;
	}
	out << "}\n\n";

	//---------------------------
	// Calculate task graphs here
	//---------------------------
	arc_type.clear();
	MAP (x, fn_list.size()) {
		bool is_main = false;
		long curr_func = fn_list[x];
		if (fg_[curr_func].name() == "main") {
			is_main = true;
		}

		out << "#  " << fg_[curr_func].name() << endl;
		if (is_main) {
			out << "@TASK_GRAPH " << x << "  {" << endl;
			out << "  PERIOD 1" << endl;
		} else {
			out << "# @SUBTASK_GRAPH " << x << "  {" << endl;
			out << "#  APERIODIC " << endl;
		}

		// Print nodes
		MAP (y, fg_[curr_func].size_vertex()) {
			if (!is_main) {
				out << "# ";
			}
			out << "   TASK t" << x << "_" << y;
			out << "   TYPE " << task_type.size() << endl;
			task_type.push_back (fg_[curr_func][y].time_unit());
		}
		out << endl << endl;

		// Print edges
		MAP (y, fg_[curr_func].size_edge()) {
			if (!is_main) {
				out << "# ";
			}
			out << "   ARC a" << x << "_" << y;
			out << "\t FROM t" << x << "_" << fg_[curr_func].edge(y)->from();
			out << "\t TO t" << x << "_" << fg_[curr_func].edge(y)->to();
			out << "\t TYPE " << arc_type.size();

			arc_type.push_back (fg_[curr_func](y).val());
			if (arc_type[arc_type.size() - 1] < 0) {
				cerr << "Edge with negative value.  "
					<< "Probably caused by pointer."  << endl;
				Rabort();
			}

			out << endl;
		}

		// Print deadlines
		out << endl;
		long dl_cnt = 0;
		MAP (y, fg_[curr_func].size_vertex()) {
			if (fg_[curr_func].vertex(y)->size_out() == 0) {
				if (!is_main) {
					out << "# ";
				}
				out << "   HARD_DEADLINE d" << x << "_" << dl_cnt
					<< " ON t" << x << "_" << y << " AT 1";
				out << endl;

			}
		}

		out << endl;
		if (!is_main) {
			out << "# ";
		}
		out << "}\n" << endl;
	}

	// Print out processor info
	out << "@CORE 0 {\n";
	out << "# price buffered max_freq width    height   density "
		<< " preempt_power commun_en_bit io_en_bit idle_power" << endl;
	out << "  1 \t 1 \t 6.67e+08 6.48e-03 6.48e-03 .275 "
		<< " 0 \t 0 \t 0 \t 1.6" << endl;
	out << "#--------------------------------------"
		<< "----------------------------------------" << endl;
	out << "# type version valid task_time preempt_time code_bits task_power"
		<< endl;

	TimeUnit t_zero;
	t_zero.set_time(0,1);
	MAP (x, task_type.size()) {
		// output task size...last 2 numbers should be improved...
		out << x << " \t 0 \t 1 \t";
		if (task_type[x] < t_zero) {
			out << t_zero;
		} else {
			out << task_type[x];
		}
		out << "\t\t 150E-6 \t\t "
			<< "1 \t 16" << endl;
	
	}

	out << "}\n\n";

	out.close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -