From 77d3fab30b70ba23f9ffdf681cfe57a1b2e2edc2 Mon Sep 17 00:00:00 2001 From: Jeff Preshing Date: Tue, 2 Feb 2016 17:15:02 -0500 Subject: [PATCH] Add libcuckoo to test suite --- CMakeLists.txt | 6 ++ cmake/junction_config.h.in | 1 + cmake/modules/FindLibCuckoo.cmake | 11 +++ junction/extra/impl/MapAdapter_LibCuckoo.h | 79 +++++++++++++++++++++ samples/MapScalabilityTests/RenderGraphs.py | 13 ++-- samples/MapScalabilityTests/TestAllMaps.py | 1 + 6 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 cmake/modules/FindLibCuckoo.cmake create mode 100644 junction/extra/impl/MapAdapter_LibCuckoo.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0452094..1f89f5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,12 @@ if(JUNCTION_WITH_TERVEL) 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/*) diff --git a/cmake/junction_config.h.in b/cmake/junction_config.h.in index 37dcd70..e59fb6f 100644 --- a/cmake/junction_config.h.in +++ b/cmake/junction_config.h.in @@ -3,6 +3,7 @@ #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 diff --git a/cmake/modules/FindLibCuckoo.cmake b/cmake/modules/FindLibCuckoo.cmake new file mode 100644 index 0000000..60da098 --- /dev/null +++ b/cmake/modules/FindLibCuckoo.cmake @@ -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 index 0000000..76119ba --- /dev/null +++ b/junction/extra/impl/MapAdapter_LibCuckoo.h @@ -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 + +#if !JUNCTION_WITH_LIBCUCKOO +#error "You must configure with JUNCTION_WITH_LIBCUCKOO=1!" +#endif + +#include + +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 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 diff --git a/samples/MapScalabilityTests/RenderGraphs.py b/samples/MapScalabilityTests/RenderGraphs.py index 9b21d85..458f38e 100644 --- a/samples/MapScalabilityTests/RenderGraphs.py +++ b/samples/MapScalabilityTests/RenderGraphs.py @@ -11,14 +11,15 @@ def colorTuple(h): ALL_MAPS = [ ('folly', colorTuple('606080')), - ('tervel', colorTuple('9090b0')), - ('stdmap', colorTuple('606080')), + ('tervel', colorTuple('408040')), + ('stdmap', colorTuple('b0b090')), ('nbds', colorTuple('9090b0')), - ('michael', colorTuple('606080')), - ('tbb', colorTuple('9090b0')), ('linear', colorTuple('ff4040')), - ('grampa', colorTuple('ff4040')), - ('leapfrog', colorTuple('ff4040')), + ('michael', colorTuple('202020')), + ('tbb', colorTuple('0090b0')), + ('cuckoo', colorTuple('d040d0')), + ('grampa', colorTuple('ff6040')), + ('leapfrog', colorTuple('ff8040')), ] #--------------------------------------------------- diff --git a/samples/MapScalabilityTests/TestAllMaps.py b/samples/MapScalabilityTests/TestAllMaps.py index f60f167..bc9cbd5 100644 --- a/samples/MapScalabilityTests/TestAllMaps.py +++ b/samples/MapScalabilityTests/TestAllMaps.py @@ -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']), + ('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. -- 2.34.1