From 39e02b325f8e3104b71b2fce9cc6c7a19f8dc639 Mon Sep 17 00:00:00 2001 From: Jeff Preshing Date: Wed, 18 May 2016 14:19:40 -0400 Subject: [PATCH] Fixes for C++98 --- junction/QSBR.cpp | 1 - junction/extra/impl/MapAdapter_CDS_Cuckoo.h | 2 +- junction/extra/impl/MapAdapter_CDS_Michael.h | 2 +- junction/extra/impl/MapAdapter_Crude.h | 2 +- junction/extra/impl/MapAdapter_Folly.h | 2 +- junction/extra/impl/MapAdapter_Grampa.h | 2 +- junction/extra/impl/MapAdapter_Leapfrog.h | 2 +- .../extra/impl/MapAdapter_Leapfrog_RWLock.h | 2 +- junction/extra/impl/MapAdapter_LibCuckoo.h | 2 +- junction/extra/impl/MapAdapter_Linear.h | 2 +- junction/extra/impl/MapAdapter_Linear_Mutex.h | 2 +- .../extra/impl/MapAdapter_Linear_RWLock.h | 2 +- junction/extra/impl/MapAdapter_NBDS.h | 2 +- junction/extra/impl/MapAdapter_Null.h | 2 +- junction/extra/impl/MapAdapter_StdMap.h | 2 +- junction/extra/impl/MapAdapter_TBB.h | 2 +- junction/extra/impl/MapAdapter_Tervel.h | 2 +- samples/MapCorrectnessTests/TestEnvironment.h | 2 +- .../MapPerformanceTests.cpp | 39 ++++++++++--------- .../MapScalabilityTests.cpp | 37 +++++++++--------- 20 files changed, 56 insertions(+), 55 deletions(-) diff --git a/junction/QSBR.cpp b/junction/QSBR.cpp index b1ed138..c8131e6 100644 --- a/junction/QSBR.cpp +++ b/junction/QSBR.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace junction { diff --git a/junction/extra/impl/MapAdapter_CDS_Cuckoo.h b/junction/extra/impl/MapAdapter_CDS_Cuckoo.h index 56ea0df..975ab88 100644 --- a/junction/extra/impl/MapAdapter_CDS_Cuckoo.h +++ b/junction/extra/impl/MapAdapter_CDS_Cuckoo.h @@ -30,7 +30,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "CDS CuckooMap"; + static TURF_CONSTEXPR const char* getMapName() { return "CDS CuckooMap"; } cds::gc::HP* m_hpGC; diff --git a/junction/extra/impl/MapAdapter_CDS_Michael.h b/junction/extra/impl/MapAdapter_CDS_Michael.h index 8820b79..b82ddfc 100644 --- a/junction/extra/impl/MapAdapter_CDS_Michael.h +++ b/junction/extra/impl/MapAdapter_CDS_Michael.h @@ -30,7 +30,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "CDS MichaelKVList"; + static TURF_CONSTEXPR const char* getMapName() { return "CDS MichaelKVList"; } cds::gc::HP* m_hpGC; diff --git a/junction/extra/impl/MapAdapter_Crude.h b/junction/extra/impl/MapAdapter_Crude.h index 1548ff6..b64ad2f 100644 --- a/junction/extra/impl/MapAdapter_Crude.h +++ b/junction/extra/impl/MapAdapter_Crude.h @@ -22,7 +22,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Junction Crude map"; + static TURF_CONSTEXPR const char* getMapName() { return "Junction Crude map"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Folly.h b/junction/extra/impl/MapAdapter_Folly.h index 2054483..dd2378f 100644 --- a/junction/extra/impl/MapAdapter_Folly.h +++ b/junction/extra/impl/MapAdapter_Folly.h @@ -26,7 +26,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Folly AtomicHashMap"; + static TURF_CONSTEXPR const char* getMapName() { return "Folly AtomicHashMap"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Grampa.h b/junction/extra/impl/MapAdapter_Grampa.h index 9bf4bf4..4ee552f 100644 --- a/junction/extra/impl/MapAdapter_Grampa.h +++ b/junction/extra/impl/MapAdapter_Grampa.h @@ -23,7 +23,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Junction Grampa map"; + static TURF_CONSTEXPR const char* getMapName() { return "Junction Grampa map"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Leapfrog.h b/junction/extra/impl/MapAdapter_Leapfrog.h index 7661725..9e89f9d 100644 --- a/junction/extra/impl/MapAdapter_Leapfrog.h +++ b/junction/extra/impl/MapAdapter_Leapfrog.h @@ -23,7 +23,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Junction Leapfrog map"; + static TURF_CONSTEXPR const char* getMapName() { return "Junction Leapfrog map"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Leapfrog_RWLock.h b/junction/extra/impl/MapAdapter_Leapfrog_RWLock.h index 547cee3..d47780a 100644 --- a/junction/extra/impl/MapAdapter_Leapfrog_RWLock.h +++ b/junction/extra/impl/MapAdapter_Leapfrog_RWLock.h @@ -23,7 +23,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Single + RWLock"; + static TURF_CONSTEXPR const char* getMapName() { return "Single + RWLock"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_LibCuckoo.h b/junction/extra/impl/MapAdapter_LibCuckoo.h index 784f9b0..2f90587 100644 --- a/junction/extra/impl/MapAdapter_LibCuckoo.h +++ b/junction/extra/impl/MapAdapter_LibCuckoo.h @@ -26,7 +26,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "libcuckoo cuckoohash_map"; + static TURF_CONSTEXPR const char* getMapName() { return "libcuckoo cuckoohash_map"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Linear.h b/junction/extra/impl/MapAdapter_Linear.h index d991782..d0ae898 100644 --- a/junction/extra/impl/MapAdapter_Linear.h +++ b/junction/extra/impl/MapAdapter_Linear.h @@ -23,7 +23,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Junction Linear map"; + static TURF_CONSTEXPR const char* getMapName() { return "Junction Linear map"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Linear_Mutex.h b/junction/extra/impl/MapAdapter_Linear_Mutex.h index 3592a1f..c11acba 100644 --- a/junction/extra/impl/MapAdapter_Linear_Mutex.h +++ b/junction/extra/impl/MapAdapter_Linear_Mutex.h @@ -23,7 +23,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Single + Mutex"; + static TURF_CONSTEXPR const char* getMapName() { return "Single + Mutex"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Linear_RWLock.h b/junction/extra/impl/MapAdapter_Linear_RWLock.h index 24bb227..7109c13 100644 --- a/junction/extra/impl/MapAdapter_Linear_RWLock.h +++ b/junction/extra/impl/MapAdapter_Linear_RWLock.h @@ -23,7 +23,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Single + RWLock"; + static TURF_CONSTEXPR const char* getMapName() { return "Single + RWLock"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_NBDS.h b/junction/extra/impl/MapAdapter_NBDS.h index 13e9334..8e2e745 100644 --- a/junction/extra/impl/MapAdapter_NBDS.h +++ b/junction/extra/impl/MapAdapter_NBDS.h @@ -31,7 +31,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "nbds hashtable_t"; + static TURF_CONSTEXPR const char* getMapName() { return "nbds hashtable_t"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Null.h b/junction/extra/impl/MapAdapter_Null.h index f25dd9d..dfbb0ad 100644 --- a/junction/extra/impl/MapAdapter_Null.h +++ b/junction/extra/impl/MapAdapter_Null.h @@ -20,7 +20,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Null"; + static TURF_CONSTEXPR const char* getMapName() { return "Null"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_StdMap.h b/junction/extra/impl/MapAdapter_StdMap.h index 9fde8f4..9ec81da 100644 --- a/junction/extra/impl/MapAdapter_StdMap.h +++ b/junction/extra/impl/MapAdapter_StdMap.h @@ -22,7 +22,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "std::map + std::mutex"; + static TURF_CONSTEXPR const char* getMapName() { return "std::map + std::mutex"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_TBB.h b/junction/extra/impl/MapAdapter_TBB.h index 3e9bc01..a409726 100644 --- a/junction/extra/impl/MapAdapter_TBB.h +++ b/junction/extra/impl/MapAdapter_TBB.h @@ -26,7 +26,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Intel TBB concurrent_hash_map"; + static TURF_CONSTEXPR const char* getMapName() { return "Intel TBB concurrent_hash_map"; } MapAdapter(ureg) { } diff --git a/junction/extra/impl/MapAdapter_Tervel.h b/junction/extra/impl/MapAdapter_Tervel.h index 440dff0..a3f7ebd 100644 --- a/junction/extra/impl/MapAdapter_Tervel.h +++ b/junction/extra/impl/MapAdapter_Tervel.h @@ -27,7 +27,7 @@ namespace extra { class MapAdapter { public: - static TURF_CONSTEXPR const char* MapName = "Tervel HashMap"; + static TURF_CONSTEXPR const char* getMapName() { return "Tervel HashMap"; } tervel::Tervel m_tervel; diff --git a/samples/MapCorrectnessTests/TestEnvironment.h b/samples/MapCorrectnessTests/TestEnvironment.h index 2ff9997..7ef9b6b 100644 --- a/samples/MapCorrectnessTests/TestEnvironment.h +++ b/samples/MapCorrectnessTests/TestEnvironment.h @@ -30,7 +30,7 @@ struct TestEnvironment { TestEnvironment() : numThreads(dispatcher.getNumPhysicalCores()), adapter(numThreads) { TURF_ASSERT(numThreads > 0); for (ureg t = 0; t < numThreads; t++) - threads.emplace_back(adapter, t); + threads.push_back(MapAdapter::ThreadContext(adapter, t)); dispatcher.kickMulti(&MapAdapter::ThreadContext::registerThread, &threads[0], threads.size()); } diff --git a/samples/MapPerformanceTests/MapPerformanceTests.cpp b/samples/MapPerformanceTests/MapPerformanceTests.cpp index ceead97..331aba0 100644 --- a/samples/MapPerformanceTests/MapPerformanceTests.cpp +++ b/samples/MapPerformanceTests/MapPerformanceTests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include using namespace turf::intTypes; typedef junction::extra::MapAdapter MapAdapter; @@ -70,7 +71,7 @@ struct SharedState { class ThreadState { public: - SharedState& m_shared; + SharedState* m_shared; MapAdapter::ThreadContext m_threadCtx; ureg m_threadIndex; u32 m_rangeLo; @@ -104,8 +105,8 @@ public: Stats m_stats; - ThreadState(SharedState& shared, ureg threadIndex, u32 rangeLo, u32 rangeHi) - : m_shared(shared), m_threadCtx(shared.adapter, threadIndex) { + ThreadState(SharedState* shared, ureg threadIndex, u32 rangeLo, u32 rangeHi) + : m_shared(shared), m_threadCtx(shared->adapter, threadIndex) { m_threadIndex = threadIndex; m_rangeLo = rangeLo; m_rangeHi = rangeHi; @@ -123,8 +124,8 @@ public: void initialPopulate() { TURF_ASSERT(m_addIndex == m_removeIndex); - MapAdapter::Map* map = m_shared.map; - for (ureg i = 0; i < m_shared.numKeysPerThread; i++) { + MapAdapter::Map* map = m_shared->map; + for (ureg i = 0; i < m_shared->numKeysPerThread; i++) { u32 key = m_addIndex * Prime; map->assign(key, (void*) (key & ~uptr(3))); if (++m_addIndex == m_rangeHi) @@ -133,17 +134,17 @@ public: } void run() { - MapAdapter::Map* map = m_shared.map; + MapAdapter::Map* map = m_shared->map; turf::CPUTimer::Converter converter; - Delay delay(m_shared.delayFactor); + Delay delay(m_shared->delayFactor); Stats stats; ureg lookupIndex = m_rangeLo; - ureg remaining = m_shared.itersPerChunk; + ureg remaining = m_shared->itersPerChunk; if (m_threadIndex == 0) - m_shared.spinKicker.kick(m_shared.numThreads - 1); + m_shared->spinKicker.kick(m_shared->numThreads - 1); else { remaining = ~u32(0); - m_shared.spinKicker.waitForKick(); + m_shared->spinKicker.waitForKick(); } // --------- @@ -151,7 +152,7 @@ public: for (; remaining > 0; remaining--) { // Add delay.delay(stats.workUnitsDone); - if (m_shared.doneFlag.load(turf::Relaxed)) + if (m_shared->doneFlag.load(turf::Relaxed)) break; u32 key = m_addIndex * Prime; if (key >= 2) { @@ -164,9 +165,9 @@ public: // Lookup if (s32(lookupIndex - m_removeIndex) < 0) lookupIndex = m_removeIndex; - for (ureg l = 0; l < m_shared.readsPerWrite; l++) { + for (ureg l = 0; l < m_shared->readsPerWrite; l++) { delay.delay(stats.workUnitsDone); - if (m_shared.doneFlag.load(turf::Relaxed)) + if (m_shared->doneFlag.load(turf::Relaxed)) break; key = lookupIndex * Prime; if (key >= 2) { @@ -182,7 +183,7 @@ public: // Remove delay.delay(stats.workUnitsDone); - if (m_shared.doneFlag.load(turf::Relaxed)) + if (m_shared->doneFlag.load(turf::Relaxed)) break; key = m_removeIndex * Prime; if (key >= 2) { @@ -195,9 +196,9 @@ public: // Lookup if (s32(lookupIndex - m_removeIndex) < 0) lookupIndex = m_removeIndex; - for (ureg l = 0; l < m_shared.readsPerWrite; l++) { + for (ureg l = 0; l < m_shared->readsPerWrite; l++) { delay.delay(stats.workUnitsDone); - if (m_shared.doneFlag.load(turf::Relaxed)) + if (m_shared->doneFlag.load(turf::Relaxed)) break; key = lookupIndex * Prime; if (key >= 2) { @@ -212,7 +213,7 @@ public: } } if (m_threadIndex == 0) - m_shared.doneFlag.store(1, turf::Relaxed); + m_shared->doneFlag.store(1, turf::Relaxed); m_threadCtx.update(); turf::CPUTimer::Point end = turf::CPUTimer::get(); // --------- @@ -248,7 +249,7 @@ int main(int argc, const char** argv) { for (ureg t = 0; t < numThreads; t++) { u32 rangeLo = 0xffffffffu / numThreads * t + 1; u32 rangeHi = 0xffffffffu / numThreads * (t + 1) + 1; - threads.emplace_back(shared, t, rangeLo, rangeHi); + threads.push_back(ThreadState(&shared, t, rangeLo, rangeHi)); } dispatcher.kickMulti(&ThreadState::registerThread, &threads[0], threads.size()); @@ -259,7 +260,7 @@ int main(int argc, const char** argv) { dispatcher.kickMulti(&ThreadState::initialPopulate, &threads[0], threads.size()); printf("{\n"); - printf("'mapType': '%s',\n", MapAdapter::MapName); + printf("'mapType': '%s',\n", MapAdapter::getMapName()); printf("'readsPerWrite': %d,\n", (int) readsPerWrite); printf("'itersPerChunk': %d,\n", (int) itersPerChunk); printf("'chunks': %d,\n", (int) chunks); diff --git a/samples/MapScalabilityTests/MapScalabilityTests.cpp b/samples/MapScalabilityTests/MapScalabilityTests.cpp index a9fa58b..839656f 100644 --- a/samples/MapScalabilityTests/MapScalabilityTests.cpp +++ b/samples/MapScalabilityTests/MapScalabilityTests.cpp @@ -19,6 +19,7 @@ #include #include #include +#include using namespace turf::intTypes; typedef junction::extra::MapAdapter MapAdapter; @@ -49,7 +50,7 @@ struct SharedState { class ThreadState { public: - SharedState& m_shared; + SharedState* m_shared; MapAdapter::ThreadContext m_threadCtx; ureg m_threadIndex; u32 m_rangeLo; @@ -80,8 +81,8 @@ public: Stats m_stats; - ThreadState(SharedState& shared, ureg threadIndex, u32 rangeLo, u32 rangeHi) - : m_shared(shared), m_threadCtx(shared.adapter, threadIndex) { + ThreadState(SharedState* shared, ureg threadIndex, u32 rangeLo, u32 rangeHi) + : m_shared(shared), m_threadCtx(shared->adapter, threadIndex) { m_threadIndex = threadIndex; m_rangeLo = rangeLo; m_rangeHi = rangeHi; @@ -99,8 +100,8 @@ public: void initialPopulate() { TURF_ASSERT(m_addIndex == m_removeIndex); - MapAdapter::Map* map = m_shared.map; - for (ureg i = 0; i < m_shared.numKeysPerThread; i++) { + MapAdapter::Map* map = m_shared->map; + for (ureg i = 0; i < m_shared->numKeysPerThread; i++) { u32 key = m_addIndex * Prime; if (key >= 2) map->assign(key, (void*) uptr(key)); @@ -110,23 +111,23 @@ public: } void run() { - MapAdapter::Map* map = m_shared.map; + MapAdapter::Map* map = m_shared->map; turf::CPUTimer::Converter converter; Stats stats; ureg lookupIndex = m_rangeLo; - ureg remaining = m_shared.itersPerChunk; + ureg remaining = m_shared->itersPerChunk; if (m_threadIndex == 0) - m_shared.spinKicker.kick(m_shared.numThreads - 1); + m_shared->spinKicker.kick(m_shared->numThreads - 1); else { remaining = ~u32(0); - m_shared.spinKicker.waitForKick(); + m_shared->spinKicker.waitForKick(); } // --------- turf::CPUTimer::Point start = turf::CPUTimer::get(); for (; remaining > 0; remaining--) { // Add - if (m_shared.doneFlag.load(turf::Relaxed)) + if (m_shared->doneFlag.load(turf::Relaxed)) break; u32 key = m_addIndex * Prime; if (key >= 2) { @@ -139,8 +140,8 @@ public: // Lookup if (s32(lookupIndex - m_removeIndex) < 0) lookupIndex = m_removeIndex; - for (ureg l = 0; l < m_shared.readsPerWrite; l++) { - if (m_shared.doneFlag.load(turf::Relaxed)) + for (ureg l = 0; l < m_shared->readsPerWrite; l++) { + if (m_shared->doneFlag.load(turf::Relaxed)) break; key = lookupIndex * Prime; if (key >= 2) { @@ -155,7 +156,7 @@ public: } // Remove - if (m_shared.doneFlag.load(turf::Relaxed)) + if (m_shared->doneFlag.load(turf::Relaxed)) break; key = m_removeIndex * Prime; if (key >= 2) { @@ -168,8 +169,8 @@ public: // Lookup if (s32(lookupIndex - m_removeIndex) < 0) lookupIndex = m_removeIndex; - for (ureg l = 0; l < m_shared.readsPerWrite; l++) { - if (m_shared.doneFlag.load(turf::Relaxed)) + for (ureg l = 0; l < m_shared->readsPerWrite; l++) { + if (m_shared->doneFlag.load(turf::Relaxed)) break; key = lookupIndex * Prime; if (key >= 2) { @@ -184,7 +185,7 @@ public: } } if (m_threadIndex == 0) - m_shared.doneFlag.store(1, turf::Relaxed); + m_shared->doneFlag.store(1, turf::Relaxed); m_threadCtx.update(); turf::CPUTimer::Point end = turf::CPUTimer::get(); // --------- @@ -221,7 +222,7 @@ int main(int argc, const char** argv) { for (ureg t = 0; t < numCores; t++) { u32 rangeLo = 0xffffffffu / numCores * t + 1; u32 rangeHi = 0xffffffffu / numCores * (t + 1) + 1; - threads.emplace_back(shared, t, rangeLo, rangeHi); + threads.push_back(ThreadState(&shared, t, rangeLo, rangeHi)); } dispatcher.kickOne(0, &ThreadState::registerThread, threads[0]); @@ -234,7 +235,7 @@ int main(int argc, const char** argv) { } printf("{\n"); - printf("'mapType': '%s',\n", MapAdapter::MapName); + printf("'mapType': '%s',\n", MapAdapter::getMapName()); printf("'population': %d,\n", (int) (numCores * NumKeysPerThread)); printf("'readsPerWrite': %d,\n", (int) readsPerWrite); printf("'itersPerChunk': %d,\n", (int) itersPerChunk); -- 2.34.1