<p dir="ltr">It is hard finding a statement or direct quote from Thomas<br>
on the licensing of his algorithm.<br>
I tried the 6 shift algorithm Bob suggests this morning before work.<br>
It seems Thomas' algorithm inlines very nicely, giving the boost.<br>
Bob's version probably gives more collisions, as the time spent<br>
in the insert and search functions increase.<br>
Also there is no speedup of the hash compared to FNV-1a.<br>
Disclaimer: It was hacked together and tested over a<br>
bowl of cereal, so I might have messed something up.<br>
I guess we should drop this patch for now.</p>
<div class="gmail_quote">On 30 Mar 2015 01:17, "Jordan Justen" <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2015-03-29 13:28:02, Thomas Helland wrote:<br>
> (Forgot to send to list)<br>
><br>
> That is indeed an issue.<br>
> I found the original article on the wayback machine and it<br>
> doesn't state anything particular wrt license.<br>
> However, it seems to be used in a LOT of projects.<br>
> (javascript, chromium, hiphop-php, kde, +++)<br>
><br>
> I found this webpage that gives some more insight:<br>
> <a href="http://burtleburtle.net/bob/hash/integer.html" target="_blank">http://burtleburtle.net/bob/hash/integer.html</a><br>
> (it seems to be the website of Bob Jenkins)<br>
> It states the following:<br>
><br>
> "The hashes on this page (with the possible exception<br>
> of HashMap.java's) are all public domain.<br>
> So are the ones on Thomas Wang's page.<br>
> Thomas recommends citing the author<br>
> and page when using them."<br>
<br>
Is there a reference to Thomas directly indicating this?<br>
<br>
On that same page, Bob provides some hash functions of his own, and<br>
directly states that they are public domain. He would probably be in a<br>
better position to speak for his code than Thomas's. :) He does<br>
indicate that Thomas's version is faster than all of his.<br>
<br>
-Jordan<br>
<br>
> So it looks like it is public domain.<br>
> I'll add a credit to Thomas, and link<br>
> to Bob Jenkins' webpage .<br>
> Does that sound like an acceptable solution?<br>
><br>
> 2015-03-29 20:51 GMT+02:00 Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>>:<br>
> > On 2015-03-29 11:05:40, Thomas Helland wrote:<br>
> >> Since a pointer is basically just an int we can use integer hashing.<br>
> >> This one is taken from <a href="https://gist.github.com/badboy/6267743" target="_blank">https://gist.github.com/badboy/6267743</a><br>
> ><br>
> > There doesn't seem to be a license associated with this code, nor is<br>
> > it indicated that it is public domain code.<br>
> ><br>
> > -Jordan<br>
> ><br>
> >> A google search seems to suggest this is a common and good algorithm.<br>
> >> Since it operates 32 bits at a time it is really effective.<br>
> >> assert that we are hashing 32bit aligned pointers.<br>
> >><br>
> >> Signed-off-by: Thomas Helland <<a href="mailto:thomashelland90@gmail.com">thomashelland90@gmail.com</a>><br>
> >> ---<br>
> >>  src/util/hash_table.c | 24 ++++++++++++++++++++++--<br>
> >>  1 file changed, 22 insertions(+), 2 deletions(-)<br>
> >><br>
> >> diff --git a/src/util/hash_table.c b/src/util/hash_table.c<br>
> >> index 24184c0..54d04ef 100644<br>
> >> --- a/src/util/hash_table.c<br>
> >> +++ b/src/util/hash_table.c<br>
> >> @@ -393,6 +393,15 @@ _mesa_hash_table_random_entry(struct hash_table *ht,<br>
> >>     return NULL;<br>
> >>  }<br>
> >><br>
> >> +static inline uint32_t<br>
> >> +hash_32bit_int(uint32_t a) {<br>
> >> +   a = (a ^ 61) ^ (a >> 16);<br>
> >> +   a = a + (a << 3);<br>
> >> +   a = a ^ (a >> 4);<br>
> >> +   a = a * 0x27d4eb2d;<br>
> >> +   a = a ^ (a >> 15);<br>
> >> +   return a;<br>
> >> +}<br>
> >><br>
> >>  /**<br>
> >>   * Quick FNV-1a hash implementation based on:<br>
> >> @@ -406,8 +415,19 @@ _mesa_hash_table_random_entry(struct hash_table *ht,<br>
> >>  uint32_t<br>
> >>  _mesa_hash_data(const void *data, size_t size)<br>
> >>  {<br>
> >> -   return _mesa_fnv32_1a_accumulate_block(_mesa_fnv32_1a_offset_bias,<br>
> >> -                                          data, size);<br>
> >> +   uint32_t hash = _mesa_fnv32_1a_offset_bias;<br>
> >> +   const uint32_t *ints = (const uint32_t *) data;<br>
> >> +<br>
> >> +   assert((size % 4) == 0);<br>
> >> +<br>
> >> +   uint32_t i = size / 4;<br>
> >> +<br>
> >> +   while (i-- != 0) {<br>
> >> +      hash ^= hash_32bit_int(*ints);<br>
> >> +      ints++;<br>
> >> +   }<br>
> >> +<br>
> >> +   return hash;<br>
> >>  }<br>
> >><br>
> >>  /** FNV-1a string hash implementation */<br>
> >> --<br>
> >> 2.3.4<br>
> >><br>
> >> _______________________________________________<br>
> >> mesa-dev mailing list<br>
> >> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> >> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>