Commit b13d30f4 authored by Misbah Mubarak's avatar Misbah Mubarak

Adding the torus network plugin with modelnet API, see...

Adding the torus network plugin with modelnet API, see model-net/README_MN_TEST.txt for instructions to run the test
parent 0f6e417d
......@@ -20,8 +20,8 @@ typedef struct torus_param torus_param;
enum NETWORKS
{
SIMPLENET,
DRAGONFLY,
TORUS
TORUS,
DRAGONFLY
};
/* structs for initializing a network/ specifying network parameters */
......@@ -42,9 +42,12 @@ struct dragonfly_param
struct torus_param
{
char* name;
int n_dim; /*Dimension of the torus network, 5-D, 7-D or any other*/
int n_dims; /*Dimension of the torus network, 5-D, 7-D or any other*/
int* dim_length; /*Length of each torus dimension*/
double link_bandwidth;/* bandwidth for each torus link */
int buffer_size; /* number of buffer slots for each vc in flits*/
int num_vc; /* number of virtual channels for each torus link */
float mean_process;/* mean process time for each flit */
};
/* NOTE: the following auxilliary functions are probably wrong; just leaving
* these examples from simplenet for reference purposes.
......
#ifndef INC_torus_h
#define INC_torus_h
#include <ross.h>
#include <assert.h>
#include "codes/codes_mapping.h"
#include "codes/codes.h"
#include "codes/model-net.h"
#include "codes/model-net-method.h"
#define CHUNK_SIZE 32
#define DEBUG 1
#define MEAN_INTERVAL 100
#define CATEGORY_NAME_MAX 16
#define MAX_NAME_LENGTH 256
#define TRACE -1
// Total number of nodes in torus, calculate in main
int N_nodes = 1;
double link_bandwidth;
int buffer_size;
int num_vc;
int n_dims;
int * dim_length;
int * factor;
int * half_length;
char grp_name[MAX_NAME_LENGTH], type_name[MAX_NAME_LENGTH];
int grp_id, lp_type_id, rep_id, offset;
typedef enum nodes_event_t nodes_event_t;
typedef struct nodes_state nodes_state;
typedef struct nodes_message nodes_message;
/* Issues a torus packet event call */
static void torus_packet_event(
char* category,
tw_lpid final_dest_lp,
int packet_size,
int remote_event_size,
const void* remote_event,
int self_event_size,
const void* self_event,
tw_lp *sender,
int is_last_pckt);
static void torus_packet_event_rc(tw_lp *sender);
static void torus_setup(const void* net_params);
static int torus_get_msg_sz(void);
static const tw_lptype* torus_get_lp_type(void);
/* data structure for torus statistics */
struct model_net_method torus_method =
{
.method_name = "torus",
.mn_setup = torus_setup,
.model_net_method_packet_event = torus_packet_event,
.model_net_method_packet_event_rc = torus_packet_event_rc,
.mn_get_lp_type = torus_get_lp_type,
.mn_get_msg_sz = torus_get_msg_sz,
};
enum nodes_event_t
{
GENERATE = 1,
ARRIVAL,
SEND,
CREDIT,
};
struct nodes_state
{
unsigned long long packet_counter;
tw_stime** next_link_available_time;
tw_stime** next_credit_available_time;
tw_stime** next_flit_generate_time;
int** buffer;
int* dim_position;
int* neighbour_minus_lpID;
int* neighbour_plus_lpID;
int source_dim;
int direction;
};
struct nodes_message
{
char category[CATEGORY_NAME_MAX];
tw_stime travel_start_time;
tw_stime saved_available_time;
unsigned long long packet_ID;
nodes_event_t type;
int saved_src_dim;
int saved_src_dir;
int* dest;
tw_lpid final_dest_gid;
tw_lpid dest_lp;
tw_lpid sender_lp;
int my_N_hop;
int source_dim;
int source_direction;
int next_stop;
int packet_size;
short chunk_id;
// for codes local and remote events
int local_event_size_bytes;
int remote_event_size_bytes;
};
tw_stime average_travel_time = 0;
tw_stime total_time = 0;
tw_stime max_latency = 0;
float head_delay=0.0;
float credit_delay = 0.0;
static unsigned long long N_finished_packets = 0;
static unsigned long long total_hops = 0;
// run time arguments
int num_packets;
int num_chunks;
int packet_offset = 0;
#endif
lib_LIBRARIES += src/libcodes-net.a
nobase_include_HEADERS = \
codes/model-net.h
codes/model-net.h \
codes/torus.h \
codes/model-net-method.h
src_libcodes_net_a_SOURCES = \
src/models/networks/model-net/model-net-method.h \
src/models/networks/model-net/model-net.c \
src/models/networks/model-net/simplenet-upd.c
src/models/networks/model-net/simplenet-upd.c \
src/models/networks/model-net/torus.c
......@@ -8,3 +8,5 @@ mpiexec -n 4 tests/modelnet-test --sync=2 tests/modelnet-test.conf
<or>
mpiexec -n 4 tests/modelnet-test --sync=3 tests/modelnet-test.conf
(1)- To run the modelnet test with the simplenet network plugin, use tests/modelnet-test.conf (default setting).
(2)- To run the modelnet test with the torus network plugin, use tests/modelnet-test-torus.conf file.
......@@ -7,19 +7,20 @@
#include <assert.h>
#include "codes/model-net.h"
#include "model-net-method.h"
#include "codes/model-net-method.h"
#define STR_SIZE 16
#define PROC_TIME 10.0
#define NUM_NETS 1
extern struct model_net_method simplenet_method;
extern struct model_net_method torus_method;
//extern struct dragonfly_method dragonfly_method;
//extern struct torus_method torus_method;
/* Global array initialization, terminated with a NULL entry */
static struct model_net_method* method_array[] =
{&simplenet_method, NULL};
{&simplenet_method, &torus_method, NULL};
int model_net_setup(char* name,
int packet_size,
......@@ -63,7 +64,7 @@ void model_net_event(
/*Determine the network name*/
if(net_id < 0 || net_id > NUM_NETS)
{
fprintf(stderr, "Error: undefined network ID %d (Available options 0 (simplenet), 1 (dragonfly) 2 (torus) ) \n", net_id);
fprintf(stderr, "Error: undefined network ID %d (Available options 0 (simplenet), 1 (torus) 2 (dragonfly) ) \n", net_id);
exit(-1);
}
......@@ -114,8 +115,8 @@ int model_net_set_params()
configuration_get_value_double(&config, "PARAMS", "net_startup_ns", &net_startup_ns);
configuration_get_value_double(&config, "PARAMS", "net_bw_mbps", &net_bw_mbps);
net_params.net_startup_ns = 1.5;
net_params.net_bw_mbps = 20000;
net_params.net_startup_ns = net_startup_ns;
net_params.net_bw_mbps = net_bw_mbps;
net_id = model_net_setup("simplenet", packet_size, (const void*)&net_params); /* Sets the network as simplenet and packet size 512 */
}
else if(strcmp("dragonfly", mn_name)==0)
......@@ -124,7 +125,61 @@ int model_net_set_params()
}
else if(strcmp("torus", mn_name)==0)
{
printf("\n not supported yet ");
torus_param net_params;
char dim_length[MAX_NAME_LENGTH];
int n_dims=0, buffer_size=0, num_vc=0, i=0;
double link_bandwidth=0;
configuration_get_value_int(&config, "PARAMS", "n_dims", &n_dims);
if(!n_dims)
{
n_dims = 4; /* a 4-D torus */
printf("\n Number of dimensions not specified, setting to %d ", n_dims);
}
configuration_get_value_double(&config, "PARAMS", "link_bandwidth", &link_bandwidth);
if(!link_bandwidth)
{
link_bandwidth = 2.0; /*default bg/q configuration */
printf("\n Link bandwidth not specified, setting to %lf ", link_bandwidth);
}
configuration_get_value_int(&config, "PARAMS", "buffer_size", &buffer_size);
if(!buffer_size)
{
buffer_size = 2048;
printf("\n Buffer size not specified, setting to %d ",buffer_size);
}
configuration_get_value_int(&config, "PARAMS", "num_vc", &num_vc);
if(!num_vc)
{
num_vc = 1; /*by default, we have one for taking packets, another for taking credit*/
printf("\n num_vc not specified, setting to %d ", num_vc);
}
configuration_get_value(&config, "PARAMS", "dim_length", dim_length, MAX_NAME_LENGTH);
char* token;
net_params.n_dims=n_dims;
net_params.num_vc=num_vc;
net_params.buffer_size=buffer_size;
net_params.link_bandwidth=link_bandwidth;
net_params.dim_length=malloc(n_dims*sizeof(int));
token = strtok(dim_length, ",");
while(token != NULL)
{
sscanf(token, "%d", &net_params.dim_length[i]);
if(!net_params.dim_length[i])
{
printf("\n Invalid torus dimension specified %d, exitting... ", net_params.dim_length[i]);
MPI_Finalize();
exit(-1);
}
i++;
token = strtok(NULL,",");
}
net_id = model_net_setup("torus", packet_size, (const void*)&net_params);
}
else
printf("\n Invalid network argument %s ", mn_name);
......@@ -203,6 +258,9 @@ void model_net_add_lp_type(int net_id)
lp_type_register("modelnet_simplenet", model_net_get_lp_type(net_id));
break;
case TORUS:
lp_type_register("modelnet_torus", model_net_get_lp_type(net_id));
break;
default:
{
printf("\n Invalid net_id specified ");
......
......@@ -10,7 +10,7 @@
#include "codes/lp-io.h"
#include "codes/jenkins-hash.h"
#include "model-net-method.h"
#include "codes/model-net-method.h"
#include "codes/model-net.h"
#include "codes/codes_mapping.h"
#include "codes/codes.h"
......
This diff is collapsed.
LPGROUPS
{
MODELNET_GRP
{
repetitions="16";
server="1";
modelnet_torus="1";
}
}
PARAMS
{
packet_size="512";
modelnet="torus";
message_size="512";
n_dims="4";
dim_length="2,2,2,2";
link_bandwidth="2.0";
buffer_size="256";
num_vc="1";
}
......@@ -299,7 +299,7 @@ static void svr_finalize(
svr_state * ns,
tw_lp * lp)
{
printf("server %llu recvd %d bytes in %f seconds, %f MiB/s sent_count %d recvd_count %d local_count %d \n", (unsigned long long)lp->gid/2, PAYLOAD_SZ*ns->msg_recvd_count, ns_to_s((tw_now(lp)-ns->start_ts)),
printf("server %llu recvd %d bytes in %f seconds, %f MiB/s sent_count %d recvd_count %d local_count %d \n", (unsigned long long)lp->gid, PAYLOAD_SZ*ns->msg_recvd_count, ns_to_s((tw_now(lp)-ns->start_ts)),
((double)(PAYLOAD_SZ*NUM_REQS)/(double)(1024*1024)/ns_to_s(tw_now(lp)-ns->start_ts)), ns->msg_sent_count, ns->msg_recvd_count, ns->local_recvd_count);
return;
}
......@@ -463,8 +463,8 @@ static void handle_req_event(
//printf("handle_req_event(), lp %llu src %llu .\n", (unsigned long long)lp->gid, (unsigned long long) m->src);
/* safety check that this request got to the right server */
// printf("\n m->src %d lp->gid %d ", m->src, lp->gid);
assert(lp->gid == (m->src + 2)%(NUM_SERVERS*2));
ns->msg_recvd_count++;
/* send ack back */
......
......@@ -9,8 +9,8 @@ LPGROUPS
}
PARAMS
{
packet_size="512";
modelnet="simplenet";
message_size="256";
net_startup_ns="1.5";
net_bw_mbps="20000";
}
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