Commit 9c4e2fad authored by Jonathan Jenkins's avatar Jonathan Jenkins
Browse files

update modelnet interface, rc to impl local comm

parent a78fee52
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
#define CATEGORY_NAME_MAX 16 #define CATEGORY_NAME_MAX 16
#define CATEGORY_MAX 12 #define CATEGORY_MAX 12
// simple deprecation attribute hacking
#if defined(__GNUC__) || defined(__GNUG__) || defined(__clang__)
#define DEPRECATED(_msg) __attribute__((deprecated(_msg)))
#else
#define DEPRECATED(_msg)
#endif
/* HACK: there is currently no scheduling fidelity across multiple /* HACK: there is currently no scheduling fidelity across multiple
* model_net_event calls. Hence, problems arise when some LP sends multiple * model_net_event calls. Hence, problems arise when some LP sends multiple
* messages as part of an event and expects FCFS ordering. A proper fix which * messages as part of an event and expects FCFS ordering. A proper fix which
...@@ -27,14 +34,14 @@ ...@@ -27,14 +34,14 @@
* feasible for now (would basically have to redesign model-net), so expose * feasible for now (would basically have to redesign model-net), so expose
* explicit start-sequence and stop-sequence markers as a workaround * explicit start-sequence and stop-sequence markers as a workaround
*/ */
extern int mn_in_seqence; extern int mn_in_sequence;
extern tw_stime mn_msg_offset; extern tw_stime mn_msg_offset;
#define MN_START_SEQ() do {\ #define MN_START_SEQ() do {\
mn_in_seqence = 1; \ mn_in_sequence = 1; \
mn_msg_offset = 0.0; \ mn_msg_offset = 0.0; \
} while (0) } while (0)
#define MN_END_SEQ() do {\ #define MN_END_SEQ() do {\
mn_in_seqence = 0;\ mn_in_sequence = 0;\
} while (0) } while (0)
...@@ -65,6 +72,11 @@ enum msg_param_type { ...@@ -65,6 +72,11 @@ enum msg_param_type {
MAX_MN_MSG_PARAM_TYPES MAX_MN_MSG_PARAM_TYPES
}; };
// return type for model_net_*event calls, to be passed into RC
// currently is just an int, but in the future may indicate whether lp-io was
// called etc.
typedef int model_net_event_return;
// network identifiers (both the config lp names and the model-net internal // network identifiers (both the config lp names and the model-net internal
// names) // names)
extern char * model_net_lp_config_names[]; extern char * model_net_lp_config_names[];
...@@ -175,7 +187,7 @@ void model_net_event_collective_rc( ...@@ -175,7 +187,7 @@ void model_net_event_collective_rc(
* when calculating *both* sender and receiver modelnet LPs * when calculating *both* sender and receiver modelnet LPs
*/ */
// first argument becomes the network ID // first argument becomes the network ID
void model_net_event( model_net_event_return model_net_event(
int net_id, int net_id,
char const * category, char const * category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
...@@ -194,7 +206,7 @@ void model_net_event( ...@@ -194,7 +206,7 @@ void model_net_event(
* annotation is not consulted here. The corresponding CODES map context is * annotation is not consulted here. The corresponding CODES map context is
* CODES_MCTX_GROUP_MODULO with the supplied annotation arguments. * CODES_MCTX_GROUP_MODULO with the supplied annotation arguments.
*/ */
void model_net_event_annotated( model_net_event_return model_net_event_annotated(
int net_id, int net_id,
char const * annotation, char const * annotation,
char const * category, char const * category,
...@@ -212,7 +224,7 @@ void model_net_event_annotated( ...@@ -212,7 +224,7 @@ void model_net_event_annotated(
* This variant uses CODES map contexts to calculate the sender and receiver * This variant uses CODES map contexts to calculate the sender and receiver
* modelnet LPs * modelnet LPs
*/ */
void model_net_event_mctx( model_net_event_return model_net_event_mctx(
int net_id, int net_id,
struct codes_mctx const * send_map_ctx, struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx, struct codes_mctx const * recv_map_ctx,
...@@ -257,11 +269,18 @@ int model_net_get_msg_sz(int net_id); ...@@ -257,11 +269,18 @@ int model_net_get_msg_sz(int net_id);
/* NOTE: we may end up needing additoinal arguments here to track state for /* NOTE: we may end up needing additoinal arguments here to track state for
* reverse computation; add as needed * reverse computation; add as needed
*/ */
DEPRECATED("use model_net_event_rc2 instead, invalid RNG rollback can occur otherwise")
void model_net_event_rc( void model_net_event_rc(
int net_id, int net_id,
tw_lp *sender, tw_lp *sender,
uint64_t message_size); uint64_t message_size);
/* This function replaces model_net_event_rc, and will replace the name later
* on. The num_rng_calls argument is the return value of model_net_*event*
* calls */
void model_net_event_rc2(
tw_lp *sender,
model_net_event_return const * ret);
/* Issue a 'pull' from the memory of the destination LP, without /* Issue a 'pull' from the memory of the destination LP, without
* requiring the destination LP to do event processing. This is meant as a * requiring the destination LP to do event processing. This is meant as a
...@@ -275,7 +294,7 @@ void model_net_event_rc( ...@@ -275,7 +294,7 @@ void model_net_event_rc(
* - self_event_size, self_event are applied at the requester upon receipt of * - self_event_size, self_event are applied at the requester upon receipt of
* the payload from the dest * the payload from the dest
*/ */
void model_net_pull_event( model_net_event_return model_net_pull_event(
int net_id, int net_id,
char const *category, char const *category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
...@@ -284,7 +303,7 @@ void model_net_pull_event( ...@@ -284,7 +303,7 @@ void model_net_pull_event(
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_annotated( model_net_event_return model_net_pull_event_annotated(
int net_id, int net_id,
char const * annotation, char const * annotation,
char const *category, char const *category,
...@@ -294,7 +313,7 @@ void model_net_pull_event_annotated( ...@@ -294,7 +313,7 @@ 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( model_net_event_return model_net_pull_event_mctx(
int net_id, int net_id,
struct codes_mctx const * send_map_ctx, struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx, struct codes_mctx const * recv_map_ctx,
...@@ -305,6 +324,8 @@ void model_net_pull_event_mctx( ...@@ -305,6 +324,8 @@ void model_net_pull_event_mctx(
int self_event_size, int self_event_size,
void const *self_event, void const *self_event,
tw_lp *sender); tw_lp *sender);
DEPRECATED("use model_net_event_rc2 instead, invalid RNG rollback can occur otherwise")
void model_net_pull_event_rc( void model_net_pull_event_rc(
int net_id, int net_id,
tw_lp *sender); tw_lp *sender);
......
...@@ -43,7 +43,7 @@ struct model_net_method* method_array[] = { ...@@ -43,7 +43,7 @@ struct model_net_method* method_array[] = {
#undef X #undef X
// counter and offset for the MN_START_SEQ / MN_END_SEQ macros // counter and offset for the MN_START_SEQ / MN_END_SEQ macros
int mn_in_seqence = 0; int mn_in_sequence = 0;
tw_stime mn_msg_offset = 0.0; tw_stime mn_msg_offset = 0.0;
// message parameters for use via model_net_set_msg_param // message parameters for use via model_net_set_msg_param
...@@ -221,7 +221,42 @@ struct mn_stats* model_net_find_stats(char const * category, mn_stats mn_stats_a ...@@ -221,7 +221,42 @@ struct mn_stats* model_net_find_stats(char const * category, mn_stats mn_stats_a
return(&mn_stats_array[i]); return(&mn_stats_array[i]);
} }
static void model_net_event_impl_base( static model_net_event_return model_net_noop_event(
tw_lpid final_dest_lp,
int is_pull,
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_return num_rng_calls = 0;
tw_stime poffset = mn_in_sequence ? mn_msg_offset : 0.0;
if (self_event_size && self_event != NULL) {
poffset += codes_local_latency(sender);
num_rng_calls++;
tw_event *e = tw_event_new(sender->gid, poffset+offset, sender);
memcpy(tw_event_data(e), self_event, self_event_size);
tw_event_send(e);
}
if (remote_event_size && remote_event != NULL) {
poffset += codes_local_latency(sender);
num_rng_calls++;
tw_event *e = tw_event_new(final_dest_lp, poffset+offset, sender);
memcpy(tw_event_data(e), remote_event, remote_event_size);
tw_event_send(e);
}
if (mn_in_sequence)
mn_msg_offset += poffset;
return num_rng_calls;
}
static model_net_event_return model_net_event_impl_base(
int net_id, int net_id,
struct codes_mctx const * send_map_ctx, struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx, struct codes_mctx const * recv_map_ctx,
...@@ -242,7 +277,7 @@ static void model_net_event_impl_base( ...@@ -242,7 +277,7 @@ static void model_net_event_impl_base(
"%d but ROSS is configured for events of size %zd\n", "%d but ROSS is configured for events of size %zd\n",
remote_event_size+self_event_size+sizeof(model_net_wrap_msg), remote_event_size+self_event_size+sizeof(model_net_wrap_msg),
g_tw_msg_sz); g_tw_msg_sz);
return; return -1;
} }
tw_lpid src_mn_lp = model_net_find_local_device_mctx(net_id, send_map_ctx, tw_lpid src_mn_lp = model_net_find_local_device_mctx(net_id, send_map_ctx,
...@@ -250,13 +285,19 @@ static void model_net_event_impl_base( ...@@ -250,13 +285,19 @@ static void model_net_event_impl_base(
tw_lpid dest_mn_lp = model_net_find_local_device_mctx(net_id, recv_map_ctx, tw_lpid dest_mn_lp = model_net_find_local_device_mctx(net_id, recv_map_ctx,
final_dest_lp); final_dest_lp);
if (src_mn_lp == dest_mn_lp)
return model_net_noop_event(final_dest_lp, is_pull, offset,
remote_event_size, remote_event, self_event_size, self_event,
sender);
tw_stime poffset = codes_local_latency(sender); tw_stime poffset = codes_local_latency(sender);
if (mn_in_seqence){ if (mn_in_sequence){
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(src_mn_lp, poffset+offset, sender);
tw_event *e = tw_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);
...@@ -276,7 +317,7 @@ static void model_net_event_impl_base( ...@@ -276,7 +317,7 @@ static void model_net_event_impl_base(
// this is an outgoing message // this is an outgoing message
m->msg.m_base.is_from_remote = 0; m->msg.m_base.is_from_remote = 0;
// set the msg-specific params // set the msg-specific params
if (is_msg_params_set[MN_SCHED_PARAM_PRIO]) if (is_msg_params_set[MN_SCHED_PARAM_PRIO])
m->msg.m_base.sched_params = sched_params; m->msg.m_base.sched_params = sched_params;
...@@ -297,12 +338,14 @@ static void model_net_event_impl_base( ...@@ -297,12 +338,14 @@ static void model_net_event_impl_base(
//print_base(m); //print_base(m);
tw_event_send(e); tw_event_send(e);
return 1;
} }
static void model_net_event_impl_base_rc(tw_lp *sender){ static void model_net_event_impl_base_rc(tw_lp *sender){
codes_local_latency_reverse(sender); codes_local_latency_reverse(sender);
} }
void model_net_event( model_net_event_return model_net_event(
int net_id, int net_id,
char const * category, char const * category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
...@@ -314,13 +357,13 @@ void model_net_event( ...@@ -314,13 +357,13 @@ 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, CODES_MCTX_DEFAULT, CODES_MCTX_DEFAULT, return model_net_event_impl_base(net_id, CODES_MCTX_DEFAULT,
category, final_dest_lp, message_size, 0, offset, CODES_MCTX_DEFAULT, category, final_dest_lp, message_size, 0,
remote_event_size, remote_event, self_event_size, self_event, offset, remote_event_size, remote_event, self_event_size,
sender); self_event, sender);
} }
void model_net_event_annotated( model_net_event_return model_net_event_annotated(
int net_id, int net_id,
char const * annotation, char const * annotation,
char const * category, char const * category,
...@@ -333,12 +376,12 @@ void model_net_event_annotated( ...@@ -333,12 +376,12 @@ void model_net_event_annotated(
void const * self_event, void const * self_event,
tw_lp *sender){ tw_lp *sender){
struct codes_mctx mc = codes_mctx_set_group_modulo(annotation, true); struct codes_mctx mc = codes_mctx_set_group_modulo(annotation, true);
model_net_event_impl_base(net_id, &mc, &mc, category, final_dest_lp, return 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( model_net_event_return model_net_event_mctx(
int net_id, int net_id,
struct codes_mctx const * send_map_ctx, struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx, struct codes_mctx const * recv_map_ctx,
...@@ -351,12 +394,13 @@ void model_net_event_mctx( ...@@ -351,12 +394,13 @@ void model_net_event_mctx(
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, send_map_ctx, recv_map_ctx, category, return model_net_event_impl_base(net_id, send_map_ctx, recv_map_ctx,
final_dest_lp, message_size, 0, offset, remote_event_size, category, final_dest_lp, message_size, 0, offset,
remote_event, self_event_size, self_event, sender); remote_event_size, remote_event, self_event_size, self_event,
sender);
} }
void model_net_pull_event( model_net_event_return model_net_pull_event(
int net_id, int net_id,
char const *category, char const *category,
tw_lpid final_dest_lp, tw_lpid final_dest_lp,
...@@ -367,12 +411,12 @@ void model_net_pull_event( ...@@ -367,12 +411,12 @@ 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, CODES_MCTX_DEFAULT, CODES_MCTX_DEFAULT, return model_net_event_impl_base(net_id, CODES_MCTX_DEFAULT,
category, final_dest_lp, message_size, 1, offset, self_event_size, CODES_MCTX_DEFAULT, category, final_dest_lp, message_size, 1,
self_event, 0, NULL, sender); offset, self_event_size, self_event, 0, NULL, sender);
} }
void model_net_pull_event_annotated( model_net_event_return model_net_pull_event_annotated(
int net_id, int net_id,
char const * annotation, char const * annotation,
char const *category, char const *category,
...@@ -385,12 +429,12 @@ void model_net_pull_event_annotated( ...@@ -385,12 +429,12 @@ void model_net_pull_event_annotated(
/* 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 */
struct codes_mctx mc = codes_mctx_set_group_modulo(annotation, true); struct codes_mctx mc = codes_mctx_set_group_modulo(annotation, true);
model_net_event_impl_base(net_id, &mc, &mc, category, final_dest_lp, return model_net_event_impl_base(net_id, &mc, &mc, category, final_dest_lp,
message_size, 1, offset, self_event_size, self_event, 0, NULL, message_size, 1, offset, self_event_size, self_event, 0, NULL,
sender); sender);
} }
void model_net_pull_event_mctx( model_net_event_return model_net_pull_event_mctx(
int net_id, int net_id,
struct codes_mctx const * send_map_ctx, struct codes_mctx const * send_map_ctx,
struct codes_mctx const * recv_map_ctx, struct codes_mctx const * recv_map_ctx,
...@@ -403,11 +447,19 @@ void model_net_pull_event_mctx( ...@@ -403,11 +447,19 @@ void model_net_pull_event_mctx(
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, send_map_ctx, recv_map_ctx, category, return model_net_event_impl_base(net_id, send_map_ctx, recv_map_ctx,
final_dest_lp, message_size, 1, offset, self_event_size, category, final_dest_lp, message_size, 1, offset, self_event_size,
self_event, 0, NULL, sender); self_event, 0, NULL, sender);
} }
void model_net_event_rc2(
tw_lp *sender,
model_net_event_return const * ret)
{
for (int i = 0; i < *ret; i++)
codes_local_latency_reverse(sender);
}
void model_net_event_rc( void model_net_event_rc(
int net_id, int net_id,
tw_lp *sender, tw_lp *sender,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment