Commit ae285cf3 authored by Jonathan Jenkins's avatar Jonathan Jenkins

convert modelnet to provide map-ctx APIs, use map-ctx internally

parent 0d807b5f
...@@ -29,6 +29,7 @@ struct model_net_method ...@@ -29,6 +29,7 @@ struct model_net_method
tw_stime (*model_net_method_packet_event)( tw_stime (*model_net_method_packet_event)(
char const * category, char const * category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
tw_lpid dest_mn_lp, // destination modelnet lp, computed by sender
uint64_t packet_size, uint64_t packet_size,
int is_pull, int is_pull,
uint64_t pull_size, /* only used when is_pull==1 */ uint64_t pull_size, /* only used when is_pull==1 */
...@@ -62,10 +63,6 @@ struct model_net_method ...@@ -62,10 +63,6 @@ struct model_net_method
const tw_lptype* (*mn_get_lp_type)(); const tw_lptype* (*mn_get_lp_type)();
int (*mn_get_msg_sz)(); int (*mn_get_msg_sz)();
void (*mn_report_stats)(); void (*mn_report_stats)();
tw_lpid (*model_net_method_find_local_device)(
const char * annotation,
int ignore_annotations,
tw_lpid sender_gid);
void (*mn_collective_call)(char const * category, int message_size, int remote_event_size, const void* remote_event, tw_lp* sender); void (*mn_collective_call)(char const * category, int message_size, int remote_event_size, const void* remote_event, tw_lp* sender);
void (*mn_collective_call_rc)(int message_size, tw_lp* sender); void (*mn_collective_call_rc)(int message_size, tw_lp* sender);
}; };
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
#ifndef MODELNET_H #ifndef MODELNET_H
#define MODELNET_H #define MODELNET_H
#include "ross.h" #include <ross.h>
#include "codes/lp-type-lookup.h" #include <codes/lp-type-lookup.h>
#include "codes/configuration.h" #include <codes/configuration.h>
#include "codes/lp-io.h" #include <codes/lp-io.h>
#include <codes/codes-mapping-context.h>
#include <stdint.h> #include <stdint.h>
#define PULL_MSG_SIZE 128 #define PULL_MSG_SIZE 128
...@@ -73,6 +74,7 @@ extern char * model_net_method_names[]; ...@@ -73,6 +74,7 @@ extern char * model_net_method_names[];
// not the user) // not the user)
typedef struct model_net_request { typedef struct model_net_request {
tw_lpid final_dest_lp; tw_lpid final_dest_lp;
tw_lpid dest_mn_lp; // destination modelnet lp
tw_lpid src_lp; tw_lpid src_lp;
uint64_t msg_size; uint64_t msg_size;
uint64_t packet_size; uint64_t packet_size;
...@@ -167,10 +169,10 @@ void model_net_event_collective_rc( ...@@ -167,10 +169,10 @@ void model_net_event_collective_rc(
* - sender: pointer to the tw_lp structure of the API caller. This is * - sender: pointer to the tw_lp structure of the API caller. This is
* identical to the sender argument to tw_event_new(). * identical to the sender argument to tw_event_new().
* *
* The modelnet LP used for communication is the LP in the same group, same * The modelnet LP used for communication is determined by the default CODES
* repetition, using net_id to differentiate different model types. If * map context (see codes-base, codes/codes-mapping-context.h), using net_id
* more than one modelnet model of the same type but different annotation exist, * to differentiate different model types. Note that the map context is used
* then the first one listed will be used. * when calculating *both* sender and receiver modelnet LPs
*/ */
// first argument becomes the network ID // first argument becomes the network ID
void model_net_event( void model_net_event(
...@@ -189,7 +191,8 @@ void model_net_event( ...@@ -189,7 +191,8 @@ void model_net_event(
* *
* Unlike model_net_event, this function uses the annotation to differentiate * Unlike model_net_event, this function uses the annotation to differentiate
* multiple modelnet LPs with the same type but different annotation. The caller * multiple modelnet LPs with the same type but different annotation. The caller
* annotation is not consulted here. * annotation is not consulted here. The corresponding CODES map context is
* CODES_MCTX_GROUP_MODULO with the supplied annotation arguments.
*/ */
void model_net_event_annotated( void model_net_event_annotated(
int net_id, int net_id,
...@@ -203,10 +206,32 @@ void model_net_event_annotated( ...@@ -203,10 +206,32 @@ void model_net_event_annotated(
int self_event_size, int self_event_size,
void const * self_event, void const * self_event,
tw_lp *sender); tw_lp *sender);
/*
* See model_net_event for a general description.
*
* This variant uses CODES map contexts to calculate the sender and receiver
* modelnet LPs
*/
void model_net_event_mctx(
int net_id,
struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx,
char const * category,
tw_lpid final_dest_lp,
uint64_t message_size,
tw_stime offset,
int remote_event_size,
void const * remote_event,
int self_event_size,
void const * self_event,
tw_lp *sender);
/* model_net_find_local_device() /* model_net_find_local_device()
* *
* returns the LP id of the network card attached to the calling LP * returns the LP id of the network card attached to the calling LP using the
* default CODES mapping context if ignore_annotations is true, and
* CODES_MCTX_GROUP_MODULO with the supplied annotation parameters otherwise
*/ */
tw_lpid model_net_find_local_device( tw_lpid model_net_find_local_device(
int net_id, int net_id,
...@@ -214,6 +239,12 @@ tw_lpid model_net_find_local_device( ...@@ -214,6 +239,12 @@ tw_lpid model_net_find_local_device(
int ignore_annotations, int ignore_annotations,
tw_lpid sender_gid); tw_lpid sender_gid);
/* same as ^, except use the supplied mapping context */
tw_lpid model_net_find_local_device_mctx(
int net_id,
struct codes_mctx const * map_ctx,
tw_lpid sender_gid);
int model_net_get_msg_sz(int net_id); int model_net_get_msg_sz(int net_id);
/* model_net_event_rc() /* model_net_event_rc()
...@@ -263,6 +294,17 @@ void model_net_pull_event_annotated( ...@@ -263,6 +294,17 @@ void model_net_pull_event_annotated(
int self_event_size, int self_event_size,
void const *self_event, void const *self_event,
tw_lp *sender); tw_lp *sender);
void model_net_pull_event_mctx(
int net_id,
struct codes_mctx * const send_map_ctx,
struct codes_mctx * const recv_map_ctx,
char const *category,
tw_lpid final_dest_lp,
uint64_t message_size,
tw_stime offset,
int self_event_size,
void const *self_event,
tw_lp *sender);
void model_net_pull_event_rc( void model_net_pull_event_rc(
int net_id, int net_id,
tw_lp *sender); tw_lp *sender);
......
...@@ -29,8 +29,9 @@ struct terminal_message ...@@ -29,8 +29,9 @@ struct terminal_message
tw_lpid final_dest_gid; tw_lpid final_dest_gid;
/*sending LP ID from CODES, can be a server or any other LP type */ /*sending LP ID from CODES, can be a server or any other LP type */
tw_lpid sender_lp; tw_lpid sender_lp;
tw_lpid sender_mn_lp; // source modelnet id
/* destination terminal ID of the dragonfly */ /* destination terminal ID of the dragonfly */
unsigned int dest_terminal_id; tw_lpid dest_terminal_id;
/* source terminal ID of the dragonfly */ /* source terminal ID of the dragonfly */
unsigned int src_terminal_id; unsigned int src_terminal_id;
/* local LP ID to calculate the radix of the sender node/router */ /* local LP ID to calculate the radix of the sender node/router */
......
...@@ -23,7 +23,9 @@ struct loggp_message ...@@ -23,7 +23,9 @@ struct loggp_message
int magic; /* magic number */ int magic; /* magic number */
enum loggp_event_type event_type; enum loggp_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */ tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid src_mn_lp; // src modelnet id, provided by sender
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */ tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
tw_lpid dest_mn_lp; // destination modelnet id, provided by sender
uint64_t net_msg_size_bytes; /* size of modeled network message */ uint64_t net_msg_size_bytes; /* size of modeled network message */
int event_size_bytes; /* size of simulator event message that will be tunnelled to destination */ int event_size_bytes; /* size of simulator event message that will be tunnelled to destination */
int local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */ int local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */
......
...@@ -21,7 +21,9 @@ struct sn_message ...@@ -21,7 +21,9 @@ struct sn_message
int magic; /* magic number */ int magic; /* magic number */
enum sn_event_type event_type; enum sn_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */ tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid src_mn_lp; // src modelnet id, provided by sender
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */ tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
tw_lpid dest_mn_lp; // destination modelnet id, provided by sender
uint64_t net_msg_size_bytes; /* size of modeled network message */ uint64_t net_msg_size_bytes; /* size of modeled network message */
int event_size_bytes; /* size of simulator event message that will be tunnelled to destination */ int event_size_bytes; /* size of simulator event message that will be tunnelled to destination */
int local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */ int local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */
......
...@@ -20,7 +20,9 @@ struct sp_message ...@@ -20,7 +20,9 @@ struct sp_message
int magic; /* magic number */ int magic; /* magic number */
enum sp_event_type event_type; enum sp_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */ tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid src_mn_lp; // src modelnet id, provided by sender
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */ tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
tw_lpid dest_mn_lp; // destination modelnet id, provided by sender
/* relative ID of the sending simplep2p message (for latency/bandwidth lookup) */ /* relative ID of the sending simplep2p message (for latency/bandwidth lookup) */
int src_mn_rel_id; int src_mn_rel_id;
int dest_mn_rel_id; /* included to make rc easier */ int dest_mn_rel_id; /* included to make rc easier */
......
...@@ -423,7 +423,7 @@ void dragonfly_collective_init(terminal_state * s, ...@@ -423,7 +423,7 @@ void dragonfly_collective_init(terminal_state * s,
} }
/* dragonfly packet event , generates a dragonfly packet on the compute node */ /* dragonfly packet event , generates a dragonfly packet on the compute node */
static tw_stime dragonfly_packet_event(char* category, tw_lpid final_dest_lp, uint64_t packet_size, int is_pull, uint64_t pull_size, tw_stime offset, const mn_sched_params *sched_params, int remote_event_size, const void* remote_event, int self_event_size, const void* self_event, tw_lpid src_lp, tw_lp *sender, int is_last_pckt) static tw_stime dragonfly_packet_event(char const * category, tw_lpid final_dest_lp, tw_lpid dest_mn_lp, uint64_t packet_size, int is_pull, uint64_t pull_size, tw_stime offset, const mn_sched_params *sched_params, int remote_event_size, const void* remote_event, int self_event_size, const void* self_event, tw_lpid src_lp, tw_lp *sender, int is_last_pckt)
{ {
tw_event * e_new; tw_event * e_new;
tw_stime xfer_to_nic_time; tw_stime xfer_to_nic_time;
...@@ -438,7 +438,9 @@ static tw_stime dragonfly_packet_event(char* category, tw_lpid final_dest_lp, ui ...@@ -438,7 +438,9 @@ static tw_stime dragonfly_packet_event(char* category, tw_lpid final_dest_lp, ui
sender, DRAGONFLY, (void**)&msg, (void**)&tmp_ptr); sender, DRAGONFLY, (void**)&msg, (void**)&tmp_ptr);
strcpy(msg->category, category); strcpy(msg->category, category);
msg->final_dest_gid = final_dest_lp; msg->final_dest_gid = final_dest_lp;
msg->dest_terminal_id = dest_mn_lp;
msg->sender_lp=src_lp; msg->sender_lp=src_lp;
msg->sender_mn_lp = sender->gid;
msg->packet_size = packet_size; msg->packet_size = packet_size;
msg->remote_event_size_bytes = 0; msg->remote_event_size_bytes = 0;
msg->local_event_size_bytes = 0; msg->local_event_size_bytes = 0;
...@@ -576,11 +578,6 @@ void router_credit_send(router_state * s, tw_bf * bf, terminal_message * msg, tw ...@@ -576,11 +578,6 @@ void router_credit_send(router_state * s, tw_bf * bf, terminal_message * msg, tw
/* generates packet at the current dragonfly compute node */ /* generates packet at the current dragonfly compute node */
void packet_generate(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_lp * lp) void packet_generate(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_lp * lp)
{ {
tw_lpid dest_terminal_id;
dest_terminal_id = model_net_find_local_device(DRAGONFLY, s->anno, 0,
msg->final_dest_gid);
msg->dest_terminal_id = dest_terminal_id;
const dragonfly_param *p = s->params; const dragonfly_param *p = s->params;
tw_stime ts; tw_stime ts;
...@@ -613,7 +610,6 @@ void packet_generate(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_ ...@@ -613,7 +610,6 @@ void packet_generate(terminal_state * s, tw_bf * bf, terminal_message * msg, tw_
e = model_net_method_event_new(lp->gid, i+ts, lp, DRAGONFLY, e = model_net_method_event_new(lp->gid, i+ts, lp, DRAGONFLY,
(void**)&m, &m_data); (void**)&m, &m_data);
memcpy(m, msg, sizeof(terminal_message)); memcpy(m, msg, sizeof(terminal_message));
m->dest_terminal_id = dest_terminal_id;
void * m_data_src = model_net_method_get_edata(DRAGONFLY, msg); void * m_data_src = model_net_method_get_edata(DRAGONFLY, msg);
if (msg->remote_event_size_bytes){ if (msg->remote_event_size_bytes){
memcpy(m_data, m_data_src, msg->remote_event_size_bytes); memcpy(m_data, m_data_src, msg->remote_event_size_bytes);
...@@ -803,10 +799,14 @@ if( msg->packet_ID == TRACK && msg->chunk_id == num_chunks-1) ...@@ -803,10 +799,14 @@ if( msg->packet_ID == TRACK && msg->chunk_id == num_chunks-1)
void * tmp_ptr = model_net_method_get_edata(DRAGONFLY, msg); void * tmp_ptr = model_net_method_get_edata(DRAGONFLY, msg);
ts = g_tw_lookahead + 0.1 + (1/s->params->cn_bandwidth) * msg->remote_event_size_bytes; ts = g_tw_lookahead + 0.1 + (1/s->params->cn_bandwidth) * msg->remote_event_size_bytes;
if (msg->is_pull){ if (msg->is_pull){
struct codes_mctx mc_dst =
codes_mctx_set_global_direct(msg->sender_mn_lp);
struct codes_mctx mc_src =
codes_mctx_set_global_direct(lp->gid);
int net_id = model_net_get_id(LP_METHOD_NM); int net_id = model_net_get_id(LP_METHOD_NM);
model_net_event(net_id, msg->category, msg->sender_lp, model_net_event_mctx(net_id, &mc_src, &mc_dst, msg->category,
msg->pull_size, ts, msg->remote_event_size_bytes, msg->sender_lp, msg->pull_size, ts,
tmp_ptr, 0, NULL, lp); msg->remote_event_size_bytes, tmp_ptr, 0, NULL, lp);
} }
else{ else{
e = tw_event_new(msg->final_dest_gid, ts, lp); e = tw_event_new(msg->final_dest_gid, ts, lp);
...@@ -1982,22 +1982,6 @@ static const tw_lptype* dragonfly_get_router_lp_type(void) ...@@ -1982,22 +1982,6 @@ static const tw_lptype* dragonfly_get_router_lp_type(void)
return(&dragonfly_lps[1]); return(&dragonfly_lps[1]);
} }
static tw_lpid dragonfly_find_local_device(
const char * annotation,
int ignore_annotations,
tw_lp * sender)
{
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,
NULL, &mapping_type_id, NULL, &mapping_rep_id, &mapping_offset);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, annotation,
ignore_annotations, mapping_rep_id, mapping_offset, &dest_id);
return(dest_id);
}
static void dragonfly_register(tw_lptype *base_type) { static void dragonfly_register(tw_lptype *base_type) {
lp_type_register(LP_CONFIG_NM, base_type); lp_type_register(LP_CONFIG_NM, base_type);
lp_type_register("dragonfly_router", &dragonfly_lps[1]); lp_type_register("dragonfly_router", &dragonfly_lps[1]);
...@@ -2015,7 +1999,6 @@ struct model_net_method dragonfly_method = ...@@ -2015,7 +1999,6 @@ struct model_net_method dragonfly_method =
.mn_get_lp_type = dragonfly_get_cn_lp_type, .mn_get_lp_type = dragonfly_get_cn_lp_type,
.mn_get_msg_sz = dragonfly_get_msg_sz, .mn_get_msg_sz = dragonfly_get_msg_sz,
.mn_report_stats = dragonfly_report_stats, .mn_report_stats = dragonfly_report_stats,
.model_net_method_find_local_device = NULL,
.mn_collective_call = dragonfly_collective, .mn_collective_call = dragonfly_collective,
.mn_collective_call_rc = dragonfly_collective_rc .mn_collective_call_rc = dragonfly_collective_rc
}; };
......
...@@ -110,8 +110,9 @@ static void loggp_set_params(const char * config_file, loggp_param * params); ...@@ -110,8 +110,9 @@ static void loggp_set_params(const char * config_file, loggp_param * params);
/* Issues a loggp packet event call */ /* Issues a loggp packet event call */
static tw_stime loggp_packet_event( static tw_stime loggp_packet_event(
char* category, char const * category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
tw_lpid dest_mn_lp,
uint64_t packet_size, uint64_t packet_size,
int is_pull, int is_pull,
uint64_t pull_size, /* only used when is_pull==1 */ uint64_t pull_size, /* only used when is_pull==1 */
...@@ -142,11 +143,6 @@ void loggp_recv_msg_event_rc(tw_lp *sender); ...@@ -142,11 +143,6 @@ void loggp_recv_msg_event_rc(tw_lp *sender);
static void loggp_report_stats(); static void loggp_report_stats();
static tw_lpid loggp_find_local_device(
const char * annotation,
int ignore_annotations,
tw_lp * sender);
static const struct param_table_entry* find_params( static const struct param_table_entry* find_params(
uint64_t msg_size, uint64_t msg_size,
const loggp_param *params); const loggp_param *params);
...@@ -163,7 +159,6 @@ struct model_net_method loggp_method = ...@@ -163,7 +159,6 @@ struct model_net_method loggp_method =
.mn_get_lp_type = loggp_get_lp_type, .mn_get_lp_type = loggp_get_lp_type,
.mn_get_msg_sz = loggp_get_msg_sz, .mn_get_msg_sz = loggp_get_msg_sz,
.mn_report_stats = loggp_report_stats, .mn_report_stats = loggp_report_stats,
.model_net_method_find_local_device = NULL,
.mn_collective_call = loggp_collective, .mn_collective_call = loggp_collective,
.mn_collective_call_rc = loggp_collective_rc .mn_collective_call_rc = loggp_collective_rc
}; };
...@@ -438,10 +433,14 @@ static void handle_msg_ready_event( ...@@ -438,10 +433,14 @@ static void handle_msg_ready_event(
//tmp_ptr += loggp_get_msg_sz(); //tmp_ptr += loggp_get_msg_sz();
if (m->is_pull){ if (m->is_pull){
/* call the model-net event */ /* call the model-net event */
struct codes_mctx mc_dst =
codes_mctx_set_global_direct(m->src_mn_lp);
struct codes_mctx mc_src =
codes_mctx_set_global_direct(lp->gid);
int net_id = model_net_get_id(LP_METHOD_NM); int net_id = model_net_get_id(LP_METHOD_NM);
model_net_event(net_id, m->category, m->src_gid, m->pull_size, model_net_event_mctx(net_id, &mc_src, &mc_dst, m->category,
recv_queue_time, m->event_size_bytes, tmp_ptr, 0, NULL, m->src_gid, m->pull_size, recv_queue_time,
lp); m->event_size_bytes, tmp_ptr, 0, NULL, lp);
} }
else{ else{
e_new = tw_event_new(m->final_dest_gid, recv_queue_time, lp); e_new = tw_event_new(m->final_dest_gid, recv_queue_time, lp);
...@@ -503,9 +502,6 @@ static void handle_msg_start_event( ...@@ -503,9 +502,6 @@ static void handle_msg_start_event(
loggp_message *m_new; loggp_message *m_new;
tw_stime send_queue_time = 0; tw_stime send_queue_time = 0;
mn_stats* stat; mn_stats* stat;
int mapping_grp_id, mapping_type_id, mapping_rep_id, mapping_offset;
tw_lpid dest_id;
char lp_group_name[MAX_NAME_LENGTH];
int total_event_size; int total_event_size;
double xmit_time; double xmit_time;
const struct param_table_entry *param; const struct param_table_entry *param;
...@@ -549,10 +545,6 @@ static void handle_msg_start_event( ...@@ -549,10 +545,6 @@ static void handle_msg_start_event(
ns->net_send_next_idle = tw_now(lp); ns->net_send_next_idle = tw_now(lp);
ns->net_send_next_idle += xmit_time + param->g*1000.0; ns->net_send_next_idle += xmit_time + param->g*1000.0;
/* create new event to send msg to receiving NIC */
dest_id = model_net_find_local_device(LOGGP, ns->anno, 0,
m->final_dest_gid);
dprintf("%lu (mn): start msg %lu->%lu, size %lu (%3s last)\n" dprintf("%lu (mn): start msg %lu->%lu, size %lu (%3s last)\n"
" now:%0.3le, idle[prev:%0.3le, next:%0.3le], " " now:%0.3le, idle[prev:%0.3le, next:%0.3le], "
"q-time:%0.3le\n", "q-time:%0.3le\n",
...@@ -562,16 +554,13 @@ static void handle_msg_start_event( ...@@ -562,16 +554,13 @@ static void handle_msg_start_event(
send_queue_time); send_queue_time);
#if USE_RECV_QUEUE #if USE_RECV_QUEUE
model_net_method_send_msg_recv_event(m->final_dest_gid, dest_id, m->src_gid, model_net_method_send_msg_recv_event(m->final_dest_gid, m->dest_mn_lp,
m->net_msg_size_bytes, m->is_pull, m->pull_size, m->src_gid, m->net_msg_size_bytes, m->is_pull, m->pull_size,
m->event_size_bytes, &m->sched_params, m->category, LOGGP, m, m->event_size_bytes, &m->sched_params, m->category, LOGGP, m,
send_queue_time, lp); send_queue_time, lp);
#else #else
void *m_data; void *m_data;
// printf("\n msg start sending to %d ", dest_id); e_new = model_net_method_event_new(m->dest_mn_lp, send_queue_time, lp, LOGGP,
//e_new = tw_event_new(dest_id, send_queue_time, lp);
//m_new = tw_event_data(e_new);
e_new = model_net_method_event_new(dest_id, send_queue_time, lp, LOGGP,
(void**)&m_new, &m_data); (void**)&m_new, &m_data);
/* copy entire previous message over, including payload from user of /* copy entire previous message over, including payload from user of
* this module * this module
...@@ -618,8 +607,9 @@ static void handle_msg_start_event( ...@@ -618,8 +607,9 @@ static void handle_msg_start_event(
/*This method will serve as an intermediate layer between loggp and modelnet. /*This method will serve as an intermediate layer between loggp and modelnet.
* It takes the packets from modelnet layer and calls underlying loggp methods*/ * It takes the packets from modelnet layer and calls underlying loggp methods*/
static tw_stime loggp_packet_event( static tw_stime loggp_packet_event(
char* category, char const* category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
tw_lpid dest_mn_lp,
uint64_t packet_size, uint64_t packet_size,
int is_pull, int is_pull,
uint64_t pull_size, /* only used when is_pull==1 */ uint64_t pull_size, /* only used when is_pull==1 */
...@@ -645,7 +635,9 @@ static tw_stime loggp_packet_event( ...@@ -645,7 +635,9 @@ static tw_stime loggp_packet_event(
//msg = tw_event_data(e_new); //msg = tw_event_data(e_new);
strcpy(msg->category, category); strcpy(msg->category, category);
msg->final_dest_gid = final_dest_lp; msg->final_dest_gid = final_dest_lp;
msg->dest_mn_lp = dest_mn_lp;
msg->src_gid = src_lp; msg->src_gid = src_lp;
msg->src_mn_lp = sender->gid;
msg->magic = loggp_get_magic(); msg->magic = loggp_get_magic();
msg->net_msg_size_bytes = packet_size; msg->net_msg_size_bytes = packet_size;
msg->event_size_bytes = 0; msg->event_size_bytes = 0;
...@@ -834,25 +826,6 @@ static const struct param_table_entry* find_params( ...@@ -834,25 +826,6 @@ static const struct param_table_entry* find_params(
return(&params->table[i]); return(&params->table[i]);
} }
static tw_lpid loggp_find_local_device(
const char * annotation,
int ignore_annotations,
tw_lp * sender)
{
char lp_group_name[MAX_NAME_LENGTH];
int mapping_grp_id, mapping_rep_id, mapping_type_id, mapping_offset;
tw_lpid 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, annotation,
ignore_annotations, mapping_rep_id, mapping_offset, &dest_id);
return(dest_id);
}
/* /*
* Local variables: * Local variables:
* c-indent-level: 4 * c-indent-level: 4
......
...@@ -534,6 +534,8 @@ void model_net_method_send_msg_recv_event( ...@@ -534,6 +534,8 @@ void model_net_method_send_msg_recv_event(
m->msg.m_base.req.final_dest_lp = final_dest_lp; m->msg.m_base.req.final_dest_lp = final_dest_lp;
m->msg.m_base.req.src_lp = src_lp; m->msg.m_base.req.src_lp = src_lp;
// for "recv" events, set the "dest" to this LP in the case of a pull event
m->msg.m_base.req.dest_mn_lp = sender->gid;
m->msg.m_base.req.msg_size = is_pull ? pull_size : msg_size; m->msg.m_base.req.msg_size = is_pull ? pull_size : msg_size;
m->msg.m_base.req.packet_size = m->msg.m_base.req.msg_size; m->msg.m_base.req.packet_size = m->msg.m_base.req.msg_size;
m->msg.m_base.req.net_id = net_id; m->msg.m_base.req.net_id = net_id;
......
...@@ -264,8 +264,9 @@ int fcfs_next( ...@@ -264,8 +264,9 @@ int fcfs_next(
lp->gid, psize, q->rem, q->req.src_lp, q->req.final_dest_lp, lp->gid, psize, q->rem, q->req.src_lp, q->req.final_dest_lp,
tw_now(lp), is_last_packet); tw_now(lp), is_last_packet);
*poffset = s->method->model_net_method_packet_event(q->req.category, *poffset = s->method->model_net_method_packet_event(q->req.category,
q->req.final_dest_lp, psize, q->req.is_pull, q->req.msg_size, q->req.final_dest_lp, q->req.dest_mn_lp, psize, q->req.is_pull,
0.0, &q->sched_params, q->req.remote_event_size, q->remote_event, q->req.msg_size, 0.0, &q->sched_params,
q->req.remote_event_size, q->remote_event,
q->req.self_event_size, q->local_event, q->req.src_lp, lp, q->req.self_event_size, q->local_event, q->req.src_lp, lp,
is_last_packet); is_last_packet);
} }
......
...@@ -223,8 +223,8 @@ struct mn_stats* model_net_find_stats(char const * category, mn_stats mn_stats_a ...@@ -223,8 +223,8 @@ struct mn_stats* model_net_find_stats(char const * category, mn_stats mn_stats_a
static void model_net_event_impl_base( static void model_net_event_impl_base(
int net_id, int net_id,
char const * annotation, struct codes_mctx const * send_map_ctx,
int ignore_annotations, struct codes_mctx const * recv_map_ctx,
char const * category, char const * category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
uint64_t message_size, uint64_t message_size,
...@@ -245,15 +245,18 @@ static void model_net_event_impl_base( ...@@ -245,15 +245,18 @@ static void model_net_event_impl_base(
return; return;
} }
tw_lpid mn_lp = model_net_find_local_device(net_id, annotation, tw_lpid src_mn_lp = model_net_find_local_device_mctx(net_id, send_map_ctx,
ignore_annotations, sender->gid); sender->gid);
tw_lpid dest_mn_lp = model_net_find_local_device_mctx(net_id, recv_map_ctx,
final_dest_lp);
tw_stime poffset = codes_local_latency(sender); tw_stime poffset = codes_local_latency(sender);
if (mn_in_seqence){ if (mn_in_seqence){
tw_stime tmp = mn_msg_offset; tw_stime tmp = mn_msg_offset;
mn_msg_offset += poffset; mn_msg_offset += poffset;
poffset += tmp; poffset += tmp;
} }
tw_event *e = codes_event_new(mn_lp, poffset+offset, sender); tw_event *e = codes_event_new(src_mn_lp, poffset+offset, sender);
model_net_wrap_msg *m = tw_event_data(e); model_net_wrap_msg *m = tw_event_data(e);
msg_set_header(model_net_base_magic, MN_BASE_NEW_MSG, sender->gid, &m->h); msg_set_header(model_net_base_magic, MN_BASE_NEW_MSG, sender->gid, &m->h);
...@@ -262,6 +265,7 @@ static void model_net_event_impl_base( ...@@ -262,6 +265,7 @@ static void model_net_event_impl_base(
model_net_request *r = &m->msg.m_base.req; model_net_request *r = &m->msg.m_base.req;
r->net_id = net_id; r->net_id = net_id;
r->final_dest_lp = final_dest_lp; r->final_dest_lp = final_dest_lp;
r->dest_mn_lp = dest_mn_lp;
r->src_lp = sender->gid; r->src_lp = sender->gid;
r->msg_size = message_size; r->msg_size = message_size;
r->remote_event_size = remote_event_size; r->remote_event_size = remote_event_size;
...@@ -310,9 +314,10 @@ void model_net_event( ...@@ -310,9 +314,10 @@ void model_net_event(
void const * self_event, void const * self_event,
tw_lp *sender) tw_lp *sender)
{ {
model_net_event_impl_base(net_id, NULL, 1, category, final_dest_lp, model_net_event_impl_base(net_id, CODES_MCTX_DEFAULT, CODES_MCTX_DEFAULT,
message_size, 0, offset, remote_event_size, remote_event, category, final_dest_lp, message_size, 0, offset,
self_event_size, self_event, sender); remote_event_size, remote_event, self_event_size, self_event,
sender);
} }
void model_net_event_annotated( void model_net_event_annotated(
...@@ -327,11 +332,30 @@ void model_net_event_annotated( ...@@ -327,11 +332,30 @@ void model_net_event_annotated(
int self_event_size, int self_event_size,
void const * self_event, void const * self_event,
tw_lp *sender){ tw_lp *sender){
model_net_event_impl_base(net_id, annotation, 0, category, final_dest_lp, struct codes_mctx mc = codes_mctx_set_group_modulo(annotation, true);
model_net_event_impl_base(net_id, &mc, &mc, category, final_dest_lp,
message_size, 0, offset, remote_event_size, remote_event, message_size, 0, offset, remote_event_size, remote_event,
self_event_size, self_event, sender); self_event_size, self_event, sender);
} }
void model_net_event_mctx(
int net_id,
struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx,
char const * category,
tw_lpid final_dest_lp,
uint64_t message_size,
tw_stime offset,
int remote_event_size,
void const * remote_event,
int self_event_size,
void const * self_event,
tw_lp *sender){
model_net_event_impl_base(net_id, send_map_ctx, recv_map_ctx, category,
final_dest_lp, message_size, 0, offset, remote_event_size,
remote_event, self_event_size, self_event, sender);
}
void model_net_pull_event( void model_net_pull_event(
int net_id, int net_id,
char const *category, char const *category,
...@@ -343,9 +367,9 @@ void model_net_pull_event( ...@@ -343,9 +367,9 @@ void model_net_pull_event(
tw_lp *sender){ tw_lp *sender){
/* NOTE: for a pull, we are filling the *remote* event - it will be remote /* NOTE: for a pull, we are filling the *remote* event - it will be remote
* from the destination's POV */ * from the destination's POV */
model_net_event_impl_base(net_id, NULL, 0, category, final_dest_lp, model_net_event_impl_base(net_id, CODES_MCTX_DEFAULT, CODES_MCTX_DEFAULT,
message_size, 1, offset, self_event_size, self_event, 0, NULL, category, final_dest_lp, message_size, 1, offset, self_event_size,
sender); self_event, 0, NULL, sender);
} }
void model_net_pull_event_annotated( void model_net_pull_event_annotated(
...@@ -360,11 +384,30 @@ void model_net_pull_event_annotated( ...@@ -360,11 +384,30 @@ void model_net_pull_event_annotated(
tw_lp *sender){