Skip to content

Commit

Permalink
Upgrade dependencies and cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteHamster committed Nov 21, 2024
1 parent 736f3a9 commit aba9b85
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 36 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ on:

jobs:
build:
name: Build
runs-on: ubuntu-22.04
strategy:
matrix:
version: [10, 11, 12, 13]
name: Build (GCC ${{ matrix.version }})
runs-on: ubuntu-24.04
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --assume-yes --no-install-recommends build-essential cmake git autoconf libtbb-dev libxxhash-dev libboost-dev
- uses: actions/checkout@v2
sudo apt-get install --assume-yes --no-install-recommends ca-certificates cmake git libtbb-dev gcc-${{ matrix.version }} g++-${{ matrix.version }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} ${{ matrix.version }}
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.version }} ${{ matrix.version }}
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Build
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "extlib/tlx"]
path = extlib/tlx
url = https://github.com/tlx/tlx.git
[submodule "extlib/sdsl-lite"]
path = extlib/sdsl-lite
url = https://github.com/simongog/sdsl-lite.git
29 changes: 19 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.25)
project(LeMonHash)

if((CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
if(TARGET LeMonHash)
return()
endif()

if((CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") AND PROJECT_IS_TOP_LEVEL)
add_compile_options(-march=native)
endif()

set(TLX_INSTALL_INCLUDE_DIR tlx CACHE PATH "Workaround for TLX breaking the first cmake call")
add_subdirectory(extlib/tlx EXCLUDE_FROM_ALL)
add_subdirectory(extlib/tlx SYSTEM EXCLUDE_FROM_ALL)
add_subdirectory(extlib/util EXCLUDE_FROM_ALL)
add_subdirectory(extlib/simpleRibbon EXCLUDE_FROM_ALL)

add_library(PTHash INTERFACE)
target_compile_features(PTHash INTERFACE cxx_std_20)
target_include_directories(PTHash INTERFACE extlib/pthash/include)
add_subdirectory(extlib/pthash SYSTEM EXCLUDE_FROM_ALL)

option(SUCCINCT_USE_INTRINSICS "Use a set of intrinsics available on all x86-64 architectures" ON)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/extlib/ds2i/succinct/succinct_config.hpp.in
Expand All @@ -23,13 +24,21 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/extlib/ds2i/ds2i_config.hpp.in
add_library(ds2i INTERFACE)
target_include_directories(ds2i SYSTEM INTERFACE extlib/ds2i)

add_subdirectory(extlib/sdsl-lite/external SYSTEM EXCLUDE_FROM_ALL)
add_subdirectory(extlib/sdsl-lite/include SYSTEM EXCLUDE_FROM_ALL)
add_subdirectory(extlib/sdsl-lite/lib SYSTEM EXCLUDE_FROM_ALL)
target_compile_options(sdsl PRIVATE -w)
target_include_directories(sdsl SYSTEM INTERFACE extlib/sdsl-lite/include)

add_library(LeMonHash INTERFACE)
target_compile_features(LeMonHash INTERFACE cxx_std_20)
target_include_directories(LeMonHash INTERFACE include)
target_link_libraries(LeMonHash INTERFACE SimpleRibbon ByteHamsterUtil ds2i PTHash)
target_link_libraries(LeMonHash INTERFACE SimpleRibbon ByteHamster::Util ds2i PTHASH sdsl)
add_library(LeMonHash::lemonhash ALIAS LeMonHash)

if(PROJECT_IS_TOP_LEVEL)
target_compile_options(LeMonHash INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wall -Wextra -Wpedantic -Werror -frecord-gcc-switches>)

# Do not create benchmark targets when this is a subdirectory
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_executable(IntegerDistributions benchmark/integerDistributions.cpp)
target_compile_features(IntegerDistributions PRIVATE cxx_std_20)
target_link_libraries(IntegerDistributions PRIVATE LeMonHash tlx)
Expand Down
4 changes: 2 additions & 2 deletions benchmark/simpleMmphfBenchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include <ctime>
#include <chrono>
#include <XorShift64.h>
#include <vector>
#include <iostream>
#include <malloc.h>
#include <bytehamster/util/XorShift64.h>

template <typename MMphf, typename key_t>
void simpleMmphfBenchmark(std::vector<key_t> &inputData, std::string &dataset, size_t numQueries) {
Expand All @@ -27,7 +27,7 @@ void simpleMmphfBenchmark(std::vector<key_t> &inputData, std::string &dataset, s

std::cout<<"\r\033[K"<<"Benchmarking "<<MMphf::name()<<std::flush;
size_t N = inputData.size();
util::XorShift64 prng(time(nullptr));
bytehamster::util::XorShift64 prng(time(nullptr));
uint64_t h = prng();
std::chrono::steady_clock::time_point beginQuery = std::chrono::steady_clock::now();
for (size_t i = 0; i < numQueries; i++) {
Expand Down
6 changes: 3 additions & 3 deletions benchmark/stringDistributions.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <unordered_set>
#include <tlx/cmdline_parser.hpp>
#include <XorShift64.h>
#include <bytehamster/util/XorShift64.h>
#include <LeMonHashVL.hpp>
#include <LeMonHashVLIndexed.hpp>
#include "simpleMmphfBenchmark.hpp"

std::string stringOfLength(size_t length, util::XorShift64 &prng) {
std::string stringOfLength(size_t length, bytehamster::util::XorShift64 &prng) {
std::string key(length, 'x');
size_t i = 0;
while (i < (length & ~0xf)) {
Expand All @@ -24,7 +24,7 @@ std::vector<std::string> randomUniformStrings(size_t n, size_t length, size_t co
keys.reserve(n);
size_t seed = time(nullptr);
std::cout<<"Seed: "<<seed<<std::endl;
util::XorShift64 prng(seed);
bytehamster::util::XorShift64 prng(seed);
std::string prefix = stringOfLength(commonPrefixLength, prng);
while (keys.size() < n) {
std::string key = prefix + stringOfLength(length, prng);
Expand Down
1 change: 1 addition & 0 deletions extlib/sdsl-lite
Submodule sdsl-lite added at c32874
2 changes: 1 addition & 1 deletion extlib/simpleRibbon
3 changes: 2 additions & 1 deletion include/LeMonHash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <Function.h>
#include <bytehamster/util/Function.h>
#include <MultiRetrievalDataStructure.hpp>

#include "support/sequence/BucketOffsets.hpp"
#include "bucket_mapping/LinearBucketMapper.hpp"
#include "bucket_mapping/PGMBucketMapper.hpp"
Expand Down
6 changes: 3 additions & 3 deletions include/LeMonHashHeuristic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <Function.h>
#include <bytehamster/util/Function.h>
#include <MultiRetrievalDataStructure.hpp>
#include "support/sequence/BucketOffsets.hpp"
#include "bucket_mapping/LinearBucketMapper.hpp"
Expand All @@ -23,10 +23,10 @@ class LeMonHashHeuristic {
public:
const size_t N;
private:
MultiRetrievalDataStructure<retrievalCoeffBits> retrievalDataStructure;
BucketOffsets bucketOffsets;
const size_t segments;
EliasFanoM eliasFano;
BucketOffsets bucketOffsets;
MultiRetrievalDataStructure<retrievalCoeffBits> retrievalDataStructure;
public:
static std::string name() {
return std::string("LeMonHash")
Expand Down
8 changes: 4 additions & 4 deletions include/LeMonHashVL.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <algorithm>
#include <fstream>
#include <memory>
#include <pthash.hpp>
#include <MurmurHash64.h>
#include <include/pthash.hpp>
#include <bytehamster/util/MurmurHash64.h>

#include "bucket_mapping/SuccinctPGMBucketMapper.hpp"
#include "bucket_mapping/UnalignedPGMBucketMapper.hpp"
Expand Down Expand Up @@ -333,7 +333,7 @@ class LeMonHashVL {
uint32_t indexInBucket = 0;
auto it = begin;
while (it != end) {
retrieval.addInput(currentBucketSize, util::MurmurHash64(*it), indexInBucket);
retrieval.addInput(currentBucketSize, bytehamster::util::MurmurHash64(*it), indexInBucket);
it++;
indexInBucket++;
}
Expand Down Expand Up @@ -442,7 +442,7 @@ class LeMonHashVL {
if (bucketSize == 1) {
return bucketOffset;
} else {
return bucketOffset + retrieval.query(bucketSize, util::MurmurHash64(string));
return bucketOffset + retrieval.query(bucketSize, bytehamster::util::MurmurHash64(string));
}
} else {
layer++;
Expand Down
4 changes: 2 additions & 2 deletions include/LeMonHashVLIndexed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class LeMonHashVLIndexed {
uint32_t indexInBucket = 0;
auto it = begin;
while (it != end) {
retrieval.addInput(currentBucketSize, util::MurmurHash64(*it), indexInBucket);
retrieval.addInput(currentBucketSize, bytehamster::util::MurmurHash64(*it), indexInBucket);
it++;
indexInBucket++;
}
Expand Down Expand Up @@ -418,7 +418,7 @@ class LeMonHashVLIndexed {
if (bucketSize == 1) {
return bucketOffset;
} else {
return bucketOffset + retrieval.query(bucketSize, util::MurmurHash64(string));
return bucketOffset + retrieval.query(bucketSize, bytehamster::util::MurmurHash64(string));
}
} else {
layer++;
Expand Down
13 changes: 12 additions & 1 deletion include/bucket_mapping/support/OptimalPiecewiseLinearModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,23 @@
#include <utility>
#include <vector>

namespace lemonhash::pgm {
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
using int128 = __int128;
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
}

namespace lemonhash::pgm::internal {

template<typename T>
using LargeSigned = typename std::conditional_t<std::is_floating_point_v<T>,
long double,
std::conditional_t<(sizeof(T) < 8), int64_t, __int128>>;
std::conditional_t<(sizeof(T) < 8), int64_t, int128>>;

template<typename X, typename Y>
class OptimalPiecewiseLinearModel {
Expand Down
2 changes: 1 addition & 1 deletion include/bucket_mapping/support/SuccinctPGM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class SuccinctPGMIndex {
&& !__builtin_mul_overflow(dk, int64_t(y1 - y0), &mul))
return int64_t(y0) + mul / dx;
}
return y0 + ((__int128(k) - x0) * (y1 - y0)) / (x1 - x0);
return y0 + ((int128(k) - x0) * (y1 - y0)) / (x1 - x0);
}
};

Expand Down
4 changes: 2 additions & 2 deletions include/support/TreePath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class TreePath {
TreePath() = default;

[[nodiscard]] TreePath getChild(size_t childIndex) const {
return TreePath(util::remix(hash + childIndex));
return TreePath(bytehamster::util::remix(hash + childIndex));
}

[[nodiscard]] uint64_t currentNodeHash() const {
return hash;
}

[[nodiscard]] uint64_t alternativeHash() const {
return util::remix(hash + 378368305212772073ul);
return bytehamster::util::remix(hash + 378368305212772073ul);
}
};
} // namespace lemonhash

0 comments on commit aba9b85

Please sign in to comment.