Commit 20bfbd44 authored by Nikhil's avatar Nikhil

Fix cimpler issues

Change-Id: I5bd8ffda63820260eaecb58061e903ccabafe567
parent d9571f96
...@@ -41,6 +41,8 @@ include $(top_srcdir)/src/Makefile.subdir ...@@ -41,6 +41,8 @@ include $(top_srcdir)/src/Makefile.subdir
include $(top_srcdir)/tests/Makefile.subdir include $(top_srcdir)/tests/Makefile.subdir
include $(top_srcdir)/doc/Makefile.subdir include $(top_srcdir)/doc/Makefile.subdir
LDADD += -lcgraph
if USE_DEBUG if USE_DEBUG
AM_CPPFLAGS += -g AM_CPPFLAGS += -g
AM_CFLAGS += -g AM_CFLAGS += -g
......
...@@ -31,6 +31,7 @@ extern "C" { ...@@ -31,6 +31,7 @@ extern "C" {
#include "net/simplep2p.h" #include "net/simplep2p.h"
#include "net/torus.h" #include "net/torus.h"
#include "net/express-mesh.h" #include "net/express-mesh.h"
#include "net/network-graph.h"
extern int model_net_base_magic; extern int model_net_base_magic;
...@@ -140,6 +141,7 @@ typedef struct model_net_wrap_msg { ...@@ -140,6 +141,7 @@ typedef struct model_net_wrap_msg {
sp_message m_sp2p; // simplep2p sp_message m_sp2p; // simplep2p
nodes_message m_torus; // torus nodes_message m_torus; // torus
em_message m_em; // express-mesh em_message m_em; // express-mesh
network_graph_message m_ng; // express-mesh
// add new ones here // add new ones here
} msg; } msg;
} model_net_wrap_msg; } model_net_wrap_msg;
......
...@@ -74,6 +74,8 @@ typedef struct mn_stats mn_stats; ...@@ -74,6 +74,8 @@ typedef struct mn_stats mn_stats;
X(LOGGP, "modelnet_loggp", "loggp", &loggp_method)\ X(LOGGP, "modelnet_loggp", "loggp", &loggp_method)\
X(EXPRESS_MESH, "modelnet_express_mesh", "express_mesh", &express_mesh_method)\ X(EXPRESS_MESH, "modelnet_express_mesh", "express_mesh", &express_mesh_method)\
X(EXPRESS_MESH_ROUTER, "modelnet_express_mesh_router", "express_mesh_router", &express_mesh_router_method)\ X(EXPRESS_MESH_ROUTER, "modelnet_express_mesh_router", "express_mesh_router", &express_mesh_router_method)\
X(NETWORK_GRAPH, "modelnet_network_graph", "network_graph", &network_graph_method)\
X(NETWORK_GRAPH_ROUTER, "modelnet_network_graph_router", "network_graph_router", &network_graph_router_method)\
X(DRAGONFLY_PLUS, "modelnet_dragonfly_plus", "dragonfly_plus", &dragonfly_plus_method)\ X(DRAGONFLY_PLUS, "modelnet_dragonfly_plus", "dragonfly_plus", &dragonfly_plus_method)\
X(DRAGONFLY_PLUS_ROUTER, "modelnet_dragonfly_plus_router", "dragonfly_plus_router", &dragonfly_plus_router_method)\ X(DRAGONFLY_PLUS_ROUTER, "modelnet_dragonfly_plus_router", "dragonfly_plus_router", &dragonfly_plus_router_method)\
X(MAX_NETS, NULL, NULL, NULL) X(MAX_NETS, NULL, NULL, NULL)
......
...@@ -99,11 +99,12 @@ nobase_include_HEADERS = \ ...@@ -99,11 +99,12 @@ nobase_include_HEADERS = \
codes/net/slimfly.h \ codes/net/slimfly.h \
codes/net/fattree.h \ codes/net/fattree.h \
codes/net/loggp.h \ codes/net/loggp.h \
codes/net/network-graph.h \
codes/net/simplenet-upd.h \ codes/net/simplenet-upd.h \
codes/net/simplep2p.h \ codes/net/simplep2p.h \
codes/net/express-mesh.h \ codes/net/express-mesh.h \
codes/net/torus.h \ codes/net/torus.h \
codes/codes-mpi-replay.h \ codes/codes-mpi-replay.h \
codes/configfile.h codes/configfile.h
...@@ -166,6 +167,7 @@ src_libcodes_la_SOURCES = \ ...@@ -166,6 +167,7 @@ src_libcodes_la_SOURCES = \
src/networks/model-net/dragonfly-plus.C \ src/networks/model-net/dragonfly-plus.C \
src/networks/model-net/slimfly.c \ src/networks/model-net/slimfly.c \
src/networks/model-net/fattree.c \ src/networks/model-net/fattree.c \
src/networks/model-net/network-graph.c \
src/networks/model-net/loggp.c \ src/networks/model-net/loggp.c \
src/networks/model-net/simplep2p.c \ src/networks/model-net/simplep2p.c \
src/networks/model-net/model-net-lp.c \ src/networks/model-net/model-net-lp.c \
......
...@@ -385,6 +385,10 @@ void model_net_base_configure(){ ...@@ -385,6 +385,10 @@ void model_net_base_configure(){
offsetof(model_net_wrap_msg, msg.m_em); offsetof(model_net_wrap_msg, msg.m_em);
msg_offsets[EXPRESS_MESH_ROUTER] = msg_offsets[EXPRESS_MESH_ROUTER] =
offsetof(model_net_wrap_msg, msg.m_em); offsetof(model_net_wrap_msg, msg.m_em);
msg_offsets[NETWORK_GRAPH] =
offsetof(model_net_wrap_msg, msg.m_ng);
msg_offsets[NETWORK_GRAPH_ROUTER] =
offsetof(model_net_wrap_msg, msg.m_ng);
// perform the configuration(s) // perform the configuration(s)
// This part is tricky, as we basically have to look up all annotations that // This part is tricky, as we basically have to look up all annotations that
...@@ -406,7 +410,7 @@ void model_net_base_configure(){ ...@@ -406,7 +410,7 @@ void model_net_base_configure(){
} }
} }
if (a == num_params){ if (a == num_params){
// found a new annotation // found a new annotatio
annos[num_params++] = amap->annotations[n].ptr; annos[num_params++] = amap->annotations[n].ptr;
} }
} }
......
...@@ -32,6 +32,10 @@ extern struct model_net_method dragonfly_custom_router_method; ...@@ -32,6 +32,10 @@ extern struct model_net_method dragonfly_custom_router_method;
extern struct model_net_method loggp_method; extern struct model_net_method loggp_method;
extern struct model_net_method express_mesh_method; extern struct model_net_method express_mesh_method;
extern struct model_net_method express_mesh_router_method; extern struct model_net_method express_mesh_router_method;
extern struct model_net_method express_mesh_method;
extern struct model_net_method express_mesh_router_method;
extern struct model_net_method network_graph_method;
extern struct model_net_method network_graph_router_method;
#define X(a,b,c,d) b, #define X(a,b,c,d) b,
char * model_net_lp_config_names[] = { char * model_net_lp_config_names[] = {
......
...@@ -15,8 +15,11 @@ ...@@ -15,8 +15,11 @@
#include "codes/quickhash.h" #include "codes/quickhash.h"
#include "codes/rc-stack.h" #include "codes/rc-stack.h"
#include <vector> #include <vector>
#include <string>
#include <map>
#include <graphviz/cgraph.h> #include <graphviz/cgraph.h>
#include <cstdio> #include <cstdio>
#include <search.h>
#define CREDIT_SZ 8 #define CREDIT_SZ 8
#define HASH_TABLE_SIZE 4999 #define HASH_TABLE_SIZE 4999
...@@ -79,19 +82,21 @@ class End { ...@@ -79,19 +82,21 @@ class End {
int id; int id;
bool isTerm; bool isTerm;
End() { }
End(int _port, int _id, bool _isTerm) { End(int _port, int _id, bool _isTerm) {
port = _port; port = _port;
id = _id; id = _id;
isTerm = _isTerm; isTerm = _isTerm;
} }
} };
class Switch_info { class Switch_info {
public: public:
std::string name; std::string name;
long long guid; long long guid;
int radix; int radix;
vector<End> ports; std::vector<End> ports;
}; };
class Terminal_info { class Terminal_info {
...@@ -99,7 +104,7 @@ class Terminal_info { ...@@ -99,7 +104,7 @@ class Terminal_info {
std::string name; std::string name;
long long guid; long long guid;
int radix; int radix;
vector<End> ports; std::vector<End> ports;
}; };
struct local_param struct local_param
...@@ -120,10 +125,10 @@ struct local_param ...@@ -120,10 +125,10 @@ struct local_param
//CHANGE: add network specific data here //CHANGE: add network specific data here
int num_switches, num_terminals; int num_switches, num_terminals;
vector<Switch_info> switch_id_to_info; std::vector<Switch_info> switch_id_to_info;
vector<Terminal_info> terminal_id_to_info; std::vector<Terminal_info> term_id_to_info;
map<long long, int> switch_guid_to_id, terminal_guid_to_id; std::map<long long, int> switch_guid_to_id, term_guid_to_id;
map<std::string, int> switch_name_to_id, terminal_name_to_id; std::map<std::string, int> switch_name_to_id, term_name_to_id;
}; };
struct local_router_sample struct local_router_sample
...@@ -143,7 +148,7 @@ struct local_cn_sample ...@@ -143,7 +148,7 @@ struct local_cn_sample
long data_size_sample; long data_size_sample;
double fin_hops_sample; double fin_hops_sample;
tw_stime fin_chunks_time; tw_stime fin_chunks_time;
tw_stime busy_time_sample; tw_stime *busy_time_sample;
tw_stime end_time; tw_stime end_time;
long fwd_events; long fwd_events;
long rev_events; long rev_events;
...@@ -163,7 +168,7 @@ struct terminal_state ...@@ -163,7 +168,7 @@ struct terminal_state
int radix; //my radix int radix; //my radix
//which router I am connected to //which router I am connected to
vector<tw_lpid> conn_gids; std::vector<tw_lpid> conn_gids;
// Each terminal will have input/output channel(s) with the router // Each terminal will have input/output channel(s) with the router
int** vc_occupancy; // NUM_VC int** vc_occupancy; // NUM_VC
...@@ -255,7 +260,7 @@ struct router_state ...@@ -255,7 +260,7 @@ struct router_state
//CHANGE: may need to be changed if linear storage is not desired //CHANGE: may need to be changed if linear storage is not desired
//array/linked list based storage of info about ports/vcs //array/linked list based storage of info about ports/vcs
vector<tw_lpid> conn_gids; std::vector<tw_lpid> conn_gids;
tw_stime* next_output_available_time; tw_stime* next_output_available_time;
message_list ***pending_msgs; message_list ***pending_msgs;
message_list ***pending_msgs_tail; message_list ***pending_msgs_tail;
...@@ -394,7 +399,7 @@ static void local_read_config(const char * anno, local_param *params){ ...@@ -394,7 +399,7 @@ static void local_read_config(const char * anno, local_param *params){
&p->num_terminals); &p->num_terminals);
p->switch_id_to_info.resize(p->num_switches); p->switch_id_to_info.resize(p->num_switches);
p->terminal_id_to_info.resize(p->num_terminals); p->term_id_to_info.resize(p->num_terminals);
configuration_get_value(&config, "PARAMS", "network_graph_file", anno, configuration_get_value(&config, "PARAMS", "network_graph_file", anno,
network_graph_file, MAX_NAME_LENGTH); network_graph_file, MAX_NAME_LENGTH);
...@@ -404,31 +409,32 @@ static void local_read_config(const char * anno, local_param *params){ ...@@ -404,31 +409,32 @@ static void local_read_config(const char * anno, local_param *params){
int num_switches = 0, num_terminals = 0; int num_switches = 0, num_terminals = 0;
Agnode_t *g_node; Agnode_t *g_node;
Agedge_t *e;
for(g_node = agfstnode(input_graph); g_node; g_node = agnxtnode(input_graph, g_nodes)) { for(g_node = agfstnode(input_graph); g_node; g_node = agnxtnode(input_graph, g_node)) {
char *name = agnameof(g_node); char *name = agnameof(g_node);
if(name[0] == 'S') { if(name[0] == 'S') {
switch_info next_switch; Switch_info next_switch;
next_switch.name = std::string(name); next_switch.name = std::string(name);
switch_name_to_id[next_switch.name] = num_switches; p->switch_name_to_id[next_switch.name] = num_switches;
char * comment = agget(g_node, "comment"); char * comment = agget(g_node, "comment");
sscanf(comment, "%x,radix=%d", &next_switch.guid, &next_switch.radix); sscanf(comment, "%x,radix=%d", &next_switch.guid, &next_switch.radix);
switch_id_to_info[num_switches] = next_switch; p->switch_id_to_info[num_switches] = next_switch;
switch_id_to_info[num_switches].ports.resize(next_switch.radix); p->switch_id_to_info[num_switches].ports.resize(next_switch.radix);
switch_guid_to_id[next_switch.guid] = num_switches; p->switch_guid_to_id[next_switch.guid] = num_switches;
num_switches++; num_switches++;
} }
if(name[0] == 'T') { if(name[0] == 'T') {
terminal_id_to_info next_term; Terminal_info next_term;
next_term.name = std::string(name); next_term.name = std::string(name);
int term_id; int term_id;
sscanf(name, "T<%d", &term_id); sscanf(name, "T<%d", &term_id);
term_name_to_id[next_term.name] = term_id; p->term_name_to_id[next_term.name] = term_id;
char * comment = agget(g_node, "comment"); char * comment = agget(g_node, "comment");
sscanf(comment, "%x,radix=%d", &next_term.guid, &next_term.radix); sscanf(comment, "%x,radix=%d", &next_term.guid, &next_term.radix);
term_id_to_info[term_id] = next_term; p->term_id_to_info[term_id] = next_term;
term_id_to_info[term_id].ports.resize(next_term.radix); p->term_id_to_info[term_id].ports.resize(next_term.radix);
term_guid_to_id[next_term.guid] = term_id; p->term_guid_to_id[next_term.guid] = term_id;
if(term_id > num_terminals) num_terminals = term_id; if(term_id > num_terminals) num_terminals = term_id;
} }
} }
...@@ -436,31 +442,31 @@ static void local_read_config(const char * anno, local_param *params){ ...@@ -436,31 +442,31 @@ static void local_read_config(const char * anno, local_param *params){
assert(num_terminals == p->num_terminals); assert(num_terminals == p->num_terminals);
assert(num_switches == p->num_switches); assert(num_switches == p->num_switches);
for(g_node = agfstnode(input_graph); g_node; g_node = agnxtnode(input_graph, g_nodes)) { for(g_node = agfstnode(input_graph); g_node; g_node = agnxtnode(input_graph, g_node)) {
char *name = agnameof(g_node); char *name = agnameof(g_node);
int index_in_info; int index_in_info;
if(name[0] == 'S') { if(name[0] == 'S') {
index_in_info = switch_name_to_id[std::string(name)]; index_in_info = p->switch_name_to_id[std::string(name)];
} else { } else {
index_in_info = term_name_to_id[std::string(name)]; index_in_info = p->term_name_to_id[std::string(name)];
} }
for (e = agfstedge(g,g_node); e; e = agnxtedge(g,e,g_node)) { for (e = agfstedge(input_graph,g_node); e; e = agnxtedge(input_graph,e,g_node)) {
char *partner = agnameof(e->node); char *partner = agnameof(e->node);
char *edge_comment = agget(e, "comment"); char *edge_comment = agget(e, "comment");
int srcPort, dstPort; int srcPort, dstPort;
sscanf(edge_comment, "P%d->P%d", &srcPort, &dstPort); sscanf(edge_comment, "P%d->P%d", &srcPort, &dstPort);
int dstId; bool isTerm; int dstId; bool isTerm;
if(partner[0] == 'S') { if(partner[0] == 'S') {
dstId = switch_name_to_id[std::string(partner)]; dstId = p->switch_name_to_id[std::string(partner)];
isTerm = false; isTerm = false;
} else { } else {
dstId = term_name_to_id[std::string(partner)]; dstId = p->term_name_to_id[std::string(partner)];
isTerm = true; isTerm = true;
} }
if(name[0] == 'S') { if(name[0] == 'S') {
switch_id_to_info[index_in_info].ports[srcPort] = End(dstPort, dstId, isTerm); p->switch_id_to_info[index_in_info].ports[srcPort] = End(dstPort, dstId, isTerm);
} else { } else {
term_id_to_info[index_in_info].ports[srcPort] = End(dstPort, dstId, isTerm); p->term_id_to_info[index_in_info].ports[srcPort] = End(dstPort, dstId, isTerm);
} }
} }
} }
...@@ -564,7 +570,7 @@ static int cmp_guids(const void *g1, const void *g2) ...@@ -564,7 +570,7 @@ static int cmp_guids(const void *g1, const void *g2)
return 1; return 1;
} }
static int read_static_lft(long long guid, int & *lft, local_param * params) static int read_static_lft(long long guid, int * &lft, const local_param * params)
{ {
char dir_name[512]; char dir_name[512];
char file_name[512]; char file_name[512];
...@@ -583,9 +589,9 @@ static int read_static_lft(long long guid, int & *lft, local_param * params) ...@@ -583,9 +589,9 @@ static int read_static_lft(long long guid, int & *lft, local_param * params)
int num_added = 0; int num_added = 0;
//temp storage for the entire table //temp storage for the entire table
guid_port_combi_t *tmpLFT = calloc(params->num_terminals + params->num_switches, sizeof(guid_port_combi_t)); guid_port_combi_t *tmpLFT = (guid_port_combi_t*)calloc(params->num_terminals + params->num_switches, sizeof(guid_port_combi_t));
//storage for port to take for the destination terminal //storage for port to take for the destination terminal
lft = malloc(params->num_terminals * sizeof(int)); lft = (int*)malloc(params->num_terminals * sizeof(int));
/* init all with -1 so that we find missing routing entries */ /* init all with -1 so that we find missing routing entries */
for (int i = 0; i < params->num_terminals; i++) lft[i] = -1; for (int i = 0; i < params->num_terminals; i++) lft[i] = -1;
...@@ -622,12 +628,10 @@ static int read_static_lft(long long guid, int & *lft, local_param * params) ...@@ -622,12 +628,10 @@ static int read_static_lft(long long guid, int & *lft, local_param * params)
* convert the read lft, which might contain entries for switches * convert the read lft, which might contain entries for switches
* or is permutated, into the correct format * or is permutated, into the correct format
*/ */
ft_terminal_state tmpTerm;
for (int dest_num = 0; dest_num < params->num_terminals; dest_num++) { for (int dest_num = 0; dest_num < params->num_terminals; dest_num++) {
tmpTerm.terminal_id = dest_num; uint64_t key = params->term_id_to_info[dest_num].guid;
uint64_t key = term_id_to_info[dest_num].guid;
size_t size = params->num_terminals + params->num_switches; size_t size = params->num_terminals + params->num_switches;
guid_port_combi_t *elem = lfind(&key, tmpLFT, &size, guid_port_combi_t *elem = (guid_port_combi_t*)lfind(&key, tmpLFT, &size,
sizeof(guid_port_combi_t), cmp_guids); sizeof(guid_port_combi_t), cmp_guids);
assert(elem); assert(elem);
lft[dest_num] = elem->port - 1; lft[dest_num] = elem->port - 1;
...@@ -668,19 +672,15 @@ static void terminal_init( terminal_state * s, tw_lp * lp ) ...@@ -668,19 +672,15 @@ static void terminal_init( terminal_state * s, tw_lp * lp )
int num_lps = codes_mapping_get_lp_count(lp_group_name, 0, LP_CONFIG_NM_TERM, int num_lps = codes_mapping_get_lp_count(lp_group_name, 0, LP_CONFIG_NM_TERM,
s->anno, 0); s->anno, 0);
if(num_lps != s->params->total_terminals) {
tw_error(TW_LOC, "Number of terminals LP does not match number of nodes\n");
}
s->terminal_id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0); s->terminal_id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0);
Terminal_info &my_info = terminal_id_to_info[s->terminal_id]; const Terminal_info &my_info = s->params->term_id_to_info[s->terminal_id];
s->radix = my_info->radix; s->radix = my_info.radix;
conn_gids.resize(s->radix); s->conn_gids.resize(s->radix);
for(int port = 0; port < s->radix; port++) { for(int port = 0; port < s->radix; port++) {
End &next_port = my_info.ports[port]; const End &next_port = my_info.ports[port];
if(End.isTerm) { if(next_port.isTerm) {
s->conn_gids[port] = codes_mapping_get_lpid_from_relative(next_port.id, s->conn_gids[port] = codes_mapping_get_lpid_from_relative(next_port.id,
NULL, LP_CONFIG_NM_TERM, s->anno, 1); NULL, LP_CONFIG_NM_TERM, s->anno, 1);
} else { } else {
...@@ -712,7 +712,7 @@ static void terminal_init( terminal_state * s, tw_lp * lp ) ...@@ -712,7 +712,7 @@ static void terminal_init( terminal_state * s, tw_lp * lp )
s->terminal_msgs_tail = (message_list ***)malloc(s->radix * sizeof(message_list**)); s->terminal_msgs_tail = (message_list ***)malloc(s->radix * sizeof(message_list**));
s->vc_occupancy = (int **)malloc(s->radix * sizeof(int*)); s->vc_occupancy = (int **)malloc(s->radix * sizeof(int*));
s->total_terminal_length = (int *)malloc(s->radix * sizeof(int)); s->total_terminal_length = (int *)malloc(s->radix * sizeof(int));
s->terminal_length = (int *)malloc(s->radix * sizeof(int)); s->terminal_length = (int **)malloc(s->radix * sizeof(int*));
s->in_send_loop = (int *)malloc(s->radix * sizeof(int)); s->in_send_loop = (int *)malloc(s->radix * sizeof(int));
s->terminal_available_time = (tw_stime*)malloc(s->radix * sizeof(tw_stime)); s->terminal_available_time = (tw_stime*)malloc(s->radix * sizeof(tw_stime));
s->last_buf_full = (tw_stime*)malloc(s->radix * sizeof(tw_stime)); s->last_buf_full = (tw_stime*)malloc(s->radix * sizeof(tw_stime));
...@@ -749,7 +749,7 @@ void post_terminal_init(terminal_state *s, tw_lp *lp) ...@@ -749,7 +749,7 @@ void post_terminal_init(terminal_state *s, tw_lp *lp)
* algorithm, e.g., through the use of opensm\ * algorithm, e.g., through the use of opensm\
*/ */
if(s->params->routing == STATIC) { if(s->params->routing == STATIC) {
if(0 != read_static_lft(terminal_id_to_info[s->terminal_id].guid, s->lft, s->params)) { if(0 != read_static_lft(s->params->term_id_to_info[s->terminal_id].guid, s->lft, s->params)) {
tw_error(TW_LOC, "Error while reading the routing table for terminal"); tw_error(TW_LOC, "Error while reading the routing table for terminal");
} }
} }
...@@ -759,15 +759,15 @@ void post_terminal_init(terminal_state *s, tw_lp *lp) ...@@ -759,15 +759,15 @@ void post_terminal_init(terminal_state *s, tw_lp *lp)
//specific data structures //specific data structures
static void create_router_connections(router_state * r, tw_lp * lp) { static void create_router_connections(router_state * r, tw_lp * lp) {
local_param *p = (local_param *)r->params; local_param *p = (local_param *)r->params;
Switch_info &my_info = switch_id_to_info[r->router_id]; Switch_info &my_info = p->switch_id_to_info[r->router_id];
for(int port = 0; port < r->radix; port++) { for(int port = 0; port < r->radix; port++) {
End &next_port = my_info.ports[port]; End &next_port = my_info.ports[port];
if(End.isTerm) { if(next_port.isTerm) {
r->conn_gids[port] = codes_mapping_get_lpid_from_relative(next_port.id, r->conn_gids[port] = codes_mapping_get_lpid_from_relative(next_port.id,
NULL, LP_CONFIG_NM_TERM, s->anno, 1); NULL, LP_CONFIG_NM_TERM, r->anno, 1);
} else { } else {
r->conn_gids[port] = codes_mapping_get_lpid_from_relative(next_port.id, r->conn_gids[port] = codes_mapping_get_lpid_from_relative(next_port.id,
NULL, LP_CONFIG_NM_ROUT, s->anno, 1); NULL, LP_CONFIG_NM_ROUT, r->anno, 1);
} }
} }
} }
...@@ -791,7 +791,7 @@ static void router_setup(router_state * r, tw_lp * lp) ...@@ -791,7 +791,7 @@ static void router_setup(router_state * r, tw_lp * lp)
r->router_id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0); r->router_id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0);
Switch_info &my_info = switch_id_to_info[r->router_id]; Switch_info &my_info = p->switch_id_to_info[r->router_id];
r->radix = my_info.radix; r->radix = my_info.radix;
r->fwd_events = 0; r->fwd_events = 0;
...@@ -817,7 +817,7 @@ static void router_setup(router_state * r, tw_lp * lp) ...@@ -817,7 +817,7 @@ static void router_setup(router_state * r, tw_lp * lp)
r->busy_time_sample = (tw_stime*)malloc(r->radix * sizeof(tw_stime)); r->busy_time_sample = (tw_stime*)malloc(r->radix * sizeof(tw_stime));
rc_stack_create(&r->st); rc_stack_create(&r->st);
for(int i = 0; i < p->radix; i++) for(int i = 0; i < r->radix; i++)
{ {
// Set credit & router occupancy // Set credit & router occupancy
r->last_buf_full[i] = 0.0; r->last_buf_full[i] = 0.0;
...@@ -855,8 +855,8 @@ void post_router_init(router_state *r, tw_lp *lp) ...@@ -855,8 +855,8 @@ void post_router_init(router_state *r, tw_lp *lp)
/* read any LFTs which might have been generated by an external routing /* read any LFTs which might have been generated by an external routing
* algorithm, e.g., through the use of opensm\ * algorithm, e.g., through the use of opensm\
*/ */
if(s->params->routing == STATIC) { if(r->params->routing == STATIC) {
if(0 != read_static_lft(switch_id_to_info[r->router_id].guid, r->lft, r->params)) { if(0 != read_static_lft(r->params->switch_id_to_info[r->router_id].guid, r->lft, r->params)) {
tw_error(TW_LOC, "Error while reading the routing table for switch"); tw_error(TW_LOC, "Error while reading the routing table for switch");
} }
} }
...@@ -896,7 +896,7 @@ static tw_stime local_packet_event( ...@@ -896,7 +896,7 @@ static tw_stime local_packet_event(
msg->type = T_GENERATE; msg->type = T_GENERATE;
msg->dest_terminal_id = req->dest_mn_lp; msg->dest_terminal_id = req->dest_mn_lp;
msg->dest_terminal = codes_mapping_get_lp_relative_id(msg->dest_terminal_id, 0, 0); msg->dest_terminal = codes_mapping_get_lp_relative_id(msg->dest_terminal_id, 0, 0);
sg->message_id = req->msg_id; msg->message_id = req->msg_id;
msg->is_pull = req->is_pull; msg->is_pull = req->is_pull;
msg->pull_size = req->pull_size; msg->pull_size = req->pull_size;
msg->magic = terminal_magic_num; msg->magic = terminal_magic_num;
...@@ -953,7 +953,7 @@ static void packet_generate(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m ...@@ -953,7 +953,7 @@ static void packet_generate(terminal_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m
msg->packet_ID = lp->gid + g_tw_nlp * s->packet_counter; msg->packet_ID = lp->gid + g_tw_nlp * s->packet_counter;
msg->my_N_hop = 0; msg->my_N_hop = 0;
int output_port = -1, out_vc = 0; int output_port = -1, use_vc = 0;
//find the next port by looking up the lft //find the next port by looking up the lft
if(s->params->routing == STATIC) { if(s->params->routing == STATIC) {
output_port = s->lft[msg->dest_terminal]; output_port = s->lft[msg->dest_terminal];
...@@ -1667,10 +1667,10 @@ get_next_stop(router_state * s, ...@@ -1667,10 +1667,10 @@ get_next_stop(router_state * s,
tw_error(TW_LOC, "Only static routing supported in this topology\n"); tw_error(TW_LOC, "Only static routing supported in this topology\n");
} }
int use_vc = 0; int use_vc = 0;
int min_vc_length = s->terminal_length[output_port][use_vc]; int min_vc_length = s->vc_occupancy[output_port][use_vc];
for(int vc = 1; vc < s->params->num_vcs; vc++) { for(int vc = 1; vc < s->params->num_vcs; vc++) {
if(s->vc_occupancy[output_port][vc] < min_vc_length) { if(s->vc_occupancy[output_port][vc] < min_vc_length) {
min_vc_length = s->terminal_length[output_port][vc]; min_vc_length = s->vc_occupancy[output_port][vc];
use_vc = vc; use_vc = vc;
} }
} }
...@@ -1751,7 +1751,7 @@ router_packet_receive( router_state * s, ...@@ -1751,7 +1751,7 @@ router_packet_receive( router_state * s,
} }
int max_vc_size = s->params->vc_size; int max_vc_size = s->params->vc_size;
if(switch_id_to_info[s->router_id].ports[next_port].isTerm) { if(s->params->switch_id_to_info[s->router_id].ports[next_port].isTerm) {
max_vc_size = s->params->cn_vc_size; max_vc_size = s->params->cn_vc_size;
} }
...@@ -1871,7 +1871,7 @@ router_packet_send( router_state * s, ...@@ -1871,7 +1871,7 @@ router_packet_send( router_state * s,
int to_terminal = 0; int to_terminal = 0;
double delay = s->params->link_delay; double delay = s->params->link_delay;
if(switch_id_to_info[s->router_id].ports[next_port].isTerm) { if(s->params->switch_id_to_info[s->router_id].ports[output_port].isTerm) {
to_terminal = 1; to_terminal = 1;
delay = s->params->cn_delay; delay = s->params->cn_delay;
} }
...@@ -2018,7 +2018,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m ...@@ -2018,7 +2018,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m
s->vc_occupancy[indx][output_chan] -= s->params->chunk_size; s->vc_occupancy[indx][output_chan] -= s->params->chunk_size;
int max_vc_size = s->params->vc_size; int max_vc_size = s->params->vc_size;
if(indx < s->params->num_cn) { if(s->params->switch_id_to_info[s->router_id].ports[indx].isTerm) {
max_vc_size = s->params->cn_vc_size; max_vc_size = s->params->cn_vc_size;
} }
...@@ -2034,7 +2034,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m ...@@ -2034,7 +2034,7 @@ static void router_buf_update(router_state * s, tw_bf * bf, LOCAL_MSG_STRUCT * m
s->queued_count[indx] -= s->params->chunk_size; s->queued_count[indx] -= s->params->chunk_size;
} }
if(s->in_send_loop[indx] == 0 && (s->pending_msgs[indx][output_chan] != NULL)) if(s->in_send_loop[indx] == 0 && (s->pending_msgs[indx][output_chan] != NULL)) {
bf->c2 = 1; bf->c2 = 1;
LOCAL_MSG_STRUCT *m; LOCAL_MSG_STRUCT *m;
tw_stime ts = codes_local_latency(lp); tw_stime ts = codes_local_latency(lp);
...@@ -2125,7 +2125,7 @@ static void router_final(router_state * s, ...@@ -2125,7 +2125,7 @@ static void router_final(router_state * s,
tw_lp * lp) tw_lp * lp)
{ {
int i, j; int i, j;
for(i = 0; i < s->params->radix; i++) { for(i = 0; i < s->radix; i++) {
for(j = 0; j < s->params->num_vcs; j++) { for(j = 0; j < s->params->num_vcs; j++) {
if(s->queued_msgs[i][j] != NULL) { if(s->queued_msgs[i][j] != NULL) {
printf("[%llu] leftover queued messages %d %d %d\n", LLU(lp->gid), i, j, printf("[%llu] leftover queued messages %d %d %d\n", LLU(lp->gid), i, j,
...@@ -2148,7 +2148,7 @@ static void router_final(router_state * s, ...@@ -2148,7 +2148,7 @@ static void router_final(router_state * s,
written += sprintf(s->output_buf + written, "\n %llu %d ", written += sprintf(s->output_buf + written, "\n %llu %d ",
LLU(lp->gid), LLU(lp->gid),
s->router_id); s->router_id);
for(int d = 0; d < p->radix; d++) for(int d = 0; d < s->radix; d++)
written += sprintf(s->output_buf + written, " %lf", s->busy_time[d]); written += sprintf(s->output_buf + written, " %lf", s->busy_time[d]);
lp_io_write(lp->gid, (char*)"router-stats", written, s->output_buf); lp_io_write(lp->gid, (char*)"router-stats", written, s->output_buf);
...@@ -2162,7 +2162,7 @@ static void router_final(router_state * s, ...@@ -2162,7 +2162,7 @@ static void router_final(router_state * s,
LLU(lp->gid), LLU(lp->gid),
s->router_id); s->router_id);
for(int d = 0; d < p->radix; d++) for(int d = 0; d < s->radix; d++)
written += sprintf(s->output_buf2 + written, " %lld", LLD(s->link_traffic[d])); written += sprintf(s->output_buf2 + written, " %lld", LLD(s->link_traffic[d]));
assert(written < 4096); assert(written < 4096);
...