Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56994 - in sandbox/stm/branches/vbe: boost/stm boost/stm/contention_managers boost/stm/detail libs/stm/src
From: vicente.botet_at_[hidden]
Date: 2009-10-19 11:19:01


Author: viboes
Date: 2009-10-19 11:19:00 EDT (Mon, 19 Oct 2009)
New Revision: 56994
URL: http://svn.boost.org/trac/boost/changeset/56994

Log:
TBoost.STM vbe: Static and polymorphic contention managers
* this could improve the performances as when we choose a static contention manager there is no virtual calls.
* boost/stm/select_contention_manager.hpp select the good contention manager depending on compilations directives (see detail/congig.hpp)

Added:
   sandbox/stm/branches/vbe/boost/stm/select_contention_manager.hpp (contents, props changed)
Text files modified:
   sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp | 10 ++++
   sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 9 +++
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 87 +--------------------------------------
   sandbox/stm/branches/vbe/libs/stm/src/transaction.cpp | 5 +
   4 files changed, 24 insertions(+), 87 deletions(-)

Modified: sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp 2009-10-19 11:19:00 EDT (Mon, 19 Oct 2009)
@@ -75,5 +75,15 @@
    static int const initialSleepTime_;
 };
 
+typedef except_and_back_off_on_abort_notice_cm contention_manager_type;
+
+#define BOOST_STM_CM_STATIC() \
+ int boost::stm::except_and_back_off_on_abort_notice_cm::sleepTime_=BOOST_STM_CM_STATIC_INITIAL_SLEEP_TIME; \
+ int const boost::stm::except_and_back_off_on_abort_notice_cm::kSleepFactorIncrease_=BOOST_STM_CM_STATIC_SLEEP_INCREASE; \
+ int const boost::stm::except_and_back_off_on_abort_notice_cm::kMaxIncreases_=BOOST_STM_CM_STATIC_MAX_INCREASES; \
+ int const boost::stm::except_and_back_off_on_abort_notice_cm::initialSleepTime_=BOOST_STM_CM_STATIC_INITIAL_SLEEP_TIME; \
+ int boost::stm::except_and_back_off_on_abort_notice_cm::kMaxSleepTime_=BOOST_STM_CM_STATIC_SLEEP_INCREASE*BOOST_STM_CM_STATIC_INITIAL_SLEEP_TIME*BOOST_STM_CM_STATIC_MAX_INCREASES
+
+
 }}
 #endif

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-10-19 11:19:00 EDT (Mon, 19 Oct 2009)
@@ -56,13 +56,18 @@
 // BOOST_STM_CM_STATIC_CONF when you want a staticacly configured CM
 // BOOST_STM_CM_DYNAMIC_CONF when you want a polymorphic CM configured at run time
 
-#define BOOST_STM_CM_STATIC_CONF 1
+//#define BOOST_STM_CM_STATIC_CONF 1
 //#define BOOST_STM_CM_DYNAMIC_CONF 1
 
 // Define only one of
 // BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm when configuration manager is except_and_back_off_on_abort_notice_cm
 
-#define BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm 1
+//#define BOOST_STM_CM_STATIC_CONF <boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp>
+//#define BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm 1
+
+#define BOOST_STM_CM_STATIC_INITIAL_SLEEP_TIME 0
+#define BOOST_STM_CM_STATIC_SLEEP_INCREASE 0
+#define BOOST_STM_CM_STATIC_MAX_INCREASES 0
 
 ///////////////////////////////////////////////////////////////////////////////
 // BOOST_STM_USE_SPECIFIC_TRANSACTION_MEMORY_MANAGER

