Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57568 - in sandbox/stm/branches/vbe: boost/stm boost/stm/detail boost/stm/non_tx/detail boost/stm/tx boost/stm/txw libs/stm/src
From: vicente.botet_at_[hidden]
Date: 2009-11-11 10:58:30


Author: viboes
Date: 2009-11-11 10:58:29 EST (Wed, 11 Nov 2009)
New Revision: 57568
URL: http://svn.boost.org/trac/boost/changeset/57568

Log:
TBoost.STM vbe: use of memory_manager and reorganization of config.hpp file

Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 85 +++++++++++++++++++++++++++++++++------
   sandbox/stm/branches/vbe/boost/stm/non_tx/detail/cache_map.hpp | 6 +-
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 12 ++++-
   sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp | 25 +---------
   sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp | 4
   sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp | 22 ---------
   sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp | 8 ---
   7 files changed, 92 insertions(+), 70 deletions(-)

Modified: sandbox/stm/branches/vbe/boost/stm/detail/config.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/config.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/config.hpp 2009-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -22,18 +22,22 @@
 #define UNIX
 #endif
 
-//#define DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
+
+///////////////////////////////////////////////////////////////////////////////
+// LOGGING
 //#define LOGGING_COMMITS_AND_ABORTS 1
+//#define LOGGING_BLOCKS 1
+
+
+///////////////////////////////////////////////////////////////////////////////
+//#define DELAY_INVALIDATION_DOOMED_TXS_UNTIL_COMMIT
 //#define PERFORMING_VALIDATION 1
-#define PERFORMING_LATM 1
 #define PERFORMING_COMPOSITION 1
-#define USE_STM_MEMORY_MANAGER 1
-#define BUILD_MOVE_SEMANTICS 0
+#define PERFORMING_LATM 1
 #define USING_TRANSACTION_SPECIFIC_LATM 1
-#define USE_BLOOM_FILTER 1
-#define PERFORMING_WRITE_BLOOM 1
 //#define ALWAYS_ALLOW_ABORT 1
-//#define LOGGING_BLOCKS 1
+#define USING_SHARED_FORCED_TO_ABORT 1
+
 
 ///////////////////////////////////////////////////////////////////////////////
 // The cache can be structured in different ways. Define ony one of
@@ -41,7 +45,7 @@
 // BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP: use of common tss_context as TSS
 // OTHER: each TSS data has its specific TSS
 
-//#define USE_SINGLE_THREAD_CONTEXT_MAP 1
+#define USE_SINGLE_THREAD_CONTEXT_MAP 1
 //#define BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP 1
 
 
@@ -70,28 +74,76 @@
 #define BOOST_STM_CM_STATIC_MAX_INCREASES 0
 
 ///////////////////////////////////////////////////////////////////////////////
-// BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER
-//#define BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER 1
+// OPTIMIZATIONS: MEMORY MANAGERS
+// Define only one of
+//// BOOST_STM_USE_DEFAULT_MEMORY_MANAGER: uses the global memory manager
+//// BOOST_STM_USE_GLOBAL_MEMORY_MANAGER: uses the global memory manager
+//// BOOST_STM_USE_CLASS_MEMORY_MANAGER: uses the class specific memory manager
+
+//#define BOOST_STM_USE_DEFAULT_MEMORY_MANAGER 1
+#define BOOST_STM_USE_GLOBAL_MEMORY_MANAGER 1
+//#define BOOST_STM_USE_CLASS_MEMORY_MANAGER 1
+
+#if (defined(BOOST_STM_USE_DEFAULT_MEMORY_MANAGER) && defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER)) || \
+ (defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER) && defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER)) || \
+ (defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER) && defined(BOOST_STM_USE_DEFAULT_MEMORY_MANAGER))
+#error only one of BOOST_STM_USE_DEFAULT_MEMORY_MANAGER, BOOST_STM_USE_GLOBAL_MEMORY_MANAGER or BOOST_STM_USE_CLASS_MEMORY_MANAGER can be defined
+#endif
+
+// Define BOOST_STM_USE_MEMORY_MANAGER if you use BOOST_STM_USE_GLOBAL_MEMORY_MANAGER or BOOST_STM_USE_CLASS_MEMORY_MANAGER
+#if defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER) || defined(BOOST_STM_USE_CLASS_MEMORY_MANAGER)
+#define BOOST_STM_USE_MEMORY_MANAGER 1
+#define USE_STM_MEMORY_MANAGER 1
+#endif
 
