From: bdemsky Date: Tue, 20 Aug 2019 21:21:46 +0000 (-0700) Subject: Remove msqueue test case X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c740f6dcf34a9afd8e3bf7a9c857cfdbc27420c8;p=c11tester.git Remove msqueue test case --- diff --git a/libcdsTest/ms-queue/.intrusive_msqueue_hp.cc b/libcdsTest/ms-queue/.intrusive_msqueue_hp.cc deleted file mode 100644 index 877f5450..00000000 --- a/libcdsTest/ms-queue/.intrusive_msqueue_hp.cc +++ /dev/null @@ -1,125 +0,0 @@ -#include "test_intrusive_msqueue.h" - -#include -#include -#include -#include -#include - -namespace ci = cds::intrusive; -typedef cds::gc::HP gc_type; - -typedef cds_test::intrusive_msqueue base_class; -typedef typename base_class::base_hook_item< ci::msqueue::node> base_item_type; -typedef typename base_class::member_hook_item< ci::msqueue::node> member_item_type; - -typedef cds_test::intrusive_msqueue::mock_disposer mock_disposer; - -template -void test( Queue& q, Data& arr ) -{ - typedef typename Queue::value_type value_type; - size_t nSize = arr.size(); - - value_type * pv; - for ( size_t i = 0; i < nSize; ++i ) - arr[i].nVal = static_cast(i); - - assert(q.empty()); - assert(q.size() == 0); - - // pop from empty queue - pv = q.pop(); - assert( pv == nullptr ); - assert( q.empty()); - assert(q.size() == 0); - - pv =q.dequeue(); - assert( pv == nullptr ); - assert( q.empty()); - assert(q.size() == 0); - - // push/pop test - for ( size_t i = 0; i < nSize; ++i ) { - if ( i & 1 ) - q.push( arr[i] ); - else - q.enqueue( arr[i] ); - assert( !q.empty()); - assert(q.size() == i+1); - } - - for ( size_t i = 0; i < nSize; ++i ) { - assert( !q.empty()); - assert( q.size() == nSize - i ); - if ( i & 1 ) - pv = q.pop(); - else - pv = q.dequeue(); - assert( pv != nullptr ); - assert( pv->nVal == i); - } - assert( q.empty()); - assert( q.size() == 0 ); - - Queue::gc::scan(); - --nSize; // last element of array is in queue yet as a dummy item - for ( size_t i = 0; i < nSize; ++i ) { - assert( arr[i].nDisposeCount == 1 ); - } - assert( arr[nSize].nDisposeCount == 0 ); - - // clear test - for ( size_t i = 0; i < nSize; ++i ) - q.push( arr[i] ); - - assert( !q.empty()); - assert( q.size() == nSize ); - - q.clear(); - assert( q.empty()); - assert( q.size() == 0 ); - - Queue::gc::scan(); - for ( size_t i = 0; i < nSize - 1; ++i ) { - printf("nDisCount (2): %d, (i) %lu\n", arr[i].nDisposeCount, i ); - } - printf("nDisCount: (1) %d\n", arr[nSize - 1].nDisposeCount ); // this element is in the queue yet - assert( arr[nSize].nDisposeCount == 1 ); -} - -int main () { - cds::Initialize(); - - { - typedef ci::MSQueue< gc_type, base_item_type > queue_type; - cds::gc::hp::GarbageCollector::Construct( queue_type::c_nHazardPtrCount, 1, 16 ); - cds::threading::Manager::attachThread(); - - { - typedef cds::intrusive::MSQueue< gc_type, base_item_type, - typename ci::msqueue::make_traits< - ci::opt::disposer< mock_disposer > - , cds::opt::item_counter< cds::atomicity::item_counter > - , ci::opt::hook< ci::msqueue::base_hook< ci::opt::gc>> - >::type - > test_queue; - - std::vector arr; - arr.resize(5); - printf("test start\n"); - { - test_queue q; - test(q, arr); - } - printf("test end\n"); - -// gc_type::scan(); -// check_array( arr ); - - } - - } - - cds::Terminate(); -} diff --git a/libcdsTest/ms-queue/Makefile b/libcdsTest/ms-queue/Makefile deleted file mode 100644 index a2b45572..00000000 --- a/libcdsTest/ms-queue/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -all: intrusive_msqueue_hp.o - -CXX = clang++ - -#%.o : %.cc -# $(CXX) -c $@ - -INCLUDE = -I. -I /scratch/benchmarks/libcds - -INCLUDE += -Xclang -load -Xclang /scratch/llvm/build/lib/libCDSPass.so -I. -I /scratch/benchmarks/libcds - -CPPFLAGS = $(INCLUDE) -g -O1 -std=c++11 - -CDSDIR=/scratch/benchmarks/libcds/build-release/bin -CDSLIB=-lcds_d -lpthread - -intrusive_msqueue_hp.o: intrusive_msqueue_hp.cc - $(CXX) -o msqueue intrusive_msqueue_hp.cc $(CPPFLAGS) -L $(CDSDIR) $(CDSLIB) - -clean: - rm -f *.o diff --git a/libcdsTest/ms-queue/intrusive_msqueue_hp.cc b/libcdsTest/ms-queue/intrusive_msqueue_hp.cc deleted file mode 100644 index 88861fd7..00000000 --- a/libcdsTest/ms-queue/intrusive_msqueue_hp.cc +++ /dev/null @@ -1,155 +0,0 @@ -#include "test_intrusive_msqueue.h" - -#include -#include -#include -#include -#include - -#define NDEBUG // disable assert() -#include -#include - -namespace ci = cds::intrusive; -typedef cds::gc::HP gc_type; - -typedef cds_test::intrusive_msqueue base_class; -typedef typename base_class::base_hook_item< ci::msqueue::node> base_item_type; -typedef typename base_class::member_hook_item< ci::msqueue::node> member_item_type; - -typedef cds_test::intrusive_msqueue::mock_disposer mock_disposer; - -std::atomic_int x; - -template -void test_enqueue( Queue& q, Data& arr ) -{ - typedef typename Queue::value_type value_type; - size_t nSize = arr.size(); - - value_type * pv; -// for ( size_t i = 0; i < nSize; ++i ) -// arr[i].nVal = static_cast(i); - - base_item_type test; - test.nVal = static_cast(4); -// arr[0].nVal = static_cast(5); - x.load(); - q.enqueue( test ); -/* - assert(q.empty()); - assert(q.size() == 0); - - // pop from empty queue -// pv = q.pop(); - assert( pv == nullptr ); - assert( q.empty()); - assert(q.size() == 0); - -// pv = q.dequeue(); - assert( pv == nullptr ); - assert( q.empty()); - assert(q.size() == 0); -*/ -/* - for ( size_t i = 0; i < nSize; ++i ) { - if ( i & 1 ) - q.push( arr[i] ); - else - q.enqueue( arr[i] ); - assert( !q.empty()); - assert(q.size() == i+1); - } -*/ -} - - -template -void test_dequeue( Queue& q, Data& arr ) -{ - typedef typename Queue::value_type value_type; - size_t nSize = arr.size(); - - value_type * pv; - - for ( size_t i = 0; i < nSize; ++i ) { - assert( !q.empty()); - assert( q.size() == nSize - i ); - if ( i & 1 ) - pv = q.pop(); - else - pv = q.dequeue(); - assert( pv != nullptr ); - assert( pv->nVal == i); - } - assert( q.empty()); - assert( q.size() == 0 ); - -/* - Queue::gc::scan(); - --nSize; // last element of array is in queue yet as a dummy item - for ( size_t i = 0; i < nSize; ++i ) { - assert( arr[i].nDisposeCount == 1 ); - } - assert( arr[nSize].nDisposeCount == 0 ); - - // clear test - for ( size_t i = 0; i < nSize; ++i ) - q.push( arr[i] ); - - assert( !q.empty()); - assert( q.size() == nSize ); - - q.clear(); - assert( q.empty()); - assert( q.size() == 0 ); - - Queue::gc::scan(); - for ( size_t i = 0; i < nSize - 1; ++i ) { - printf("nDisCount (2): %d, (i) %lu\n", arr[i].nDisposeCount, i ); - } - printf("nDisCount: (1) %d\n", arr[nSize - 1].nDisposeCount ); // this element is in the queue yet - assert( arr[nSize].nDisposeCount == 1 ); -*/ - -} - -int main () { - cds::Initialize(); - - { - typedef ci::MSQueue< gc_type, base_item_type > queue_type; - cds::gc::hp::GarbageCollector::Construct( queue_type::c_nHazardPtrCount, 1, 16 ); - cds::threading::Manager::attachThread(); - - { - typedef cds::intrusive::MSQueue< gc_type, base_item_type, - typename ci::msqueue::make_traits< - ci::opt::disposer< mock_disposer > - , cds::opt::item_counter< cds::atomicity::item_counter > - , ci::opt::hook< ci::msqueue::base_hook< ci::opt::gc>> - >::type - > test_queue; - - std::vector arr; - arr.resize(5); - printf("test start\n"); - - atomic_store_explicit(&x, 0xaaa, std::memory_order_seq_cst); - test_queue q; - test_enqueue(q, arr); - atomic_store_explicit(&x, 0xccc, std::memory_order_seq_cst); -// test_dequeue(q, arr); - atomic_store_explicit(&x, 0xbbb, std::memory_order_seq_cst); - - printf("test end\n"); - -// gc_type::scan(); -// check_array( arr ); - - } - - } - - cds::Terminate(); -} diff --git a/libcdsTest/ms-queue/msqueue b/libcdsTest/ms-queue/msqueue deleted file mode 100755 index ebafe1e4..00000000 Binary files a/libcdsTest/ms-queue/msqueue and /dev/null differ diff --git a/libcdsTest/ms-queue/msqueue2 b/libcdsTest/ms-queue/msqueue2 deleted file mode 100755 index c6121b20..00000000 Binary files a/libcdsTest/ms-queue/msqueue2 and /dev/null differ diff --git a/libcdsTest/ms-queue/script.sh b/libcdsTest/ms-queue/script.sh deleted file mode 100755 index 6080cb79..00000000 --- a/libcdsTest/ms-queue/script.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -clang++ -o msqueue2 -Xclang -load -Xclang /scratch/llvm/build/lib/libCDSPass.so intrusive_msqueue_hp.cc -I. -I /scratch/benchmarks/libcds -g -O1 -std=c++11 -L /scratch/new-fuzzer -lmodel -L /scratch/benchmarks/libcds/libcds-llvm/bin -lcds_d -lpthread - -export LD_LIBRARY_PATH=/scratch/benchmarks/libcds/libcds-llvm/bin:/scratch/new-fuzzer/ diff --git a/libcdsTest/ms-queue/test_intrusive_msqueue.h b/libcdsTest/ms-queue/test_intrusive_msqueue.h deleted file mode 100644 index 8890cd36..00000000 --- a/libcdsTest/ms-queue/test_intrusive_msqueue.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2006-2018 Maxim Khizhinsky -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef CDSUNIT_QUEUE_TEST_INTRUSIVE_MSQUEUE_H -#define CDSUNIT_QUEUE_TEST_INTRUSIVE_MSQUEUE_H - -namespace cds_test { - - class intrusive_msqueue - { - public: - template - struct base_hook_item : public Base - { - int nVal; - int nDisposeCount; - - base_hook_item() - : nDisposeCount( 0 ) - {} - - base_hook_item( base_hook_item const& s) - : nVal( s.nVal ) - , nDisposeCount( s.nDisposeCount ) - {} - }; - - template - struct member_hook_item - { - int nVal; - int nDisposeCount; - Member hMember; - - member_hook_item() - : nDisposeCount( 0 ) - {} - - member_hook_item( member_hook_item const& s ) - : nVal( s.nVal ) - , nDisposeCount( s.nDisposeCount ) - {} - }; - - struct mock_disposer - { - template - void operator ()( T * p ) - { - ++p->nDisposeCount; - } - }; - - }; - -} // namespace cds_test - -#endif // CDSUNIT_QUEUE_TEST_INTRUSIVE_MSQUEUE_H