Skip to content

Commit

Permalink
NMHASH32: WIP-N+1
Browse files Browse the repository at this point in the history
  • Loading branch information
darkk committed Sep 26, 2024
1 parent 93e5768 commit 8b486e7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Hashes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,25 +1286,30 @@ const char * const nmhash32_ver("nmhash32, " NMHASH32_DESC_STR);
const char * const nmhash32x_ver("nmhash32x, " NMHASH32_DESC_STR);
constexpr unsigned sizeof_NMH_ACC_INIT = sizeof(NMH_ACC_INIT);
constexpr unsigned countof_NMH_ACC_INIT = sizeof(NMH_ACC_INIT)/sizeof(*NMH_ACC_INIT);

static const char rand_str[] = "rwgk8M1uxM6XX6c3teQX2yaw8FQWArmcWUSBJ8dcQQJWHYC9Wt2BmpvETxwhYcJTheTbjf49SVRaDJhbEZCq7ki1D6KxpKQSjgwqsiHGSgHLxvPG5kcRnBhjJ1YC8kuhbaJCWn9G6jm58Lr5wkVWNy38KcNjXVM3vExhQK516zntjrHTxSJYNQ1yvGucKZD8M34iBXT86B7y5xK3tu9pLGqgomKEbzvBJmod66BY3tDwRwttjfgB75xGAHMpLELXpArPJHWQxjHPQQgAcL9j4GDLyEmRSS2Fkv1sLwZoBMUmaD84cmKjocK4phgVEr13a65LsjKBw9Pg4VN4hkd149izWLjcA5";

// objsize: 4202f0-420c7d: 2445
void nmhash32_test ( const void * key, int len, uint32_t seed, void * out ) {
static bool once = false;
if (!once) {
NMH_ALIGN(NMH_ACC_ALIGN) uint32_t accX[sizeof(NMH_ACC_INIT)/sizeof(*NMH_ACC_INIT)];
NMH_ALIGN(NMH_ACC_ALIGN) uint32_t accY[sizeof(accX)/sizeof(*accX)];
printf("sizeof_NMH_ACC_INIT: %u\ncountof_NMH_ACC_INIT: %u\nsizeof(accX): %u\nsizeof(accY): %u\n", sizeof_NMH_ACC_INIT, countof_NMH_ACC_INIT, sizeof(accX), sizeof(accY));
const uint32_t x = NMHASH32_long(NMH_ACC_INIT, sizeof(NMH_ACC_INIT), 42);
printf("NMHASH32_long(NMH_ACC_INIT, %u, 42) = %x\n", sizeof(NMH_ACC_INIT), x);
const unsigned count = 256;
static_assert(sizeof(rand_str) >= count);
const uint32_t x = NMHASH32_long(reinterpret_cast<const uint8_t*>(rand_str), count, 42);
printf("NMHASH32_long(rand_str, %u, 42) = %x\n", count, x);
once = true;
}
const uint32_t v = NMHASH32 (key, (const size_t) len, seed);
printf("NMHASH32(%p, %d, %u) = %u\n", key, len, seed, v);
// printf("NMHASH32(%p, %d, %u) = %u\n", key, len, seed, v);
*(uint32_t*)out = v;
}
// objsize: 466100-4666d6: 1494
void nmhash32x_test ( const void * key, int len, uint32_t seed, void * out ) {
const uint32_t v = NMHASH32X (key, (const size_t) len, seed);
printf("NMHASH32X(%p, %d, %u) = %u\n", key, len, seed, v);
// printf("NMHASH32X(%p, %d, %u) = %u\n", key, len, seed, v);
*(uint32_t*)out = v;
}

Expand Down

0 comments on commit 8b486e7

Please sign in to comment.