+///////////////////////////////////////////////////////////////////////////////
+// BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER
 //// The cache using BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER can use the following memory managers
 //// BOOST_STM_CACHE_USE_MALLOC: uses malloc/free
-//// BOOST_STM_CACHE_USE_MEMORY_MANAGER: uses the class specific memory manager
+//// BOOST_STM_CACHE_USE_GLOBAL_MEMORY_MANAGER: uses the global memory manager
+//// BOOST_STM_CACHE_USE_CLASS_MEMORY_MANAGER: uses the class specific memory manager
 //// BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER: uses the monotonic storage memory manager
 
-#define BOOST_STM_CACHE_USE_MALLOC 1
+//#define BOOST_STM_CACHE_USE_MALLOC 1
+#if defined(BOOST_STM_USE_GLOBAL_MEMORY_MANAGER)
 //#define BOOST_STM_CACHE_USE_MEMORY_MANAGER 1
+#endif
+//#define BOOST_STM_CACHE_USE_CLASS_MEMORY_MANAGER 1
+#if defined(USE_SINGLE_THREAD_CONTEXT_MAP)
 //#define BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER 1
+#endif
+
+#if defined(BOOST_STM_CACHE_USE_MALLOC) || defined(BOOST_STM_CACHE_USE_MEMORY_MANAGER) || defined(BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER)
+#define BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER 1
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// OPTIMIZATIONS: BLOOM FILTERS
+///////////////////////////////////////////////////////////////////////////////
+// define USE_BLOOM_FILTER if you want STM uses Bloom filters for read set
+#define USE_BLOOM_FILTER 1
+///////////////////////////////////////////////////////////////////////////////
+// define PERFORMING_WRITE_BLOOM if you want STM uses Bloom filters for write set
+#define PERFORMING_WRITE_BLOOM 1
 
 #ifdef USE_BLOOM_FILTER
 #define DISABLE_READ_SETS 1
 #endif
 
+///////////////////////////////////////////////////////////////////////////////
+// OPTIMIZATIONS: MAPS AND SETS
+///////////////////////////////////////////////////////////////////////////////
+// define MAP_WRITE_CONTAINER if you want STM uses flat map for write map
 #define MAP_WRITE_CONTAINER 1
+///////////////////////////////////////////////////////////////////////////////
+// define MAP_NEW_CONTAINER if you want STM uses flat map for new set
 //#define MAP_NEW_CONTAINER 1
+///////////////////////////////////////////////////////////////////////////////
+// define MAP_THREAD_MUTEX_CONTAINER if you want STM uses flat map for thread mutex set
 //#define MAP_THREAD_MUTEX_CONTAINER 1
+///////////////////////////////////////////////////////////////////////////////
+// define MAP_THREAD_BOOL_CONTAINER if you want STM uses flat map for thread bool set
 #define MAP_THREAD_BOOL_CONTAINER 1
-#define USING_SHARED_FORCED_TO_ABORT 1
-
 
 ///////////////////////////////////////////////////////////////////////////////
 // Define BOOST_STM_USE_BOOST when you want STM uses BOOST internally
@@ -105,7 +157,12 @@
 //#define BOOST_STM_USE_BOOST_MUTEX 1
 #endif
 
+///////////////////////////////////////////////////////////////////////////////
+// COMPILERS DEPENDENT
+///////////////////////////////////////////////////////////////////////////////
 #define BOOST_STM_NO_PARTIAL_SPECIALIZATION 1
+///////////////////////////////////////////////////////////////////////////////
+#define BUILD_MOVE_SEMANTICS 0
 
 ///////////////////////////////////////////////////////////////////////////////
 // Define BOOST_STM_ALLOWS_EMBEDEEDS when you want embeed TO

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-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -38,13 +38,13 @@
 
 template <typename T>
 class cache : public
