本文整理汇总了C++中Router::id方法的典型用法代码示例。如果您正苦于以下问题:C++ Router::id方法的具体用法?C++ Router::id怎么用?C++ Router::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Router
的用法示例。
在下文中一共展示了Router::id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildTopology
void TopologyFatTree::buildTopology(int num_way)
{
assert(is_power2(g_cfg.core_num));
assert(is_power2(num_way));
m_num_way = num_way;
m_max_level = log_int(g_cfg.core_num, m_num_way);
m_num_router_per_level = g_cfg.core_num/m_num_way;
fprintf(stderr, "[Fat Tree] m_num_way=%d m_max_level=%d\n", m_num_way, m_max_level);
fprintf(stderr, "[Fat Tree] m_num_router_per_level=%d\n", m_num_router_per_level);
// check relationship between #cores and #routers.
if (g_cfg.router_num != m_num_router_per_level*m_max_level) {
fprintf(stderr, "[Fat Tree] g_cfg.core_num=%d g_cfg.router_num=%d #routers_required=%d\n",
g_cfg.core_num, g_cfg.router_num, m_num_router_per_level*m_max_level);
g_cfg.router_num = m_num_router_per_level*m_max_level;
fprintf(stderr, "[Fat Tree] We changed g_cfg.router_num=%d.\n", g_cfg.router_num);
}
// topology name
m_topology_name = int2str(m_num_way) + "-way Fat Tree";
// create cores
for (int n=0; n<g_cfg.core_num; n++) {
Core* p_Core = new Core(n, g_cfg.core_num_NIs);
g_Core_vec.push_back(p_Core);
}
// create routers
unsigned int router_id = 0;
for (int l=0; l<m_max_level; l++) {
for (int w=0; w<m_num_router_per_level; w++) {
int router_num_pc;
int router_num_ipc, router_num_epc;
if (l == 0) { // 0-level(external) router
router_num_epc = router_num_ipc = (m_num_way * g_cfg.core_num_NIs);
router_num_pc = m_num_way + router_num_epc;
} else { // internal-level router
router_num_epc = router_num_ipc = 0;
router_num_pc = m_num_way * 2;
}
Router* pRouter = new Router(router_id, router_num_pc, g_cfg.router_num_vc,
router_num_ipc, router_num_epc, g_cfg.router_inbuf_depth);
#ifdef _DEBUG_TOPOLOGY_FTREE
printf("[Fat Tree] router=%d level=%d num_pc=%d num_ipc=%d num_epc=%d\n", pRouter->id(), l, router_num_pc, router_num_ipc, router_num_epc);
#endif
g_Router_vec.push_back(pRouter);
router_id++;
}
}
#ifdef _DEBUG_TOPOLOGY_FTREE
printf("[Fat Tree] # of created routers=%d\n", g_Router_vec.size());
#endif
// core and router connection
int num_cores_in_dim = (int)sqrt(g_cfg.core_num);
int num_routers_in_dim = (int)sqrt(m_num_router_per_level);
// printf("num_cores_in_dim = %d, num_routers_in_dim = %d.\n", num_cores_in_dim, num_routers_in_dim);
for(int n=0; n<m_num_router_per_level; n++){
int router_x_coord = n % num_routers_in_dim;
int router_y_coord = n / num_routers_in_dim;
// FIXME: support only 4-way fat-trees
vector< int > core_id_vec;
core_id_vec.resize(m_num_way);
core_id_vec[0] = 2 * router_x_coord + 2 * num_cores_in_dim * router_y_coord;
core_id_vec[1] = core_id_vec[0] + 1;
core_id_vec[2] = core_id_vec[0] + num_cores_in_dim;
core_id_vec[3] = core_id_vec[2] + 1;
// core to router map: core_id -> (router_id, port_pos (relative))
m_core2router_map[core_id_vec[0]] = make_pair(n, 0);
m_core2router_map[core_id_vec[1]] = make_pair(n, 1);
m_core2router_map[core_id_vec[2]] = make_pair(n, 2);
m_core2router_map[core_id_vec[3]] = make_pair(n, 3);
// router to core map: (router_id, port_pos (relative)) -> core_id
m_router2core_map[make_pair(n, 0)] = core_id_vec[0];
m_router2core_map[make_pair(n, 1)] = core_id_vec[1];
m_router2core_map[make_pair(n, 2)] = core_id_vec[2];
m_router2core_map[make_pair(n, 3)] = core_id_vec[3];
#ifdef _DEBUG_TOPOLOGY_FTREE
printf(" router_id=%d first_core=%d second_core=%d third_core=%d fourth_core=%d\n", n, core_id_vec[0], core_id_vec[1], core_id_vec[2], core_id_vec[3]);
#endif
for (int w=0; w<m_num_way; w++) {
Core * p_Core = g_Core_vec[core_id_vec[w]];
Router * p_Router = g_Router_vec[n];
// map PCs between input-NI and router
for (int ipc=0; ipc<g_cfg.core_num_NIs; ipc++) {
int router_in_pc = p_Router->num_internal_pc() + w * g_cfg.core_num_NIs + ipc;
p_Core->getNIInput(ipc)->attachRouter(p_Router, router_in_pc);
p_Router->appendNIInput(p_Core->getNIInput(ipc));
}
// map PCs between output-NI and router
//.........这里部分代码省略.........