Commit 21293ecc authored by Jonathan Jenkins's avatar Jonathan Jenkins

clean up parameter usage in base modelnet/sched

parent 77cf5291
......@@ -88,7 +88,7 @@ typedef struct model_net_sched_interface {
// prio (currently the only user): int priority
// - NULL arguments should be treated as "use default value"
void (*add)(
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -98,7 +98,7 @@ typedef struct model_net_sched_interface {
model_net_sched_rc * rc,
tw_lp * lp);
// reverse the previous request addition
void (*add_rc)(void *sched, model_net_sched_rc *rc, tw_lp *lp);
void (*add_rc)(void *sched, const model_net_sched_rc *rc, tw_lp *lp);
// schedule the next packet for processing by the model
int (*next)(
tw_stime * poffset,
......@@ -110,8 +110,8 @@ typedef struct model_net_sched_interface {
// reverse schedule the previous packet
void (*next_rc)(
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp);
} model_net_sched_interface;
......@@ -166,8 +166,8 @@ int model_net_sched_next(
void model_net_sched_next_rc(
model_net_sched *sched,
void *rc_event_save,
model_net_sched_rc *sched_rc,
const void *rc_event_save,
const model_net_sched_rc *sched_rc,
tw_lp *lp);
/// enter a new request into the scheduler, storing any info needed for rc in
......@@ -175,7 +175,7 @@ void model_net_sched_next_rc(
/// sched_msg_params is scheduler-specific parameters (currently only used by
/// prio scheduler)
void model_net_sched_add(
model_net_request *req,
const model_net_request *req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -187,7 +187,7 @@ void model_net_sched_add(
void model_net_sched_add_rc(
model_net_sched *sched,
model_net_sched_rc *sched_rc,
const model_net_sched_rc *sched_rc,
tw_lp *lp);
// set default parameters for messages that don't specify any
......
......@@ -89,6 +89,7 @@ typedef struct model_net_request {
tw_lpid dest_mn_lp; // destination modelnet lp
tw_lpid src_lp;
uint64_t msg_size;
uint64_t pull_size;
uint64_t packet_size;
int net_id;
int is_pull;
......
......@@ -532,20 +532,23 @@ void model_net_method_send_msg_recv_event(
else
model_net_sched_set_default_params(&m->msg.m_base.sched_params);
m->msg.m_base.req.final_dest_lp = final_dest_lp;
m->msg.m_base.req.src_lp = src_lp;
model_net_request *r = &m->msg.m_base.req;
r->final_dest_lp = final_dest_lp;
r->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.packet_size = m->msg.m_base.req.msg_size;
m->msg.m_base.req.net_id = net_id;
m->msg.m_base.req.is_pull = is_pull;
m->msg.m_base.req.remote_event_size = remote_event_size;
m->msg.m_base.req.self_event_size = 0;
r->dest_mn_lp = sender->gid;
r->pull_size = pull_size;
r->msg_size = msg_size;
// TODO: document why we're setting packet_size this way
r->packet_size = msg_size;
r->net_id = net_id;
r->is_pull = is_pull;
r->remote_event_size = remote_event_size;
r->self_event_size = 0;
m->msg.m_base.is_from_remote = 1;
strncpy(m->msg.m_base.req.category, category, CATEGORY_NAME_MAX-1);
m->msg.m_base.req.category[CATEGORY_NAME_MAX-1] = '\0';
strncpy(r->category, category, CATEGORY_NAME_MAX-1);
r->category[CATEGORY_NAME_MAX-1] = '\0';
if (remote_event_size > 0){
void * m_dat = model_net_method_get_edata(net_id, msg);
......
......@@ -14,11 +14,10 @@
#define MN_SCHED_DEBUG_VERBOSE 0
#if MN_SCHED_DEBUG_VERBOSE
#define dprintf(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
#else
#define dprintf(_fmt, ...)
#endif
#define dprintf(_fmt, ...) \
do { \
if (MN_SCHED_DEBUG_VERBOSE) printf(_fmt, ##__VA_ARGS__); \
} while(0)
/// scheduler-specific data structures
......@@ -62,7 +61,7 @@ static void fcfs_init (
void ** sched);
static void fcfs_destroy (void *sched);
static void fcfs_add (
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -71,7 +70,7 @@ static void fcfs_add (
void * sched,
model_net_sched_rc * rc,
tw_lp * lp);
static void fcfs_add_rc(void *sched, model_net_sched_rc *rc, tw_lp *lp);
static void fcfs_add_rc(void *sched, const model_net_sched_rc *rc, tw_lp *lp);
static int fcfs_next(
tw_stime * poffset,
void * sched,
......@@ -80,8 +79,8 @@ static int fcfs_next(
tw_lp * lp);
static void fcfs_next_rc(
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp);
// ROUND-ROBIN
......@@ -92,7 +91,7 @@ static void rr_init (
void ** sched);
static void rr_destroy (void *sched);
static void rr_add (
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -101,7 +100,7 @@ static void rr_add (
void * sched,
model_net_sched_rc * rc,
tw_lp * lp);
static void rr_add_rc(void *sched, model_net_sched_rc *rc, tw_lp *lp);
static void rr_add_rc(void *sched, const model_net_sched_rc *rc, tw_lp *lp);
static int rr_next(
tw_stime * poffset,
void * sched,
......@@ -110,8 +109,8 @@ static int rr_next(
tw_lp * lp);
static void rr_next_rc (
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp);
static void prio_init (
const struct model_net_method * method,
......@@ -120,7 +119,7 @@ static void prio_init (
void ** sched);
static void prio_destroy (void *sched);
static void prio_add (
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -129,7 +128,7 @@ static void prio_add (
void * sched,
model_net_sched_rc * rc,
tw_lp * lp);
static void prio_add_rc(void *sched, model_net_sched_rc *rc, tw_lp *lp);
static void prio_add_rc(void *sched, const model_net_sched_rc *rc, tw_lp *lp);
static int prio_next(
tw_stime * poffset,
void * sched,
......@@ -138,8 +137,8 @@ static int prio_next(
tw_lp * lp);
static void prio_next_rc (
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp);
/// function tables (names defined by X macro in model-net-sched.h)
......@@ -176,7 +175,7 @@ void fcfs_destroy(void *sched){
}
void fcfs_add (
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -189,7 +188,7 @@ void fcfs_add (
q->entry_time = tw_now(lp);
q->req = *req;
q->sched_params = *sched_params;
q->rem = req->is_pull ? PULL_MSG_SIZE : req->msg_size;
q->rem = req->msg_size;
if (remote_event_size > 0){
q->remote_event = malloc(remote_event_size);
memcpy(q->remote_event, remote_event, remote_event_size);
......@@ -208,7 +207,7 @@ void fcfs_add (
req->final_dest_lp, req->msg_size, tw_now(lp));
}
void fcfs_add_rc(void *sched, model_net_sched_rc *rc, tw_lp *lp){
void fcfs_add_rc(void *sched, const model_net_sched_rc *rc, tw_lp *lp){
mn_sched_queue *s = sched;
s->queue_len--;
struct qlist_head *ent = qlist_pop_back(&s->reqs);
......@@ -257,7 +256,7 @@ int fcfs_next(
// soruce in the case of a pull
*poffset = s->method->model_net_method_recv_msg_event(q->req.category,
q->req.final_dest_lp, q->req.dest_mn_lp, psize,
q->req.is_pull, q->req.msg_size, 0.0, q->req.remote_event_size,
q->req.is_pull, q->req.pull_size, 0.0, q->req.remote_event_size,
q->remote_event, q->req.src_lp, lp);
}
else{
......@@ -267,7 +266,7 @@ int fcfs_next(
tw_now(lp), is_last_packet);
*poffset = s->method->model_net_method_packet_event(q->req.category,
q->req.final_dest_lp, q->req.dest_mn_lp, psize, q->req.is_pull,
q->req.msg_size, 0.0, &q->sched_params,
q->req.pull_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,
is_last_packet);
......@@ -278,7 +277,7 @@ int fcfs_next(
dprintf("last %spkt: %lu (%lu) to %lu, size %lu at %1.5e (pull:%d)\n",
s->is_recv_queue ? "recv " : "send ",
lp->gid, q->req.src_lp, q->req.final_dest_lp,
q->req.is_pull ? PULL_MSG_SIZE : q->req.msg_size, tw_now(lp),
q->req.is_pull ? q->req.pull_size : q->req.msg_size, tw_now(lp),
q->req.is_pull);
qlist_pop(&s->reqs);
s->queue_len--;
......@@ -306,8 +305,8 @@ int fcfs_next(
void fcfs_next_rc(
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp){
mn_sched_queue *s = sched;
if (rc->rtn == -1){
......@@ -334,8 +333,7 @@ void fcfs_next_rc(
assert(q);
q->req = rc->req;
q->sched_params = rc->sched_params;
q->rem = (q->req.is_pull ? PULL_MSG_SIZE : q->req.msg_size) %
q->req.packet_size;
q->rem = q->req.msg_size % q->req.packet_size;
if (q->rem == 0){ // processed exactly a packet's worth of data
q->rem = q->req.packet_size;
}
......@@ -376,7 +374,7 @@ void rr_destroy (void *sched){
}
void rr_add (
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -389,7 +387,7 @@ void rr_add (
local_event_size, local_event, sched, rc, lp);
}
void rr_add_rc(void *sched, model_net_sched_rc *rc, tw_lp *lp){
void rr_add_rc(void *sched, const model_net_sched_rc *rc, tw_lp *lp){
fcfs_add_rc(sched, rc, lp);
}
......@@ -414,8 +412,8 @@ int rr_next(
void rr_next_rc (
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp){
// only time we need to do something apart from fcfs is on a successful
// rr_next that didn't remove the item from the queue
......@@ -452,7 +450,7 @@ void prio_destroy (void *sched){
}
void prio_add (
model_net_request * req,
const model_net_request * req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -479,7 +477,7 @@ void prio_add (
rc->prio = prio;
}
void prio_add_rc(void * sched, model_net_sched_rc *rc, tw_lp *lp){
void prio_add_rc(void * sched, const model_net_sched_rc *rc, tw_lp *lp){
// just call the sub scheduler's add_rc
mn_sched_prio *ss = sched;
dprintf("%lu (mn): rc adding with prio %d\n", lp->gid, rc->prio);
......@@ -509,8 +507,8 @@ int prio_next(
void prio_next_rc (
void * sched,
void * rc_event_save,
model_net_sched_rc * rc,
const void * rc_event_save,
const model_net_sched_rc * rc,
tw_lp * lp){
if (rc->prio != -1){
// we called a next somewhere
......
......@@ -49,14 +49,14 @@ int model_net_sched_next(
void model_net_sched_next_rc(
model_net_sched *sched,
void *rc_event_save,
model_net_sched_rc *sched_rc,
const void *rc_event_save,
const model_net_sched_rc *sched_rc,
tw_lp *lp) {
sched->impl->next_rc(sched->dat, rc_event_save, sched_rc, lp);
}
void model_net_sched_add(
model_net_request *req,
const model_net_request *req,
const mn_sched_params * sched_params,
int remote_event_size,
void * remote_event,
......@@ -71,7 +71,7 @@ void model_net_sched_add(
void model_net_sched_add_rc(
model_net_sched *sched,
model_net_sched_rc *sched_rc,
const model_net_sched_rc *sched_rc,
tw_lp *lp){
sched->impl->add_rc(sched->dat, sched_rc, lp);
}
......
......@@ -304,14 +304,21 @@ static model_net_event_return model_net_event_impl_base(
// set the request struct
model_net_request *r = &m->msg.m_base.req;
r->net_id = net_id;
r->final_dest_lp = final_dest_lp;
r->dest_mn_lp = dest_mn_lp;
r->src_lp = sender->gid;
r->is_pull = is_pull;
if (r->is_pull) {
r->msg_size = PULL_MSG_SIZE;
r->pull_size = message_size;
}
else {
r->msg_size = message_size;
r->pull_size = 0;
}
r->net_id = net_id;
r->remote_event_size = remote_event_size;
r->self_event_size = self_event_size;
r->is_pull = is_pull;
strncpy(r->category, category, CATEGORY_NAME_MAX-1);
r->category[CATEGORY_NAME_MAX-1]='\0';
......
......@@ -107,6 +107,7 @@ static tw_stime simplenet_packet_event(
tw_lpid src_lp,
tw_lp *sender,
int is_last_pckt);
static void simplenet_packet_event_rc(tw_lp *sender);
static void simplenet_packet_event_rc(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