-#ifdef USE_STM_MEMORY_MANAGER2
+#ifdef USE_STM_MEMORY_MANAGER
     memory_manager<cache<T>, base_transaction_object>
 #else
     base_transaction_object
 #endif
 {
-#ifdef USE_STM_MEMORY_MANAGER2
+#ifdef USE_STM_MEMORY_MANAGER
     typedef memory_manager<cache<T>, base_transaction_object> base_type;
 #else
     typedef base_transaction_object base_type;
@@ -115,7 +115,7 @@
         ptr_=0;
     }
 
-#if USE_STM_MEMORY_MANAGER
+#if USE_STM_MEMORY_MANAGER2
    void* operator new(std::size_t size, const std::nothrow_t&) throw ()
    {
       return base_memory_manager::retrieve_mem(size);

Modified: sandbox/stm/branches/vbe/boost/stm/transaction.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction.hpp 2009-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -1543,8 +1543,9 @@
 ////////////////////////////////////////
 #ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
 ////////////////////////////////////////
+//public:
     tx_context &context_;
-
+//private:
 #ifdef BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS
     mutable WriteContainer *write_list_ref_;
     inline WriteContainer *write_list() {return write_list_ref_;}
@@ -1645,7 +1646,7 @@
         }
     }
 
- static void thread_conflicting_mutexes_set_all_cnd(Mutex *mutex, int b) {
+ static void thread_conflicting_mutexes_set_all_cnd(latm::mutex_type *mutex, int b) {
         for (latm::thread_id_mutex_set_map::iterator iter = threadConflictingMutexes_.begin();
             threadConflictingMutexes_.end() != iter; ++iter)
         {
@@ -2031,6 +2032,7 @@
 inline void unlock(M& m, latm::mutex_type& lock) {transaction::unlock(m, lock);}
 
 
+#if defined(BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER)
 template <class T> T* cache_allocate(transaction* t) {
     #if defined(BOOST_STM_CACHE_USE_MEMORY_MANAGER) && defined (USE_STM_MEMORY_MANAGER)
     return reinterpret_cast<T*>(base_memory_manager::retrieve_mem(sizeof(T)));
@@ -2039,13 +2041,16 @@
     #elif defined(BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER)
     return reinterpret_cast<T*>(t->context_.mstorage_.allocate<T>());
     #else
+ return 0;
     #error "BOOST_STM_CACHE_USE_MEMORY_MANAGER, BOOST_STM_CACHE_USE_MALLOC or BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER must be defined"
     #endif
 }
+#endif
 
 // this function must be specialized for objects that are non transactional
 // by deleting the object
 
+#if defined(BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER)
 #ifdef BOOST_STM_NO_PARTIAL_SPECIALIZATION
 namespace partial_specialization_workaround {
 template <class T>
@@ -2084,11 +2089,12 @@
         free(ptr);
     #elif defined(BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER)
     #else
- #error "BOOST_STM_CACHE_USE_MEMORY_MANAGER or BOOST_STM_CACHE_USE_MALLOC must be defined"#endif
+ #error "BOOST_STM_CACHE_USE_MEMORY_MANAGER or BOOST_STM_CACHE_USE_MALLOC must be defined"
     #endif
     }
 }
 #endif //BOOST_STM_NO_PARTIAL_SPECIALIZATION
+#endif
 
 inline void cache_release(base_transaction_object* ptr) {
     if (ptr==0) return ;

Modified: sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/transaction_object.hpp 2009-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -55,14 +55,14 @@
 //-----------------------------------------------------------------------------
 template <class Derived, typename Base=base_transaction_object>
 class transaction_object : public
-#ifdef USE_STM_MEMORY_MANAGER2
- memory_manager<transaction_object<Derived,Base>, Base>
+#ifdef USE_STM_MEMORY_MANAGER
+ memory_manager<Derived, Base>
 #else
     Base
 #endif
 {
-#ifdef USE_STM_MEMORY_MANAGER2
- typedef memory_manager<transaction_object<Derived,Base>, Base> base_type;
+#ifdef USE_STM_MEMORY_MANAGER
+ typedef memory_manager<Derived, Base> base_type;
 #else
     typedef Base base_type;
 #endif
@@ -112,23 +112,6 @@
    }
 #endif
 
-#if USE_STM_MEMORY_MANAGER
- void* operator new(std::size_t size, const std::nothrow_t&) throw ()
- {
- return base_memory_manager::retrieve_mem(size);
- }
- void* operator new(std::size_t size) throw (std::bad_alloc)
- {
- void* ptr= base_memory_manager::retrieve_mem(size);
- if (ptr==0) throw std::bad_alloc();
- return ptr;
- }
-
- void operator delete(void* mem) throw ()
- {
- base_memory_manager::return_mem(mem, sizeof(Derived));
- }
-#endif
 };
 
 template <typename T> class native_trans :

Modified: sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/tx/shallow_transaction_object.hpp 2009-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -56,13 +56,13 @@
 template <class Derived, typename Base=base_transaction_object>
 class shallow_transaction_object : public
 #ifdef USE_STM_MEMORY_MANAGER
- memory_manager<shallow_transaction_object<Derived,Base>, Base>
+ memory_manager<Derived, Base>
 #else
     Base
 #endif
 {
 #ifdef USE_STM_MEMORY_MANAGER
- typedef memory_manager<transaction_object<Derived,Base>, Base> base_type;
+ typedef memory_manager<Derived, Base> base_type;
 #else
     typedef Base base_type;
 #endif

Modified: sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/txw/transactional_object.hpp 2009-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -46,13 +46,13 @@
 
 template <typename T>
 class transactional_object : public
-#ifdef USE_STM_MEMORY_MANAGER2
+#ifdef USE_STM_MEMORY_MANAGER
     memory_manager<transactional_object<T>, base_transaction_object>
 #else
     base_transaction_object
 #endif
 {
-#ifdef USE_STM_MEMORY_MANAGER2
+#ifdef USE_STM_MEMORY_MANAGER
     typedef memory_manager<transactional_object<T>, base_transaction_object> base_type;
 #else
     typedef base_transaction_object base_type;
@@ -118,24 +118,6 @@
         *this=*static_cast<transactional_object<T> const * const>(rhs);
     }
 
- #if USE_STM_MEMORY_MANAGER
- void* operator new(std::size_t size, const std::nothrow_t&) throw ()
- {
- return base_memory_manager::retrieve_mem(size);
- }
- void* operator new(std::size_t size) throw (std::bad_alloc)
- {
- void* ptr= base_memory_manager::retrieve_mem(size);
- if (ptr==0) throw std::bad_alloc();
- return ptr;
- }
-
- void operator delete(void* mem) throw ()
- {
- base_memory_manager::return_mem(mem, sizeof(transactional_object<T>));
- }
- #endif
-
 };
 
 //-----------------------------------------------------------------------------

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-11-11 10:58:29 EST (Wed, 11 Nov 2009)
@@ -80,7 +80,7 @@
 std::ofstream transaction::logFile_;
 
 #ifndef BOOST_STM_USE_BOOST_MUTEX
-Mutex base_memory_manager::transactionObjectMutex_ = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t base_memory_manager::transactionObjectMutex_ = PTHREAD_MUTEX_INITIALIZER;
 #else
 boost::mutex base_memory_manager::transactionObjectMutex_;
 #endif
@@ -170,16 +170,10 @@
    logFile_.open("DracoSTM_log.txt");
 
 #ifndef BOOST_STM_USE_BOOST_MUTEX
- //pthread_mutexattr_settype(&transactionMutexAttribute_, PTHREAD_MUTEX_NORMAL);
-
    pthread_mutex_init(&transactionMutex_, 0);
    pthread_mutex_init(&transactionsInFlightMutex_, 0);
    pthread_mutex_init(&deletionBufferMutex_, 0);
    pthread_mutex_init(&latm::instance().latmMutex_, 0);
-
- //pthread_mutex_init(&transactionMutex_, &transactionMutexAttribute_);
- //pthread_mutex_init(&transactionsInFlightMutex_, &transactionMutexAttribute_);
- //pthread_mutex_init(&latmMutex_, &transactionMutexAttribute_);
 #endif
 }
 


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