chiark / gitweb /
break out maxhamweight_ok (no functional change)
[matchsticks-search.git] / main.c
diff --git a/main.c b/main.c
index 38bd8541ca6d5c382aa6beb06cd5d088f18f6ed8..8aaebad359679275a74ebd524460c6f67d0356f6 100644 (file)
--- a/main.c
+++ b/main.c
  * GNU General Public License for more details.
  */
 
+#define _GNU_SOURCE
+
+#include <publib.h>
+
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -35,7 +39,6 @@
 #include <sys/uio.h>
 #include <sys/fcntl.h>
 
-#include <publib.h>
 #include <glpk.h>
 
 /*
@@ -95,6 +98,8 @@ static unsigned printcounter;
 
 static void iterate(void);
 static void iterate_recurse(int i, AdjWord min);
+static bool preconsider_ok(int nwords, bool doprint);
+static bool maxhamweight_ok(void);
 static void optimise(bool doprint);
 
 static void progress_eol(void) {
@@ -142,6 +147,8 @@ typedef struct {
 } Worker;
 static Worker *mc_us;
 
+static void multicore_check_for_new_best(void);
+
 #define MAX_NIOVS 3
 static AdjWord mc_iter_min;
 static int mc_niovs;
@@ -331,6 +338,11 @@ static int count_set_adj_bits(AdjWord w) {
 
 static int totalfrags;
 
+static bool maxhamweight_ok(void) {
+  double maxminsize = (double)m / maxhamweight;
+  return maxminsize > best;
+}
+
 static bool preconsider_ok(int nwords, bool doprint) {
   int i;
 
@@ -580,8 +592,7 @@ static void iterate_recurse(int i, AdjWord min) {
 
 static void iterate(void) {
   for (maxhamweight=1; maxhamweight<=m; maxhamweight++) {
-    double maxminsize = (double)m / maxhamweight;
-    if (maxminsize <= best)
+    if (!maxhamweight_ok())
       continue;
 
     iterate_recurse(0, 1);