Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

.vscode
test/.vscode
build
.cache
13 changes: 7 additions & 6 deletions test/inc/zoo/debug/rh/RobinHood.debug.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef ZOO_TEST_ROBINHOOD_DEBUGGING
#define ZOO_TEST_ROBINHOOD_DEBUGGING

#include "zoo/map/RobinHood.h"

#include <sstream>
#include <stdio.h>

Expand All @@ -24,8 +22,9 @@ auto display(
constexpr auto HexPerHash = (MD::NBitsMost + 3) / 4;

char format[60];
snprintf(format, 59, "%%0%dllx %%0%dllx %%0%dllx", HexPerSlot, HexPerSlot, HexPerPSL);

const auto hexPerSlot = static_cast<int>(HexPerSlot);
snprintf(format, 59, "%%0%dllx %%0%dllx %%0%dllx", hexPerSlot, hexPerSlot, HexPerPSL);

auto swarNdx = begin / MD::NSlots;
auto swarEnd = end/MD::NSlots;

Expand All @@ -34,8 +33,9 @@ auto display(
auto printLine =
[&]() {
char buffer[100];
sprintf(
snprintf(
buffer,
sizeof(buffer),
format,
initial.at(0), initial.hashes().at(0), initial.PSLs().at(0)
);
Expand Down Expand Up @@ -87,7 +87,8 @@ auto satisfiesInvariant(const Table &map, std::size_t begin = 0, std::size_t end
for(auto n = Table::MD::NSlots; n--; ) {
auto current = v.at(0);
if(prior + 1 < current) {
return std::tuple(false, swarIndexBegin * Table::MD::NSlots + Table::MD::NSlots - n - 1);
const std::size_t index = swarIndexBegin * Table::MD::NSlots + Table::MD::NSlots - n - 1;
return std::tuple(false, index);
}
v = v.shiftLanesRight(1);
prior = current;
Expand Down
1 change: 0 additions & 1 deletion test/inc/zoo/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <tuple>
// provides std::tuple_element to be able to index a pack of types,
// indirectly includes type traits and utility
#include <new>
#include <zoo/meta/in_place_operations.h>
#include <zoo/meta/traits.h>

Expand Down
23 changes: 12 additions & 11 deletions test/map/RobinHood.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <algorithm>
#include <regex>
#include <map>
#include <sstream>
#include <fstream>
#include <unordered_map>

Expand Down Expand Up @@ -54,22 +53,24 @@ struct V {

std::ostream &operator<<(std::ostream &out, V v) {
char buffer[30];
const auto bufferSize = sizeof(buffer);
char *ptr = buffer;
auto val = v.v;
auto printHalf = [&](auto low, auto high) {
for(auto ndx = low; ndx < high; ++ndx) {
if(v.intraIndex == ndx) {
ptr += sprintf(ptr, "<");
ptr += snprintf(ptr, bufferSize, "<");
}
ptr += sprintf(ptr, "%02lx", val & 0xFF);
const std::size_t va = val & 0xFF;
ptr += snprintf(ptr, bufferSize, "%02lx", va);
if(v.intraIndex == ndx) {
ptr += sprintf(ptr, ">");
ptr += snprintf(ptr, bufferSize, ">");
}
val >>= 8;
}
};
printHalf(0, 4);
ptr += sprintf(ptr, "'");
ptr += snprintf(ptr, bufferSize, "'");
printHalf(4, 8);
out << buffer;
return out;
Expand Down Expand Up @@ -143,7 +144,7 @@ TEST_CASE("Robin Hood", "[api][mapping][swar][robin-hood]") {
}
return true;
};

std::regex words("\\w+");
std::sregex_iterator
wordsEnd{},
Expand Down Expand Up @@ -227,7 +228,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata basic",
CHECK(std::tuple{0,0} == zoo::rh::impl::peek(table.md_, 0));
CHECK(std::tuple{0,0} == zoo::rh::impl::peek(table.md_, 2));

// If we ask for a skarupke tail
// If we ask for a skarupke tail
FrontendSmall32::Backend be{table.md_.data()};
auto [index, deadline, metadata] =
be.findMisaligned_assumesSkarupkeTail(0x7, 1, [](int i) {return true;});
Expand Down Expand Up @@ -331,7 +332,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata psl one",
CHECK(i+1 == missIndex);
CHECK((missIndex)%4 ==
FrontendSmall32::MD{missDeadline}.lsbIndex());
CHECK(0x02 ==
CHECK(0x02 ==
missMetadata.at(FrontendSmall32::MD{missDeadline}.lsbIndex()));
}
{
Expand Down Expand Up @@ -375,7 +376,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata psl not one",
CHECK(i-p+4 == missIndex);
CHECK((missIndex)%4 ==
FrontendSmall32::MD{missDeadline}.lsbIndex());
CHECK(0x04 ==
CHECK(0x04 ==
missMetadata.at(FrontendSmall32::MD{missDeadline}.lsbIndex()));
}
}
Expand Down Expand Up @@ -449,7 +450,7 @@ TEST_CASE(
m.data_ = MD35u32Ops::SSL{0x0401'8201};
CHECK(0x0000'8001u == m.attemptMatch(SM{hash1}, SM{psl1}).value());
CHECK(0x0000'8001u == SO35u32Ops::attemptMatch(m.data_, SM{hash1}, SM{psl1}).value());
}
}
}

template<typename Container>
Expand Down Expand Up @@ -485,7 +486,7 @@ TEST_CASE("RH Validation") {

while(corpus) {
getline(corpus, line);

std::sregex_iterator
wordsEnd{},
wordIterator{line.begin(), line.end(), words};
Expand Down