projects
/
libfirm
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
efc0f62
)
Continued refactoring.
author
Sebastian Buchwald
<Sebastian.Buchwald@kit.edu>
Wed, 3 Dec 2008 20:22:59 +0000
(20:22 +0000)
committer
Sebastian Buchwald
<Sebastian.Buchwald@kit.edu>
Wed, 3 Dec 2008 20:22:59 +0000
(20:22 +0000)
[r24272]
heuristical.c
patch
|
blob
|
history
diff --git
a/heuristical.c
b/heuristical.c
index
a1c3dd5
..
48c7dc9
100644
(file)
--- a/
heuristical.c
+++ b/
heuristical.c
@@
-18,6
+18,9
@@
static pbqp_node **node_buckets[4];
static pbqp_node **reduced_bucket = NULL;
static int buckets_filled = 0;
static pbqp_node **reduced_bucket = NULL;
static int buckets_filled = 0;
+/* Forward declarations. */
+static void apply_Brute_Force(pbqp *pbqp);
+
static void insert_into_edge_bucket(pbqp_edge *edge)
{
if (edge_bucket_contains(edge_bucket, edge)) {
static void insert_into_edge_bucket(pbqp_edge *edge)
{
if (edge_bucket_contains(edge_bucket, edge)) {
@@
-489,14
+492,8
@@
static void back_propagate(pbqp *pbqp)
}
}
}
}
-
void solve_pbqp_heuristical
(pbqp *pbqp)
+
static void apply_heuristic_reductions
(pbqp *pbqp)
{
{
- /* Reduce nodes degree ... */
- initial_simplify_edges(pbqp);
-
- /* ... and put node into bucket representing their degree. */
- fill_node_buckets(pbqp);
-
for (;;) {
if (edge_bucket_get_length(edge_bucket) > 0) {
apply_edge(pbqp);
for (;;) {
if (edge_bucket_get_length(edge_bucket) > 0) {
apply_edge(pbqp);
@@
-507,9
+504,20
@@
void solve_pbqp_heuristical(pbqp *pbqp)
} else if (node_bucket_get_length(node_buckets[3]) > 0) {
apply_RN(pbqp);
} else {
} else if (node_bucket_get_length(node_buckets[3]) > 0) {
apply_RN(pbqp);
} else {
-
break
;
+
return
;
}
}
}
}
+}
+
+void solve_pbqp_heuristical(pbqp *pbqp)
+{
+ /* Reduce nodes degree ... */
+ initial_simplify_edges(pbqp);
+
+ /* ... and put node into bucket representing their degree. */
+ fill_node_buckets(pbqp);
+
+ apply_heuristic_reductions(pbqp);
pbqp->solution = determine_solution(pbqp->dump_file);
pbqp->solution = determine_solution(pbqp->dump_file);
@@
-828,6
+836,23
@@
void apply_RN(pbqp *pbqp)
select_alternative(node, min_index);
}
select_alternative(node, min_index);
}
+static void apply_brute_force_reductions(pbqp *pbqp)
+{
+ for (;;) {
+ if (edge_bucket_get_length(edge_bucket) > 0) {
+ apply_edge(pbqp);
+ } else if (node_bucket_get_length(node_buckets[1]) > 0) {
+ apply_RI(pbqp);
+ } else if (node_bucket_get_length(node_buckets[2]) > 0) {
+ apply_RII(pbqp);
+ } else if (node_bucket_get_length(node_buckets[3]) > 0) {
+ apply_Brute_Force(pbqp);
+ } else {
+ return;
+ }
+ }
+}
+
static unsigned get_minimal_alternative(pbqp *pbqp, pbqp_node *node)
{
pbqp_edge *edge;
static unsigned get_minimal_alternative(pbqp *pbqp, pbqp_node *node)
{
pbqp_edge *edge;
@@
-861,6
+886,7
@@
static unsigned get_minimal_alternative(pbqp *pbqp, pbqp_node *node)
pbqp_node_bucket *bucket_red = node_bucket_deep_copy(reduced_bucket);
/* TODO */
pbqp_node_bucket *bucket_red = node_bucket_deep_copy(reduced_bucket);
/* TODO */
+ apply_brute_force_reductions(pbqp);
if (value < min) {
min = value;
if (value < min) {
min = value;
@@
-899,6
+925,24
@@
void apply_Brute_Force(pbqp *pbqp)
select_alternative(node, min_index);
}
select_alternative(node, min_index);
}
+void solve_pbqp_brute_force(pbqp *pbqp)
+{
+ /* Reduce nodes degree ... */
+ initial_simplify_edges(pbqp);
+
+ /* ... and put node into bucket representing their degree. */
+ fill_node_buckets(pbqp);
+
+ apply_brute_force_reductions(pbqp);
+
+ pbqp->solution = determine_solution(pbqp->dump_file);
+
+ /* Solve reduced nodes. */
+ back_propagate(pbqp);
+
+ free_buckets();
+}
+
void back_propagate_RI(pbqp *pbqp, pbqp_node *node)
{
pbqp_edge *edge;
void back_propagate_RI(pbqp *pbqp, pbqp_node *node)
{
pbqp_edge *edge;