|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56356 - in sandbox/stm/branches/vbe/boost: . stm stm/detail
From: vicente.botet_at_[hidden]
Date: 2009-09-22 14:01:01
Author: viboes
Date: 2009-09-22 14:01:00 EDT (Tue, 22 Sep 2009)
New Revision: 56356
URL: http://svn.boost.org/trac/boost/changeset/56356
Log:
TBoost.Stm vbe
* file reorganization
Text files modified:
sandbox/stm/branches/vbe/boost/stm.hpp | 11 +
sandbox/stm/branches/vbe/boost/stm/detail/config.hpp | 38 ++++-
sandbox/stm/branches/vbe/boost/stm/detail/transaction_bookkeeping.hpp | 247 ---------------------------------------
sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp | 20 +-
sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 12 +
5 files changed, 59 insertions(+), 269 deletions(-)
Modified: sandbox/stm/branches/vbe/boost/stm.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm.hpp 2009-09-22 14:01:00 EDT (Tue, 22 Sep 2009)
@@ -37,15 +37,22 @@
#include <boost/stm/detail/config.hpp>
-#include <boost/stm/base_transaction_object.hpp>
#include <boost/stm/base_contention_manager.hpp>
+#include <boost/stm/base_transaction_object.hpp>
+#include <boost/stm/cache_fct.hpp>
#include <boost/stm/contention_manager.hpp>
+#include <boost/stm/datatypes.hpp>
+#include <boost/stm/exceptions.hpp>
+#include <boost/stm/move.hpp>
#include <boost/stm/non_tx_smart_ptr.hpp>
+#include <boost/stm/synchro.hpp>
#include <boost/stm/transaction.hpp>
+#include <boost/stm/transaction_bookkeeping.hpp>
#include <boost/stm/transaction_object.hpp>
#include <boost/stm/transaction_object_ptr.hpp>
-#include <boost/stm/tx_smart_ptr.hpp>
+#include <boost/stm/transactional_object.hpp>
#include <boost/stm/tx_ptr.hpp>
+#include <boost/stm/tx_smart_ptr.hpp>
///////////////////////////////////////////////////////////////////////////////
#endif // TRANSACTION_H
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-09-22 14:01:00 EDT (Tue, 22 Sep 2009)
@@ -26,24 +26,46 @@
#define PERFORMING_WRITE_BLOOM 1
//#define ALWAYS_ALLOW_ABORT 1
//#define LOGGING_BLOCKS 1
+
+///////////////////////////////////////////////////////////////////////////////
+// The cache an be structured in different ways. Define ony one of
+// USE_SINGLE_THREAD_CONTEXT_MAP: use of a common tx_context as TSS
+// 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 BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP 1
+
+///////////////////////////////////////////////////////////////////////////////
+// When USE_SINGLE_THREAD_CONTEXT_MAP or BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP are defined you can want to store references to the TSS or not
+// BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS if you want to add these references
+
#define BOOST_STM_TX_CONTAINS_REFERENCES_TO_TSS_FIELDS 1
-// BOOST_STM_CM_STATIC_CONF: configuration manager is static
-#define BOOST_STM_CM_STATIC_CONF 1
-// BOOST_STM_CM_STATIC_CONF_ExceptAndBackOffOnAbortNoticeCM: configuration manager is ExceptAndBackOffOnAbortNoticeCM
-#define BOOST_STM_CM_STATIC_CONF_ExceptAndBackOffOnAbortNoticeCM 1
+///////////////////////////////////////////////////////////////////////////////
+// Define only one of
+// 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_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
+
+///////////////////////////////////////////////////////////////////////////////
// BOOST_STM_USE_MEMCOPY: STM uses memcpy insted of the copy constructor
#define BOOST_STM_USE_MEMCOPY 1
-//// The cache using uninitialized_copy can use the following memeory manager
-////BOOST_STM_CACHE_USE_MALLOC: uses malloc/free
-#define BOOST_STM_CACHE_USE_MALLOC 1
+//// The cache using memcpy 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
-//#define BOOST_STM_CACHE_USE_MEMORY_MANAGER 1
//// 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_MEMORY_MANAGER 1
//#define BOOST_STM_CACHE_USE_TSS_MONOTONIC_MEMORY_MANAGER 1
#ifdef USE_BLOOM_FILTER
Modified: sandbox/stm/branches/vbe/boost/stm/detail/transaction_bookkeeping.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transaction_bookkeeping.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transaction_bookkeeping.hpp 2009-09-22 14:01:00 EDT (Tue, 22 Sep 2009)
@@ -11,251 +11,6 @@
//
//////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_STM_TRANSACTION_BOOKKEEPING_H
-#define BOOST_STM_TRANSACTION_BOOKKEEPING_H
-#include <iostream>
-#include <vector>
-#include <map>
-#include <pthread.h>
-#include <boost/stm/detail/datatypes.hpp>
-
-namespace boost { namespace stm {
-
-//-----------------------------------------------------------------------------
-class ThreadIdAndCommitId
-{
-public:
-
- ThreadIdAndCommitId(uint32 const &threadId, uint32 const &commitId) :
- threadId_(threadId), commitId_(commitId) {}
-
- uint32 threadId_;
- uint32 commitId_;
-
- bool operator==(ThreadIdAndCommitId const &rhs) const
- { return threadId_ == rhs.threadId_ && commitId_ == rhs.commitId_; }
-
- bool operator<(ThreadIdAndCommitId const &rhs) const
- {
- if (threadId_ < rhs.threadId_) return true;
- if (threadId_ == rhs.threadId_)
- {
- if (commitId_ < rhs.commitId_) return true;
- }
- return false;
- }
-};
-
-//-----------------------------------------------------------------------------
-class transaction_bookkeeping
-{
-public:
-
- typedef std::map<uint32, uint32> thread_commit_map;
- typedef std::map<ThreadIdAndCommitId, uint32> CommitHistory;
- typedef std::map<ThreadIdAndCommitId, uint32> AbortHistory;
-
- transaction_bookkeeping() : aborts_(0), writeAborts_(0), readAborts_(0),
- abortPermDenied_(0), commits_(0), handOffs_(0), newMemoryCommits_(0),
- newMemoryAborts_(0), deletedMemoryCommits_(0), deletedMemoryAborts_(0),
- readStayedAsRead_(0), readChangedToWrite_(0), commitTimeMs_(0), lockConvoyMs_(0)
- {
- //abortTrackingMutex_ = PTHREAD_MUTEX_INITIALIZER;
- }
-
- uint32 const & lockConvoyMs() const { return lockConvoyMs_; }
- uint32 const & commitTimeMs() const { return commitTimeMs_; }
- uint32 const & readAborts() const { return readAborts_; }
- uint32 const & writeAborts() const { return writeAborts_; }
- uint32 const & abortPermDenied() const { return abortPermDenied_; }
- uint32 const totalAborts() const { return readAborts_ + writeAborts_ + abortPermDenied_; }
- uint32 const & commits() const { return commits_; }
- uint32 const & handOffs() const { return handOffs_; }
- uint32 const & newMemoryAborts() const { return newMemoryAborts_; }
- uint32 const & newMemoryCommits() const { return newMemoryCommits_; }
- uint32 const & deletedMemoryAborts() const { return deletedMemoryAborts_; }
- uint32 const & deletedMemoryCommits() const { return deletedMemoryCommits_; }
- uint32 const & readChangedToWrite() const { return readChangedToWrite_; }
- uint32 const & readStayedAsRead() const { return readStayedAsRead_; }
-
- void inc_read_aborts() { ++readAborts_; }
- void inc_write_aborts() { ++writeAborts_; }
-
- void inc_thread_commits(uint32 threadId)
- {
-#if 0
- std::map<uint32, uint32>::iterator i = threadedCommits_.find(threadId);
-
- if (threadedCommits_.end() == i) threadedCommits_[threadId] = 1;
- else i->second = i->second + 1;
-#endif
- }
-
- void inc_thread_aborts(uint32 threadId)
- {
-#if 0
- std::map<uint32, uint32>::iterator i = threadedAborts_.find(threadId);
-
- if (threadedAborts_.end() == i)
- {
- threadedAborts_.insert(std::make_pair(threadId, 1));
- }
- else
- {
- i->second += 1;
- }
-#endif
- }
-
- thread_commit_map const & threadedCommits() const { return threadedCommits_; }
- thread_commit_map const & threadedAborts() const { return threadedAborts_; }
-
- void inc_lock_convoy_ms(uint32 const &rhs) { lockConvoyMs_ += rhs; }
- void inc_commit_time_ms(uint32 const &rhs) { commitTimeMs_ += rhs; }
- void inc_commits() { ++commits_; inc_thread_commits(THREAD_ID); }
- void inc_abort_perm_denied(uint32 const &threadId) { ++abortPermDenied_; inc_thread_aborts(threadId); }
- void inc_handoffs() { ++handOffs_; }
- void inc_new_mem_aborts_by(uint32 const &rhs) { newMemoryAborts_ += rhs; }
- void inc_new_mem_commits_by(uint32 const &rhs) { newMemoryCommits_ += rhs; }
- void inc_del_mem_aborts_by(uint32 const &rhs) { deletedMemoryAborts_ += rhs; }
- void inc_del_mem_commits_by(uint32 const &rhs) { deletedMemoryCommits_ += rhs; }
- void incrementReadChangedToWrite() { ++readChangedToWrite_; }
- void incrementReadStayedAsRead() { ++readStayedAsRead_; }
-
- CommitHistory const& getCommitReadSetList() const { return committedReadSetSize_; }
- CommitHistory const& getCommitWriteSetList() const { return committedWriteSetSize_; }
- AbortHistory const& getAbortReadSetList() const { return abortedReadSetSize_; }
- AbortHistory const& getAbortWriteSetList() const { return abortedWriteSetSize_; }
-
- void pushBackSizeOfReadSetWhenAborting(uint32 const &size)
- {
- //lock(&abortTrackingMutex_);
-
- ThreadIdAndCommitId tcId(THREAD_ID, ++aborts_);
-
- // if waiting for commit read from thread is already true, it means there
- // was no commit on the last abort, so drop it from the map
-
- if (waitingForCommitReadFromThread[THREAD_ID])
- {
- abortedReadSetSize_.erase(ThreadIdAndCommitId(THREAD_ID, aborts_-1));
- abortedWriteSetSize_.erase(ThreadIdAndCommitId(THREAD_ID, aborts_-1));
- }
-
- abortedReadSetSize_[tcId] = size;
- waitingForCommitReadFromThread[THREAD_ID] = true;
- //unlock(&abortTrackingMutex_);
- }
-
- void pushBackSizeOfWriteSetWhenAborting(uint32 const &size)
- {
- //lock(&abortTrackingMutex_);
- ThreadIdAndCommitId tcId(THREAD_ID, aborts_);
- abortedWriteSetSize_[tcId] = size;
- waitingForCommitWriteFromThread[THREAD_ID] = true;
- //unlock(&abortTrackingMutex_);
- }
-
- void pushBackSizeOfReadSetWhenCommitting(uint32 const &size)
- {
- //lock(&abortTrackingMutex_);
- ThreadIdAndCommitId tcId(THREAD_ID, aborts_);
-
- // only insert this commit if an abort made an entry at this commit point
- if (waitingForCommitReadFromThread[THREAD_ID])
- {
- committedReadSetSize_[tcId] = size;
- waitingForCommitReadFromThread[THREAD_ID] = false;
- }
- //unlock(&abortTrackingMutex_);
- }
-
- void pushBackSizeOfWriteSetWhenCommitting(uint32 const &size)
- {
- //lock(&abortTrackingMutex_);
- ThreadIdAndCommitId tcId(THREAD_ID, aborts_);
-
- // only insert this commit if an abort made an entry at this commit point
- if (waitingForCommitWriteFromThread[THREAD_ID])
- {
- committedWriteSetSize_[tcId] = size;
- waitingForCommitWriteFromThread[THREAD_ID] = false;
- }
- //unlock(&abortTrackingMutex_);
- }
-
- bool isLoggingAbortAndCommitSize() const { return isLoggingAbortAndCommitSize_; }
- void setIsLoggingAbortAndCommitSize(bool const &in) { isLoggingAbortAndCommitSize_ = in; }
-
- ////////////////////////////////////////////////////////////////////////////
- friend std::ostream& operator<<(std::ostream& out, transaction_bookkeeping const &that)
- {
- using namespace std;
-
- out << "########################################" << endl;
- //out << "total_aborts=" << that.totalAborts() << endl;
-
-
- for (thread_commit_map::const_iterator i = that.threadedCommits().begin();
- i != that.threadedCommits().end(); ++i)
- {
- out << " thread [" << i->first << "]: commits: " << i->second << " aborts: ";
-
- bool found = false;
-
- for (thread_commit_map::const_iterator j = that.threadedAborts().begin();
- j != that.threadedAborts().end(); ++j)
- {
- if (j->first == i->first)
- {
- out << j->second;
- found = true;
- break;
- }
- }
-
- if (!found) out << 0;
-
- out << endl;
- }
-
- return out;
- }
-
-private:
-
- bool isLoggingAbortAndCommitSize_;
-
- AbortHistory abortedReadSetSize_;
- AbortHistory abortedWriteSetSize_;
- CommitHistory committedReadSetSize_;
- CommitHistory committedWriteSetSize_;
-
- std::map<uint32, bool> waitingForCommitReadFromThread;
- std::map<uint32, bool> waitingForCommitWriteFromThread;
-
- thread_commit_map threadedCommits_;
- thread_commit_map threadedAborts_;
-
- uint32 aborts_;
- uint32 writeAborts_;
- uint32 readAborts_;
- uint32 abortPermDenied_;
- uint32 commits_;
- uint32 handOffs_;
- uint32 newMemoryCommits_;
- uint32 newMemoryAborts_;
- uint32 deletedMemoryCommits_;
- uint32 deletedMemoryAborts_;
- uint32 readStayedAsRead_;
- uint32 readChangedToWrite_;
- uint32 commitTimeMs_;
- uint32 lockConvoyMs_;
-
- //Mutex abortTrackingMutex_;
-};
-
-}}
-#endif // TRANSACTION_BOOKKEEPING_H
+#include <boost/stm/transaction_bookkeeping.hpp>
Modified: sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/except_and_back_off_on_abort_notice_cm.hpp 2009-09-22 14:01:00 EDT (Tue, 22 Sep 2009)
@@ -39,30 +39,30 @@
}
#endif
////////////////////////////////////////////////////////////////////////////
- inline static void abort_on_write(transaction &t,
+ static void abort_on_write(transaction &t,
base_transaction_object const &in);
- inline static void abort_on_read(transaction const &t,
+ static void abort_on_read(transaction const &t,
base_transaction_object const &in);
- inline static void abort_on_delete(transaction const &t,
+ static void abort_on_delete(transaction const &t,
base_transaction_object const &in);
- inline static void abort_on_new(transaction const &t);
+ static void abort_on_new(transaction const &t);
////////////////////////////////////////////////////////////////////////////
- inline static void perform_isolated_tx_wait_priority_promotion(transaction &lhs);
+ static void perform_isolated_tx_wait_priority_promotion(transaction &lhs);
////////////////////////////////////////////////////////////////////////////
- inline static void perform_irrevocable_tx_wait_priority_promotion(transaction &lhs);
- inline static int lock_sleep_time() { return 10; }
+ static void perform_irrevocable_tx_wait_priority_promotion(transaction &lhs);
+ static int lock_sleep_time() { return 10; }
//--------------------------------------------------------------------------
// this code is only ever called if "validation" is on not "invalidation"
// so don't worry about this code EVER stopping invalidation from committing
//--------------------------------------------------------------------------
- inline static bool abort_before_commit(transaction const &t);
+ static bool abort_before_commit(transaction const &t);
- inline static bool permission_to_abort(transaction const &lhs, transaction const &rhs);
+ static bool permission_to_abort(transaction const &lhs, transaction const &rhs);
- inline static bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
+ static bool allow_lock_to_abort_tx(int const & lockWaitTime, int const &lockAborted,
bool txTryingToAbortIsIrrevocable, transaction const &rhs);
//private:
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-09-22 14:01:00 EDT (Tue, 22 Sep 2009)
@@ -29,9 +29,9 @@
#include <boost/stm/detail/config.hpp>
//-----------------------------------------------------------------------------
#include <boost/stm/base_transaction.hpp>
+#include <boost/stm/transaction_bookkeeping.hpp>
//-----------------------------------------------------------------------------
#include <boost/stm/detail/datatypes.hpp>
-#include <boost/stm/detail/transaction_bookkeeping.hpp>
#include <boost/stm/detail/bloom_filter.hpp>
#include <boost/stm/detail/vector_map.hpp>
#include <boost/stm/detail/vector_set.hpp>
@@ -43,8 +43,14 @@
#endif
#if defined(BOOST_STM_CM_STATIC_CONF)
-#if defined(BOOST_STM_CM_STATIC_CONF_ExceptAndBackOffOnAbortNoticeCM)
+#if defined(BOOST_STM_CM_STATIC_CONF_except_and_back_off_on_abort_notice_cm)
#include <boost/stm/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
@@ -68,7 +74,7 @@
bool const begin_transaction = true;
#if defined(BOOST_STM_CM_STATIC_CONF)
-#if defined(BOOST_STM_CM_STATIC_CONF_ExceptAndBackOffOnAbortNoticeCM)
+#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
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