Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
codes
codes
Commits
e5cd0779
Commit
e5cd0779
authored
Apr 24, 2014
by
Jonathan Jenkins
Browse files
modified simplewan to use square matrix for p2p capacities
parent
cc0d01b6
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/models/networks/model-net/README.simplewan.txt
View file @
e5cd0779
...
...
@@ -22,18 +22,30 @@ relative to the configuration file) to configurations for the startup and
bandwidth costs, respectively.
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
2:3 2:4 ... 2:N
...
N-1: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. In the future, a full NxN
matrix may be used to facilitate asymmetric link capacities if the need arises.
However, this option is currently disabled (the configuration code path has not
been expanded to allow specifying the option). The option will be enabled
into the configuration routines if deemed necessary.
Caveats:
--------
...
...
src/models/networks/model-net/simplewan.c
View file @
e5cd0779
...
...
@@ -88,6 +88,7 @@ struct sw_message
static
double
*
global_net_startup_ns
=
NULL
;
/* net bw, MB/s */
static
double
*
global_net_bw_mbs
=
NULL
;
static
int
mat_len
=
-
1
;
/* number of simplewan lps, used for addressing the network parameters
* set by the first LP to init per process */
static
int
num_lps
=
-
1
;
...
...
@@ -233,7 +234,7 @@ static int sw_get_msg_sz(void)
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
;
double
*
vals
=
malloc
(
bufn
*
sizeof
(
double
));
...
...
@@ -261,10 +262,14 @@ static double * parse_tri_mat(char * buf, int *nvals_first, int *nvals_total){
if
(
*
nvals_first
==
0
)
{
*
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
"
);
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
;
line_ct_prev
=
line_ct
;
line
=
strtok_r
(
NULL
,
"
\r\n
"
,
&
line_save
);
...
...
@@ -293,6 +298,8 @@ static void fill_tri_mat(int N, double *mat, double *tri){
/* lets caller specify model parameters to use */
static
void
sw_set_params
(
char
*
startup_fname
,
char
*
bw_fname
){
long
int
fsize_s
,
fsize_b
;
/* TODO: make this a run-time option */
int
is_tri_mat
=
0
;
/* slurp the files */
FILE
*
sf
=
fopen
(
startup_fname
,
"r"
);
...
...
@@ -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
;
double
*
startup_tmp
=
parse_
tri_
mat
(
sbuf
,
&
nvals_first_s
,
&
nvals_total_s
);
double
*
bw_tmp
=
parse_
tri_
mat
(
bbuf
,
&
nvals_first_b
,
&
nvals_total_b
);
double
*
startup_tmp
=
parse_mat
(
sbuf
,
&
nvals_first_s
,
&
nvals_total_s
,
is_tri_mat
);
double
*
bw_tmp
=
parse_mat
(
bbuf
,
&
nvals_first_b
,
&
nvals_total_b
,
is_tri_mat
);
/* convert tri mat into a regular mat */
assert
(
nvals_first_s
==
nvals_first_b
);
int
N
=
nvals_first_s
+
1
;
global_net_startup_ns
=
malloc
(
N
*
N
*
sizeof
(
double
));
global_net_bw_mbs
=
malloc
(
N
*
N
*
sizeof
(
double
));
/* first fill in mat, then fill opposites */
fill_tri_mat
(
N
,
global_net_startup_ns
,
startup_tmp
);
fill_tri_mat
(
N
,
global_net_bw_mbs
,
bw_tmp
);
free
(
startup_tmp
);
free
(
bw_tmp
);
mat_len
=
nvals_first_s
+
((
is_tri_mat
)
?
1
:
0
);
if
(
is_tri_mat
){
global_net_startup_ns
=
malloc
(
mat_len
*
mat_len
*
sizeof
(
double
));
global_net_bw_mbs
=
malloc
(
mat_len
*
mat_len
*
sizeof
(
double
));
fill_tri_mat
(
mat_len
,
global_net_startup_ns
,
startup_tmp
);
fill_tri_mat
(
mat_len
,
global_net_bw_mbs
,
bw_tmp
);
free
(
startup_tmp
);
free
(
bw_tmp
);
}
else
{
global_net_startup_ns
=
startup_tmp
;
global_net_bw_mbs
=
bw_tmp
;
}
/* done */
}
...
...
@@ -356,6 +368,14 @@ static void sw_init(
if
(
num_lps
==
-
1
){
num_lps
=
codes_mapping_get_global_lp_count
(
"modelnet_simplewan"
);
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 */
...
...
tests/conf/modelnet-test-bw-tri.conf
0 → 100644
View file @
e5cd0779
0
.
0
50
.
0
100
.
0
tests/conf/modelnet-test-bw.conf
View file @
e5cd0779
0
.
0
50
.
0
100
.
0
0
.
0
0
.
0
50
.
0
0
.
0
0
.
0
100
.
0
50
.
0
100
.
0
0
.
0
tests/conf/modelnet-test-startup-tri.conf
0 → 100644
View file @
e5cd0779
0
.
0
10000
.
0
20000
.
0
tests/conf/modelnet-test-startup.conf
View file @
e5cd0779
0
.
0
10000
.
0
20000
.
0
0
.
0
0
.
0
10000
.
0
0
.
0
0
.
0
20000
.
0
10000
.
0
20000
.
0
0
.
0
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment