Commit e5cd0779 authored by Jonathan Jenkins's avatar Jonathan Jenkins
Browse files

modified simplewan to use square matrix for p2p capacities

parent cc0d01b6
...@@ -22,18 +22,30 @@ relative to the configuration file) to configurations for the startup and ...@@ -22,18 +22,30 @@ relative to the configuration file) to configurations for the startup and
bandwidth costs, respectively. bandwidth costs, respectively.
Each of the latency/bandwidth configuration files have the same format, based Each of the latency/bandwidth configuration files have the same format, based
on a triangular matrix. Given N modelnet LPs, it has the format: on a square matrix of directed point to point capacities. Given N modelnet LPs,
it has the format:
1:1 1:2 ... 1:N
2:1 2:2 ... 2:N
...
N:1 N:2 ... N:N
where x:y is the latency or bandwidth between components x and y. Whitespace is
ignored, but linebreaks are not, and delimit rows of the matrix. The relative
simplewan identifiers 1..N are assigned to simplewan LPs in the order of
their appearance in the codes-configuration file. It is expected that all i:i
entries are 0 - modelnet currently doesn't handle self messages.
Support in the code is also available for triangular matrices of the format:
1:2 1:3 ... 1:N 1:2 1:3 ... 1:N
2:3 2:4 ... 2:N 2:3 2:4 ... 2:N
... ...
N-1:N N-1:N
where x:y is the latency or bandwidth between components x and y. Whitespace is However, this option is currently disabled (the configuration code path has not
ignored, but linebreaks are not, and delimit rows of the matrix. The relative been expanded to allow specifying the option). The option will be enabled
simplewan identifiers 1..N are assigned to simplewan LPs in the order of into the configuration routines if deemed necessary.
their appearance in the codes-configuration file. In the future, a full NxN
matrix may be used to facilitate asymmetric link capacities if the need arises.
Caveats: Caveats:
-------- --------
......
...@@ -88,6 +88,7 @@ struct sw_message ...@@ -88,6 +88,7 @@ struct sw_message
static double *global_net_startup_ns = NULL; static double *global_net_startup_ns = NULL;
/* net bw, MB/s */ /* net bw, MB/s */
static double *global_net_bw_mbs = NULL; static double *global_net_bw_mbs = NULL;
static int mat_len = -1;
/* number of simplewan lps, used for addressing the network parameters /* number of simplewan lps, used for addressing the network parameters
* set by the first LP to init per process */ * set by the first LP to init per process */
static int num_lps = -1; static int num_lps = -1;
...@@ -233,7 +234,7 @@ static int sw_get_msg_sz(void) ...@@ -233,7 +234,7 @@ static int sw_get_msg_sz(void)
return(sizeof(sw_message)); return(sizeof(sw_message));
} }
static double * parse_tri_mat(char * buf, int *nvals_first, int *nvals_total){ static double * parse_mat(char * buf, int *nvals_first, int *nvals_total, int is_tri_mat){
int bufn = 128; int bufn = 128;
double *vals = malloc(bufn*sizeof(double)); double *vals = malloc(bufn*sizeof(double));
...@@ -261,10 +262,14 @@ static double * parse_tri_mat(char * buf, int *nvals_first, int *nvals_total){ ...@@ -261,10 +262,14 @@ static double * parse_tri_mat(char * buf, int *nvals_first, int *nvals_total){
if (*nvals_first == 0) { if (*nvals_first == 0) {
*nvals_first = line_ct; *nvals_first = line_ct;
} }
else if (line_ct != line_ct_prev-1){ else if (is_tri_mat && line_ct != line_ct_prev-1){
fprintf(stderr, "ERROR: tokens in line don't match triangular matrix format\n"); fprintf(stderr, "ERROR: tokens in line don't match triangular matrix format\n");
exit(1); exit(1);
} }
else if (!is_tri_mat && line_ct != line_ct_prev){
fprintf(stderr, "ERROR: tokens in line don't match square matrix format\n");
exit(1);
}
*nvals_total += line_ct; *nvals_total += line_ct;
line_ct_prev = line_ct; line_ct_prev = line_ct;
line = strtok_r(NULL, "\r\n", &line_save); line = strtok_r(NULL, "\r\n", &line_save);
...@@ -293,6 +298,8 @@ static void fill_tri_mat(int N, double *mat, double *tri){ ...@@ -293,6 +298,8 @@ static void fill_tri_mat(int N, double *mat, double *tri){
/* lets caller specify model parameters to use */ /* lets caller specify model parameters to use */
static void sw_set_params(char * startup_fname, char * bw_fname){ static void sw_set_params(char * startup_fname, char * bw_fname){
long int fsize_s, fsize_b; long int fsize_s, fsize_b;
/* TODO: make this a run-time option */
int is_tri_mat = 0;
/* slurp the files */ /* slurp the files */
FILE *sf = fopen(startup_fname, "r"); FILE *sf = fopen(startup_fname, "r");
...@@ -314,20 +321,25 @@ static void sw_set_params(char * startup_fname, char * bw_fname){ ...@@ -314,20 +321,25 @@ static void sw_set_params(char * startup_fname, char * bw_fname){
int nvals_first_s, nvals_first_b, nvals_total_s, nvals_total_b; int nvals_first_s, nvals_first_b, nvals_total_s, nvals_total_b;
double *startup_tmp = parse_tri_mat(sbuf, &nvals_first_s, double *startup_tmp = parse_mat(sbuf, &nvals_first_s,
&nvals_total_s); &nvals_total_s, is_tri_mat);
double *bw_tmp = parse_tri_mat(bbuf, &nvals_first_b, &nvals_total_b); double *bw_tmp = parse_mat(bbuf, &nvals_first_b, &nvals_total_b, is_tri_mat);
/* convert tri mat into a regular mat */ /* convert tri mat into a regular mat */
assert(nvals_first_s == nvals_first_b); assert(nvals_first_s == nvals_first_b);
int N = nvals_first_s + 1; mat_len = nvals_first_s + ((is_tri_mat) ? 1 : 0);
global_net_startup_ns = malloc(N*N*sizeof(double)); if (is_tri_mat){
global_net_bw_mbs = malloc(N*N*sizeof(double)); global_net_startup_ns = malloc(mat_len*mat_len*sizeof(double));
/* first fill in mat, then fill opposites */ global_net_bw_mbs = malloc(mat_len*mat_len*sizeof(double));
fill_tri_mat(N, global_net_startup_ns, startup_tmp); fill_tri_mat(mat_len, global_net_startup_ns, startup_tmp);
fill_tri_mat(N, global_net_bw_mbs, bw_tmp); fill_tri_mat(mat_len, global_net_bw_mbs, bw_tmp);
free(startup_tmp); free(startup_tmp);
free(bw_tmp); free(bw_tmp);
}
else{
global_net_startup_ns = startup_tmp;
global_net_bw_mbs = bw_tmp;
}
/* done */ /* done */
} }
...@@ -356,6 +368,14 @@ static void sw_init( ...@@ -356,6 +368,14 @@ static void sw_init(
if (num_lps == -1){ if (num_lps == -1){
num_lps = codes_mapping_get_global_lp_count("modelnet_simplewan"); num_lps = codes_mapping_get_global_lp_count("modelnet_simplewan");
assert(num_lps > 0); assert(num_lps > 0);
if (mat_len == -1){
tw_error(TW_LOC, "Simplewan config matrix not initialized "
"at lp init time\n");
}
else if (mat_len != num_lps){
tw_error(TW_LOC, "Simplewan config matrix doesn't match the "
"number of simplewan LPs\n");
}
} }
/* all devices are idle to begin with */ /* all devices are idle to begin with */
......
0.0 50.0 0.0 0.0 50.0
100.0 0.0 0.0 100.0
50.0 100.0 0.0
0.0 10000.0 0.0 0.0 10000.0
20000.0 0.0 0.0 20000.0
10000.0 20000.0 0.0
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