@@ -475,14 +475,15 @@ static bool onestep(
475
475
}
476
476
477
477
// Weight of this step
478
- int weight = (node -> to_parent == NULL || ctx == node -> to_parent -> after ) ? 0 : 1 ;
478
+ unsigned int weight = (node -> to_parent == NULL || ctx == node -> to_parent -> after ) ? 0 : 1 ;
479
479
480
480
// Allocate edge now
481
481
struct edge * edge = walloc (w , sizeof (struct edge ) + step -> nlog * sizeof (hvalue_t ), false);
482
482
edge -> src = node ;
483
483
edge -> ctx = ctx ;
484
484
edge -> choice = choice_copy ;
485
485
edge -> interrupt = interrupt ;
486
+ edge -> weight = weight ;
486
487
edge -> after = after ;
487
488
edge -> ai = step -> ai ;
488
489
memcpy (edge -> log , step -> log , step -> nlog * sizeof (hvalue_t ));
@@ -507,7 +508,9 @@ static bool onestep(
507
508
else {
508
509
unsigned int len = node -> len + weight ;
509
510
unsigned int steps = node -> steps + instrcnt ;
510
- if (len < next -> len || (len == next -> len && steps < next -> steps )) {
511
+ // TODO: not sure how to minimize. For some cases, this works better than
512
+ // if (len < next->len || (len == next->len && steps < next->steps)) {
513
+ if (len < next -> len || (len == next -> len && steps <= next -> steps )) {
511
514
next -> len = len ;
512
515
next -> steps = steps ;
513
516
next -> to_parent = edge ;
@@ -2164,6 +2167,15 @@ int main(int argc, char **argv){
2164
2167
2165
2168
printf ("Phase 3: analysis\n" );
2166
2169
if (minheap_empty (global -> failures )) {
2170
+ double now = gettime ();
2171
+ global -> phase2 = true;
2172
+ global -> scc_todo = scc_alloc (0 , global -> graph .size , NULL , NULL );
2173
+ barrier_wait (& middle_barrier );
2174
+ // Workers working on finding SCCs
2175
+ barrier_wait (& end_barrier );
2176
+
2177
+ printf ("%u components (%.3lf seconds)\n" , global -> ncomponents , gettime () - now );
2178
+
2167
2179
#ifdef DUMP_GRAPH
2168
2180
printf ("digraph Harmony {\n" );
2169
2181
for (unsigned int i = 0 ; i < global -> graph .size ; i ++ ) {
@@ -2179,15 +2191,6 @@ int main(int argc, char **argv){
2179
2191
printf ("}\n" );
2180
2192
#endif
2181
2193
2182
- double now = gettime ();
2183
- global -> phase2 = true;
2184
- global -> scc_todo = scc_alloc (0 , global -> graph .size , NULL , NULL );
2185
- barrier_wait (& middle_barrier );
2186
- // Workers working on finding SCCs
2187
- barrier_wait (& end_barrier );
2188
-
2189
- printf ("%u components (%.3lf seconds)\n" , global -> ncomponents , gettime () - now );
2190
-
2191
2194
// mark the components that are "good" because they have a way out
2192
2195
struct component * components = calloc (global -> ncomponents , sizeof (* components ));
2193
2196
for (unsigned int i = 0 ; i < global -> graph .size ; i ++ ) {
@@ -2276,6 +2279,37 @@ int main(int argc, char **argv){
2276
2279
}
2277
2280
}
2278
2281
2282
+ #ifdef DUMP_GRAPH
2283
+ if (true) {
2284
+ FILE * df = fopen ("charm.gv" , "w" );
2285
+ fprintf (df , "digraph Harmony {\n" );
2286
+ for (unsigned int i = 0 ; i < global -> graph .size ; i ++ ) {
2287
+ struct node * node = global -> graph .nodes [i ];
2288
+ fprintf (df , " s%u [label=\"%u/%u\"]\n" , i , i , node -> len );
2289
+ }
2290
+ for (unsigned int i = 0 ; i < global -> graph .size ; i ++ ) {
2291
+ struct node * node = global -> graph .nodes [i ];
2292
+ for (struct edge * edge = node -> fwd ; edge != NULL ; edge = edge -> fwdnext ) {
2293
+ struct state * state = node -> state ;
2294
+ unsigned int j ;
2295
+ for (j = 0 ; j < state -> bagsize ; j ++ ) {
2296
+ if (state -> contexts [j ] == edge -> ctx ) {
2297
+ break ;
2298
+ }
2299
+ }
2300
+ assert (j < state -> bagsize );
2301
+ fprintf (df , " s%u -> s%u [style=%s label=\"%u/%u\"]\n" ,
2302
+ node -> id , edge -> dst -> id ,
2303
+ edge -> dst -> to_parent == edge ? "solid" : "dashed" ,
2304
+ multiplicities (state )[j ],
2305
+ edge -> weight );
2306
+ }
2307
+ }
2308
+ fprintf (df , "}\n" );
2309
+ fclose (df );
2310
+ }
2311
+ #endif
2312
+
2279
2313
#ifdef OBSOLETE
2280
2314
if (true) {
2281
2315
FILE * df = fopen ("charm.dump" , "w" );
0 commit comments