2 * collectd - src/sn-info.c
3 * Copyright (C) 2010 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <ff at octo.it>
28 #include "sn_network.h"
30 static _Bool is_normalized (sn_network_t *n) /* {{{ */
34 for (i = 0; i < SN_NETWORK_STAGE_NUM (n); i++)
36 sn_stage_t *s = SN_NETWORK_STAGE_GET (n, i);
39 for (j = 0; j < SN_STAGE_COMP_NUM (s); j++)
41 sn_comparator_t *c = SN_STAGE_COMP_GET (s, j);
49 } /* }}} _Bool is_normalized */
51 int main (int argc, char **argv)
61 int stages_num_compressed;
64 n = sn_network_read_file (argv[1]);
66 n = sn_network_read (stdin);
69 fprintf (stderr, "Unable to read network.\n");
73 inputs_num = SN_NETWORK_INPUT_NUM (n);
74 stages_num = SN_NETWORK_STAGE_NUM (n);
75 comparators_num = sn_network_get_comparator_num (n);
77 normalized = is_normalized (n);
80 sn_network_normalize (n);
81 sn_network_compress (n);
83 stages_num_compressed = SN_NETWORK_STAGE_NUM (n);
87 if (sn_network_brute_force_check (n) == 0)
97 printf ("%s %s network:\n"
100 (normalized ? "Standard" : "Non-standard"),
101 (sorts ? "sorting" : "comparator"),
104 if (stages_num_compressed == stages_num)
105 printf (" Stages: %4i\n",
108 printf (" Stages: %4i (compressed: %i)\n",
109 stages_num, stages_num_compressed);
111 printf (" Comparators: %4i\n"
117 (normalized ? "yes" : "no"),
118 ((inputs_num > 16) ? "unknown" : (sorts ? "yes" : "no")),
119 (stages_num_compressed * inputs_num) + comparators_num);
124 /* vim: set shiftwidth=2 softtabstop=2 : */