Added: sandbox/stm/branches/vbe/boost/stm/select_contention_manager.hpp
==============================================================================
--- (empty file)
+++ sandbox/stm/branches/vbe/boost/stm/select_contention_manager.hpp 2009-10-19 11:19:00 EDT (Mon, 19 Oct 2009)
@@ -0,0 +1,145 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Justin E. Gottchlich 2009.
+// (C) Copyright Vicente J. Botet Escriba 2009.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/stm for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_STM_SELECT_CONTENTION_MANAGER__HPP
+#define BOOST_STM_SELECT_CONTENTION_MANAGER__HPP
+
+//-----------------------------------------------------------------------------
+#include <boost/stm/detail/config.hpp>
+//-----------------------------------------------------------------------------
+
+#if defined(BOOST_STM_CM_STATIC_CONF)
+#if defined(BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm)
+#include <boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp>
+#else
+#include BOOST_STM_CM_STATIC_CONF
+//#include <boost/stm/contention_managers/default.hpp>
+#endif
+#else
+#if defined(BOOST_STM_CM_DYNAMIC_CONF)
+#include <boost/stm/contention_managers/polymorphic.hpp>
+#endif
+#endif
+
+namespace boost { namespace stm {
+
+
+#if defined(BOOST_STM_CM_STATIC_CONF)
+ inline static contention_manager_type* get_contention_manager() {
+ static contention_manager_type cm_;return &cm_;
+ }
+ inline static void cm_abort_on_new(transaction const &t) {
+ return contention_manager_type::abort_on_new(t);
+ }
+ inline static void cm_abort_on_delete(transaction const &t,
+ base_transaction_object const &in) {
+ return contention_manager_type::abort_on_delete(t,in);
+ }
+
+ inline static void cm_abort_on_read(transaction const &t,
+ base_transaction_object const &in) {
+ return contention_manager_type::abort_on_read(t,in);
+ }
+ inline static void cm_abort_on_write(transaction &t,
+ base_transaction_object const &in) {
+ return contention_manager_type::abort_on_write(t,in);
+ }
+
+ inline static bool cm_abort_before_commit(transaction const &t) {
+ return contention_manager_type::abort_before_commit(t);
+ }
+
+ inline static bool cm_permission_to_abort(transaction const &lhs, transaction const &rhs) {
+ return contention_manager_type::permission_to_abort(lhs,rhs);
+ }
+
+ inline static bool cm_permission_to_abort(transaction const &lhs, std::list<transaction*> &rhs) {
+ return contention_manager_type::permission_to_abort(lhs,rhs);
+ }
+
+ inline static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
+ bool txIsIrrevocable, transaction const &rhs) {
+ return contention_manager_type::allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs);
+ }
+
+ inline static int cm_lock_sleep_time() {
+ return contention_manager_type::lock_sleep_time();
+ }
+
+ inline static void cm_perform_isolated_tx_wait_priority_promotion(transaction &t) {
+ return contention_manager_type::perform_isolated_tx_wait_priority_promotion(t);
+ }
+ inline static void cm_perform_irrevocable_tx_wait_priority_promotion(transaction &t) {
+ return contention_manager_type::perform_irrevocable_tx_wait_priority_promotion(t);
+ }
+
+#else
+ struct poly_contention_manager {
+ static base_contention_manager *cm_;
+ };
+ inline static void contention_manager(base_contention_manager *rhs) {
+ delete poly_contention_manager::cm_; poly_contention_manager::cm_ = rhs;
+ }
+ inline static base_contention_manager* get_contention_manager() {
+ return poly_contention_manager::cm_;
+ }
+ inline static base_contention_manager* get_cm() {
+ return poly_contention_manager::cm_;
+ }
+
+ inline static void cm_abort_on_new(transaction const &t) {
+ return get_cm()->abort_on_new(t);
+ }
+ inline static void cm_abort_on_delete(transaction const &t, base_transaction_object const &in) {
+ return get_cm()->abort_on_delete(t,in);
+ }
+
+ inline static void cm_abort_on_read(transaction const &t, base_transaction_object const &in) {
+ return get_cm()->abort_on_read(t,in);
+ }
+ inline static void cm_abort_on_write(transaction &t, base_transaction_object const &in) {
+ return get_cm()->abort_on_write(t,in);
+ }
+
+ inline static bool cm_abort_before_commit(transaction const &t) {
+ return get_cm()->abort_before_commit(t);
+ }
+
+ inline static bool cm_permission_to_abort(transaction const &lhs, transaction const &rhs) {
+ return get_cm()->permission_to_abort(lhs,rhs);
+ }
+
+ inline static bool cm_permission_to_abort(transaction const &lhs, std::list<transaction*> &rhs) {
+ return get_cm()->permission_to_abort(lhs,rhs);
+ }
+
+ inline static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
+ bool txIsIrrevocable, transaction const &rhs) {
+ return get_cm()->allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs); }
+
+ inline static int cm_lock_sleep_time() {
+ return get_cm()->lock_sleep_time();
+ }
+
+ inline static void cm_perform_isolated_tx_wait_priority_promotion(transaction &t) {
+ return get_cm()->perform_isolated_tx_wait_priority_promotion(t);
+ }
+ inline static void cm_perform_irrevocable_tx_wait_priority_promotion(transaction &t) {
+ return get_cm()->perform_irrevocable_tx_wait_priority_promotion(t);
+ }
+
+#endif
+
+
+}}
+#endif // CONTENTION_MANAGER_H

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-10-19 11:19:00 EDT (Mon, 19 Oct 2009)
@@ -26,14 +26,15 @@
 #include <string>
 #include <vector>
 //-----------------------------------------------------------------------------
