Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing std::hash to ensure portability of interpolation files #174

Open
Jean1995 opened this issue May 24, 2021 · 3 comments
Open

Replacing std::hash to ensure portability of interpolation files #174

Jean1995 opened this issue May 24, 2021 · 3 comments

Comments

@Jean1995
Copy link
Member

PROPOSAL uses std::hash to calculate hashes. However, the implementation of std::hash is different for clang and gcc (and therefore the resulting hashes are different). This causes the names of the interpolation table files to differ on different operating systems, e.g. they are not really portable.

From the documentation of std::hash:

The actual hash functions are implementation-dependent [...]
Hash functions are only required to produce the same result for the same input within a single execution of a program [...]

It should be more than enough to use something like sha512, I found stbrumme/hash-library as one set of implementations of hashing algorithms.

Hashing std::string (for names) is of course straight forward, but I probably need to think more about a good way to hash integers and especially floating-points numbers (e.g. for the particle masses).

@Jean1995 Jean1995 added this to the v7.1.0 milestone May 24, 2021
@maxnoe
Copy link
Member

maxnoe commented May 24, 2021

https://abseil.io/docs/cpp/guides/hash

@MaxSac
Copy link
Contributor

MaxSac commented May 25, 2021

Not the solution but maybe nice to know 😅
https://www.boost.org/doc/libs/master/libs/uuid/doc/uuid.html

@HDembinski
Copy link

HDembinski commented Nov 10, 2023

I am slightly biased, but would of course propose boost::container_hash https://github.com/boostorg/container_hash

Hash values are not promised to be stable forever, but are historically fairly stable and the library includes a test that the result of the implementation is the same everywhere. Sounds like boost is the right solution as usual.
https://www.boost.org/doc/libs/1_83_0/libs/container_hash/doc/html/hash.html#notes_hash_value_stability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants