Hi Arnaud,<div><br></div><div>Apologies for the delayed reply.</div><div><br></div><div>Thank you for the excellent test case - it exposed a subtle bug in the colorability heuristic. This has been fixed in r153958.</div>
<div><br></div><div>In case you are curious, the bug was as follows: the PBQP solver applies applies a simplification step to each matrix. When all elements of a matrix row or column are equal, the value for those elements is "pushed out" to the corresponding element of the cost vector, and the row/column is zeroed out. This is an attempt to turn the matrices into zero matrices which can be eliminated from the problem. This simplification step runs even for rows/columns that are all infinite. When an all infinite row/column is encountered, it will be zeroed out, and the infinite cost attached to some register in the cost vector. Unfortunately the infinite-cost elements of vectors were not being taken into consideration when determining colorability, only the infinities in the matrices were. In your test case this led to a node being falsely assumed to be colorable when it was not, and pushed to the coloring stack too early. By the time it was encountered in the coloring phase it had already been over-constrained, and no finite cost solutions were available.</div>

<div><br></div><div>In future I hope to make the simplification step strip infinite rows/columns from the problem altogether (along with their corresponding vector elements). This would speed the solver up further by avoiding consideration of such impossible options.</div>

<div><br></div><div>With the fix from r153958 applied the solver now finds a zero-cost solution for the test case you sent me. This should translate to a valid register allocation for your test case. Please try it out and let me know if it works for you.</div>

<div><br></div><div>Cheers,</div><div>Lang.</div><div><br><div class="gmail_quote">
On Tue, Mar 27, 2012 at 5:05 AM, Arnaud de Grandmaison <span dir="ltr"><<a href="mailto:arnaud.allarddegrandmaison@parrot.com" target="_blank">arnaud.allarddegrandmaison@parrot.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Lang,<br>
<br>
I have reduced the testcase as much as possible. The log of the run and the<br>
dumped graphes are attached.<br>
<br>
Cheers,<br>
<span><font color="#888888">--<br>
Arnaud de Grandmaison<br>
</font></span><div><div><br>
On Tuesday, March 27, 2012 01:20:35 Lang Hames wrote:<br>
> Hi Arnaud,<br>
><br>
> Thanks for attaching those files. I'll take a look at them.<br>
><br>
> Commit r153483 adds an option to the PBQP allocator,<br>
> "-pbqp-dump-graphs", to dump the PBQP graph for each round of each<br>
> function in a compilation unit. The generated files are named "<module<br>
> id>.<function>.<round>.pbqpgraph", and contain a simple text<br>
> representation of the PBQP graph. The PBQP allocator has been stable<br>
> for some time - I think this patch should apply cleanly to the 3.0<br>
> version.<br>
><br>
> Can you run the failing test case through the allocator with this<br>
> patch applied, passing the "-regalloc=pbqp -pbqp-dump-graphs<br>
> -debug-only=regalloc" options. I'll need to take a look at the last<br>
> graph dumped before the assertion is triggered.<br>
><br>
> Cheers,<br>
> Lang.<br>
><br>
> On Mon, Mar 26, 2012 at 7:35 AM, Arnaud de Grandmaison<br>
><br>
> <<a href="mailto:arnaud.allarddegrandmaison@parrot.com" target="_blank">arnaud.allarddegrandmaison@parrot.com</a>> wrote:<br>
> > Hi Lang,<br>
> ><br>
> >> From memory your target is not public, so I won't be able to reproduce<br>
> >> the crash myself. Is that correct?<br>
> ><br>
> > Correct.<br>
> ><br>
> >> If that's the case, I could add functionality to dump the PBQP graphs<br>
> >> during allocation. I think they should give me enough information to<br>
> >> debug the issue. Would you be able to share the PBQP graphs?<br>
> ><br>
> > I can share the pbqp graph if you send me a patch with the added<br>
> > functionality you want. On my side, I already checked the node cost for<br>
> > this register, which is correctly set to inf for spill, as well as the<br>
> > edge costs, and they look ok.<br>
> ><br>
> > I also attached my target's pbqp related file in case you want to double<br>
> > check what I did. This is llvm-3.0 based. It comprises 2 passes : the<br>
> > FemtoPBQPBuilder, plus a FemtoPairablepass, which undo some of the<br>
> > coalescer's work. The insertRegCopy may specifically need a double<br>
> > check, as I am not 100% sure to have updated correctly the LiveInterval<br>
> > information.<br>
> ><br>
> > In terms of registers, the Femto target is simplistic : a single<br>
> > register<br>
> > class GR16, for data and pointers, all i16. It has 16 registers, R0 to<br>
> > R15; R15 is used as stack pointer, and R14 potentialy as framepointer.<br>
> > A pair is constituted from a register + its successor, i.e. (R0, R1),<br>
> > (R1,R2), (R2, R3), ... are valid pairs. This is an instruction encoding<br>
> > constraint, as we only have 16bits wide instructions. Pairs involving<br>
> > R15 are never allowed, those with R14 may be allowed, depending on each<br>
> > function.<br>
> ><br>
> > Most instructions have no pairing constraints, and do not appear here,<br>
> > being handled by the PBQPBuilder default base class. A few instructions<br>
> > have 1 or 2 pairs of registers, and are all handled by the 2 passes<br>
> > above.<br>
> ><br>
> > Thanks for your help,<br>
> > --<br>
> > Arnaud de Grandmaison<br>
> > Senior CPU engineer<br>
> > Business Unit Digital Tuner<br>
> ><br>
> > Parrot S.A.<br>
> > 174, quai de Jemmapes<br>
> > 75010 Paris - France<br>
> > Phone: <a href="tel:%2B33%201%2048%2003%2084%2059" value="+33148038459" target="_blank">+33 1 48 03 84 59</a><br>
</div></div></blockquote></div><br></div>