Commit 595c5155 authored by Jonathan Jenkins's avatar Jonathan Jenkins

model-net 'base LP' integration + various refactorings

parent 771e4767
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
/* This is the base model-net LP that all events pass through before
* performing any topology-specific work. Packet scheduling, dealing with
* packet loss (potentially), etc. happens here.
* Additionally includes wrapper event "send" function that all
* events for underlying models must go through */
#ifndef MODEL_NET_LP_H
#define MODEL_NET_LP_H
#include <ross.h>
#include "net/dragonfly.h"
#include "net/loggp.h"
#include "net/simplenet-upd.h"
#include "net/simplewan.h"
#include "net/torus.h"
extern int model_net_base_magic;
// Construct a model-net-specific event, analagous to a tw_event_new and
// codes_event_new. The difference here is that we return pointers to
// both the message data (to be cast into the appropriate type) and the
// pointer to the end of the event struct.
//
// This function is expected to be called within each specific model-net
// method - strange and disturbing things will happen otherwise
tw_event * model_net_method_event_new(
tw_lpid dest_gid,
tw_stime offset_ts,
tw_lp *sender,
int net_id,
void **msg_data,
void **extra_data);
// Get a ptr to past the message struct area, where the self/remote events
// are located, given the type of network.
// NOTE: this should ONLY be called on model-net implementations, nowhere else
void * model_net_method_get_edata(int net_id, void * msg);
/// The following functions/data structures should not need to be used by
/// model developers - they are just provided so other internal components can
/// use them
// init method
void model_net_base_init();
enum model_net_base_event_type {
MN_BASE_NEW_MSG,
// schedule next packet
MN_BASE_SCHED_NEXT,
// message goes directly down to topology-specific event handler
MN_BASE_PASS
};
typedef struct model_net_request {
tw_lpid final_dest_lp;
uint64_t msg_size;
int net_id;
int is_pull;
int remote_event_size;
int self_event_size;
char category[CATEGORY_NAME_MAX];
} model_net_request;
typedef struct model_net_base_msg {
// no need for event type - in wrap message
tw_lpid src;
union {
model_net_request req;
struct {} sched; // needs nothing at the moment
} u;
} model_net_base_msg;
typedef struct model_net_wrap_msg {
enum model_net_base_event_type event_type;
int magic;
union {
model_net_base_msg m_base; // base lp
terminal_message m_dfly; // dragonfly
loggp_message m_loggp; // loggp
sn_message m_snet; // simplenet
sw_message m_swan; // simplewan
nodes_message m_torus; // torus
// add new ones here
} msg;
} model_net_wrap_msg;
#endif /* end of include guard: MODEL_NET_LP_H */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/
......@@ -11,7 +11,6 @@
struct model_net_method
{
char* method_name; /* example: "dragonfly" */
uint64_t packet_size; /* packet size */
void (*mn_setup)(const void* net_params); /* For initializing the network */
tw_stime (*model_net_method_packet_event)(
......@@ -25,7 +24,8 @@ struct model_net_method
const void* remote_event,
int self_event_size, /* 0 means don't deliver self event */
const void* self_event,
tw_lp *sender,
tw_lpid src_lp, // original caller of model_net_(pull_)event
tw_lp *sender, // lp message is being called from (base LP)
int is_last_pckt);
void (*model_net_method_packet_event_rc)(tw_lp *sender);
const tw_lptype* (*mn_get_lp_type)();
......@@ -34,6 +34,8 @@ struct model_net_method
tw_lpid (*model_net_method_find_local_device)(tw_lp *sender);
};
extern struct model_net_method * method_array[];
#endif /* MODELNET_METHOD_H */
/*
......
......@@ -13,6 +13,8 @@
#include "codes/lp-io.h"
#include <stdint.h>
#define PULL_MSG_SIZE 128
#define MAX_NAME_LENGTH 256
#define CATEGORY_NAME_MAX 16
#define CATEGORY_MAX 12
......@@ -41,15 +43,28 @@ typedef struct torus_param torus_param;
typedef struct loggp_param loggp_param;
typedef struct mn_stats mn_stats;
// use the X-macro to get types and names rolled up into one structure
// format: { enum vals, config name, internal lp name, lp method struct}
// last value is sentinel
#define NETWORK_DEF \
X(SIMPLENET, "modelnet_simplenet", "simplenet", &simplenet_method)\
X(SIMPLEWAN, "modelnet_simplewan", "simplewan", &simplewan_method)\
X(TORUS, "modelnet_torus", "torus", &torus_method)\
X(DRAGONFLY, "modelnet_dragonfly", "dragonfly", &dragonfly_method)\
X(LOGGP, "modelnet_loggp", "loggp", &loggp_method)\
X(MAX_NETS, NULL, NULL, NULL)
#define X(a,b,c,d) a,
enum NETWORKS
{
SIMPLENET,
SIMPLEWAN,
TORUS,
DRAGONFLY,
LOGGP,
MAX_NETS, /* sentinal value, this must be last in the enumeration */
NETWORK_DEF
};
#undef X
// network identifiers (both the config lp names and the model-net internal
// names)
extern char * model_net_lp_config_names[];
extern char * model_net_method_names[];
/* data structure for tracking network statistics */
struct mn_stats
......@@ -170,6 +185,8 @@ void model_net_event(
*/
tw_lpid model_net_find_local_device(int net_id, tw_lp *sender);
int model_net_get_msg_sz(int net_id);
/* model_net_event_rc()
*
* This function does reverse computation for the model_net_event_new()
......@@ -216,8 +233,6 @@ const tw_lptype* model_net_get_lp_type(int net_id);
uint64_t model_net_get_packet_size(int net_id);
void model_net_add_lp_type(int net_id);
/* used for reporting overall network statistics for e.g. average latency ,
* maximum latency, total number of packets finished during the entire
* simulation etc. */
......
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef DRAGONFLY_H
#define DRAGONFLY_H
#include <ross.h>
typedef struct terminal_message terminal_message;
/* this message is used for both dragonfly compute nodes and routers */
struct terminal_message
{
/* flit travel start time*/
tw_stime travel_start_time;
/* packet ID of the flit */
unsigned long long packet_ID;
/* event type of the flit */
short type;
/* category: comes from codes */
char category[CATEGORY_NAME_MAX];
/* final destination LP ID, this comes from codes can be a server or any other LP type*/
tw_lpid final_dest_gid;
/*sending LP ID from CODES, can be a server or any other LP type */
tw_lpid sender_lp;
/* destination terminal ID of the dragonfly */
unsigned int dest_terminal_id;
/* source terminal ID of the dragonfly */
unsigned int src_terminal_id;
/* number of hops traversed by the packet */
short my_N_hop;
/* Intermediate LP ID from which this message is coming */
unsigned int intm_lp_id;
short old_vc;
short saved_vc;
/* last hop of the message, can be a terminal, local router or global router */
short last_hop;
// For buffer message
short vc_index;
int input_chan;
int output_chan;
int is_pull;
uint64_t pull_size;
tw_stime saved_available_time;
tw_stime saved_credit_time;
int intm_group_id;
short chunk_id;
uint64_t packet_size;
int remote_event_size_bytes;
int local_event_size_bytes;
};
#endif /* end of include guard: DRAGONFLY_H */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef LOGGP_H
#define LOGGP_H
/* types of events that will constitute triton requests */
enum loggp_event_type
{
LG_MSG_READY = 1, /* sender has transmitted msg to receiver */
LG_MSG_START, /* initiate a transmission */
};
typedef struct loggp_message loggp_message;
struct loggp_message
{
int magic; /* magic number */
enum loggp_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
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 local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */
char category[CATEGORY_NAME_MAX]; /* category for communication */
int is_pull;
uint64_t pull_size;
/* for reverse computation */
tw_stime net_send_next_idle_saved;
tw_stime net_recv_next_idle_saved;
tw_stime xmit_time_saved;
tw_stime recv_time_saved;
};
#endif /* end of include guard: LOGGP_H */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef SIMPLENET_UPD_H
#define SIMPLENET_UPD_H
typedef struct sn_message sn_message;
/* types of events that will constitute triton requests */
enum sn_event_type
{
SN_MSG_READY = 1, /* sender has transmitted msg to receiver */
SN_MSG_START, /* initiate a transmission */
};
struct sn_message
{
int magic; /* magic number */
enum sn_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
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 local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */
char category[CATEGORY_NAME_MAX]; /* category for communication */
int is_pull; /* this message represents a pull request from the destination LP to the source */
uint64_t pull_size; /* data size to pull from dest LP */
/* for reverse computation */
tw_stime net_send_next_idle_saved;
tw_stime net_recv_next_idle_saved;
tw_stime send_time_saved;
tw_stime recv_time_saved;
};
#endif /* end of include guard: SIMPLENET_UPD_H */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef SIMPLEWAN_H
#define SIMPLEWAN_H
typedef struct sw_message sw_message;
enum sw_event_type
{
SW_MSG_READY = 1, /* sender has transmitted msg to receiver */
SW_MSG_START, /* initiate a transmission */
};
struct sw_message
{
int magic; /* magic number */
enum sw_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
/* relative ID of the sending simplewan message (for latency/bandwidth lookup) */
int src_mn_rel_id;
int dest_mn_rel_id; /* included to make rc easier */
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 local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */
char category[CATEGORY_NAME_MAX]; /* category for communication */
int is_pull;
uint64_t pull_size;
/* for reverse computation */
// TODO: clean up
tw_stime send_next_idle_saved;
tw_stime recv_next_idle_saved;
tw_stime send_time_saved;
tw_stime recv_time_saved;
tw_stime send_next_idle_all_saved;
tw_stime send_prev_idle_all_saved;
tw_stime recv_next_idle_all_saved;
tw_stime recv_prev_idle_all_saved;
};
#endif /* end of include guard: SIMPLEWAN_H */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/
/*
* Copyright (C) 2014 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef TORUS_H
#define TORUS_H
typedef enum nodes_event_t nodes_event_t;
typedef struct nodes_message nodes_message;
/* event type of each torus message, can be packet generate, flit arrival, flit send or credit */
enum nodes_event_t
{
GENERATE = 1,
ARRIVAL,
SEND,
CREDIT,
};
struct nodes_message
{
/* category: comes from codes message */
char category[CATEGORY_NAME_MAX];
/* time the packet was generated */
tw_stime travel_start_time;
/* for reverse event computation*/
tw_stime saved_available_time;
/* packet ID */
unsigned long long packet_ID;
/* event type of the message */
nodes_event_t type;
/* for reverse computation */
int saved_src_dim;
int saved_src_dir;
/* coordinates of the destination torus nodes */
int* dest;
/* final destination LP ID, comes from codes, can be a server or any other I/O LP type */
tw_lpid final_dest_gid;
/* destination torus node of the message */
tw_lpid dest_lp;
/* LP ID of the sender, comes from codes, can be a server or any other I/O LP type */
tw_lpid sender_lp;
/* number of hops traversed by the packet */
int my_N_hop;
/* source dimension of the message */
int source_dim;
/* source direction of the message */
int source_direction;
/* next torus hop that the packet will traverse */
int next_stop;
/* size of the torus packet */
uint64_t packet_size;
/* chunk id of the flit (distinguishes flits) */
short chunk_id;
int is_pull;
uint64_t pull_size;
/* for codes local and remote events, only carried by the last packet of the message */
int local_event_size_bytes;
int remote_event_size_bytes;
};
#endif /* end of include guard: TORUS_H */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/
......@@ -2,7 +2,13 @@ lib_LIBRARIES += src/libcodes-net.a
nobase_include_HEADERS = \
codes/model-net.h \
codes/model-net-method.h
codes/model-net-method.h \
codes/model-net-lp.h \
codes/net/dragonfly.h \
codes/net/loggp.h \
codes/net/simplenet-upd.h \
codes/net/simplewan.h \
codes/net/torus.h
src_libcodes_net_a_SOURCES = \
src/models/networks/model-net/model-net-method.h \
......@@ -11,4 +17,5 @@ src_libcodes_net_a_SOURCES = \
src/models/networks/model-net/torus.c \
src/models/networks/model-net/dragonfly.c \
src/models/networks/model-net/loggp.c \
src/models/networks/model-net/simplewan.c
src/models/networks/model-net/simplewan.c \
src/models/networks/model-net/model-net-lp.c
This diff is collapsed.
......@@ -12,23 +12,20 @@
#include "codes/jenkins-hash.h"
#include "codes/model-net-method.h"
#include "codes/model-net.h"
#include "codes/model-net-lp.h"
#include "codes/codes_mapping.h"
#include "codes/codes.h"
#include "codes/net/loggp.h"
#define CATEGORY_NAME_MAX 16
#define CATEGORY_MAX 12
#define LP_CONFIG_NM (model_net_lp_config_names[LOGGP])
#define LP_METHOD_NM (model_net_method_names[LOGGP])
/*Define loggp data types and structs*/
typedef struct loggp_message loggp_message;
typedef struct loggp_state loggp_state;
/* types of events that will constitute triton requests */
enum loggp_event_type
{
MSG_READY = 1, /* sender has transmitted msg to receiver */
MSG_START, /* initiate a transmission */
};
struct loggp_state
{
......@@ -38,26 +35,6 @@ struct loggp_state
struct mn_stats loggp_stats_array[CATEGORY_MAX];
};
struct loggp_message
{
int magic; /* magic number */
enum loggp_event_type event_type;
tw_lpid src_gid; /* who transmitted this msg? */
tw_lpid final_dest_gid; /* who is eventually targetted with this msg? */
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 local_event_size_bytes; /* size of simulator event message that delivered locally upon local completion */
char category[CATEGORY_NAME_MAX]; /* category for communication */
int is_pull;
uint64_t pull_size;
/* for reverse computation */
tw_stime net_send_next_idle_saved;
tw_stime net_recv_next_idle_saved;
tw_stime xmit_time_saved;
tw_stime recv_time_saved;
};
/* loggp parameters for a given msg size, as reported by netgauge */
struct param_table_entry
{
......@@ -118,6 +95,7 @@ static tw_stime loggp_packet_event(
const void* remote_event,
int self_event_size,
const void* self_event,
tw_lpid src_lp,
tw_lp *sender,
int is_last_pckt);
static void loggp_packet_event_rc(tw_lp *sender);
......@@ -133,7 +111,6 @@ static struct param_table_entry* find_params(uint64_t msg_size);
/* data structure for model-net statistics */
struct model_net_method loggp_method =
{
.method_name = "loggp",
.mn_setup = loggp_setup,
.model_net_method_packet_event = loggp_packet_event,
.model_net_method_packet_event_rc = loggp_packet_event_rc,
......@@ -221,7 +198,7 @@ static void loggp_init(
ns->net_send_next_idle = tw_now(lp);
ns->net_recv_next_idle = tw_now(lp);
bj_hashlittle2("loggp", strlen("loggp"), &h1, &h2);
bj_hashlittle2(LP_METHOD_NM, strlen(LP_METHOD_NM), &h1, &h2);
loggp_magic = h1+h2;
/* printf("\n loggp_magic %d ", loggp_magic); */
......@@ -238,10 +215,10 @@ static void loggp_event(
switch (m->event_type)
{
case MSG_START:
case LG_MSG_START:
handle_msg_start_event(ns, b, m, lp);
break;
case MSG_READY:
case LG_MSG_READY:
handle_msg_ready_event(ns, b, m, lp);
break;
default:
......@@ -260,10 +237,10 @@ static void loggp_rev_event(
switch (m->event_type)
{
case MSG_START:
case LG_MSG_START:
handle_msg_start_rev_event(ns, b, m, lp);
break;
case MSG_READY:
case LG_MSG_READY:
handle_msg_ready_rev_event(ns, b, m, lp);
break;
default:
......@@ -304,7 +281,7 @@ static void handle_msg_ready_rev_event(
stat->recv_time -= m->recv_time_saved;
if (m->event_size_bytes && m->is_pull){
int net_id = model_net_get_id("loggp");
int net_id = model_net_get_id(LP_METHOD_NM);
model_net_event_rc(net_id, lp, m->pull_size);
}
......@@ -359,11 +336,12 @@ static void handle_msg_ready_event(
/* schedule event to final destination for when the recv is complete */
// printf("\n Remote message to LP %d ", m->final_dest_gid);
char* tmp_ptr = (char*)m;
tmp_ptr += loggp_get_msg_sz();
void *tmp_ptr = model_net_method_get_edata(SIMPLENET, m);
//char* tmp_ptr = (char*)m;
//tmp_ptr += loggp_get_msg_sz();
if (m->is_pull){
/* call the model-net event */
int net_id = model_net_get_id("loggp");
int net_id = model_net_get_id(LP_METHOD_NM);
model_net_event(net_id, m->category, m->src_gid, m->pull_size,
recv_queue_time, m->event_size_bytes, tmp_ptr, 0, NULL,
lp);
......@@ -424,7 +402,8 @@ static void handle_msg_start_event(
param = find_params(m->net_msg_size_bytes);
total_event_size = loggp_get_msg_sz() + m->event_size_bytes + m->local_event_size_bytes;
total_event_size = model_net_get_msg_sz(LOGGP) + m->event_size_bytes +
m->local_event_size_bytes;
/* NOTE: we do not use the o_s or o_r parameters here; as indicated in
* the netgauge paper those are typically overlapping with L (and the
......@@ -462,17 +441,25 @@ 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, "modelnet_loggp", mapping_rep_id , mapping_offset, &dest_id);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id , mapping_offset, &dest_id);
void *m_data;
// printf("\n msg start sending to %d ", dest_id);
e_new = tw_event_new(dest_id, send_queue_time, lp);
m_new = tw_event_data(e_new);
//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);
/* copy entire previous message over, including payload from user of
* this module
*/
memcpy(m_new, m, m->event_size_bytes + loggp_get_msg_sz());
m_new->event_type = MSG_READY;
memcpy(m_new, m, sizeof(loggp_message));
if (m->event_size_bytes){
memcpy(m_data, model_net_method_get_edata(LOGGP, m),
m->event_size_bytes);
}
m_new->event_type = LG_MSG_READY;
tw_event_send(e_new);
......@@ -481,15 +468,17 @@ static void handle_msg_start_event(
*/
if(m->local_event_size_bytes > 0)
{
char* local_event;
//char* local_event;
e_new = tw_event_new(m->src_gid, send_queue_time+codes_local_latency(lp), lp);
m_new = tw_event_data(e_new);
local_event = (char*)m;
local_event += loggp_get_msg_sz() + m->event_size_bytes;
void * m_loc = (char*) model_net_method_get_edata(SIMPLENET, m) +
m->event_size_bytes;
//local_event = (char*)m;
//local_event += loggp_get_msg_sz() + m->event_size_bytes;
/* copy just the local event data over */
memcpy(m_new, local_event, m->local_event_size_bytes);
memcpy(m_new, m_loc, m->local_event_size_bytes);
tw_event_send(e_new);
}
return;
......@@ -510,36 +499,40 @@ static tw_stime loggp_packet_event(
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_stime xfer_to_nic_time;
loggp_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, "modelnet_loggp", mapping_rep_id, mapping_offset, &dest_id);
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 = 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, LOGGP, (void**)&msg, (void**)&tmp_ptr);
//e_new = tw_event_new(dest_id, xfer_to_nic_time+offset, sender);
//msg = tw_event_data(e_new);
strcpy(msg->category, category);
msg->final_dest_gid = final_dest_lp;
msg->src_gid = sender->gid;
msg->src_gid = src_lp;
msg->magic = loggp_get_magic();
msg->net_msg_size_bytes = packet_size;
msg->event_size_bytes = 0;
msg->local_event_size_bytes = 0;
msg->event_type = MSG_START;
msg->event_type = LG_MSG_START;
msg->is_pull = is_pull;
msg->pull_size = pull_size;
tmp_ptr = (char*)msg;
tmp_ptr += loggp_get_msg_sz();
//tmp_ptr = (char*)msg;
//tmp_ptr += loggp_get_msg_sz();
//printf("\n Sending to LP %d msg magic %d ", (int)dest_id, loggp_get_magic());
/*Fill in loggp information*/
......@@ -651,7 +644,7 @@ static tw_lpid loggp_find_local_device(tw_lp *sender)
tw_lpid dest_id;