|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57029 - in sandbox/stm/branches/vbe: boost/stm/non_tx boost/stm/non_tx/detail libs/stm/example libs/stm/src libs/stm/test
From: vicente.botet_at_[hidden]
Date: 2009-10-20 20:09:37
Author: viboes
Date: 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
New Revision: 57029
URL: http://svn.boost.org/trac/boost/changeset/57029
Log:
TBoost.STM vbe: Fix non_tx_counter test
Text files modified:
sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp | 7 ++++++-
sandbox/stm/branches/vbe/boost/stm/non_tx/numeric.hpp | 9 +++++----
sandbox/stm/branches/vbe/boost/stm/non_tx/smart_ptr.hpp | 4 +---
sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp | 28 ++++++++++++++--------------
sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp | 1 +
sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 | 27 ++++++++++++++++-----------
6 files changed, 43 insertions(+), 33 deletions(-)
Modified: sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
@@ -19,6 +19,7 @@
#include <map>
#include <boost/stm/base_transaction_object.hpp>
#include <boost/stm/cache_fct.hpp>
+#include <boost/stm/synchro.hpp>
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
@@ -56,7 +57,8 @@
}
inline T * get() {
- return ptr_;
+ if(ptr_!=0) return ptr_;
+ else return value_;
}
#if BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER
@@ -139,10 +141,12 @@
//-----------------------------------------------------------------------------
class cache_map {
typedef std::map<void*, base_transaction_object*> map_type;
+ static Mutex mtx_;
static std::map<void*, base_transaction_object*> map_;
public:
template <typename T>
static cache<T>* get(T* ptr) {
+ synchro::lock_guard<Mutex> lk(mtx_);
map_type::iterator it = map_.find(ptr);
cache<T>* res=0;
if (it == map_.end()) {
@@ -155,6 +159,7 @@
}
template <typename T>
static cache<T>* get(T const* ptr) {
+ synchro::lock_guard<Mutex> lk(mtx_);
map_type::iterator it = map_.find(const_cast<T*>(ptr));
cache<T>* res=0;
if (it == map_.end()) {
Modified: sandbox/stm/branches/vbe/boost/stm/non_tx/numeric.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/non_tx/numeric.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/non_tx/numeric.hpp 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
@@ -22,12 +22,13 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-namespace boost { namespace stm {
-namespace non_tx {
-
+namespace boost { namespace stm { namespace non_tx {
//-----------------------------------------------------------------------------
-// class numeric wraps a transactional_object providing builting operators
+// class numeric wraps a numeric builtin type providing
+// a transactional view on a transactional context
+// a non-transactional view on a non-transactional context
+// Note: the sizeof(numeric<T>)==sizeof(T)
//-----------------------------------------------------------------------------
template <typename T>
Modified: sandbox/stm/branches/vbe/boost/stm/non_tx/smart_ptr.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/non_tx/smart_ptr.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/non_tx/smart_ptr.hpp 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
@@ -184,14 +184,12 @@
}
}
- return &ptr_->value;
+ return ptr_->get();
}
inline T const & operator*() const { return *get(); }
inline T const * operator->() const { return get(); }
- //operator const T*() const { return get(); }
-
typedef detail::cache<T>* this_type::*unspecified_bool_type;
inline operator unspecified_bool_type() const {
Modified: sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/example/non_tx_counter.cpp 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
@@ -27,59 +27,59 @@
void inc() {
thread_initializer thi;
- use_atomic(t) {
+ atomic(t) {
non_tx::wr_ptr<int> tx_counter(t, counter);
++(*tx_counter);
- }
+ } end_atom
}
void decr() {
thread_initializer thi;
- use_atomic(_) {
+ atomic(_) {
non_tx::wr_ptr<int> tx_counter(_, counter);
--(*tx_counter);
- }
+ } end_atom
}
bool check(int val) {
//thread_initializer thi;
bool res;
- use_atomic(_) {
+ atomic(_) {
non_tx::rd_ptr<int> tx_counter(_, counter);
res =(*tx_counter==val);
- }
+ } end_atom
return res;
}
bool assign() {
//thread_initializer thi;
- use_atomic(_) {
+ atomic(_) {
non_tx::wr_ptr<int> tx_counter(_, counter);
non_tx::wr_ptr<int> tx_counter2(_, counter2);
*tx_counter=1;
*tx_counter2=*tx_counter;
- }
+ } end_atom
bool res;
- use_atomic(_) {
+ atomic(_) {
non_tx::rd_ptr<int> tx_counter(_, counter);
non_tx::rd_ptr<int> tx_counter2(_, counter2);
res =(*tx_counter==1) && (*tx_counter2==1) && (tx_counter==tx_counter2) ;
- }
+ } end_atom
return res;
}
bool test_const(int const& c) {
//thread_initializer thi;
- use_atomic(_) {
+ atomic(_) {
non_tx::rd_ptr<int> tx_c(_, c);
non_tx::wr_ptr<int> tx_counter2(_, counter2);
*tx_counter2=*tx_c;
- }
+ } end_atom
bool res;
- use_atomic(_) {
+ atomic(_) {
non_tx::rd_ptr<int> tx_c(_, c);
non_tx::wr_ptr<int> tx_counter2(_, counter2);
res =(*tx_c==*tx_counter2) ;
- }
+ } end_atom
return res;
}
Modified: sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp (original)
+++ sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
@@ -21,6 +21,7 @@
namespace boost { namespace stm {
namespace non_tx {
std::map<void*, base_transaction_object*> detail::cache_map::map_;
+ Mutex detail::cache_map::mtx_=PTHREAD_MUTEX_INITIALIZER;
}
Modified: sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2
==============================================================================
--- sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 (original)
+++ sandbox/stm/branches/vbe/libs/stm/test/Jamfile.v2 2009-10-20 20:09:36 EDT (Tue, 20 Oct 2009)
@@ -44,7 +44,7 @@
: stm.cpp testatom.cpp pointer_test.cpp smart.cpp globalIntArr.cpp testHashMapAndLinkedListsWithLocks.cpp irrevocableInt.cpp testHashMapWithLocks.cpp isolatedComposedIntLockInTx.cpp testInt.cpp isolatedComposedIntLockInTx2.cpp testLL_latm.cpp isolatedInt.cpp testLinkedList.cpp isolatedIntLockInTx.cpp testLinkedListWithLocks.cpp litExample.cpp testPerson.cpp lotExample.cpp testRBTree.cpp transferFun.cpp nestedTxs.cpp txLinearLock.cpp testHT_latm.cpp usingLockTx.cpp testHashMap.cpp
;
- test-suite "tests"
+ test-suite "draco"
:
[ run test_default.cpp .//all_my_tests/<link>static ]
@@ -79,31 +79,31 @@
#assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
########### deadlock. without CHECK
#[ run test_tx_linear_lock_dir_t2.cpp .//all_my_tests/<link>static ]
-
+
########### deadlock. killed after 0:26. 00% CPU
# assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
# 19469 [sig] test_tx_linear_lock_def_t2 3768 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)
#[ run test_tx_linear_lock_def_t2.cpp .//all_my_tests/<link>static ]
[ run test_isolated_int_lock_dir_t2.cpp .//all_my_tests/<link>static ]
-
+
########### deadlock. killed after 0:26. 00% CPU
#[ run test_isolated_int_lock_def_t2.cpp .//all_my_tests/<link>static ]
########### deadlock. killed after 0:20. 00% CPU
#[ run test_isolated_composed_int_lock_dir_t2.cpp .//all_my_tests/<link>static ]
-
+
########### fails
# /bin/sh: line 4: 3660 Segmentation fault (core dumped) "bin/test_isolated_composed_int_lock_def_t2.test/gcc-3.4.4/debug/threading-multi/test_isolated_composed_int_lock_def_t2.exe" > "bin/test_isolated_composed_int_lock_def_t2.test/gcc-3.4.4/debug/threading-multi/test_isolated_composed_int_lock_def_t2.output" 2>&1
# assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
#[ run test_isolated_composed_int_lock_def_t2.cpp .//all_my_tests/<link>static ]
-
+
########### fails
# /bin/sh: line 4: 3172 Aborted (core dumped) "bin/test_isolated_composed_int_lock2_dir_t2.test/gcc-3.4.4/debug/threading-multi/test_isolated_composed_int_lock2_dir_t2.exe" > "bin/test_isolated_composed_int_lock2_dir_t2.test/gcc-3.4.4/debug/threading-multi/test_isolated_composed_int_lock2_dir_t2.output" 2>&1
#assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
# 11 [sig] test_isolated_composed_int_lock_def_t2 3660 _cygtls::handle_except ions: Error while dumping state (probably corrupted stack)
[ run test_isolated_composed_int_lock2_dir_t2.cpp .//all_my_tests/<link>static ]
-
+
########### fails
# /bin/sh: line 4: 3172 Aborted (core dumped) "bin/test_isolated_composed_int_lock2_dir_t2.test/gcc-3.4.4/debug/threading-multi/test_isolated_composed_int_lock2_dir_t2.exe" > "bin/test_isolated_composed_int_lock2_dir_t2.test/gcc-3.4.4/debug/threading-multi/test_isolated_composed_int_lock2_dir_t2.output" 2>&1
# ====== BEGIN OUTPUT ======
@@ -120,7 +120,7 @@
########### deadlock. killed after 0:40. 00% CPU
#[ run test_lit_dir_t2.cpp .//all_my_tests/<link>static ]
-
+
########### fails with CHECK
# /bin/sh: line 4: 4072 Aborted (core dumped) "bin/test_lit_def_t2.test/gcc-3.4.4/debug/threading-multi/test_lit_def_t2.exe" > "bin/test_lit_def_t2.test/gcc-3.4.4/debug/threading-multi/test_lit_def_t2.output" 2>&1
########### deadlock sometimes without CHECK. killed after 0:40. 00% CPU
@@ -147,25 +147,30 @@
[ run test_hashmap_w_locks_dir_t2.cpp .//all_my_tests/<link>static ]
-
+
########### fails
# assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
[ run test_hashmap_w_locks_def_t2.cpp .//all_my_tests/<link>static ]
[ run test_list_hash_w_locks_dir_t2.cpp .//all_my_tests/<link>static ]
########### fails
- # assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
+ # assertion "res==0" failed: file "../../../boost/synchro/pthread/mutex.hpp", line 40
[ run test_list_hash_w_locks_def_t2.cpp .//all_my_tests/<link>static ]
+ ;
+ test-suite "examples"
+ :
[ run ../example/bank.cpp ]
########### fails
+ # /bin/sh: line 4: 2656 Segmentation fault (core dumped) "bin/list.test/gcc-3.4.4/debug/threading-multi/list.exe" > "bin/list.test/gcc-3.4.4/debug/threading-multi/list.output" 2>&1
#[ run ../example/list.cpp ]
-
+
[ run ../example/counter.cpp ]
[ run ../example/numeric.cpp ]
[ run ../example/counter_ptr.cpp ]
########### fails
- #[ run ../example/non_tx_counter.cpp ]
+ # /bin/sh: line 4: 2084 Segmentation fault (core dumped) "bin/non_tx_counter.test/gcc-3.4.4/debug/threading-multi/non_tx_counter.exe" > "bin/non_tx_counter.test/gcc-3.4.4/debug/threading-multi/non_tx_counter.output" 2>&1
+ [ run ../example/non_tx_counter.cpp ]
;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk