chiark / gitweb /
machinery for checking that our OUTER parallel iteration works - before we delete it
[moebius2.git] / energy.c
index f6a4c290c5883d2c04ef0b9150717cc991f409b6..a4cfbb1491221f90b4e454105e8e04473ed89f99 100644 (file)
--- a/energy.c
+++ b/energy.c
@@ -59,6 +59,20 @@ static const CostContribution costs[]= {
     COST(  1e18,   noncircular_rim_cost)
 #endif
 
+#if XBITS==5
+#define STOP_EPSILON 1e-6
+    COST(  3e5,   line_bending_cost)
+    COST( 10e2,   edge_length_variation_cost)
+    COST( 9.0e1,  rim_proximity_cost) // 5e1 is too much
+                                     // 2.5e1 is too little
+    // 0.2e1 grows compared to previous ?
+    // 0.6e0 shrinks compared to previous ?
+
+    COST(  1e12,   edge_angle_cost)
+                  #define EDGE_ANGLE_COST_CIRCCIRCRAT (0.5/1.3)
+    COST(  1e18,   noncircular_rim_cost)
+#endif
+
 };
 
 const double edge_angle_cost_circcircrat= EDGE_ANGLE_COST_CIRCCIRCRAT;
@@ -160,6 +174,8 @@ void compute_edge_lengths(const Vertices vertices, int section) {
     edge_lengths[v1][e]= hypotD(vertices[v1],vertices[v2]);
 }
 
+#include <pthread.h>
+
 void compute_vertex_areas(const Vertices vertices, int section) {
   int v0,v1,v2, e1,e2;
 //  int k;
@@ -234,7 +250,24 @@ double line_bending_cost(const Vertices vertices, int section) {
   double  a[D3], b[D3], axb[D3];
   double total_cost= 0;
 
+  if (quitting_last_iteration) {
+    char buf[100];
+    int n= sprintf(buf,
+                  "section=%d thr=%#08lx qi=0x%03x START\n",
+                  section,(unsigned long)pthread_self(), N);
+    write(2,buf,n);
+    quitting_reported_threads= 1;
+  }
+
   FOR_EDGE(qi,e,ri, OUTER) {
+    if (quitting_last_iteration) {
+      char buf[100];
+      int n= sprintf(buf,
+                    "section=%d thr=%#08lx qi=0x%03x,e=%d,ri=0x%03x\n",
+                    section,(unsigned long)pthread_self(),qi,e,ri);
+      write(2,buf,n);
+    }
+
     pi= EDGE_END2(qi,(e+3)%V6); if (pi<0) continue;
 
 //if (!(qi&XMASK)) fprintf(stderr,"%02x-%02x-%02x (%d)\n",pi,qi,ri,e);