+#include <boost/synchro/tss.hpp>
+//-----------------------------------------------------------------------------
 #include <boost/stm/detail/config.hpp>
 //-----------------------------------------------------------------------------
 #include <boost/stm/base_transaction.hpp>
 #include <boost/stm/datatypes.hpp>
 #include <boost/stm/move.hpp>
 #include <boost/stm/transaction_bookkeeping.hpp>
-
-#include <boost/synchro/tss.hpp>
+#include <boost/stm/select_contention_manager.hpp>
 //-----------------------------------------------------------------------------
 #include <boost/stm/detail/bloom_filter.hpp>
 #include <boost/stm/detail/deleters.hpp>
@@ -42,24 +43,9 @@
 #include <boost/stm/detail/vector_map.hpp>
 #include <boost/stm/detail/vector_set.hpp>
 
-
-#if defined(BOOST_STM_CM_STATIC_CONF)
-#if defined(BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm)
-#include <boost/stm/contention_managers/except_and_back_off_on_abort_notice_cm.hpp>
-#else
-#include <boost/stm/contention_managers/default.hpp>
-#endif
-#else
-#if defined(BOOST_STM_CM_DYNAMIC_CONF)
-#include <boost/stm/contention_managers/polymorphic.hpp>
-#endif
-#endif
-
-//-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 namespace boost { namespace stm {
 
-
 //-----------------------------------------------------------------------------
 // boolean which is used to invoke "begin_transaction()" upon transaction
 // object construction (so two lines of code aren't needed to make a
@@ -68,11 +54,6 @@
 //-----------------------------------------------------------------------------
 bool const begin_transaction = true;
 
-#if defined(BOOST_STM_CM_STATIC_CONF)
-#if defined(BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm)
-typedef except_and_back_off_on_abort_notice_cm contention_manager_type;
-#endif
-#endif
 
 
 typedef std::pair<base_transaction_object*, base_transaction_object*> tx_pair;
@@ -227,68 +208,6 @@
    static void initialize();
    static void initialize_thread();
    static void terminate_thread();
