)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sequential)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/parallel)
-#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/misc)
-#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/freelist)
-#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/map)
-#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue)
-#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/queue)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/freelist)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/queue)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stack)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/map)
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/misc)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/parallel)
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/set)
-#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/stack)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue)
add_custom_target( stress-all
DEPENDS
stress-sequential-all
- stress-parallel-all
- #stress-misc
- #stress-freelist
- #stress-map
+ stress-freelist
+ stress-queue
+ stress-stack
+ stress-map
+ stress-misc
+ #stress-parallel-all
#stress-pqueue
- #stress-queue
- #stress-stack
#stress-set
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCDSUNIT_USE_URCU")
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/delodd)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/del3)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/find_string)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_func)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_string)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_item_int)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/delodd)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/del3)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/find_string)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_func)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_string)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdel_item_int)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/insdelfind)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/minmax)
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/iter_erase)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/minmax)
+#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/iter_erase)
add_custom_target( stress-map
DEPENDS
- stress-map-delodd
- stress-map-del3
- stress-map-find-string
- stress-map-insdel-func
- stress-map-insdel-string
- stress-map-insdel-item-int
+ #stress-map-delodd
+ #stress-map-del3
+ #stress-map-find-string
+ #stress-map-insdel-func
+ #stress-map-insdel-string
+ #stress-map-insdel-item-int
stress-map-insdelfind
- stress-map-minmax
- stress-map-iter-erase
+ #stress-map-minmax
+ #stress-map-iter-erase
)
set(CDSSTRESS_MAP_INSDELFIND_HP_SOURCES
../../main.cpp
map_insdelfind.cpp
- map_insdelfind_cuckoo.cpp
+ #map_insdelfind_cuckoo.cpp
map_insdelfind_ellentree_hp.cpp
map_insdelfind_feldman_hashset_hp.cpp
map_insdelfind_michael_hp.cpp
map_insdelfind_skip_hp.cpp
map_insdelfind_split_hp.cpp
- map_insdelfind_std.cpp
- map_insdelfind_striped.cpp
+ #map_insdelfind_std.cpp
+ #map_insdelfind_striped.cpp
)
set(CDSSTRESS_MAP_INSDELFIND_RCU_SOURCES
../../main.cpp
map_insdelfind.cpp
- map_insdelfind_bronsonavltree.cpp
+ #map_insdelfind_bronsonavltree.cpp
map_insdelfind_ellentree_rcu.cpp
map_insdelfind_feldman_hashset_rcu.cpp
map_insdelfind_michael_rcu.cpp
size_t Map_InsDelFind::s_nMapSize = 500000;
size_t Map_InsDelFind::s_nThreadCount = 8;
+ size_t Map_InsDelFind::s_nPassCount = 100000;
size_t Map_InsDelFind::s_nMaxLoadFactor = 8;
unsigned int Map_InsDelFind::s_nInsertPercentage = 5;
unsigned int Map_InsDelFind::s_nDeletePercentage = 5;
if ( s_nThreadCount == 0 )
s_nThreadCount = std::min( 16u, std::thread::hardware_concurrency() * 2 );
+ s_nPassCount = cfg.get_size_t( "PassCount", s_nPassCount );
+ if ( s_nPassCount == 0 )
+ s_nThreadCount = 1000;
+
s_nMaxLoadFactor = cfg.get_size_t( "MaxLoadFactor", s_nMaxLoadFactor );
if ( s_nMaxLoadFactor == 0 )
s_nMaxLoadFactor = 1;
public:
static size_t s_nMapSize; // initial map size
static size_t s_nThreadCount; // thread count
+ static size_t s_nPassCount; // pass count
static size_t s_nMaxLoadFactor; // maximum load factor
static unsigned int s_nInsertPercentage;
static unsigned int s_nDeletePercentage;
size_t const nNormalize = size_t(-1) / ( s_nMapSize * 2 );
size_t nRand = 0;
- while ( !time_elapsed()) {
+ for (size_t pCount; pCount < s_nPassCount; pCount++) {
nRand = cds::bitop::RandXorShift( nRand );
size_t n = nRand / nNormalize;
switch ( s_arrShuffle[i] ) {
<< std::make_pair( "delete_percentage", s_nDeletePercentage )
<< std::make_pair( "map_size", s_nMapSize );
- std::chrono::milliseconds duration = pool.run( std::chrono::seconds( s_nDuration ));
+ std::chrono::milliseconds duration = pool.run();
propout() << std::make_pair( "duration", duration );
typedef cds_others::SpinBarrier Barrier;
-static size_t s_nBarrierThreadCount = 6;
+static size_t s_nBarrierThreadCount = 4;
static size_t s_nBarrierPassCount = 100000000;
class BarrierTest : public cds_test::stress_fixture {
namespace {
typedef cds_others::ChaseLevDeque Deque;
-static size_t s_nDequeStealerThreadCount = 5;
+static size_t s_nDequeStealerThreadCount = 3;
static size_t s_nDequeMainPassCount = 100000000;
class ChaseLevDequeTest : public cds_test::stress_fixture {
static void StealerThread(int index) {
while (!terminate_stealer.load(memory_order_relaxed)) {
- int res = deque->steal();
- if (res != EMPTY && res != ABORT) {
- sums[index] += res;
- succ_counts[index]++;
+ while (true) {
+ int res = deque->steal();
+ if (res != EMPTY && res != ABORT) {
+ sums[index] += res;
+ succ_counts[index]++;
+ } else {
+ break;
+ }
}
}
}
namespace {
-static size_t s_nMCSLockThreadCount = 6;
+static size_t s_nMCSLockThreadCount = 4;
static size_t s_nMCSLockPassCount = 3000000;
class MCSLockTest : public cds_test::stress_fixture {
namespace {
-static size_t s_nRWLockThreadCount = 6;
+static size_t s_nRWLockThreadCount = 4;
static size_t s_nRWLockPassCount = 200000;
typedef cds_others::RWLock RWLock;
+++ /dev/null
-#include <cds/container/rwqueue.h>
-#include <cstdlib>
-#include <ctime>
-#include <iostream>
-#include <string>
-
-using namespace std;
-
-cds::container::RWQueue<int> queue;
-
-void InitQueue() {
- for (int i = 0; i < 2000000; i++) {
- queue.enqueue(rand() % 100);
- }
-}
-
-void ProducerThread() {
- for (int i = 0; i < 1000000; i++) {
- for (int j = 0; j < 50; j++) {
- queue.enqueue(rand() % 100);
- }
- }
-}
-
-void ProducerConsumerThread() {
- unsigned long long sum = 0;
- int element;
- for (int i = 0; i < 1000000; i++) {
- for (int j = 0; j < 50; j++) {
- if (!queue.empty() && queue.dequeue(element)) {
- sum += element;
- }
- if (j % 2 == 0) {
- queue.enqueue(rand() % 100);
- }
- }
- }
-}
-
-void ConsumerThread() {
- int element;
- unsigned long long sum = 0;
- int yield_times = 3;
- while (yield_times > 0) {
- while (queue.dequeue(element)) {
- sum += element;
- yield_times = 3;
- }
- std::this_thread::yield();
- yield_times--;
- }
-}
-
-int main() {
- srand(time(NULL));
- const int kThreads = 6;
- // Initialize the queue with some elements.
- InitQueue();
- cout << "Starting " << kThreads << " threads for RWQueue...\n";
-
- struct timespec start, finish;
- double elapsed = 0.0;
- clock_gettime(CLOCK_MONOTONIC, &start);
-
- std::thread threads[kThreads];
- // Producer thread
- threads[0] = std::thread(ProducerThread);
- // ProducerConsumer threads
- for (int i = 1; i < kThreads; i++) {
- threads[i] = std::thread(ProducerConsumerThread);
- }
-
- for (int i = 0; i < kThreads; i++) {
- threads[i].join();
- }
-
- clock_gettime(CLOCK_MONOTONIC, &finish);
- elapsed = (finish.tv_sec - start.tv_sec);
- elapsed += (finish.tv_nsec - start.tv_nsec) / 1000000000.0;
- cout << "All threads finished.\n";
- cout << "Time: " << elapsed << " seconds\n";
- return 0;
-}
typedef cds_others::SeqLock SeqLock;
-static size_t s_nSeqLockReaderWriterThreadCount = 6;
+static size_t s_nSeqLockReaderWriterThreadCount = 4;
static size_t s_nSeqLockPassCount = 2000000;
class SeqLockTest : public cds_test::stress_fixture {
typedef cds::sync::spin SpinLock;
typedef cds::sync::reentrant_spin32 Reentrant32;
typedef cds::sync::reentrant_spin64 Reentrant64;
-static size_t s_nSpinLockThreadCount = 6;
+static size_t s_nSpinLockThreadCount = 4;
static size_t s_nSpinLockPassCount = 2500000000;
static size_t s_nTicketLockPassCount = 4000000;
public:
static void SetUpTestCase()
{
- cds_test::config const& cfg = get_config( "SequentialFreeList" );
+ cds_test::config const& cfg = get_config( "ParallelFreeList" );
+ s_nThreadCount = cfg.get_size_t( "ThreadCount", s_nThreadCount );
s_nPassCount = cfg.get_size_t( "PassCount", s_nPassCount );
- s_nThreadCount = 1;
+ if ( s_nThreadCount == 0 )
+ s_nThreadCount = 1;
if ( s_nPassCount == 0 )
s_nPassCount = 1000;
}
for ( auto& i : arr )
list.put( &i );
- std::unique_ptr<Worker<FreeList>> worker(
- new Worker<FreeList>(pool, list));
- worker->test();
+ pool.add( new Worker<FreeList>( pool, list ), s_nThreadCount );
+
+ propout() << std::make_pair( "work_thread", s_nThreadCount )
+ << std::make_pair( "pass_count", s_nPassCount );
+
+ std::chrono::milliseconds duration = pool.run();
+
+ propout() << std::make_pair( "duration", duration );
// analyze result
size_t nTotal = 0;
for ( auto const& i : arr )
nTotal += i.counter;
- EXPECT_EQ( worker->m_nSuccess, nTotal );
+ size_t nSuccess = 0;
+ for ( size_t threadNo = 0; threadNo < pool.size(); ++threadNo )
+ nSuccess += static_cast<Worker<FreeList>&>( pool.get( threadNo )).m_nSuccess;
+
+ EXPECT_EQ( nSuccess, nTotal );
list.clear( []( typename FreeList::node* ) {} );
}
};
- size_t put_get::s_nThreadCount = 1;
+ size_t put_get::s_nThreadCount = 4;
size_t put_get::s_nPassCount = 100000;
-#define CDSSTRESS_FREELIST_F(name, freelist_type) \
- TEST_F(put_get, name) { \
- std::unique_ptr<freelist_type> fl(new freelist_type()); \
- test(*fl); \
- }
+#define CDSSTRESS_FREELIST_F( name, freelist_type ) \
+ TEST_F( put_get, name ) \
+ { \
+ freelist_type fl; \
+ test( fl ); \
+ }
CDSSTRESS_FREELIST_F( FreeList, cds::intrusive::FreeList )
atomics::atomic<tagged_ptr> tp;
if ( tp.is_lock_free()) {
- using FL = cds::intrusive::TaggedFreeList;
- std::unique_ptr<FL> fl(new FL());
- test( *fl );
+ cds::intrusive::TaggedFreeList fl;
+ test( fl );
}
else
std::cout << "Double-width CAS is not supported\n";
for ( size_t pass = 0; pass < s_nPassCount; ++pass ) {
item_type* p;
while ( (p = static_cast<item_type*>( m_FreeList.get())) == nullptr );
+ p->counter.fetch_add( 1, atomics::memory_order_relaxed );
m_FreeList.put( p );
}
}
{
cds_test::config const& cfg = get_config( "SequentialFreeList" );
- s_nPassCount = cfg.get_size_t( "SinglePassCount", s_nPassCount );
+ s_nThreadCount = cfg.get_size_t( "ThreadCount", s_nThreadCount );
+ s_nPassCount = cfg.get_size_t( "PassCount", s_nPassCount );
- s_nThreadCount = 1;
+ if ( s_nThreadCount == 0 )
+ s_nThreadCount = 1;
if ( s_nPassCount == 0 )
s_nPassCount = 1000;
}
list.put( &item );
pool.add( new Worker<FreeList>( pool, list ), s_nThreadCount );
- std::unique_ptr<Worker<FreeList>> worker(
- new Worker<FreeList>(pool, list));
- worker->test();
+
+ propout() << std::make_pair( "work_thread", s_nThreadCount )
+ << std::make_pair( "pass_count", s_nPassCount );
+
+ std::chrono::milliseconds duration = pool.run();
+
+ propout() << std::make_pair( "duration", duration );
+
+ // analyze result
+ EXPECT_EQ( item.counter.load( atomics::memory_order_relaxed ), s_nPassCount * s_nThreadCount );
+
list.clear( []( typename FreeList::node* ) {} );
}
};
- size_t put_get_single::s_nThreadCount = 1;
+ size_t put_get_single::s_nThreadCount = 4;
size_t put_get_single::s_nPassCount = 100000;
-#define CDSSTRESS_FREELIST_F(name, freelist_type) \
- TEST_F(put_get_single, name) { \
- std::unique_ptr<freelist_type> fl(new freelist_type()); \
- test(*fl); \
- }
+#define CDSSTRESS_FREELIST_F( name, freelist_type ) \
+ TEST_F( put_get_single, name ) \
+ { \
+ freelist_type fl; \
+ test( fl ); \
+ }
CDSSTRESS_FREELIST_F( FreeList, cds::intrusive::FreeList )
atomics::atomic<tagged_ptr> tp;
if ( tp.is_lock_free()) {
- using FL = cds::intrusive::TaggedFreeList;
- std::unique_ptr<FL> fl(new FL());
- test( *fl );
+ cds::intrusive::TaggedFreeList fl;
+ test( fl );
}
else
std::cout << "Double-width CAS is not supported\n";
../main.cpp
pop.cpp
)
-add_executable(${CDSSTRESS_QUEUE_POP} ${CDSSTRESS_QUEUE_POP_SOURCES})
-target_link_libraries(${CDSSTRESS_QUEUE_POP} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
-add_test(NAME ${CDSSTRESS_QUEUE_POP} COMMAND ${CDSSTRESS_QUEUE_POP} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+#add_executable(${CDSSTRESS_QUEUE_POP} ${CDSSTRESS_QUEUE_POP_SOURCES})
+#target_link_libraries(${CDSSTRESS_QUEUE_POP} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
+#add_test(NAME ${CDSSTRESS_QUEUE_POP} COMMAND ${CDSSTRESS_QUEUE_POP} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
# stress-queue-push
set(CDSSTRESS_QUEUE_PUSH stress-queue-push)
../main.cpp
push.cpp
)
-add_executable(${CDSSTRESS_QUEUE_PUSH} ${CDSSTRESS_QUEUE_PUSH_SOURCES})
-target_link_libraries(${CDSSTRESS_QUEUE_PUSH} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
-add_test(NAME ${CDSSTRESS_QUEUE_PUSH} COMMAND ${CDSSTRESS_QUEUE_PUSH} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+#add_executable(${CDSSTRESS_QUEUE_PUSH} ${CDSSTRESS_QUEUE_PUSH_SOURCES})
+#target_link_libraries(${CDSSTRESS_QUEUE_PUSH} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
+#add_test(NAME ${CDSSTRESS_QUEUE_PUSH} COMMAND ${CDSSTRESS_QUEUE_PUSH} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
# stress-queue-push-pop
set(CDSSTRESS_QUEUE_PUSHPOP stress-queue-push-pop)
push_pop.cpp
#intrusive_push_pop.cpp
)
-add_executable(${CDSSTRESS_QUEUE_PUSHPOP} ${CDSSTRESS_QUEUE_PUSHPOP_SOURCES})
-target_link_libraries(${CDSSTRESS_QUEUE_PUSHPOP} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
-add_test(NAME ${CDSSTRESS_QUEUE_PUSHPOP} COMMAND ${CDSSTRESS_QUEUE_PUSHPOP} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+#add_executable(${CDSSTRESS_QUEUE_PUSHPOP} ${CDSSTRESS_QUEUE_PUSHPOP_SOURCES})
+#target_link_libraries(${CDSSTRESS_QUEUE_PUSHPOP} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
+#add_test(NAME ${CDSSTRESS_QUEUE_PUSHPOP} COMMAND ${CDSSTRESS_QUEUE_PUSHPOP} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
# stress-queue-random
set(CDSSTRESS_QUEUE_RANDOM stress-queue-random)
spsc_queue.cpp
spsc_buffer.cpp
)
-add_executable(${CDSSTRESS_SPSC_QUEUE} ${CDSSTRESS_SPSC_QUEUE_SOURCES})
-target_link_libraries(${CDSSTRESS_SPSC_QUEUE} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
-add_test(NAME ${CDSSTRESS_SPSC_QUEUE} COMMAND ${CDSSTRESS_SPSC_QUEUE} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+#add_executable(${CDSSTRESS_SPSC_QUEUE} ${CDSSTRESS_SPSC_QUEUE_SOURCES})
+#target_link_libraries(${CDSSTRESS_SPSC_QUEUE} ${CDS_TEST_LIBRARIES} ${CDSSTRESS_FRAMEWORK_LIBRARY})
+#add_test(NAME ${CDSSTRESS_SPSC_QUEUE} COMMAND ${CDSSTRESS_SPSC_QUEUE} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
# stress-queue
../main.cpp
#intrusive_push_pop.cpp
#intrusive_push_pop_fcstack.cpp
- push.cpp
+ #push.cpp
push_pop.cpp
)