-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmain.cpp
More file actions
55 lines (44 loc) · 1.68 KB
/
main.cpp
File metadata and controls
55 lines (44 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include <sys/time.h>
#include "mcf.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////////
//
// launching point;
//
////////////////////////////////////////////////////////////////////////////////
int main( int argc, char **argv)
{
struct timeval tv_start, tv_end;
gettimeofday( &tv_start, (struct timezone*) NULL);
// (1) run MCF solver;
MCF mcf;
// here you should build your network either by reading it from a
// file (network examples are in /tests) or by populating the
// mcf object directly from the host application (the one inside
// which you plan to call MCF solver possibly multiple times);
mcf.parse_options( argc, argv);
mcf.build_network_from_file();
//mcf.build_network_from_host_application();
mcf.run_mcf_solver();
// (2) entertain user;
printf("\n\nFINAL RESULT:");
if ( mcf.problem_type() == MCMCF_TYPE) {
printf("\nFinal latency L=%lf", mcf.get_L());
}
mcf.print_network_demands( true); // print_only_edges;
// Note: rounding is not required; you may want or not to use this
// in your application; in my case I do it so that one commodity
// is shipped only via one path (in the context of NoCs I want to
// avoid packet (re)ordering at destinations); be aware: randomization
// "damages" optimality and may violate capacities;
mcf.do_randomized_rounding();
mcf.print_routing_paths();
// (3) clean up
mcf.free_topology();
gettimeofday( &tv_end, (struct timezone*) NULL);
printf("\nRuntime: %ld sec \n", tv_end.tv_sec - tv_start.tv_sec);
return 1;
}