HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hash.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenImageIO project.
2 // SPDX-License-Identifier: Apache-2.0
3 // https://github.com/AcademySoftwareFoundation/OpenImageIO
4 
5 // clang-format off
6 
7 /// \file
8 ///
9 /// Wrapper so that hash_map and hash_set mean what we want regardless
10 /// of the compiler.
11 ///
12 
13 #pragma once
14 
15 #include <cassert>
16 #include <cstdint>
17 #include <cstdlib>
18 #include <cstring>
19 #include <unordered_map>
20 #include <utility>
21 #include <vector>
22 
23 #include <OpenImageIO/export.h>
26 
27 // We should never have included fmath.h here. But we did, oops. Once we're
28 // allowed to break back compatibility, remove it.
29 #if OIIO_VERSION < OIIO_MAKE_VERSION(3,0,0)
30 # include <OpenImageIO/fmath.h>
31 #endif
32 
33 #include <OpenImageIO/span.h>
34 
35 
37 
38 using std::hash;
39 using std::unordered_map;
40 
41 namespace fasthash {
42 
43 /* The MIT License
44  Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com)
45  Permission is hereby granted, free of charge, to any person
46  obtaining a copy of this software and associated documentation
47  files (the "Software"), to deal in the Software without
48  restriction, including without limitation the rights to use, copy,
49  modify, merge, publish, distribute, sublicense, and/or sell copies
50  of the Software, and to permit persons to whom the Software is
51  furnished to do so, subject to the following conditions:
52  The above copyright notice and this permission notice shall be
53  included in all copies or substantial portions of the Software.
54  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
55  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
56  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
57  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
58  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
59  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
60  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61  SOFTWARE.
62 */
63 
64 // Compression function for Merkle-Damgard construction.
65 // This function is generated using the framework provided.
66 static inline uint64_t mix(uint64_t h) {
67  h ^= h >> 23;
68  h *= 0x2127599bf4325c37ULL;
69  h ^= h >> 47;
70  return h;
71 }
72 
73 inline uint64_t fasthash64(const void *buf, size_t len, uint64_t seed=1771)
74 {
75  const uint64_t m = 0x880355f21e6d1965ULL;
76  const uint64_t *pos = (const uint64_t *)buf;
77  const uint64_t *end = pos + (len / 8);
78  const unsigned char *pos2;
79  uint64_t h = seed ^ (len * m);
80  uint64_t v;
81 
82  while (pos != end) {
83  // This appears to be a false positive which only affects GCC.
84  // https://godbolt.org/z/5q7Y7ndfb
86  OIIO_GCC_ONLY_PRAGMA(GCC diagnostic ignored "-Wmaybe-uninitialized")
87  v = *pos++;
89  h ^= mix(v);
90  h *= m;
91  }
92 
93  pos2 = (const unsigned char*)pos;
94  v = 0;
95 
96  switch (len & 7) {
97  case 7: v ^= (uint64_t)pos2[6] << 48;
98  case 6: v ^= (uint64_t)pos2[5] << 40;
99  case 5: v ^= (uint64_t)pos2[4] << 32;
100  case 4: v ^= (uint64_t)pos2[3] << 24;
101  case 3: v ^= (uint64_t)pos2[2] << 16;
102  case 2: v ^= (uint64_t)pos2[1] << 8;
103  case 1: v ^= (uint64_t)pos2[0];
104  h ^= mix(v);
105  h *= m;
106  }
107 
108  return mix(h);
109 }
110 
111 // simplified version for hashing just a few ints
112 inline uint64_t fasthash64(const std::initializer_list<uint64_t> buf) {
113  const uint64_t m = 0x880355f21e6d1965ULL;
114  uint64_t h = (buf.size() * sizeof(uint64_t)) * m;
115  for (const uint64_t v : buf) {
116  h ^= mix(v);
117  h *= m;
118  }
119  return mix(h);
120 }
121 
122 } // namespace fasthash
123 
124 
125 namespace xxhash {
126 
127 // xxhash: https://github.com/Cyan4973/xxHash
128 // BSD 2-clause license
129 
130 unsigned int OIIO_API XXH32 (const void* input, size_t length,
131  unsigned seed=1771);
132 unsigned long long OIIO_API XXH64 (const void* input, size_t length,
133  unsigned long long seed=1771);
134 
135 inline size_t xxhash (const void* input, size_t length, size_t seed=1771)
136 {
137  return size_t (XXH64 (input, length, (unsigned long long)seed));
138 }
139 
140 template <typename Str>
141 inline size_t xxhash (const Str& s, size_t seed=1771) {
142  assert(sizeof(s[0]) == 1);
143  return xxhash (s.data(), s.length(), seed);
144 }
145 
146 } // end namespace xxhash
147 
148 
149 
150 
151 namespace bjhash {
152 
153 // Bob Jenkins "lookup3" hashes: http://burtleburtle.net/bob/c/lookup3.c
154 // It's in the public domain.
155 
157 rotl32(uint32_t x, int k)
158 {
159 #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 320
160  return __funnelshift_lc(x, x, k);
161 #else
162  return (x << k) | (x >> (32 - k));
163 #endif
164 }
165 
167 rotl64(uint64_t x, int k)
168 {
169  return (x << k) | (x >> (64 - k));
170 }
171 
172 // Mix up the bits of a, b, and c (changing their values in place).
173 inline OIIO_HOSTDEVICE void bjmix (uint32_t &a, uint32_t &b, uint32_t &c)
174 {
175  a -= c; a ^= rotl32(c, 4); c += b;
176  b -= a; b ^= rotl32(a, 6); a += c;
177  c -= b; c ^= rotl32(b, 8); b += a;
178  a -= c; a ^= rotl32(c,16); c += b;
179  b -= a; b ^= rotl32(a,19); a += c;
180  c -= b; c ^= rotl32(b, 4); b += a;
181 }
182 
183 // Mix up and combine the bits of a, b, and c (doesn't change them, but
184 // returns a hash of those three original values). 21 ops
185 inline OIIO_HOSTDEVICE uint32_t bjfinal (uint32_t a, uint32_t b, uint32_t c=0xdeadbeef)
186 {
187  c ^= b; c -= rotl32(b,14);
188  a ^= c; a -= rotl32(c,11);
189  b ^= a; b -= rotl32(a,25);
190  c ^= b; c -= rotl32(b,16);
191  a ^= c; a -= rotl32(c,4);
192  b ^= a; b -= rotl32(a,14);
193  c ^= b; c -= rotl32(b,24);
194  return c;
195 }
196 
197 // Mix up 4 64-bit inputs (non-destructively), and return a 64 bit hash.
198 // Adapted from http://burtleburtle.net/bob/c/SpookyV2.h 33 ops
199 inline uint64_t bjfinal64 (uint64_t h0, uint64_t h1, uint64_t h2, uint64_t h3)
200 {
201  h3 ^= h2; h2 = rotl64(h2,15); h3 += h2;
202  h0 ^= h3; h3 = rotl64(h3,52); h0 += h3;
203  h1 ^= h0; h0 = rotl64(h0,26); h1 += h0;
204  h2 ^= h1; h1 = rotl64(h1,51); h2 += h1;
205  h3 ^= h2; h2 = rotl64(h2,28); h3 += h2;
206  h0 ^= h3; h3 = rotl64(h3,9); h0 += h3;
207  h1 ^= h0; h0 = rotl64(h0,47); h1 += h0;
208  h2 ^= h1; h1 = rotl64(h1,54); h2 += h1;
209  h3 ^= h2; h2 = rotl64(h2,32); h3 += h2;
210  h0 ^= h3; h3 = rotl64(h3,25); h0 += h3;
211  h1 ^= h0; h0 = rotl64(h0,63); h1 += h0;
212  return h1;
213 }
214 
215 // Standard "lookup3" hash, arbitrary length in bytes.
216 uint32_t OIIO_API hashlittle (const void *key, size_t length,
217  uint32_t seed=1771);
218 
219 // Hash an array of 32 bit words -- faster than hashlittle if you know
220 // it's a whole number of 4-byte words.
221 uint32_t OIIO_API hashword (const uint32_t *key, size_t nwords,
222  uint32_t seed=1771);
223 
224 // Hash a string without pre-known length. We use the Jenkins
225 // one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function),
226 // which seems to be a good speed/quality/requirements compromise.
227 // Note that this is only returning a 32 bit hash space.
228 inline size_t
229 strhash (const char *s)
230 {
231  if (! s) return 0;
232  unsigned int h = 0;
233  while (*s) {
234  h += (unsigned char)(*s);
235  h += h << 10;
236  h ^= h >> 6;
237  ++s;
238  }
239  h += h << 3;
240  h ^= h >> 11;
241  h += h << 15;
242  return h;
243 }
244 
245 
246 // Hash a string_view. We use the Jenkins
247 // one-at-a-time hash (http://en.wikipedia.org/wiki/Jenkins_hash_function),
248 // which seems to be a good speed/quality/requirements compromise.
249 // Note that this is only returning a 32 bit hash space.
250 inline size_t
252 {
253  size_t len = s.length();
254  if (! len) return 0;
255  unsigned int h = 0;
256  for (size_t i = 0; i < len; ++i) {
257  h += (unsigned char)(s[i]);
258  h += h << 10;
259  h ^= h >> 6;
260  }
261  h += h << 3;
262  h ^= h >> 11;
263  h += h << 15;
264  return h;
265 }
266 
267 } // end namespace bjhash
268 
269 
270 namespace murmur {
271 
272 // These functions were lifted from the public domain Murmurhash3. We
273 // don't bother using Murmurhash -- in my tests, it was slower than
274 // xxhash in all cases, and comparable to bjhash. But these two fmix
275 // functions are useful for scrambling the bits of a single 32 or 64 bit
276 // value.
277 
278 inline uint32_t fmix (uint32_t h)
279 {
280  h ^= h >> 16;
281  h *= 0x85ebca6b;
282  h ^= h >> 13;
283  h *= 0xc2b2ae35;
284  h ^= h >> 16;
285  return h;
286 }
287 
288 inline uint64_t fmix (uint64_t k)
289 {
290  k ^= k >> 33;
291  k *= 0xff51afd7ed558ccdULL;
292  k ^= k >> 33;
293  k *= 0xc4ceb9fe1a85ec53ULL;
294  k ^= k >> 33;
295  return k;
296 }
297 
298 } // end namespace murmur
299 
300 
301 
302 namespace farmhash {
303 
304 // Copyright (c) 2014 Google, Inc.
305 // https://github.com/google/farmhash
306 // See OpenImageIO's hashes.cpp for the MIT license for this code.
307 
308 
309 #if defined(FARMHASH_UINT128_T_DEFINED)
310 
311 OIIO_HOSTDEVICE inline constexpr uint64_t Uint128Low64(const uint128_t x) {
312  return static_cast<uint64_t>(x);
313 }
314 
315 OIIO_HOSTDEVICE inline constexpr uint64_t Uint128High64(const uint128_t x) {
316  return static_cast<uint64_t>(x >> 64);
317 }
318 
319 OIIO_HOSTDEVICE inline constexpr uint128_t Uint128(uint64_t lo, uint64_t hi) {
320  return lo + (((uint128_t)hi) << 64);
321 }
322 
325  dst = src;
326 }
327 
328 #else
329 
330 typedef std::pair<uint64_t, uint64_t> uint128_t;
331 OIIO_HOSTDEVICE inline constexpr uint64_t Uint128Low64(const uint128_t x) {
332  return x.first;
333 }
334 
335 OIIO_HOSTDEVICE inline constexpr uint64_t Uint128High64(const uint128_t x) {
336  return x.second;
337 }
338 
339 OIIO_HOSTDEVICE inline OIIO_CONSTEXPR14 uint128_t Uint128(uint64_t lo, uint64_t hi) {
340  return uint128_t(lo, hi);
341 }
342 
345  dst.first = src.first;
346  dst.second = src.second;
347 
348 }
349 #endif
350 
351 
352 // BASIC STRING HASHING
353 
354 // Hash function for a byte array.
355 // May change from time to time, may differ on different platforms, may differ
356 // depending on NDEBUG.
357 size_t OIIO_API Hash(const char* s, size_t len);
358 
359 // Hash function for a byte array. Most useful in 32-bit binaries.
360 // May change from time to time, may differ on different platforms, may differ
361 // depending on NDEBUG.
362 uint32_t OIIO_API Hash32(const char* s, size_t len);
363 
364 // Hash function for a byte array. For convenience, a 32-bit seed is also
365 // hashed into the result.
366 // May change from time to time, may differ on different platforms, may differ
367 // depending on NDEBUG.
368 uint32_t OIIO_API Hash32WithSeed(const char* s, size_t len, uint32_t seed);
369 
370 // Hash 128 input bits down to 64 bits of output.
371 // Hash function for a byte array.
372 // May change from time to time, may differ on different platforms, may differ
373 // depending on NDEBUG.
374 uint64_t OIIO_API Hash64(const char* s, size_t len);
375 
376 // Hash function for a byte array. For convenience, a 64-bit seed is also
377 // hashed into the result.
378 // May change from time to time, may differ on different platforms, may differ
379 // depending on NDEBUG.
380 uint64_t OIIO_API Hash64WithSeed(const char* s, size_t len, uint64_t seed);
381 
382 // Hash function for a byte array. For convenience, two seeds are also
383 // hashed into the result.
384 // May change from time to time, may differ on different platforms, may differ
385 // depending on NDEBUG.
386 uint64_t OIIO_API Hash64WithSeeds(const char* s, size_t len,
387  uint64_t seed0, uint64_t seed1);
388 
389 // Hash function for a byte array.
390 // May change from time to time, may differ on different platforms, may differ
391 // depending on NDEBUG.
392 uint128_t OIIO_API Hash128(const char* s, size_t len);
393 
394 // Hash function for a byte array. For convenience, a 128-bit seed is also
395 // hashed into the result.
396 // May change from time to time, may differ on different platforms, may differ
397 // depending on NDEBUG.
398 uint128_t OIIO_API Hash128WithSeed(const char* s, size_t len, uint128_t seed);
399 
400 // BASIC NON-STRING HASHING
401 
402 // This is intended to be a reasonably good hash function.
403 // May change from time to time, may differ on different platforms, may differ
404 // depending on NDEBUG.
406  // Murmur-inspired hashing.
407  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
408  uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
409  a ^= (a >> 47);
410  uint64_t b = (Uint128High64(x) ^ a) * kMul;
411  b ^= (b >> 47);
412  b *= kMul;
413  return b;
414 }
415 
416 // FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
417 
418 // Fingerprint function for a byte array. Most useful in 32-bit binaries.
419 uint32_t OIIO_API Fingerprint32(const char* s, size_t len);
420 
421 // Fingerprint function for a byte array.
422 uint64_t OIIO_API Fingerprint64(const char* s, size_t len);
423 
424 // Fingerprint function for a byte array.
425 uint128_t OIIO_API Fingerprint128(const char* s, size_t len);
426 
427 // This is intended to be a good fingerprinting primitive.
428 // See below for more overloads.
430  // Murmur-inspired hashing.
431  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
432  uint64_t a = (Uint128Low64(x) ^ Uint128High64(x)) * kMul;
433  a ^= (a >> 47);
434  uint64_t b = (Uint128High64(x) ^ a) * kMul;
435  b ^= (b >> 44);
436  b *= kMul;
437  b ^= (b >> 41);
438  b *= kMul;
439  return b;
440 }
441 
442 // This is intended to be a good fingerprinting primitive.
443 OIIO_HOSTDEVICE inline OIIO_CONSTEXPR14 uint64_t Fingerprint(uint64_t x) {
444  // Murmur-inspired hashing.
445  const uint64_t kMul = 0x9ddfea08eb382d69ULL;
446  uint64_t b = x * kMul;
447  b ^= (b >> 44);
448  b *= kMul;
449  b ^= (b >> 41);
450  b *= kMul;
451  return b;
452 }
453 
454 #ifndef FARMHASH_NO_CXX_STRING
455 
456 // Convenience functions to hash or fingerprint C++ strings.
457 // These require that Str::data() return a pointer to the first char
458 // (as a const char*) and that Str::length() return the string's length;
459 // they work with std::string, for example.
460 
461 // Hash function for a byte array.
462 // May change from time to time, may differ on different platforms, may differ
463 // depending on NDEBUG.
464 template <typename Str>
465 inline size_t Hash(const Str& s) {
466  assert(sizeof(s[0]) == 1);
467  return Hash(s.data(), s.length());
468 }
469 
470 // Hash function for a byte array. Most useful in 32-bit binaries.
471 // May change from time to time, may differ on different platforms, may differ
472 // depending on NDEBUG.
473 template <typename Str>
474 inline uint32_t Hash32(const Str& s) {
475  assert(sizeof(s[0]) == 1);
476  return Hash32(s.data(), s.length());
477 }
478 
479 // Hash function for a byte array. For convenience, a 32-bit seed is also
480 // hashed into the result.
481 // May change from time to time, may differ on different platforms, may differ
482 // depending on NDEBUG.
483 template <typename Str>
484 inline uint32_t Hash32WithSeed(const Str& s, uint32_t seed) {
485  assert(sizeof(s[0]) == 1);
486  return Hash32WithSeed(s.data(), s.length(), seed);
487 }
488 
489 // Hash 128 input bits down to 64 bits of output.
490 // Hash function for a byte array.
491 // May change from time to time, may differ on different platforms, may differ
492 // depending on NDEBUG.
493 template <typename Str>
494 inline uint64_t Hash64(const Str& s) {
495  assert(sizeof(s[0]) == 1);
496  return Hash64(s.data(), s.length());
497 }
498 
499 // Hash function for a byte array. For convenience, a 64-bit seed is also
500 // hashed into the result.
501 // May change from time to time, may differ on different platforms, may differ
502 // depending on NDEBUG.
503 template <typename Str>
504 inline uint64_t Hash64WithSeed(const Str& s, uint64_t seed) {
505  assert(sizeof(s[0]) == 1);
506  return Hash64WithSeed(s.data(), s.length(), seed);
507 }
508 
509 // Hash function for a byte array. For convenience, two seeds are also
510 // hashed into the result.
511 // May change from time to time, may differ on different platforms, may differ
512 // depending on NDEBUG.
513 template <typename Str>
514 inline uint64_t Hash64WithSeeds(const Str& s, uint64_t seed0, uint64_t seed1) {
515  assert(sizeof(s[0]) == 1);
516  return Hash64WithSeeds(s.data(), s.length(), seed0, seed1);
517 }
518 
519 // Hash function for a byte array.
520 // May change from time to time, may differ on different platforms, may differ
521 // depending on NDEBUG.
522 template <typename Str>
523 inline uint128_t Hash128(const Str& s) {
524  assert(sizeof(s[0]) == 1);
525  return Hash128(s.data(), s.length());
526 }
527 
528 // Hash function for a byte array. For convenience, a 128-bit seed is also
529 // hashed into the result.
530 // May change from time to time, may differ on different platforms, may differ
531 // depending on NDEBUG.
532 template <typename Str>
533 inline uint128_t Hash128WithSeed(const Str& s, uint128_t seed) {
534  assert(sizeof(s[0]) == 1);
535  return Hash128(s.data(), s.length(), seed);
536 }
537 
538 // FINGERPRINTING (i.e., good, portable, forever-fixed hash functions)
539 
540 // Fingerprint function for a byte array. Most useful in 32-bit binaries.
541 template <typename Str>
542 inline uint32_t Fingerprint32(const Str& s) {
543  assert(sizeof(s[0]) == 1);
544  return Fingerprint32(s.data(), s.length());
545 }
546 
547 // Fingerprint 128 input bits down to 64 bits of output.
548 // Fingerprint function for a byte array.
549 template <typename Str>
550 inline uint64_t Fingerprint64(const Str& s) {
551  assert(sizeof(s[0]) == 1);
552  return Fingerprint64(s.data(), s.length());
553 }
554 
555 // Fingerprint function for a byte array.
556 template <typename Str>
557 inline uint128_t Fingerprint128(const Str& s) {
558  assert(sizeof(s[0]) == 1);
559  return Fingerprint128(s.data(), s.length());
560 }
561 
562 #endif
563 
564 } // namespace farmhash
565 
566 
567 
568 
569 class CSHA1; // opaque forward declaration
570 
571 
572 /// Class that encapsulates SHA-1 hashing, a crypticographic-strength
573 /// 160-bit hash function. It's not as fast as our other hashing
574 /// methods, but has an extremely low chance of having collisions.
575 class OIIO_API SHA1 {
576 public:
577  /// Create SHA1, optionally read data
578  SHA1 (const void *data=NULL, size_t size=0);
579  ~SHA1 ();
580 
581  /// Append more data
582  void append (const void *data, size_t size);
583 
584  /// Append more data from a string_view
586  append(s.data(), s.size());
587  }
588 
589  /// Append more data from a span, without thinking about sizes.
590  template<class T> void append (span<T> v) {
591  append (v.data(), v.size()*sizeof(T));
592  }
593 
594  /// Type for storing the raw bits of the hash
595  struct Hash {
596  unsigned char hash[20];
597  };
598 
599  /// Get the digest and store it in Hash h.
600  void gethash (Hash &h);
601 
602  /// Get the digest and store it in h (must point to enough storage
603  /// to accommodate 20 bytes).
604  void gethash (void *h) { gethash (*(Hash *)h); }
605 
606  /// Return the digest as a hex string
607  std::string digest ();
608 
609  /// Roll the whole thing into one functor, return the string digest.
610  static std::string digest (const void *data, size_t size) {
611  SHA1 s (data, size); return s.digest();
612  }
613 
614 private:
615  CSHA1 *m_csha1;
616  bool m_final;
617 };
618 
619 
#define OIIO_CONSTEXPR14
Definition: platform.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
#define OIIO_FORCEINLINE
Definition: platform.h:403
OIIO_HOSTDEVICE constexpr uint64_t Uint128Low64(const uint128_t x)
Definition: hash.h:331
const GLdouble * v
Definition: glcorearb.h:837
void gethash(void *h)
Definition: hash.h:604
uint128_t OIIO_API Hash128WithSeed(const char *s, size_t len, uint128_t seed)
Definition: farmhash.h:2130
OIIO_HOSTDEVICE uint32_t bjfinal(uint32_t a, uint32_t b, uint32_t c=0xdeadbeef)
Definition: hash.h:185
size_t xxhash(const Str &s, size_t seed=1771)
Definition: hash.h:141
size_t strhash(const char *s)
Definition: hash.h:229
Definition: span.h:74
uint32_t OIIO_API hashlittle(const void *key, size_t length, uint32_t seed=1771)
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
Type for storing the raw bits of the hash.
Definition: hash.h:595
void append(string_view s)
Append more data from a string_view.
Definition: hash.h:585
unsigned long long OIIO_API XXH64(const void *input, size_t length, unsigned long long seed=1771)
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 uint64_t Hash128to64(uint128_t x)
Definition: hash.h:405
uint64_t OIIO_API Hash64WithSeeds(const char *s, size_t len, uint64_t seed0, uint64_t seed1)
Definition: farmhash.h:746
#define OIIO_PRAGMA_WARNING_PUSH
Definition: platform.h:297
size_t OIIO_API Hash(const char *s, size_t len)
Definition: farmhash.h:2099
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 uint128_t Uint128(uint64_t lo, uint64_t hi)
Definition: hash.h:339
size_t xxhash(const void *input, size_t length, size_t seed=1771)
Definition: hash.h:135
unsigned int OIIO_API XXH32(const void *input, size_t length, unsigned seed=1771)
#define OIIO_PRAGMA_WARNING_POP
Definition: platform.h:298
std::string digest()
Return the digest as a hex string.
GLuint GLuint end
Definition: glcorearb.h:475
uint64_t bjfinal64(uint64_t h0, uint64_t h1, uint64_t h2, uint64_t h3)
Definition: hash.h:199
#define OIIO_GCC_ONLY_PRAGMA(UnQuotedPragma)
Definition: platform.h:302
Definition: hash.h:575
#define OIIO_HOSTDEVICE
Definition: platform.h:529
OIIO_HOSTDEVICE constexpr uint64_t Uint128High64(const uint128_t x)
Definition: hash.h:335
constexpr size_type size() const noexcept
Definition: span.h:186
OIIO_FORCEINLINE OIIO_HOSTDEVICE uint64_t rotl64(uint64_t x, int k)
Definition: hash.h:167
OIIO_HOSTDEVICE void bjmix(uint32_t &a, uint32_t &b, uint32_t &c)
Definition: hash.h:173
uint64_t OIIO_API Hash64(const char *s, size_t len)
Definition: farmhash.h:691
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
uint32_t OIIO_API Fingerprint32(const char *s, size_t len)
Definition: farmhash.h:2139
uint128_t OIIO_API Hash128(const char *s, size_t len)
Definition: farmhash.h:2122
uint32_t fmix(uint32_t h)
Definition: hash.h:278
uint64_t fasthash64(const void *buf, size_t len, uint64_t seed=1771)
Definition: hash.h:73
uint64_t OIIO_API Fingerprint64(const char *s, size_t len)
Definition: farmhash.h:2144
constexpr auto size() const noexcept-> size_t
Definition: core.h:443
void append(span< T > v)
Append more data from a span, without thinking about sizes.
Definition: hash.h:590
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
GLenum GLenum dst
Definition: glcorearb.h:1793
uint64_t OIIO_API Hash64WithSeed(const char *s, size_t len, uint64_t seed)
Definition: farmhash.h:750
static std::string digest(const void *data, size_t size)
Roll the whole thing into one functor, return the string digest.
Definition: hash.h:610
constexpr auto data() const noexcept-> const Char *
Definition: core.h:440
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 uint64_t Fingerprint(uint128_t x)
Definition: hash.h:429
uint32_t OIIO_API hashword(const uint32_t *key, size_t nwords, uint32_t seed=1771)
#define OIIO_NAMESPACE_END
Definition: oiioversion.h:127
OIIO_HOSTDEVICE OIIO_CONSTEXPR14 void CopyUint128(uint128_t &dst, const uint128_t src)
Definition: hash.h:344
uint32_t OIIO_API Hash32WithSeed(const char *s, size_t len, uint32_t seed)
Definition: farmhash.h:1175
OIIO_FORCEINLINE OIIO_HOSTDEVICE uint32_t rotl32(uint32_t x, int k)
Definition: hash.h:157
constexpr pointer data() const noexcept
Definition: span.h:190
uint32_t OIIO_API Hash32(const char *s, size_t len)
Definition: farmhash.h:1170
std::pair< uint64_t, uint64_t > uint128_t
Definition: hash.h:330
constexpr size_type length() const noexcept
Definition: string_view.h:204
Definition: format.h:1821
#define OIIO_NAMESPACE_BEGIN
Definition: oiioversion.h:126
#define OIIO_API
Definition: export.h:65
GLenum src
Definition: glcorearb.h:1793
uint128_t OIIO_API Fingerprint128(const char *s, size_t len)
Definition: farmhash.h:2050