Commit 8c1f323e authored by Jonathan Jenkins's avatar Jonathan Jenkins
Browse files

Updating modelnet to the new codes-mapping API

parent 7f9d96d1
......@@ -63,7 +63,7 @@ static double global_bandwidth, local_bandwidth, cn_bandwidth;
static int global_vc_size, local_vc_size, cn_vc_size;
/* global variables for codes mapping */
static char lp_group_name[MAX_NAME_LENGTH], lp_type_name[MAX_NAME_LENGTH];
static char lp_group_name[MAX_NAME_LENGTH];
static int mapping_grp_id, mapping_type_id, mapping_rep_id, mapping_offset;
/* handles terminal and router events like packet generate/send/receive/buffer */
......@@ -251,8 +251,11 @@ static void dragonfly_report_stats()
void dragonfly_collective_init(terminal_state * s,
tw_lp * lp)
{
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, LP_CONFIG_NM);
// TODO: be annotation-aware
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, NULL,
&mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, 1, LP_CONFIG_NM,
NULL, 1);
int num_reps = codes_mapping_get_group_reps(lp_group_name);
s->node_id = (mapping_rep_id * num_lps) + mapping_offset;
......@@ -311,17 +314,12 @@ static tw_stime dragonfly_packet_event(char* category, tw_lpid final_dest_lp, ui
terminal_message * msg;
tw_lpid dest_nic_id;
char* tmp_ptr;
// printf("\n g_tw_lookahead default %f src lp %d sender %d ", g_tw_lookahead, src_lp, sender->gid);
#if 0
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &local_nic_id);
#endif
codes_mapping_get_lp_info(final_dest_lp, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_nic_id);
//TODO: be annotation-aware
codes_mapping_get_lp_info(final_dest_lp, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_nic_id);
xfer_to_nic_time = codes_local_latency(sender); /* Throws an error of found last KP time > current event time otherwise when LPs of one type are placed together*/
//printf("\n transfer in time %f %f ", xfer_to_nic_time+offset, tw_now(sender));
......@@ -546,8 +544,11 @@ void packet_send(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_lp *
s->terminal_available_time = max(s->terminal_available_time, tw_now(lp));
s->terminal_available_time += ts;
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, "dragonfly_router", s->router_id, 0, &router_id);
//TODO: be annotation-aware
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, NULL,
&mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, "dragonfly_router", NULL, 1,
s->router_id, 0, &router_id);
// we are sending an event to the router, so no method_event here
e = tw_event_new(router_id, s->terminal_available_time - tw_now(lp), lp);
......@@ -665,8 +666,11 @@ if( msg->packet_ID == TRACK && msg->chunk_id == num_chunks-1)
s->next_credit_available_time += ts;
tw_lpid router_dest_id;
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, "dragonfly_router", s->router_id, 0, &router_dest_id);
//TODO: be annotation-aware
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, NULL,
&mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, "dragonfly_router", NULL, 1,
s->router_id, 0, &router_dest_id);
// no method_event here - message going to router
buf_e = tw_event_new(router_dest_id, s->next_credit_available_time - tw_now(lp), lp);
buf_msg = tw_event_data(buf_e);
......@@ -686,8 +690,10 @@ terminal_init( terminal_state * s,
{
int i;
// Assign the global router ID
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, LP_CONFIG_NM);
// TODO: be annotation-aware
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, 1, LP_CONFIG_NM,
NULL, 1);
s->terminal_id = (mapping_rep_id * num_lps) + mapping_offset;
s->router_id=(int)s->terminal_id / num_routers;
......@@ -715,8 +721,10 @@ void dragonfly_collective(char* category, int message_size, int remote_event_siz
tw_lpid local_nic_id;
char* tmp_ptr;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &local_nic_id);
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &local_nic_id);
xfer_to_nic_time = codes_local_latency(sender);
e_new = model_net_method_event_new(local_nic_id, xfer_to_nic_time,
......@@ -787,9 +795,15 @@ static void node_collective_init(terminal_state * s,
{
//printf("\n LP %ld sending message to parent %ld ", s->node_id, s->parent_node_id);
/* get the global LP ID of the parent node */
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
num_lps = codes_mapping_get_lp_count(lp_group_name, LP_CONFIG_NM);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, s->parent_node_id/num_lps , (s->parent_node_id % num_lps), &parent_nic_id);
// TODO: be annotation-aware
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id,
&mapping_offset);
num_lps = codes_mapping_get_lp_count(lp_group_name, 1, LP_CONFIG_NM,
NULL, 1);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
s->parent_node_id/num_lps, (s->parent_node_id % num_lps),
&parent_nic_id);
/* send a message to the parent that the LP has entered the collective operation */
xfer_to_nic_time = g_tw_lookahead + LEVEL_DELAY;
......@@ -820,8 +834,10 @@ static void node_collective_fan_in(terminal_state * s,
int i;
s->num_fan_nodes++;
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, LP_CONFIG_NM);
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, 1, LP_CONFIG_NM,
NULL, 1);
tw_event* e_new;
terminal_message * msg_new;
......@@ -840,7 +856,9 @@ static void node_collective_fan_in(terminal_state * s,
xfer_to_nic_time = g_tw_lookahead + LEVEL_DELAY;
/* get the global LP ID of the parent node */
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, s->parent_node_id/num_lps , (s->parent_node_id % num_lps), &parent_nic_id);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
s->parent_node_id/num_lps, (s->parent_node_id % num_lps),
&parent_nic_id);
/* send a message to the parent that the LP has entered the collective operation */
//e_new = codes_event_new(parent_nic_id, xfer_to_nic_time, lp);
......@@ -877,7 +895,9 @@ static void node_collective_fan_in(terminal_state * s,
xfer_to_nic_time = g_tw_lookahead + COLLECTIVE_COMPUTATION_DELAY + LEVEL_DELAY + tw_rand_exponential(lp->rng, (double)LEVEL_DELAY/50);
/* get global LP ID of the child node */
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, s->children[i]/num_lps , (s->children[i] % num_lps), &child_nic_id);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
s->children[i]/num_lps, (s->children[i] % num_lps),
&child_nic_id);
//e_new = codes_event_new(child_nic_id, xfer_to_nic_time, lp);
//msg_new = tw_event_data(e_new);
......@@ -906,7 +926,8 @@ static void node_collective_fan_out(terminal_state * s,
tw_lp * lp)
{
int i;
int num_lps = codes_mapping_get_lp_count(lp_group_name, LP_CONFIG_NM);
int num_lps = codes_mapping_get_lp_count(lp_group_name, 1, LP_CONFIG_NM,
NULL, 1);
bf->c1 = 0;
bf->c2 = 0;
......@@ -928,7 +949,9 @@ static void node_collective_fan_out(terminal_state * s,
tw_lpid child_nic_id;
/* get global LP ID of the child node */
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, s->children[i]/num_lps , (s->children[i] % num_lps), &child_nic_id);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM,
NULL, 1, s->children[i]/num_lps,
(s->children[i] % num_lps), &child_nic_id);
//e_new = codes_event_new(child_nic_id, xfer_to_nic_time, lp);
//msg_new = tw_event_data(e_new);
//memcpy(msg_new, msg, sizeof(nodes_message) + msg->remote_event_size_bytes);
......@@ -1041,11 +1064,16 @@ get_next_stop(router_state * s,
int i;
int dest_group_id;
codes_mapping_get_lp_info(msg->dest_terminal_id, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, LP_CONFIG_NM);
//TODO: be annotation-aware
codes_mapping_get_lp_info(msg->dest_terminal_id, lp_group_name,
&mapping_grp_id, NULL, &mapping_type_id, NULL, &mapping_rep_id,
&mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name, 1, LP_CONFIG_NM,
NULL, 1);
int dest_router_id = (mapping_offset + (mapping_rep_id * num_lps)) / num_routers;
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, NULL,
&mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
int local_router_id = (mapping_offset + mapping_rep_id);
bf->c2 = 0;
......@@ -1102,7 +1130,8 @@ get_next_stop(router_state * s,
}
}
}
codes_mapping_get_lp_id(lp_group_name, "dragonfly_router", dest_lp, 0, &router_dest_id);
codes_mapping_get_lp_id(lp_group_name, "dragonfly_router", NULL, 1, dest_lp,
0, &router_dest_id);
return router_dest_id;
}
......@@ -1115,8 +1144,10 @@ get_output_port( router_state * s,
int next_stop )
{
int output_port = -1, i, terminal_id;
codes_mapping_get_lp_info(msg->dest_terminal_id, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name,LP_CONFIG_NM);
codes_mapping_get_lp_info(msg->dest_terminal_id, lp_group_name,
&mapping_grp_id, NULL, &mapping_type_id, NULL, &mapping_rep_id,
&mapping_offset);
int num_lps = codes_mapping_get_lp_count(lp_group_name,1,LP_CONFIG_NM,NULL,1);
terminal_id = (mapping_rep_id * num_lps) + mapping_offset;
if(next_stop == msg->dest_terminal_id)
......@@ -1127,7 +1158,8 @@ get_output_port( router_state * s,
}
else
{
codes_mapping_get_lp_info(next_stop, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_info(next_stop, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
int local_router_id = mapping_rep_id + mapping_offset;
int intm_grp_id = local_router_id / num_routers;
......@@ -1351,7 +1383,8 @@ router_packet_receive( router_state * s,
/* sets up the router virtual channels, global channels, local channels, compute node channels */
void router_setup(router_state * r, tw_lp * lp)
{
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_info(lp->gid, lp_group_name, &mapping_grp_id, NULL,
&mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
r->router_id=mapping_rep_id + mapping_offset;
r->group_id=r->router_id/num_routers;
......@@ -1623,12 +1656,13 @@ static const tw_lptype* dragonfly_get_router_lp_type(void)
static tw_lpid dragonfly_find_local_device(tw_lp *sender)
{
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
tw_lpid dest_id;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_id);
return(dest_id);
}
......
......@@ -417,7 +417,7 @@ static void handle_msg_start_event(
mn_stats* stat;
int mapping_grp_id, mapping_type_id, mapping_rep_id, mapping_offset;
tw_lpid dest_id;
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
char lp_group_name[MAX_NAME_LENGTH];
int total_event_size;
double xmit_time;
struct param_table_entry *param;
......@@ -462,8 +462,11 @@ static void handle_msg_start_event(
ns->net_send_next_idle += xmit_time + param->g*1000.0;
/* create new event to send msg to receiving NIC */
codes_mapping_get_lp_info(m->final_dest_gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id , mapping_offset, &dest_id);
// TODO: make annotation-aware
codes_mapping_get_lp_info(m->final_dest_gid, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_id);
void *m_data;
// printf("\n msg start sending to %d ", dest_id);
......@@ -529,13 +532,6 @@ static tw_stime loggp_packet_event(
tw_stime xfer_to_nic_time;
loggp_message * msg;
char* tmp_ptr;
#if 0
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
#endif
xfer_to_nic_time = codes_local_latency(sender);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
......@@ -661,12 +657,15 @@ static struct param_table_entry* find_params(uint64_t msg_size)
static tw_lpid loggp_find_local_device(tw_lp *sender)
{
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
char lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
tw_lpid dest_id;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
//TODO: be annotation-aware
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_id);
return(dest_id);
}
......
......@@ -138,11 +138,14 @@ void model_net_base_lp_init(
model_net_base_state * ns,
tw_lp * lp){
// obtain the underlying lp type through codes-mapping
char grp_name[MAX_NAME_LENGTH], lp_type_name[MAX_NAME_LENGTH];
int grp_id, lp_type_id, grp_rep_id, offset;
codes_mapping_get_lp_info(lp->gid, grp_name, &grp_id, &lp_type_id,
lp_type_name, &grp_rep_id, &offset);
char lp_type_name[MAX_NAME_LENGTH];
int dummy;
// TODO: ignoring annotation to get things up and running, but we'll want
// to actually have a sane design here at some point
// we only need the lp type name for this lp
codes_mapping_get_lp_info(lp->gid, NULL, &dummy,
lp_type_name, &dummy, NULL, &dummy, &dummy);
// find the corresponding method name / index
for (int i = 0; i < MAX_NETS; i++){
......
......@@ -60,7 +60,9 @@ static int sn_get_msg_sz(void);
/* Returns the simplenet magic number */
static int sn_get_magic();
#if SIMPLENET_DEBUG
static void print_msg(sn_message *m);
#endif
/* collective network calls */
static void simple_net_collective();
......@@ -423,9 +425,9 @@ static void handle_msg_start_event(
sn_message *m_new;
tw_stime send_queue_time = 0;
mn_stats* stat;
int mapping_grp_id, mapping_type_id, mapping_rep_id, mapping_offset;
int mapping_rep_id, mapping_offset, dummy;
tw_lpid dest_id;
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
char lp_group_name[MAX_NAME_LENGTH];
int total_event_size;
total_event_size = model_net_get_msg_sz(SIMPLENET) + m->event_size_bytes +
......@@ -456,8 +458,11 @@ static void handle_msg_start_event(
/* create new event to send msg to receiving NIC */
codes_mapping_get_lp_info(m->final_dest_gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id , mapping_offset, &dest_id);
// TODO: don't ignore annotations
codes_mapping_get_lp_info(m->final_dest_gid, lp_group_name, &dummy, NULL,
&dummy, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_id);
// printf("\n msg start sending to %d ", dest_id);
void *m_data;
......@@ -527,21 +532,9 @@ static tw_stime simplenet_packet_event(
tw_event * e_new;
tw_stime xfer_to_nic_time;
sn_message * msg;
tw_lpid dest_id;
char* tmp_ptr;
#if 0
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
#endif
//dest_id = sender->gid;
dest_id = src_lp;
xfer_to_nic_time = codes_local_latency(sender);
//e_new = tw_event_new(dest_id, xfer_to_nic_time+offset, sender);
//msg = tw_event_data(e_new);
// this is a self message
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, SIMPLENET, (void**)&msg, (void**)&tmp_ptr);
......@@ -556,10 +549,6 @@ static tw_stime simplenet_packet_event(
msg->is_pull = is_pull;
msg->pull_size = pull_size;
//tmp_ptr = (char*)msg;
//tmp_ptr += model_net_get_msg_sz(SIMPLENET);
//printf("\n Sending to LP %d msg magic %d ", (int)dest_id, sn_get_magic());
/*Fill in simplenet information*/
if(is_last_pckt) /* Its the last packet so pass in remote event information*/
{
......@@ -575,10 +564,7 @@ static tw_stime simplenet_packet_event(
memcpy(tmp_ptr, self_event, self_event_size);
tmp_ptr += self_event_size;
}
// printf("\n Last packet size: %d ", sn_get_msg_sz() + remote_event_size + self_event_size);
}
//print_base_from(SIMPLENET, msg);
//print_msg(msg);
tw_event_send(e_new);
return xfer_to_nic_time;
}
......@@ -587,7 +573,6 @@ static void sn_setup(const void* net_params)
{
simplenet_param* sn_param = (simplenet_param*)net_params;
sn_set_params(sn_param->net_startup_ns, sn_param->net_bw_mbps);
//printf("\n Bandwidth setup %lf %lf ", sn_param->net_startup_ns, sn_param->net_bw_mbps);
}
static void simplenet_packet_event_rc(tw_lp *sender)
......@@ -598,21 +583,26 @@ static void simplenet_packet_event_rc(tw_lp *sender)
static tw_lpid sn_find_local_device(tw_lp *sender)
{
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
char lp_group_name[MAX_NAME_LENGTH];
int mapping_rep_id, mapping_offset, dummy;
tw_lpid dest_id;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
// TODO: don't ignore annotations
codes_mapping_get_lp_info(sender->gid, lp_group_name, &dummy, NULL,
&dummy, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_id);
return(dest_id);
}
#if SIMPLENET_DEBUG
void print_msg(sn_message *m){
printf(" sn:\n type:%d, magic:%d, src:%lu, dest:%lu, esize:%d, lsize:%d\n",
m->event_type, m->magic, m->src_gid, m->final_dest_gid,
m->event_size_bytes, m->local_event_size_bytes);
}
#endif
/*
......
......@@ -238,7 +238,7 @@ static double * parse_mat(char * buf, int *nvals_first, int *nvals_total, int is
*nvals_total = 0;
/* parse the files by line */
int line_ct, line_ct_prev;
int line_ct, line_ct_prev = 0;
char * line_save;
char * line = strtok_r(buf, "\r\n", &line_save);
while (line != NULL){
......@@ -310,8 +310,8 @@ static void sw_set_params(char * startup_fname, char * bw_fname){
sbuf[fsize_s] = '\0';
char *bbuf = malloc(fsize_b+1);
bbuf[fsize_b] = '\0';
fread(sbuf, 1, fsize_s, sf);
fread(bbuf, 1, fsize_b, bf);
assert(fread(sbuf, 1, fsize_s, sf) == fsize_s);
assert(fread(bbuf, 1, fsize_b, bf) == fsize_b);
fclose(sf);
fclose(bf);
......@@ -357,12 +357,13 @@ static void sw_init(
sw_magic = h1+h2;
/* printf("\n sw_magic %d ", sw_magic); */
/* inititalize logical ID */
ns->id = codes_mapping_get_lp_global_rel_id(lp->gid);
/* inititalize global logical ID
* TODO: be annotation aware */
ns->id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0);
/* get the total number of simplewans */
if (num_lps == -1){
num_lps = codes_mapping_get_global_lp_count(LP_CONFIG_NM);
num_lps = codes_mapping_get_lp_count(NULL, 0, LP_CONFIG_NM, NULL, 1);
assert(num_lps > 0);
if (mat_len == -1){
tw_error(TW_LOC, "Simplewan config matrix not initialized "
......@@ -651,9 +652,9 @@ static void handle_msg_start_event(
sw_message *m_new;
tw_stime send_queue_time = 0;
mn_stats* stat;
int mapping_grp_id, mapping_type_id, mapping_rep_id, mapping_offset;
int mapping_rep_id, mapping_offset, dummy;
tw_lpid dest_id;
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
char lp_group_name[MAX_NAME_LENGTH];
int total_event_size;
int dest_rel_id;
double bw, startup;
......@@ -661,9 +662,12 @@ static void handle_msg_start_event(
total_event_size = model_net_get_msg_sz(SIMPLEWAN) + m->event_size_bytes +
m->local_event_size_bytes;
codes_mapping_get_lp_info(m->final_dest_gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id , mapping_offset, &dest_id);
dest_rel_id = codes_mapping_get_lp_global_rel_id(dest_id);
// TODO: don't ignore annotations
codes_mapping_get_lp_info(m->final_dest_gid, lp_group_name, &dummy,
NULL, &dummy, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1,
mapping_rep_id, mapping_offset, &dest_id);
dest_rel_id = codes_mapping_get_lp_relative_id(dest_id, 0, 0);
m->dest_mn_rel_id = dest_rel_id;
/* grab the link params */
......@@ -796,28 +800,17 @@ static tw_stime simplewan_packet_event(
tw_event * e_new;
tw_stime xfer_to_nic_time;
sw_message * msg;
tw_lpid dest_id;
char* tmp_ptr;
#if 0
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
#endif
dest_id = src_lp;
xfer_to_nic_time = codes_local_latency(sender);
#if SIMPLEWAN_DEBUG
printf("%lu: final %lu packet sz %d remote sz %d self sz %d is_last_pckt %d latency %lf\n",
(dest_id - 1) / 2, final_dest_lp, packet_size,
(src_lp - 1) / 2, final_dest_lp, packet_size,
remote_event_size, self_event_size, is_last_pckt,
xfer_to_nic_time+offset);
#endif
//e_new = tw_event_new(dest_id, xfer_to_nic_time+offset, sender);
//msg = tw_event_data(e_new);
e_new = model_net_method_event_new(sender->gid, xfer_to_nic_time+offset,
sender, SIMPLEWAN, (void**)&msg, (void**)&tmp_ptr);
strcpy(msg->category, category);
......@@ -831,9 +824,6 @@ static tw_stime simplewan_packet_event(
msg->is_pull = is_pull;
msg->pull_size = pull_size;
//tmp_ptr = (char*)msg;
//tmp_ptr += sw_get_msg_sz();
//printf("\n Sending to LP %d msg magic %d ", (int)dest_id, sw_get_magic());
/*Fill in simplewan information*/
if(is_last_pckt) /* Its the last packet so pass in remote event information*/
......@@ -871,12 +861,13 @@ static void simplewan_packet_event_rc(tw_lp *sender)
static tw_lpid sw_find_local_device(tw_lp *sender)
{
char lp_type_name[MAX_NAME_LENGTH], lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
char lp_group_name[MAX_NAME_LENGTH];
int mapping_rep_id, mapping_offset, dummy;
tw_lpid dest_id;
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_id);
// TODO: don't ignore annotation
codes_mapping_get_lp_info(sender->gid, lp_group_name, &dummy, NULL, &dummy, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, NULL, 1, mapping_rep_id, mapping_offset, &dest_id);
return(dest_id);
}
......
......@@ -51,7 +51,7 @@ static int * half_length;
static int chunk_size;
/* codes mapping group name, lp type name */
static char grp_name[MAX_NAME_LENGTH], type_name[MAX_NAME_LENGTH];
static char grp_name[MAX_NAME_LENGTH];
/* codes mapping group id, lp type id, repetition id and offset */
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
......@@ -150,8 +150,9 @@ static void torus_setup(const void* net_params)
void torus_collective_init(nodes_state * s,
tw_lp * lp)
{
codes_mapping_get_lp_info(lp->gid, grp_name, &mapping_grp_id, &mapping_type_id, type_name, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(grp_name, LP_CONFIG_NM);
// TODO: be annotation-aware somehow
codes_mapping_get_lp_info(lp->gid, grp_name, &mapping_grp_id, NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
int num_lps = codes_mapping_get_lp_count(grp_name, 1, LP_CONFIG_NM, NULL, 1);
int num_reps = codes_mapping_get_group_reps(grp_name);
s->node_id = (mapping_rep_id * num_lps) + mapping_offset;
......@@ -224,12 +225,11 @@ static tw_stime torus_packet_event(char* category, tw_lpid final_dest_lp, uint64
char* tmp_ptr;
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
#if 0
codes_mapping_get_lp_info(sender->gid, lp_group_name, &mapping_grp_id, &mapping_type_id, lp_type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &local_nic_id);
#endif
codes_mapping_get_lp_info(final_dest_lp, grp_name, &mapping_grp_id, &mapping_type_id, type_name, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(grp_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_nic_id);
// TODO: be annotation-aware
codes_mapping_get_lp_info(final_dest_lp, grp_name, &mapping_grp_id, NULL,
&mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(grp_name, LP_CONFIG_NM, NULL, 1, mapping_rep_id,