<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Glenn,
<div class=""><br class="">
</div>
<div class="">A quick follow-up: I like your idea of the summary bits potentially allowing large uninteresting segments of the full bit vectors to be skipped.</div>
<div class=""><br class="">
</div>
<div class="">I use 192 summary bits (= 3 x 64 bit words) since in my experiments using more bits didn’t give a significant improvement. Although&nbsp;a fixed-size summary representation&nbsp;doesn’t unambiguously identify those words in the full bit vector that are
 zero, it allows the compiler to unwind loops of logical operations and efficiently inline them.</div>
<div class=""><br class="">
</div>
<div class="">I’ll be interested in your results with the type files I sent you. (To get the graph I produced cut-down versions by removing final segments of the verbrels.tdl file).</div>
<div class=""><br class="">
</div>
<div class="">John<br class="">
<div class=""></div>
<br class="">
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 22 Aug 2017, at 23:26, John Carroll &lt;<a href="mailto:J.A.Carroll@sussex.ac.uk" class="">J.A.Carroll@sussex.ac.uk</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Glenn,
<div class=""><br class="">
</div>
<div class="">I think my scheme is very similar to yours. Each successive bit in my 192-bit “summary” representation encodes whether the next 64 bits of the full representation has any 1s in it. On reaching the end of the 192 bits, it starts again (so bit zero
 of the summary also encodes the 193rd group of 64 bits, etc).</div>
<div class=""><br class="">
</div>
<div class="">I attach the type files. They should be loaded in the following order:</div>
<br class="">
&nbsp;coretypes.tdl<br class="">
&nbsp;extratypes.tdl<br class="">
&nbsp;linktypes.tdl<br class="">
&nbsp;verbrels.tdl<br class="">
&nbsp;reltypes.tdl<br class="">
<div class=""><br class="">
</div>
<div class="">John</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 22 Aug 2017, at 22:57, Glenn Slayden &lt;<a href="mailto:glenn@thai-language.com" class="">glenn@thai-language.com</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; font-family: Courier; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Hello All,<o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I apologize for not communicating this earlier, but since 2009 Agree has used a similar approach of carrying and maintaining supplemental bits, which I call “summary” bits, along with each of the large bit vectors for use during the GLB computation. Instead
 of a fixed 192 bits, Agree uses one “summary” bit per 64-bit ‘qword’ of main bits, where summary bits are all stored together (allocated in chunks of 64). Each individual summary bit indicates whether it’s corresponding full qword has any 1s in it and is correctly
 maintained across all logical operations.<span class="Apple-converted-space">&nbsp;</span><o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
In the best case of an extreme sparse vector, finding that one summary qword is zero avoids evaluating 4096 bits. More realistically, however, it’s possible to walk the summary bits in O(number-of-set-bits), and this provides direct access to (only) those 64-bit
 qwords that are interesting.<o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I would welcome the chance to test Petter’s grammar in Agree.<o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Best regards,<o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Glenn<o:p class=""></o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div class="">
<div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0in 0in;" class="">
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<b class="">From:</b><span class="Apple-converted-space">&nbsp;</span><a href="mailto:developers-bounces@emmtee.net" class="">developers-bounces@emmtee.net</a> [<a href="mailto:developers-bounces@emmtee.net" class="">mailto:developers-bounces@emmtee.net</a>]<span class="Apple-converted-space">&nbsp;</span><b class="">On
 Behalf Of<span class="Apple-converted-space">&nbsp;</span></b>John Carroll<br class="">
<b class="">Sent:</b><span class="Apple-converted-space">&nbsp;</span>Friday, August 18, 2017 3:26 PM<br class="">
<b class="">To:</b><span class="Apple-converted-space">&nbsp;</span><a href="mailto:developers@delph-in.net" class="">developers@delph-in.net</a><br class="">
<b class="">Subject:</b><span class="Apple-converted-space">&nbsp;</span>Re: [developers] speeding up grammar loading in the LKB<o:p class=""></o:p></div>
</div>
</div>
<div style="margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class="">&nbsp;</o:p></div>
<div class="">
<div class="">
<p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size: 10pt;" class="">Hi,<br class="">
<br class="">
[This is a more detailed follow-up to emails that Petter, Stephan, Woodley and I have been exchanging over the past couple of days]<br class="">
<br class="">
At the very pleasant DELPH-IN Summit last week in Oslo, Petter mentioned to me that the full version of his Norwegian grammar takes hours to load into the LKB. He gave me some of his grammar files, and it turns out that the time is going in computing glb types
 for a partition of the type hierarchy that contains almost all the types. In this example grammar, there is a partition of almost 40000 types which cannot be split into smaller disjoint sets of non-interacting types. The LKB was having to consider 40000^2/2
 (= 800 million) type/type combinations, each combination taking time linear in the number of types. Although this is an efficiently coded part of the LKB, the computation still took around 30 minutes.<br class="">
<br class="">
One fortunate property of the glb type computation algorithm is that very few of the type/type combinations are “interesting” in that they actually lead to creation of a glb. So I came up with a scheme to quickly filter out pairs that could not possibly produce
 glbs (always erring on the permissive side in order not to make the algorithm incorrect).<br class="">
<br class="">
In this scheme, the bit code representing each type (40000 bits long for this example grammar) is augmented with a relatively short “type filter” code (192 bits empirically gives good results). The two main operations in computing glb types are ANDing pairs
 of these bit codes and testing whether the result is all zeros, and determining whether one bit code subsumes another (for every zero bit in code 1, the corresponding bit in code 2 must also be zero). By making each bit of a filter code to be the logical OR
 of a specific set of bits in the corresponding type bit code, the AND and subsume tests can also be applied to these codes as a quick pre-filter.<br class="">
<br class="">
This approach reduces the load time for Petter's example grammar from 30 minutes to 4.5 minutes. It also seems to make the computation scale a bit more happily with increasing numbers of types. I attach a graph showing a comparison for this grammar and cut-down
 versions.<br class="">
<br class="">
So that grammar writers can benefit soon, Stephan will shortly re-build the LOGON image to include this new algorithm.<br class="">
<br class="">
John</span></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>