rbyd-rr: Preserving diverging alt coloring with careful pruning rules
This seems to mostly be working, now passing rbyd tests at least. This pruning/triming logic desperately needs to be simplified/cleaned up, but preserving diverging alt color balance without breaking things is still proving to be difficult...
This commit is contained in:
@@ -2962,11 +2962,13 @@ again:;
|
|||||||
|
|
||||||
// do bounds want to take different paths? begin diverging
|
// do bounds want to take different paths? begin diverging
|
||||||
if (!diverged
|
if (!diverged
|
||||||
&& lfsr_tag_follow2(alt, weight,
|
&& lfsr_tag_follow2(
|
||||||
|
alt, weight,
|
||||||
p_alts[0], p_weights[0],
|
p_alts[0], p_weights[0],
|
||||||
lower_rid, upper_rid,
|
lower_rid, upper_rid,
|
||||||
a_rid, a_tag)
|
a_rid, a_tag)
|
||||||
^ lfsr_tag_follow2(alt, weight,
|
^ lfsr_tag_follow2(
|
||||||
|
alt, weight,
|
||||||
p_alts[0], p_weights[0],
|
p_alts[0], p_weights[0],
|
||||||
lower_rid, upper_rid,
|
lower_rid, upper_rid,
|
||||||
b_rid, b_tag)) {
|
b_rid, b_tag)) {
|
||||||
@@ -2978,7 +2980,7 @@ again:;
|
|||||||
p_alts[0],
|
p_alts[0],
|
||||||
p_weights[0]);
|
p_weights[0]);
|
||||||
if (d_upper) {
|
if (d_upper) {
|
||||||
alt &= ~LFSR_TAG_R;
|
//alt &= ~LFSR_TAG_R;
|
||||||
diverged = true;
|
diverged = true;
|
||||||
|
|
||||||
// alt = LFSR_TAG_ALT(
|
// alt = LFSR_TAG_ALT(
|
||||||
@@ -3050,13 +3052,52 @@ again:;
|
|||||||
lower_rid,
|
lower_rid,
|
||||||
upper_rid);
|
upper_rid);
|
||||||
} else {
|
} else {
|
||||||
alt &= ~LFSR_TAG_R;
|
//alt &= ~LFSR_TAG_R;
|
||||||
//d_will_diverge = true;
|
//d_will_diverge = true;
|
||||||
diverged = true;
|
diverged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// trim unreachable diverged alts so they end up pruned
|
// trim unreachable diverged alts so they end up pruned
|
||||||
} else if (diverged
|
} else if (diverged
|
||||||
|
// TODO simpler way to express this?
|
||||||
|
&& !(lfsr_tag_isred(p_alts[0])
|
||||||
|
// && (lfsr_tag_follow(
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// a_rid, a_tag)
|
||||||
|
// ^ lfsr_tag_follow(
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// b_rid, b_tag)))
|
||||||
|
// && !(lfsr_tag_follow2(
|
||||||
|
// alt, weight,
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// a_rid, a_tag)
|
||||||
|
// ^ lfsr_tag_follow2(
|
||||||
|
// alt, weight,
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// b_rid, b_tag))
|
||||||
|
&& lfsr_tag_follow(
|
||||||
|
p_alts[0], p_weights[0],
|
||||||
|
lower_rid, upper_rid,
|
||||||
|
a_rid, a_tag))
|
||||||
|
// && !(lfsr_tag_follow2(
|
||||||
|
// alt, weight,
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// a_rid, a_tag)
|
||||||
|
// ^ lfsr_tag_follow2(
|
||||||
|
// alt, weight,
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// b_rid, b_tag)))
|
||||||
|
// && lfsr_tag_follow2(
|
||||||
|
// alt, weight,
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// b_rid, b_tag))
|
||||||
&& (d_upper
|
&& (d_upper
|
||||||
^ lfsr_tag_isgt(alt)
|
^ lfsr_tag_isgt(alt)
|
||||||
^ lfsr_tag_follow2(
|
^ lfsr_tag_follow2(
|
||||||
@@ -3064,6 +3105,12 @@ again:;
|
|||||||
p_alts[0], p_weights[0],
|
p_alts[0], p_weights[0],
|
||||||
lower_rid, upper_rid,
|
lower_rid, upper_rid,
|
||||||
a_rid, a_tag))) {
|
a_rid, a_tag))) {
|
||||||
|
// && !(d_upper
|
||||||
|
// ^ lfsr_tag_isgt(alt)
|
||||||
|
// ^ lfsr_tag_follow(
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// a_rid, a_tag))) {
|
||||||
if (lfsr_tag_follow2(
|
if (lfsr_tag_follow2(
|
||||||
alt, weight,
|
alt, weight,
|
||||||
p_alts[0], p_weights[0],
|
p_alts[0], p_weights[0],
|
||||||
@@ -3075,11 +3122,68 @@ again:;
|
|||||||
lower_rid, upper_rid);
|
lower_rid, upper_rid);
|
||||||
lfs_swap32(&jump, &branch_);
|
lfs_swap32(&jump, &branch_);
|
||||||
}
|
}
|
||||||
|
printf("%04x->%04x: dtrim 0x%x w%d -> w0\n",
|
||||||
|
branch,
|
||||||
|
rbyd->eoff,
|
||||||
|
alt,
|
||||||
|
weight);
|
||||||
lfsr_tag_trim(
|
lfsr_tag_trim(
|
||||||
alt, weight,
|
alt, weight,
|
||||||
&lower_rid, &upper_rid,
|
&lower_rid, &upper_rid,
|
||||||
&lower_tag, &upper_tag);
|
&lower_tag, &upper_tag);
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
|
||||||
|
// TODO doc, cleanup?
|
||||||
|
// trim inner branches of the divering node itself
|
||||||
|
} else if (diverged
|
||||||
|
&& !d_upper
|
||||||
|
&& lfsr_tag_isred(p_alts[0])
|
||||||
|
&& lfsr_tag_follow(
|
||||||
|
p_alts[0], p_weights[0],
|
||||||
|
lower_rid, upper_rid,
|
||||||
|
a_rid, a_tag)
|
||||||
|
// && (!d_upper
|
||||||
|
// ^ lfsr_tag_isgt(alt)
|
||||||
|
// ^ lfsr_tag_follow2(
|
||||||
|
// alt, weight,
|
||||||
|
// p_alts[0], p_weights[0],
|
||||||
|
// lower_rid, upper_rid,
|
||||||
|
// b_rid, b_tag))) {
|
||||||
|
&& (lfsr_tag_follow2(
|
||||||
|
alt, weight,
|
||||||
|
p_alts[0], p_weights[0],
|
||||||
|
lower_rid, upper_rid,
|
||||||
|
a_rid, a_tag)
|
||||||
|
^ lfsr_tag_follow2(
|
||||||
|
alt, weight,
|
||||||
|
p_alts[0], p_weights[0],
|
||||||
|
lower_rid, upper_rid,
|
||||||
|
b_rid, b_tag))) {
|
||||||
|
if (lfsr_tag_follow2(
|
||||||
|
alt, weight,
|
||||||
|
p_alts[0], p_weights[0],
|
||||||
|
lower_rid, upper_rid,
|
||||||
|
b_rid, b_tag)) {
|
||||||
|
lfsr_tag_flip2(
|
||||||
|
&alt, &weight,
|
||||||
|
p_alts[0], p_weights[0],
|
||||||
|
lower_rid, upper_rid);
|
||||||
|
lfs_swap32(&jump, &branch_);
|
||||||
|
}
|
||||||
|
printf("%04x->%04x: d0trim 0x%x w%d -> w0\n",
|
||||||
|
branch,
|
||||||
|
rbyd->eoff,
|
||||||
|
alt,
|
||||||
|
weight);
|
||||||
|
// lfsr_tag_trim(
|
||||||
|
// alt, weight,
|
||||||
|
// &lower_rid, &upper_rid,
|
||||||
|
// &lower_tag, &upper_tag);
|
||||||
|
// weight = 0;
|
||||||
|
alt = (p_alts[0] & ~LFSR_TAG_R) | (alt & LFSR_TAG_R);
|
||||||
|
weight = p_weights[0];
|
||||||
|
jump = p_jumps[0];
|
||||||
|
lfsr_rbyd_p_pop(p_alts, p_weights, p_jumps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!lfsr_d_isdiverged(d_state)
|
// if (!lfsr_d_isdiverged(d_state)
|
||||||
@@ -3355,7 +3459,7 @@ again:;
|
|||||||
// | | .-'| | | .----'|
|
// | | .-'| | | .----'|
|
||||||
// 1 2 3 4 1 2 3 4 4
|
// 1 2 3 4 1 2 3 4 4
|
||||||
} else {
|
} else {
|
||||||
printf("%04x->%04x: ysplit2 0x%x w%d 0x%x w%d (%x %x %x)\n",
|
printf("%04x->%04x: ysplit2 0x%x w%d 0x%x w%d (%x %x %x %x)\n",
|
||||||
branch,
|
branch,
|
||||||
rbyd->eoff,
|
rbyd->eoff,
|
||||||
alt,
|
alt,
|
||||||
@@ -3364,7 +3468,8 @@ again:;
|
|||||||
p_weights[0],
|
p_weights[0],
|
||||||
p_jumps[0],
|
p_jumps[0],
|
||||||
jump,
|
jump,
|
||||||
branch_);
|
branch_,
|
||||||
|
y_branch);
|
||||||
LFS_ASSERT(y_branch != 0);
|
LFS_ASSERT(y_branch != 0);
|
||||||
p_alts[0] = alt;
|
p_alts[0] = alt;
|
||||||
p_weights[0] += weight;
|
p_weights[0] += weight;
|
||||||
|
|||||||
Reference in New Issue
Block a user