X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=heuristical_co.c;h=f65db2cf808c24b527fd69be9555b9cf24ef3465;hb=8290626415406f13f47a0ef51c9cfef868fe05ab;hp=18ede22de7bb7f4c9b8d1e4469cb633ff46ea130;hpb=6c2d6c360d082f09aca2c2b332c047789a75b81f;p=libfirm diff --git a/heuristical_co.c b/heuristical_co.c index 18ede22de..f65db2cf8 100644 --- a/heuristical_co.c +++ b/heuristical_co.c @@ -47,10 +47,9 @@ #include "plist.h" #include "timing.h" -static void apply_RN_co(pbqp *pbqp, plist_t *rpeo) +static void merge_into_RN_node(pbqp *pbqp, plist_t *rpeo) { pbqp_node *node = NULL; - unsigned min_index = 0; assert(pbqp); @@ -75,12 +74,23 @@ static void apply_RN_co(pbqp *pbqp, plist_t *rpeo) pbqp_dump_graph(pbqp); } #endif -#if KAPS_STATISTIC /* Check whether we can merge a neighbor into the current node. */ - for (min_index = 0; min_index < pbqp_node_get_degree(node); ++min_index) { - check_melting_possibility(pbqp, node->edges[min_index]); - } -#endif + apply_RM(pbqp, node); +} + +static void apply_RN_co(pbqp *pbqp) +{ + pbqp_node *node = NULL; + unsigned min_index = 0; + + assert(pbqp); + + node = merged_node; + merged_node = NULL; + assert(node); + + if (node_is_reduced(node)) + return; min_index = get_local_minimal_alternative(pbqp, node); @@ -107,7 +117,6 @@ static void apply_heuristic_reductions_co(pbqp *pbqp, plist_t *rpeo) #if KAPS_TIMING /* create timers */ ir_timer_t *t_edge = ir_timer_new(); - ir_timer_t *t_r0 = ir_timer_new(); ir_timer_t *t_r1 = ir_timer_new(); ir_timer_t *t_r2 = ir_timer_new(); ir_timer_t *t_rn = ir_timer_new(); @@ -116,13 +125,13 @@ static void apply_heuristic_reductions_co(pbqp *pbqp, plist_t *rpeo) for (;;) { if (edge_bucket_get_length(edge_bucket) > 0) { #if KAPS_TIMING - ir_timer_start(t_r0); + ir_timer_start(t_edge); #endif apply_edge(pbqp); #if KAPS_TIMING - ir_timer_stop(t_r0); + ir_timer_stop(t_edge); #endif } else if (node_bucket_get_length(node_buckets[1]) > 0) { #if KAPS_TIMING @@ -144,23 +153,32 @@ static void apply_heuristic_reductions_co(pbqp *pbqp, plist_t *rpeo) #if KAPS_TIMING ir_timer_stop(t_r2); #endif + } else if (merged_node != NULL) { + #if KAPS_TIMING + ir_timer_start(t_rn); + #endif + + apply_RN_co(pbqp); + + #if KAPS_TIMING + ir_timer_stop(t_rn); + #endif } else if (node_bucket_get_length(node_buckets[3]) > 0) { #if KAPS_TIMING ir_timer_start(t_rn); #endif - apply_RN_co(pbqp, rpeo); + merge_into_RN_node(pbqp, rpeo); #if KAPS_TIMING ir_timer_stop(t_rn); #endif } else { #if KAPS_TIMING - printf("pbqp reduce independent edges: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_edge) / 1000.0); - printf("pbqp R0 reductions: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_r0) / 1000.0); - printf("pbqp R1 reductions: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_r1) / 1000.0); - printf("pbqp R2 reductions: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_r2) / 1000.0); - printf("pbqp RN reductions: %8.3lf msec\n", (double)ir_timer_elapsed_usec(t_rn) / 1000.0); + printf("PBQP RE reductions: %10.3lf msec\n", (double)ir_timer_elapsed_usec(t_edge) / 1000.0); + printf("PBQP R1 reductions: %10.3lf msec\n", (double)ir_timer_elapsed_usec(t_r1) / 1000.0); + printf("PBQP R2 reductions: %10.3lf msec\n", (double)ir_timer_elapsed_usec(t_r2) / 1000.0); + printf("PBQP RN reductions: %10.3lf msec\n", (double)ir_timer_elapsed_usec(t_rn) / 1000.0); #endif return; @@ -188,9 +206,14 @@ void solve_pbqp_heuristical_co(pbqp *pbqp, plist_t *rpeo) #if KAPS_STATISTIC fh = fopen("solutions.pb", "a"); - fprintf(fh, ": %lld RE:%u R0:%u R1:%u R2:%u RM:%u RN/BF:%u\n", pbqp->solution, + #if KAPS_USE_UNSIGNED + fprintf(fh, ": %u RE:%u R0:%u R1:%u R2:%u RM:%u RN/BF:%u\n", pbqp->solution, pbqp->num_edges, pbqp->num_r0, pbqp->num_r1, pbqp->num_r2, pbqp->num_rm, pbqp->num_rn); + #else + fprintf(fh, ": %lld RE:%u R0:%u R1:%u R2:%u RM:%u RN/BF:%u\n", pbqp->solution, + pbqp->num_edges, pbqp->num_r0, pbqp->num_r1, pbqp->num_r2, + #endif fclose(fh); #endif