- #if defined(BOOST_STM_CM_STATIC_CONF)
- //static contention_manager_type cm_;
- //inline static void contention_manager(base_contention_manager *rhs) { delete cm_; cm_ = rhs; }
- inline static contention_manager_type* get_contention_manager() {
- static contention_manager_type cm_;return &cm_;
- }
- static void cm_abort_on_new(transaction const &t) {return contention_manager_type::abort_on_new(t); }
- static void cm_abort_on_delete(transaction const &t,
- base_transaction_object const &in) {return contention_manager_type::abort_on_delete(t,in); }
-
- static void cm_abort_on_read(transaction const &t,
- base_transaction_object const &in) {return contention_manager_type::abort_on_read(t,in); }
- static void cm_abort_on_write(transaction &t,
- base_transaction_object const &in) {return contention_manager_type::abort_on_write(t,in); }
-
- static bool cm_abort_before_commit(transaction const &t) {return contention_manager_type::abort_before_commit(t); }
-
- static bool cm_permission_to_abort
- (transaction const &lhs, transaction const &rhs)
- {return contention_manager_type::permission_to_abort(lhs,rhs); }
-
- static bool cm_permission_to_abort
- (transaction const &lhs, std::list<transaction*> &rhs)
- {return contention_manager_type::permission_to_abort(lhs,rhs); }
-
- static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txIsIrrevocable, transaction const &rhs) {
- return contention_manager_type::allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs); }
-
- static int cm_lock_sleep_time() {return contention_manager_type::lock_sleep_time(); }
-
- static void cm_perform_isolated_tx_wait_priority_promotion(transaction &t) {return contention_manager_type::perform_isolated_tx_wait_priority_promotion(t); }
- static void cm_perform_irrevocable_tx_wait_priority_promotion(transaction &t) {return contention_manager_type::perform_irrevocable_tx_wait_priority_promotion(t); }
-
- #else
- static base_contention_manager *cm_;
- inline static void contention_manager(base_contention_manager *rhs) { delete cm_; cm_ = rhs; }
- inline static base_contention_manager* get_contention_manager() { return cm_; }
- static void cm_abort_on_new(transaction const &t) {return cm_->abort_on_new(t); }
- static void cm_abort_on_delete(transaction const &t,
- base_transaction_object const &in) {return cm_->abort_on_delete(t,in); }
-
- static void cm_abort_on_read(transaction const &t,
- base_transaction_object const &in) {return cm_->abort_on_read(t,in); }
- static void cm_abort_on_write(transaction &t,
- base_transaction_object const &in) {return cm_->abort_on_write(t,in); }
-
- static bool cm_abort_before_commit(transaction const &t) {return cm_->abort_before_commit(t); }
-
- static bool cm_permission_to_abort
- (transaction const &lhs, transaction const &rhs) {return cm_->permission_to_abort(lhs,rhs); }
-
- static bool cm_allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
- bool txIsIrrevocable, transaction const &rhs) {
- return cm_->allow_lock_to_abort_tx(lockWaitTime,lockAborted,txIsIrrevocable,rhs); }
-
- static int cm_lock_sleep_time() {return cm_->lock_sleep_time(); }
-
- static void cm_perform_isolated_tx_wait_priority_promotion(transaction &t) {return cm_->perform_isolated_tx_wait_priority_promotion(t); }
- static void cm_perform_irrevocable_tx_wait_priority_promotion(transaction &t) {return cm_->perform_irrevocable_tx_wait_priority_promotion(t); }
-
- #endif
 
    inline static void enableLoggingOfAbortAndCommitSetSize() { bookkeeping_.setIsLoggingAbortAndCommitSize(true); }
    inline static void disableLoggingOfAbortAndCommitSetSize() { bookkeeping_.setIsLoggingAbortAndCommitSize(false); }

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-19 11:19:00 EDT (Mon, 19 Oct 2009)
@@ -77,10 +77,13 @@
    int const boost::stm::except_and_back_off_on_abort_notice_cm::kMaxIncreases_=0;
    int const boost::stm::except_and_back_off_on_abort_notice_cm::initialSleepTime_=0;
    int boost::stm::except_and_back_off_on_abort_notice_cm::kMaxSleepTime_=0;
+#else
+ BOOST_STM_CM_STATIC();
 #endif
 
+
 #else
-base_contention_manager *transaction::cm_ =
+base_contention_manager *poly_contention_manager::cm_ =
     new ExceptAndBackOffOnAbortNoticeCM(0, 0, 0);
 // new DefaultContentionManager();
 // new NoExceptionOnAbortNoticeOnReadWritesCM();


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