Add OpenSSL dependency and implement MD5 hash function

This commit is contained in:
Max Lübke 2024-03-07 12:27:13 +01:00
parent 6abf18ae73
commit 7828b00268
5 changed files with 26 additions and 1 deletions

View File

@ -21,6 +21,7 @@ get_poet_version()
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
find_package(OpenMP) find_package(OpenMP)
find_package(RRuntime REQUIRED) find_package(RRuntime REQUIRED)
find_package(OpenSSL REQUIRED)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(bench) add_subdirectory(bench)

View File

@ -20,6 +20,7 @@ target_link_libraries(poetlib PUBLIC
PhreeqcRM PhreeqcRM
tug tug
DHT_UCX DHT_UCX
OpenSSL::Crypto
) )
target_compile_definitions(poetlib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX) target_compile_definitions(poetlib PUBLIC STRICT_R_HEADERS OMPI_SKIP_MPICXX)

View File

@ -22,6 +22,7 @@
#include "DHT_Wrapper.hpp" #include "DHT_Wrapper.hpp"
#include "DHT_ucx/UCX_bcast_functions.h" #include "DHT_ucx/UCX_bcast_functions.h"
#include "HashFunctions.hpp"
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -62,7 +63,7 @@ DHT_Wrapper::DHT_Wrapper(MPI_Comm dht_comm, std::uint64_t dht_size,
.key_size = static_cast<int>(key_size), .key_size = static_cast<int>(key_size),
.data_size = static_cast<int>(data_size), .data_size = static_cast<int>(data_size),
.bucket_count = static_cast<unsigned int>(buckets_per_process), .bucket_count = static_cast<unsigned int>(buckets_per_process),
.hash_func = &poet::Murmur2_64A, .hash_func = &poet::md5_sum,
.bcast_func = UCX_INIT_BSTRAP_MPI, .bcast_func = UCX_INIT_BSTRAP_MPI,
.bcast_func_args = &ucx_bcast_mpi_args}; .bcast_func_args = &ucx_bcast_mpi_args};
dht_object = DHT_create(&dht_init); dht_object = DHT_create(&dht_init);

View File

@ -25,6 +25,9 @@
*/ */
#include "HashFunctions.hpp" #include "HashFunctions.hpp"
#include <cstdint>
#include <openssl/md5.h>
#if defined(_MSC_VER) #if defined(_MSC_VER)
@ -93,3 +96,21 @@ uint64_t poet::Murmur2_64A(int len, const void *key) {
return h; return h;
} }
uint64_t poet::md5_sum(int len, const void *key) {
MD5_CTX ctx;
unsigned char sum[MD5_DIGEST_LENGTH];
uint64_t retval;
uint64_t *v1;
uint64_t *v2;
MD5_Init(&ctx);
MD5_Update(&ctx, key, len);
MD5_Final(sum, &ctx);
v1 = (uint64_t *)&sum[0];
v2 = (uint64_t *)&sum[8];
retval = *v1 ^ *v2;
return retval;
}

View File

@ -31,6 +31,7 @@ namespace poet {
constexpr uint32_t HASH_SEED = 80 + 79 + 69 + 84; constexpr uint32_t HASH_SEED = 80 + 79 + 69 + 84;
uint64_t Murmur2_64A(int len, const void *key); uint64_t Murmur2_64A(int len, const void *key);
uint64_t md5_sum(int len, const void *key);
} // namespace poet } // namespace poet