diff --git a/include/poet/HashFunctions.hpp b/include/poet/HashFunctions.hpp index 1a7b1c4f1..49e86559a 100644 --- a/include/poet/HashFunctions.hpp +++ b/include/poet/HashFunctions.hpp @@ -1,4 +1,4 @@ -// // Time-stamp: "Last modified 2023-03-27 14:51:05 mluebke" +// // Time-stamp: "Last modified 2023-03-31 14:59:49 mluebke" /* ** Copyright (C) 2018-2021 Alexander Lindemann, Max Luebke (University of @@ -24,17 +24,12 @@ #define HASHFUNCTIONS_H_ #include -#include namespace poet { // Sum of POET interpreted as ASCII constexpr uint32_t HASH_SEED = 80 + 79 + 69 + 84; -void initHashCtx(const EVP_MD *md); -void freeHashCtx(); - -uint64_t hashDHT(int key_size, const void *key); uint64_t Murmur2_64A(int len, const void *key); } // namespace poet diff --git a/src/ChemistryModule/DHT_Wrapper.cpp b/src/ChemistryModule/DHT_Wrapper.cpp index 27e975f1a..d3e33999a 100644 --- a/src/ChemistryModule/DHT_Wrapper.cpp +++ b/src/ChemistryModule/DHT_Wrapper.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -71,7 +70,6 @@ void poet::DHT_ResultObject::ResultsToWP(std::vector &curr_wp) { DHT_Wrapper::DHT_Wrapper(MPI_Comm dht_comm, uint32_t dht_size, uint32_t key_count, uint32_t data_count) : key_count(key_count), data_count(data_count) { - poet::initHashCtx(EVP_md5()); // initialize DHT object uint32_t key_size = key_count * sizeof(DHT_Keyelement); uint32_t data_size = data_count * sizeof(double); @@ -100,7 +98,6 @@ DHT_Wrapper::~DHT_Wrapper() { // free DHT DHT_free(dht_object, NULL, NULL); - poet::freeHashCtx(); } auto DHT_Wrapper::checkDHT(int length, double dt, const std::vector &work_package) diff --git a/src/ChemistryModule/HashFunctions.cpp b/src/ChemistryModule/HashFunctions.cpp index 79a8773cd..da6e10138 100644 --- a/src/ChemistryModule/HashFunctions.cpp +++ b/src/ChemistryModule/HashFunctions.cpp @@ -1,4 +1,4 @@ -// Time-stamp: "Last modified 2023-03-27 14:50:53 mluebke" +// Time-stamp: "Last modified 2023-03-31 15:00:11 mluebke" /* **----------------------------------------------------------------------------- ** MurmurHash2 was written by Austin Appleby, and is placed in the public @@ -27,8 +27,6 @@ #include "poet/HashFunctions.hpp" #include -#include -#include #include #if defined(_MSC_VER) @@ -43,42 +41,6 @@ #endif // !defined(_MSC_VER) -// HACK: I know this is not a good practice, but this will do it for now! -EVP_MD_CTX *ctx = NULL; - -void poet::initHashCtx(const EVP_MD *md) { - if (ctx == NULL) { - ctx = EVP_MD_CTX_new(); - EVP_DigestInit_ex(ctx, md, NULL); - } -} - -void poet::freeHashCtx() { - EVP_MD_CTX_free(ctx); - ctx = NULL; -} - -uint64_t poet::hashDHT(int key_size, const void *key) { - unsigned char sum[MD5_DIGEST_LENGTH]; - uint32_t md_len; - uint64_t retval, *v1, *v2; - - // calculate md5 using MD5 functions - EVP_DigestUpdate(ctx, key, key_size); - EVP_DigestFinal_ex(ctx, sum, &md_len); - - if (md_len != MD5_DIGEST_LENGTH) { - throw std::runtime_error("Something went wrong during MD5 hashing!"); - } - - // divide hash in 2 64 bit parts and XOR them - v1 = (uint64_t *)&sum[0]; - v2 = (uint64_t *)&sum[8]; - retval = *v1 ^ *v2; - - return retval; -} - //----------------------------------------------------------------------------- // MurmurHash2, 64-bit versions, by Austin Appleby