Simdhwyhash
Implementation of HighwayHash that uses Google Highway SIMD library
Install / Use
/learn @johnplatts/SimdhwyhashREADME
simdhwyhash
simdhwyhash is an implementation of HighwayHash that uses the Google Highway SIMD library.
Building simdhwyhash library
simdhwyhash requires a C++17 compiler capable of compiling Google Highway (such as GCC 7 or later or Clang 6 or later) and cmake to build.
simdhwyhash also requires that git is installed to download the Google Highway dependency if SIMDHWYHASH_SYSTEM_HIGHWAY is set to OFF.
To build simdhwyhash as a shared or static library (depending on BUILD_SHARED_LIBS), the standard CMake workflow can be used:
mkdir -p build && cd build
cmake ..
make -j && make test
simdhwyhash API
simdhwyhash exposes a C API to allow simdhwyhash to be used from languages other than C++.
-
void SimdHwyHash_Reset(SimdHwyHashState* state, const uint64_t* key)- initializesstateusingkey(which is an array of 4 uint64_t values) -
void SimdHwyHash_Update(SimdHwyHashState* state, const void* ptr, size_t byte_len)- updatesstatewithbyte_lenbytes fromptrstatemust be initialized usingSimdHwyHash_Resetprior to the first call toSimdHwyHash_Update.If
stateis going to be updated with additional data,byte_lenshould be a multiple of 32. Otherwise, if this is the finalSimdHwyHash_Updatestep,byte_lenshould be equal to the length of the remaining data. -
uint64_t SimdHwyHash_Finalize64(SimdHwyHashState* state)- returns the 64-bit hash of the datastatemust be initialized usingSimdHwyHash_Reset, followed by zero or more calls toSimdHwyHash_Update, prior to callingSimdHwyHash_Finalize64. -
void SimdHwyHash_Finalize128(SimdHwyHashState* state, uint64_t* hash)- returns the 128-bit hash of the data inhash[0]andhash[1]statemust be initialized usingSimdHwyHash_Reset, followed by zero or more calls toSimdHwyHash_Update, prior to callingSimdHwyHash_Finalize128. -
void SimdHwyHash_Finalize256(SimdHwyHashState* state, uint64_t* hash)- returns the 256-bit hash of the data inhash[0],hash[1],hash[2], andhash[3]statemust be initialized usingSimdHwyHash_Reset, followed by zero or more calls toSimdHwyHash_Update, prior to callingSimdHwyHash_Finalize256. -
uint64_t SimdHwyHash_Hash64(const void* ptr, size_t byte_len, const uint64_t* key)- returns the 64-bit hash ofbyte_lenbytes of data pointed to byptr, hashed usingkey(which is an array of 4 uint64_t values)SimdHwyHash_Hash64(ptr, byte_len, key)is equivalent to the following:SimdHwyHashState state; SimdHwyHash_Reset(&state, key); SimdHwyHash_Update(&state, ptr, byte_len); const uint64_t hash64 = SimdHwyHash_Finalize64(&state); -
void SimdHwyHash_Hash128(const void* ptr, size_t byte_len, const uint64_t* key, uint64_t* hash)- returns the 128-bit hash ofbyte_lenbytes of data pointed to byptrinhash[0]andhash[1], hashed usingkey(which is an array of 4 uint64_t values)SimdHwyHash_Hash128(ptr, byte_len, key, hash)is equivalent to the following:SimdHwyHashState state; SimdHwyHash_Reset(&state, key); SimdHwyHash_Update(&state, ptr, byte_len); SimdHwyHash_Finalize128(&state, hash); -
void SimdHwyHash_Hash256(const void* ptr, size_t byte_len, const uint64_t* key, uint64_t* hash)- returns the 256-bit hash ofbyte_lenbytes of data pointed to byptrinhash[0],hash[1],hash[2], andhash[3], hashed usingkey(which is an array of 4 uint64_t values)SimdHwyHash_Hash256(ptr, byte_len, key, hash)is equivalent to the following:SimdHwyHashState state; SimdHwyHash_Reset(&state, key); SimdHwyHash_Update(&state, ptr, byte_len); SimdHwyHash_Finalize256(&state, hash);
simdhwyhash CMake configuration options
-
BUILD_SHARED_LIBS (defaults to ON) - set to OFF to build simdhwyhash as a static library. simdhwyhash is configured to be built as a shared library if BUILD_SHARED_LIBS is ON and SIMDHWYHASH_FORCE_STATIC_LIBS is OFF.
-
HWY_CMAKE_ARM7 (defaults to OFF) - set to enable Armv7 Highway compilation flags
-
HWY_CMAKE_SSE2 (defaults to OFF) - set to enable SSE2 as the baseline on 32-bit x86
-
HWY_CMAKE_RVV (defaults to ON) - set to enable the RISC-V "V" extension if compiling on RISC-V
-
SIMDHWYHASH_ENABLE_INSTALL (defaults to ON) - set to OFF to disable the installation of the simdhwyhash library
-
SIMDHWYHASH_ENABLE_TESTS (defaults to ON) - set to OFF to disable the simdhwyhash unit tests
-
SIMDHWYHASH_FORCE_STATIC_LIBS (defaults to OFF) - set to ON to build simdhwyhash as a static library, regardless of whether BUILD_SHARED_LIBS is set to ON or OFF.
-
SIMDHWYHASH_HWY_CXX_FLAGS - Additional C++ compiler flags used to compile the simdhwyhash library and Google Highway (if the system included Google Highway library is not used)
-
SIMDHWYHASH_SYSTEM_HIGHWAY (defaults to OFF) - set to ON to use the system included Google Highway library
-
SIMDHWYHASH_SYSTEM_GTEST (defaults to OFF) - set to ON to use the system included Google Test library
-
SIMDHWYHASH_WARNINGS_ARE_ERRORS (defaults to OFF) - set to ON to treat compiler warnings as errors
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
