martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.5k stars 142 forks source link

Detect SSE4.2 at runtime rather than compile time #77

Closed wyattoday closed 4 years ago

wyattoday commented 4 years ago

You recently changed the hashing algorithm to use CRC, and use intriniscs on modern CPUs. We compile our software to support older hardware (which may or may not have SSE4.2). However, the vast majority of our customers have modern hardware (and thus have no problem using SSE4.2).

A technique widely used is to compile newer intrinsics (if the compiler supports it) and detect whether the CPU currently executing the code can use those intrinsics. If not, fall back to "slow" methods.

A common method of "CPU support" for intinisics is something like this: https://github.com/weidai11/cryptopp/blob/master/cpu.cpp#L461

martinus commented 4 years ago

Thanks, I had a look how to best integrate it, but decided that it's not really worth it. I've (again) replaced the hash with something that is hopefully good enough and doesn't need any intrinsics.