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

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
......@@ -14,6 +14,8 @@
#include "codes/codes.h"
#include "codes/model-net.h"
#include "codes/model-net-method.h"
#include "codes/model-net-lp.h"
#include "codes/net/dragonfly.h"
#define CHUNK_SIZE 32.0
......@@ -25,6 +27,9 @@
#define PRINT_ROUTER_TABLE 1
#define DEBUG 1
#define LP_CONFIG_NM (model_net_lp_config_names[DRAGONFLY])
#define LP_METHOD_NM (model_net_method_names[DRAGONFLY])
// arrival rate
static double MEAN_INTERVAL=200.0;
/* radix of a dragonfly router = number of global channels + number of
......@@ -55,7 +60,6 @@ static int mapping_grp_id, mapping_type_id, mapping_rep_id, mapping_offset;
typedef enum event_t event_t;
typedef struct terminal_state terminal_state;
typedef struct terminal_message terminal_message;
typedef struct router_state router_state;
/* dragonfly compute node data structure */
......@@ -115,50 +119,6 @@ enum ROUTING_ALGO
ADAPTIVE
};
/* 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[MAX_NAME_LENGTH];
/* 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;
};
struct router_state
{
unsigned int router_id;
......@@ -240,29 +200,33 @@ static void dragonfly_report_stats()
}
/* 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, int remote_event_size, const void* remote_event, int self_event_size, const void* self_event, tw_lp *sender, int is_last_pckt)
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, 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_stime xfer_to_nic_time;
terminal_message * msg;
tw_lpid local_nic_id, dest_nic_id;
tw_lpid dest_nic_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_dragonfly", mapping_rep_id, mapping_offset, &local_nic_id);
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, "modelnet_dragonfly", mapping_rep_id, mapping_offset, &dest_nic_id);
codes_mapping_get_lp_id(lp_group_name, LP_CONFIG_NM, mapping_rep_id, mapping_offset, &dest_nic_id);
xfer_to_nic_time = 0.01 + codes_local_latency(sender); /* Throws an error of found last KP time > current event time otherwise when LPs of one type are placed together*/
e_new = tw_event_new(local_nic_id, xfer_to_nic_time+offset, sender);
msg = tw_event_data(e_new);
//e_new = tw_event_new(local_nic_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, DRAGONFLY, (void**)&msg, (void**)&tmp_ptr);
strcpy(msg->category, category);
msg->final_dest_gid = final_dest_lp;
msg->dest_terminal_id = dest_nic_id;
msg->sender_lp=sender->gid;
msg->sender_lp=src_lp;
msg->packet_size = packet_size;
msg->remote_event_size_bytes = 0;
msg->local_event_size_bytes = 0;
......@@ -272,8 +236,6 @@ static tw_stime dragonfly_packet_event(char* category, tw_lpid final_dest_lp, ui