Add libcuckoo to test suite
authorJeff Preshing <filter-github@preshing.com>
Tue, 2 Feb 2016 22:15:02 +0000 (17:15 -0500)
committerJeff Preshing <filter-github@preshing.com>
Tue, 2 Feb 2016 22:15:02 +0000 (17:15 -0500)
CMakeLists.txt
cmake/junction_config.h.in
cmake/modules/FindLibCuckoo.cmake [new file with mode: 0644]
junction/extra/impl/MapAdapter_LibCuckoo.h [new file with mode: 0644]
samples/MapScalabilityTests/RenderGraphs.py
samples/MapScalabilityTests/TestAllMaps.py

index 0452094972aa8959db93188cabc98a99a7b3923e..1f89f5ac14abb2384b0c35af28f48f9bfc17819c 100644 (file)
@@ -75,6 +75,12 @@ if(JUNCTION_WITH_TERVEL)
     list(APPEND JUNCTION_ALL_LIBRARIES ${TERVEL_LIBRARIES})
 endif()
 
     list(APPEND JUNCTION_ALL_LIBRARIES ${TERVEL_LIBRARIES})
 endif()
 
+# Optional: Locate libcuckoo and append it to the list of include dirs/libraries.
+if(JUNCTION_WITH_LIBCUCKOO)
+    find_package(LibCuckoo REQUIRED)
+    list(APPEND JUNCTION_ALL_INCLUDE_DIRS ${LIBCUCKOO_INCLUDE_DIRS})
+endif()
+
 # If this is the root listfile, add all samples
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     file(GLOB children samples/*)
 # If this is the root listfile, add all samples
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
     file(GLOB children samples/*)
index 37dcd70ea8f3a0addfca7a4576da2889db1bc20a..e59fb6f8b7c5449268e37e3747b6ea1d9d5efbc4 100644 (file)
@@ -3,6 +3,7 @@
 #cmakedefine01 JUNCTION_WITH_NBDS
 #cmakedefine01 JUNCTION_WITH_TBB
 #cmakedefine01 JUNCTION_WITH_TERVEL
 #cmakedefine01 JUNCTION_WITH_NBDS
 #cmakedefine01 JUNCTION_WITH_TBB
 #cmakedefine01 JUNCTION_WITH_TERVEL
+#cmakedefine01 JUNCTION_WITH_LIBCUCKOO
 #cmakedefine01 NBDS_USE_TURF_HEAP
 #cmakedefine01 TBB_USE_TURF_HEAP
 #cmakedefine01 JUNCTION_TRACK_GRAMPA_STATS
 #cmakedefine01 NBDS_USE_TURF_HEAP
 #cmakedefine01 TBB_USE_TURF_HEAP
 #cmakedefine01 JUNCTION_TRACK_GRAMPA_STATS
diff --git a/cmake/modules/FindLibCuckoo.cmake b/cmake/modules/FindLibCuckoo.cmake
new file mode 100644 (file)
index 0000000..60da098
--- /dev/null
@@ -0,0 +1,11 @@
+find_path(LIBCUCKOO_ROOT include/libcuckoo/cuckoohash_map.hh)
+
+if(LIBCUCKOO_ROOT)
+    set(LIBCUCKOO_FOUND TRUE)
+    set(LIBCUCKOO_INCLUDE_DIRS "${LIBCUCKOO_ROOT}/include")
+else()
+    message("Can't find libcuckoo!")
+    if(LibCuckoo_FIND_REQUIRED)
+        message(FATAL_ERROR "Missing required package libcuckoo")
+    endif()
+endif()
diff --git a/junction/extra/impl/MapAdapter_LibCuckoo.h b/junction/extra/impl/MapAdapter_LibCuckoo.h
new file mode 100644 (file)
index 0000000..76119ba
--- /dev/null
@@ -0,0 +1,79 @@
+/*------------------------------------------------------------------------
+  Junction: Concurrent data structures in C++
+  Copyright (c) 2016 Jeff Preshing
+
+  Distributed under the Simplified BSD License.
+  Original location: https://github.com/preshing/junction
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the LICENSE file for more information.
+------------------------------------------------------------------------*/
+
+#ifndef JUNCTION_EXTRA_IMPL_MAPADAPTER_LIBCUCKOO_H
+#define JUNCTION_EXTRA_IMPL_MAPADAPTER_LIBCUCKOO_H
+
+#include <junction/Core.h>
+
+#if !JUNCTION_WITH_LIBCUCKOO
+#error "You must configure with JUNCTION_WITH_LIBCUCKOO=1!"
+#endif
+
+#include <libcuckoo/cuckoohash_map.hh>
+
+namespace junction {
+namespace extra {
+
+class MapAdapter {
+public:
+    static TURF_CONSTEXPR const char* MapName = "libcuckoo cuckoohash_map";
+
+    MapAdapter(ureg) {
+    }
+
+    class ThreadContext {
+    public:
+        ThreadContext(MapAdapter&, ureg) {
+        }
+
+        void registerThread() {
+        }
+
+        void unregisterThread() {
+        }
+
+        void update() {
+        }
+    };
+
+    class Map {
+    private:
+        cuckoohash_map<u32, void*> m_map;
+
+    public:
+        Map(ureg capacity) : m_map(capacity) {
+        }
+
+        void insert(u32 key, void* value) {
+            m_map.insert(key, value);
+        }
+
+        void* get(u32 key) {
+            void* result;
+            return m_map.find(key, result) ? result : NULL;
+        }
+
+        void erase(u32 key) {
+            m_map.erase(key);
+        }
+    };
+
+    static ureg getInitialCapacity(ureg maxPopulation) {
+        return maxPopulation / 4;
+    }
+};
+
+} // namespace extra
+} // namespace junction
+
+#endif // JUNCTION_EXTRA_IMPL_MAPADAPTER_LIBCUCKOO_H
index 9b21d85cc1bdfbb9d130fcbdc3a13dbc0fa5202c..458f38e10943029b0c66b26858141245ad8733de 100644 (file)
@@ -11,14 +11,15 @@ def colorTuple(h):
 
 ALL_MAPS = [
     ('folly',           colorTuple('606080')),
 
 ALL_MAPS = [
     ('folly',           colorTuple('606080')),
-    ('tervel',          colorTuple('9090b0')),
-    ('stdmap',          colorTuple('606080')),
+    ('tervel',          colorTuple('408040')),
+    ('stdmap',          colorTuple('b0b090')),
     ('nbds',            colorTuple('9090b0')),
     ('nbds',            colorTuple('9090b0')),
-    ('michael',         colorTuple('606080')),
-    ('tbb',             colorTuple('9090b0')),
     ('linear',          colorTuple('ff4040')),
     ('linear',          colorTuple('ff4040')),
-    ('grampa',          colorTuple('ff4040')),
-    ('leapfrog',        colorTuple('ff4040')),
+    ('michael',         colorTuple('202020')),
+    ('tbb',             colorTuple('0090b0')),
+    ('cuckoo',          colorTuple('d040d0')),
+    ('grampa',          colorTuple('ff6040')),
+    ('leapfrog',        colorTuple('ff8040')),
 ]
 
 #---------------------------------------------------
 ]
 
 #---------------------------------------------------
index f60f16764b32a69f36e4b15cd4e4d98c58b3b103..bc9cbd5aef2cbd4abb9e4a3d905212cb8d3d4cb6 100644 (file)
@@ -17,6 +17,7 @@ ALL_MAPS = [
     ('nbds', 'junction/extra/impl/MapAdapter_NBDS.h', ['-DJUNCTION_WITH_NBDS=1'], ['-i10000', '-c200']),
     ('tbb', 'junction/extra/impl/MapAdapter_TBB.h', ['-DJUNCTION_WITH_TBB=1'], ['-i10000', '-c200']),
     ('tervel', 'junction/extra/impl/MapAdapter_Tervel.h', ['-DJUNCTION_WITH_TERVEL=1'], ['-i1000', '-c20']),
     ('nbds', 'junction/extra/impl/MapAdapter_NBDS.h', ['-DJUNCTION_WITH_NBDS=1'], ['-i10000', '-c200']),
     ('tbb', 'junction/extra/impl/MapAdapter_TBB.h', ['-DJUNCTION_WITH_TBB=1'], ['-i10000', '-c200']),
     ('tervel', 'junction/extra/impl/MapAdapter_Tervel.h', ['-DJUNCTION_WITH_TERVEL=1'], ['-i1000', '-c20']),
+    ('cuckoo', 'junction/extra/impl/MapAdapter_LibCuckoo.h', ['-DJUNCTION_WITH_LIBCUCKOO=1', '-DTURF_WITH_EXCEPTIONS=1'], ['-i5000', '-c20']),
 ]
 
 # Scan arguments for path to CMakeLists.txt and args to pass through.
 ]
 
 # Scan arguments for path to CMakeLists.txt and args to pass through.