source: branches/reconfiguration/modules/dspin_router/caba/test/recovery_bcast_evaluation/top.cpp @ 1009

Last change on this file since 1009 was 1009, checked in by cfuguet, 9 years ago

add a new platform for the evaluation of the broadcast recovery
replication policy.

File size: 4.7 KB
Line 
1/* -*- c++ -*-
2 *
3 * SOCLIB_LGPL_HEADER_BEGIN
4 *
5 * This file is part of SoCLib, GNU LGPLv2.1.
6 *
7 * SoCLib is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; version 2.1 of the License.
10 *
11 * SoCLib is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with SoCLib; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * SOCLIB_LGPL_HEADER_END
22 *
23 * Authors  : Cesar Armando Fuguet Tortolero
24 * Date     : jul 2015
25 * Copyright: UPMC - LIP6
26 */
27#include <systemc>
28#include <string>
29#include "synthetic_dspin_network.h"
30
31#if _OPENMP
32#include <omp.h>
33#endif
34
35struct Args
36{
37    size_t x_size;
38    size_t y_size;
39    size_t load;
40    size_t ncycles;
41    bool faulty;
42};
43
44
45////////////////////////////////
46// parse command line arguments
47////////////////////////////////
48void parse_args(Args *args, int argc, char **argv)
49{
50    for (int arg = 1; arg < argc; ++arg) {
51        if ((strcmp(argv[arg], "-L") == 0) && ((arg + 1) < argc)) {
52            args->load = strtol(argv[arg + 1], NULL, 0);
53            arg++;
54            continue;
55        }
56        if ((strcmp(argv[arg], "-X") == 0) && ((arg + 1) < argc)) {
57            args->x_size = strtol(argv[arg + 1], NULL, 0);
58            arg++;
59            continue;
60        }
61        if ((strcmp(argv[arg], "-Y") == 0) && ((arg + 1) < argc)) {
62            args->y_size = strtol(argv[arg + 1], NULL, 0);
63            arg++;
64            continue;
65        }
66        if ((strcmp(argv[arg], "-N") == 0) && ((arg + 1) < argc)) {
67            args->ncycles = strtol(argv[arg + 1], NULL, 0);
68            arg++;
69            continue;
70        }
71        if (strcmp(argv[arg], "-F") == 0) {
72            args->faulty = true;
73            continue;
74        }
75   
76        std::cout << "   Arguments are (key, value) couples." << std::endl;
77        std::cout << "   The order is not important." << std::endl;
78        std::cout << "   Accepted arguments are :" << std::endl << std::endl;
79        std::cout << "     -L dspin generators' accepted load * 1000" << std::endl;
80        std::cout << "     -X number of clusters per row" << std::endl;
81        std::cout << "     -Y number of clusters per column" << std::endl;
82        std::cout << "     -N simulation's cycles" << std::endl;
83        std::cout << "     -F deactivate a router" << std::endl;
84    }
85}                        // end parse_args()
86
87
88int sc_main(int argc, char **argv)
89{
90    using namespace soclib::caba;
91
92#if _OPENMP
93    omp_set_dynamic(false);
94    omp_set_num_threads(1);
95#endif
96
97
98    ////////////////////////////////
99    // parse command line arguments
100    ////////////////////////////////
101    Args args = {
102        .x_size  = 5,
103        .y_size  = 5,
104        .load    = 10,
105        .ncycles = 100000,
106        .faulty  = false
107    };
108    parse_args(&args, argc, argv);
109
110
111    ////////////////////////////
112    // components instantiation
113    ////////////////////////////
114    sc_core::sc_clock signal_clk;
115    sc_core::sc_signal<bool> signal_resetn;
116    SyntheticDspinNetwork syntheticDspinNetwork("syntheticDspinNetwork",
117                                                args.x_size,
118                                                args.y_size,
119                                                args.load);
120
121
122    ///////////
123    // netlist
124    ///////////
125    syntheticDspinNetwork.p_clk(signal_clk);
126    syntheticDspinNetwork.p_resetn(signal_resetn);
127
128
129    ////////////////////
130    // start simulation
131    ////////////////////
132    sc_core::sc_start(sc_core::SC_ZERO_TIME);
133    signal_resetn.write(0);
134    syntheticDspinNetwork.reset();
135
136    if (args.faulty) {
137        // deactivate a router in the center of the mesh and create its
138        // recovery cycle-free contour
139        syntheticDspinNetwork.set_faulty_router(args.x_size / 2, args.y_size / 2);
140    }
141
142    sc_core::sc_start(1, sc_core::SC_NS);
143    signal_resetn.write(1);
144    sc_core::sc_start(args.ncycles, sc_core::SC_NS);
145
146
147    ////////////////////
148    // print statistics
149    ////////////////////
150    for (size_t x = 0; x < args.x_size; ++x) {
151        for (size_t y = 0; y < args.y_size; ++y) {
152            syntheticDspinNetwork.print_stats(x, y);
153        }
154    }
155
156 
157    return 0;
158}                   // end sc_main()
159
160// Local Variables:
161// tab-width: 4
162// c-basic-offset: 4
163// c-file-offsets:((innamespace . 0)(inline-open . 0))
164// indent-tabs-mode: nil
165// End:
Note: See TracBrowser for help on using the repository browser.