From: Sebastian Buchwald Date: Fri, 3 Oct 2008 21:36:07 +0000 (+0000) Subject: - don't add trivial nodes when using new PBQP solver X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=65467496a93e64dbe96a16a04b16dc097d2eba88;p=libfirm - don't add trivial nodes when using new PBQP solver - enable dumping the PBQP to a html file [r22449] --- diff --git a/heuristical.c b/heuristical.c index e69de29bb..0233c46f7 100644 --- a/heuristical.c +++ b/heuristical.c @@ -0,0 +1,9 @@ +#include "heuristical.h" +#include "html_dumper.h" + +void solve_pbqp_heuristical(pbqp *pbqp) +{ + if (pbqp->dump_file) { + dump_input(pbqp); + } +} diff --git a/heuristical.h b/heuristical.h index 5ff812d11..8d24c2e40 100644 --- a/heuristical.h +++ b/heuristical.h @@ -3,14 +3,6 @@ #include "pbqp_t.h" -/** - * Create an empty PBQP instance with the given number of nodes. - */ -pbqp* alloc_pbqp(int number_nodes); - -/** - * Free the given PBQP. - */ -void free_pbqp(pbqp *pbqp); +void solve_pbqp_heuristical(pbqp *pbqp); #endif /* KAPS_HEURISTICAL_H */ diff --git a/html_dumper.c b/html_dumper.c index bbb8372eb..389656ec7 100644 --- a/html_dumper.c +++ b/html_dumper.c @@ -15,9 +15,14 @@ static void dump_vector(FILE *f, vector *vec) fprintf(f, "( "); unsigned len = vec->len; - assert(len> 0); + assert(len > 0); for (index = 0; index < len; ++index) { +#if EXT_GRS_DEBUG + fprintf(f, "%6d", vec->entries[index].name, + vec->entries[index].data); +#else fprintf(f, "%6d", vec->entries[index].data); +#endif } fprintf(f, " )\n"); } @@ -28,8 +33,8 @@ static void dump_matrix(FILE *f, pbqp_matrix *mat) assert(mat); num *p = mat->entries; - assert(mat->cols > 0); - assert(mat->rows > 0); + assert(mat->cols> 0); + assert(mat->rows> 0); fprintf(f, "\t\\begin{pmatrix}\n"); for (row = 0; row < mat->rows; ++row) { fprintf(f, "\t %6d", *p++); @@ -51,6 +56,10 @@ static void dump_edge_costs(pbqp *pbqp) fputs("

", pbqp->dump_file); for (src_index = 0; src_index < pbqp->num_nodes; ++src_index) { pbqp_node *src_node = get_node(pbqp, src_index); + + if (!src_node) + continue; + unsigned edge_index; unsigned len = ARR_LEN(src_node->edges); for (edge_index = 0; edge_index < len; ++edge_index) { @@ -79,9 +88,11 @@ static void dump_node_costs(pbqp *pbqp) fputs("

", pbqp->dump_file); for (index = 0; index < pbqp->num_nodes; ++index) { pbqp_node *node = get_node(pbqp, index); - fprintf(pbqp->dump_file, "\tc%d = ", index); - dump_vector(pbqp->dump_file, node->costs); - fputs("
\n", pbqp->dump_file); + if (node) { + fprintf(pbqp->dump_file, "\tc%d = ", index); + dump_vector(pbqp->dump_file, node->costs); + fputs("
\n", pbqp->dump_file); + } } fputs("

", pbqp->dump_file); } @@ -93,20 +104,27 @@ static void dump_section(FILE *f, int level, char *txt) fprintf(f, "%s\n", level, txt, level); } -void dump_graph(pbqp *pbqp) +void pbqp_dump_graph(pbqp *pbqp) { unsigned src_index; - assert(pbqp != NULL); - assert(pbqp->dump_file != NULL); + assert(pbqp); + assert(pbqp->dump_file); fputs("

\n\n\tgraph input {\n", pbqp->dump_file); for (src_index = 0; src_index < pbqp->num_nodes; ++src_index) { - fprintf(pbqp->dump_file, "\t n%d;\n", src_index); + pbqp_node *node = get_node(pbqp, src_index); + if (node) { + fprintf(pbqp->dump_file, "\t n%d;\n", src_index); + } } for (src_index = 0; src_index < pbqp->num_nodes; ++src_index) { pbqp_node *node = get_node(pbqp, src_index); + + if (!node) + continue; + unsigned len = ARR_LEN(node->edges); unsigned edge_index; for (edge_index = 0; edge_index < len; ++edge_index) { @@ -128,7 +146,7 @@ void dump_input(pbqp *pbqp) dump_section(pbqp->dump_file, 1, "1. PBQP Problem"); dump_section(pbqp->dump_file, 2, "1.1 Topology"); - dump_graph(pbqp); + pbqp_dump_graph(pbqp); dump_section(pbqp->dump_file, 2, "1.2 Cost Vectors"); dump_node_costs(pbqp); dump_section(pbqp->dump_file, 2, "1.3 Cost Matrices");