From: Florian Forster Date: Sun, 20 Feb 2011 13:42:35 +0000 (+0100) Subject: sn-markov: Implement the "-b" option. X-Git-Tag: v1.1.0~7 X-Git-Url: https://git.octo.it/?p=sort-networks.git;a=commitdiff_plain;h=420e9243fa1a8c0999b454fa16487d1bdf3765fa;ds=sidebyside sn-markov: Implement the "-b" option. When given, uses the bitonic merge. --- diff --git a/src/sn-markov.c b/src/sn-markov.c index 5de4284..b1f3008 100644 --- a/src/sn-markov.c +++ b/src/sn-markov.c @@ -50,6 +50,7 @@ #endif static int inputs_num = 16; +static _Bool use_bitonic = 0; static char *initial_input_file = NULL; static char *best_output_file = NULL; @@ -75,6 +76,7 @@ static void exit_usage (const char *name, int status) " -i Initial input file (REQUIRED)\n" " -o Write the current best solution to \n" " -n Maximum number of steps (iterations) to perform\n" + " -b Use the bitonic merger instead of the odd-even merger\n" " -h Display usage information (this message)\n" "\n", name); @@ -85,7 +87,7 @@ int read_options (int argc, char **argv) { int option; - while ((option = getopt (argc, argv, "i:o:n:h")) != -1) + while ((option = getopt (argc, argv, "i:o:n:bh")) != -1) { switch (option) { @@ -120,6 +122,10 @@ int read_options (int argc, char **argv) break; } + case 'b': + use_bitonic = 1; + break; + case 'h': default: exit_usage (argv[0], EXIT_SUCCESS); @@ -155,7 +161,10 @@ static sn_network_t *get_next (sn_network_t *n) assert (nright != NULL); /* combine the two parents */ - nret = sn_network_combine (nleft, nright); + if (use_bitonic) + nret = sn_network_combine_bitonic_merge (nleft, nright); + else + nret = sn_network_combine_odd_even_merge (nleft, nright); sn_network_destroy (nleft); sn_network_destroy (nright);