Loading CuckooHash/CuckooHashTable.hpp +3 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ CuckooHashTable<Item, Key, Device>::CuckooHashTable(int tableSize, uint8_t nHash m_view(new ViewType(*this, items.getConstView())) {} template<typename Item, typename Key, typename Device> CuckooHashTable<Item, Key, Device>::~CuckooHashTable() {} CuckooHashTable<Item, Key, Device>::~CuckooHashTable() { delete m_view; } template<typename Item, typename Key, typename Device> int CuckooHashTable<Item, Key, Device>::generations() const { return m_view->generations(); } Loading Makefile +8 −12 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ LD := g++ -std=c++17 LDFLAGS := -Wall -pedantic -Wextra -g $(SANITIZER_FLAGS) $(TNLFLAGS) CUDAFLAGS := -lcuda -lcudart all: pre-build test #unit_test all: pre-build unit_test test ifdef CUDA pre-build: Loading Loading @@ -54,16 +54,12 @@ test: bin/main.o $(HEADERS) unit_test: bin/unit_test.o bin/unit_test.o bin/unit_test.o: bin/unit_test_main.o bin/hashfunction.o $(LD) bin/unit_test_main.o bin/hashfunction.o -o bin/unit_test.o $(GTESTFLAGS) $(LDFLAGS) bin/unit_test_main.o: UnitTests/main.h \ bin/unit_test.o: UnitTests/main.h \ UnitTests/CuckooHashMapTest.h \ UnitTests/HashGraphV1MapTest.h \ bin/triangle.o \ UnitTests/CuckooHashSetTest.h \ $(HEADERS) $(CPP) -c UnitTests/main.cpp -o bin/unit_test_main.o $(GTESTFLAGS) $(CPPFLAGS) $(CPP) UnitTests/main.cpp -o bin/unit_test.o $(GTESTFLAGS) $(CPPFLAGS) clean: rm bin/* Loading @@ -71,4 +67,4 @@ clean: bin/main.o: main.cpp test_map.h test_set.h test_map.hpp test_set.hpp test.h $(HEADERS) $(CPP) main.cpp -o bin/main.o $(CPPFLAGS) compile: bin/main.o #bin/unit_test.o compile: bin/main.o bin/unit_test.o UnitTests/CuckooHashMapTest.h +14 −14 Original line number Diff line number Diff line Loading @@ -9,11 +9,11 @@ #include <vector> template<typename Pair> template<typename tPair> class CuckooHashMapTest : public ::testing::Test { protected: using KeyType = typename std::tuple_element<0, Pair>::type; using ValueType = typename std::tuple_element<1, Pair>::type; using KeyType = typename std::tuple_element<0, tPair>::type; using ValueType = typename std::tuple_element<1, tPair>::type; }; using CuckooHashMapTypes = ::testing::Types< Loading Loading @@ -41,16 +41,16 @@ TYPED_TEST(CuckooHashMapTest, correctQuery) { using KeyType = typename TestFixture::KeyType; using ValueType = typename TestFixture::ValueType; std::vector<std::pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.size(); int nIterations = 7 * log(pairs.size()); CuckooHashMap<KeyType, ValueType> map(tableSize, 6, nIterations, pairs, {0, 0}); Array<Pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.getSize(); int nIterations = 7 * log(pairs.getSize()); CuckooHashMap<KeyType, ValueType> map(pairs, 6); ValueType value; for (const auto& pair : pairs) { KeyType key = pair.first; for (int i = 0; i < pairs.getSize(); i++) { KeyType key = pairs[i].key; EXPECT_TRUE(map.find(key, value)); EXPECT_EQ(value, pair.second); EXPECT_EQ(value, pairs[i].value); } } Loading @@ -58,10 +58,10 @@ TYPED_TEST(CuckooHashMapTest, wrongQuery) { using KeyType = typename TestFixture::KeyType; using ValueType = typename TestFixture::ValueType; std::vector<std::pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.size(); int nIterations = 7 * log(pairs.size()); CuckooHashMap<KeyType, ValueType> map(tableSize, 6, nIterations, pairs, {0, 0}); Array<Pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.getSize(); int nIterations = 7 * log(pairs.getSize()); CuckooHashMap<KeyType, ValueType> map(pairs, 6); for (KeyType key = 8; key < 16; key++) { ValueType value; Loading UnitTests/CuckooHashSetTest.h +10 −10 Original line number Diff line number Diff line Loading @@ -22,22 +22,22 @@ TYPED_TEST_SUITE(CuckooHashSetTest, CuckooHashSetTypes); TYPED_TEST(CuckooHashSetTest, correctQuery) { using KeyType = typename TestFixture::KeyType; std::vector<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.size(); int nIterations = 7 * log(values.size()); CuckooHashSet<KeyType> set(tableSize, 6, nIterations, values, 0); Array<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.getSize(); int nIterations = 7 * log(values.getSize()); CuckooHashSet<KeyType> set(values, 6); for (const auto value : values) EXPECT_TRUE(set.contains(value)); for (int i = 0; i < values.getSize(); i++) EXPECT_TRUE(set.contains(values[i])); } TYPED_TEST(CuckooHashSetTest, wrongQuery) { using KeyType = typename TestFixture::KeyType; std::vector<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.size(); int nIterations = 7 * log(values.size()); CuckooHashSet<KeyType> map(tableSize, 6, nIterations, values, 0); Array<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.getSize(); int nIterations = 7 * log(values.getSize()); CuckooHashSet<KeyType> map(values, 6); for (KeyType key = 8; key < 16; key++) EXPECT_FALSE(map.contains(key)); Loading UnitTests/main.h +14 −10 Original line number Diff line number Diff line #include <vector> #include "../CuckooHash/CuckooHashMap.h" #include <TNL/Containers/Array.h> using namespace TNL::Containers; template<typename KeyType, typename ValueType> std::vector<std::pair<KeyType, ValueType>> get_pairs() { std::vector<std::pair<KeyType, ValueType>> pairs; Array<Pair<KeyType, ValueType>> get_pairs() { Array<Pair<KeyType, ValueType>> pairs(8); for (ValueType i = 0; i < 8; i++) pairs.push_back({i, i + 1}); pairs[i] = {i, i + 1}; return pairs; } #include "CuckooHashMapTest.h" #include "HashGraphV1MapTest.h" //#include "HashGraphV1MapTest.h" template<typename KeyType> std::vector<KeyType> get_values() { std::vector<KeyType> values; Array<KeyType> get_values() { Array<KeyType> values(8); for (KeyType i = 0; i < 8; i++) values.push_back(i); values[i] = i; return values; } #include "CuckooHashSetTest.h" int main( int argc, char* argv[] ) { int main(int argc, char* argv[]) { ::testing::InitGoogleTest( &argc, argv ); return RUN_ALL_TESTS(); } Loading
CuckooHash/CuckooHashTable.hpp +3 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,9 @@ CuckooHashTable<Item, Key, Device>::CuckooHashTable(int tableSize, uint8_t nHash m_view(new ViewType(*this, items.getConstView())) {} template<typename Item, typename Key, typename Device> CuckooHashTable<Item, Key, Device>::~CuckooHashTable() {} CuckooHashTable<Item, Key, Device>::~CuckooHashTable() { delete m_view; } template<typename Item, typename Key, typename Device> int CuckooHashTable<Item, Key, Device>::generations() const { return m_view->generations(); } Loading
Makefile +8 −12 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ LD := g++ -std=c++17 LDFLAGS := -Wall -pedantic -Wextra -g $(SANITIZER_FLAGS) $(TNLFLAGS) CUDAFLAGS := -lcuda -lcudart all: pre-build test #unit_test all: pre-build unit_test test ifdef CUDA pre-build: Loading Loading @@ -54,16 +54,12 @@ test: bin/main.o $(HEADERS) unit_test: bin/unit_test.o bin/unit_test.o bin/unit_test.o: bin/unit_test_main.o bin/hashfunction.o $(LD) bin/unit_test_main.o bin/hashfunction.o -o bin/unit_test.o $(GTESTFLAGS) $(LDFLAGS) bin/unit_test_main.o: UnitTests/main.h \ bin/unit_test.o: UnitTests/main.h \ UnitTests/CuckooHashMapTest.h \ UnitTests/HashGraphV1MapTest.h \ bin/triangle.o \ UnitTests/CuckooHashSetTest.h \ $(HEADERS) $(CPP) -c UnitTests/main.cpp -o bin/unit_test_main.o $(GTESTFLAGS) $(CPPFLAGS) $(CPP) UnitTests/main.cpp -o bin/unit_test.o $(GTESTFLAGS) $(CPPFLAGS) clean: rm bin/* Loading @@ -71,4 +67,4 @@ clean: bin/main.o: main.cpp test_map.h test_set.h test_map.hpp test_set.hpp test.h $(HEADERS) $(CPP) main.cpp -o bin/main.o $(CPPFLAGS) compile: bin/main.o #bin/unit_test.o compile: bin/main.o bin/unit_test.o
UnitTests/CuckooHashMapTest.h +14 −14 Original line number Diff line number Diff line Loading @@ -9,11 +9,11 @@ #include <vector> template<typename Pair> template<typename tPair> class CuckooHashMapTest : public ::testing::Test { protected: using KeyType = typename std::tuple_element<0, Pair>::type; using ValueType = typename std::tuple_element<1, Pair>::type; using KeyType = typename std::tuple_element<0, tPair>::type; using ValueType = typename std::tuple_element<1, tPair>::type; }; using CuckooHashMapTypes = ::testing::Types< Loading Loading @@ -41,16 +41,16 @@ TYPED_TEST(CuckooHashMapTest, correctQuery) { using KeyType = typename TestFixture::KeyType; using ValueType = typename TestFixture::ValueType; std::vector<std::pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.size(); int nIterations = 7 * log(pairs.size()); CuckooHashMap<KeyType, ValueType> map(tableSize, 6, nIterations, pairs, {0, 0}); Array<Pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.getSize(); int nIterations = 7 * log(pairs.getSize()); CuckooHashMap<KeyType, ValueType> map(pairs, 6); ValueType value; for (const auto& pair : pairs) { KeyType key = pair.first; for (int i = 0; i < pairs.getSize(); i++) { KeyType key = pairs[i].key; EXPECT_TRUE(map.find(key, value)); EXPECT_EQ(value, pair.second); EXPECT_EQ(value, pairs[i].value); } } Loading @@ -58,10 +58,10 @@ TYPED_TEST(CuckooHashMapTest, wrongQuery) { using KeyType = typename TestFixture::KeyType; using ValueType = typename TestFixture::ValueType; std::vector<std::pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.size(); int nIterations = 7 * log(pairs.size()); CuckooHashMap<KeyType, ValueType> map(tableSize, 6, nIterations, pairs, {0, 0}); Array<Pair<KeyType, ValueType>> pairs = get_pairs<KeyType, ValueType>(); int tableSize = 1.25 * pairs.getSize(); int nIterations = 7 * log(pairs.getSize()); CuckooHashMap<KeyType, ValueType> map(pairs, 6); for (KeyType key = 8; key < 16; key++) { ValueType value; Loading
UnitTests/CuckooHashSetTest.h +10 −10 Original line number Diff line number Diff line Loading @@ -22,22 +22,22 @@ TYPED_TEST_SUITE(CuckooHashSetTest, CuckooHashSetTypes); TYPED_TEST(CuckooHashSetTest, correctQuery) { using KeyType = typename TestFixture::KeyType; std::vector<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.size(); int nIterations = 7 * log(values.size()); CuckooHashSet<KeyType> set(tableSize, 6, nIterations, values, 0); Array<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.getSize(); int nIterations = 7 * log(values.getSize()); CuckooHashSet<KeyType> set(values, 6); for (const auto value : values) EXPECT_TRUE(set.contains(value)); for (int i = 0; i < values.getSize(); i++) EXPECT_TRUE(set.contains(values[i])); } TYPED_TEST(CuckooHashSetTest, wrongQuery) { using KeyType = typename TestFixture::KeyType; std::vector<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.size(); int nIterations = 7 * log(values.size()); CuckooHashSet<KeyType> map(tableSize, 6, nIterations, values, 0); Array<KeyType> values = get_values<KeyType>(); int tableSize = 1.25 * values.getSize(); int nIterations = 7 * log(values.getSize()); CuckooHashSet<KeyType> map(values, 6); for (KeyType key = 8; key < 16; key++) EXPECT_FALSE(map.contains(key)); Loading
UnitTests/main.h +14 −10 Original line number Diff line number Diff line #include <vector> #include "../CuckooHash/CuckooHashMap.h" #include <TNL/Containers/Array.h> using namespace TNL::Containers; template<typename KeyType, typename ValueType> std::vector<std::pair<KeyType, ValueType>> get_pairs() { std::vector<std::pair<KeyType, ValueType>> pairs; Array<Pair<KeyType, ValueType>> get_pairs() { Array<Pair<KeyType, ValueType>> pairs(8); for (ValueType i = 0; i < 8; i++) pairs.push_back({i, i + 1}); pairs[i] = {i, i + 1}; return pairs; } #include "CuckooHashMapTest.h" #include "HashGraphV1MapTest.h" //#include "HashGraphV1MapTest.h" template<typename KeyType> std::vector<KeyType> get_values() { std::vector<KeyType> values; Array<KeyType> get_values() { Array<KeyType> values(8); for (KeyType i = 0; i < 8; i++) values.push_back(i); values[i] = i; return values; } #include "CuckooHashSetTest.h" int main( int argc, char* argv[] ) { int main(int argc, char* argv[]) { ::testing::InitGoogleTest( &argc, argv ); return RUN_ALL_TESTS(); }