Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60554 - in sandbox/stm/branches/vbe/boost/stm: . detail
From: vicente.botet_at_[hidden]
Date: 2010-03-13 09:06:47


Author: viboes
Date: 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
New Revision: 60554
URL: http://svn.boost.org/trac/boost/changeset/60554

Log:
Boost.STM/vbe:
* Replace InflightTxes by in_flight_trans_cont
* Implement the stack of transaction intrusively using a parent pointer

Text files modified:
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp | 6
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp | 6
   sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp | 6
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp | 8
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp | 8
   sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp | 12 +-
   sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp | 6
   sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp | 165 ++++++++++++++++++++-------------------
   sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp | 16 +++
   sandbox/stm/branches/vbe/boost/stm/transaction.hpp | 61 ++++++++++----
   10 files changed, 172 insertions(+), 122 deletions(-)

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_full_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -62,11 +62,11 @@
         synchro::lock_guard<Mutex> lk_i(*inflight_lock());
 
         std::list<transaction*> txList;
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
         {
             BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
             transaction *t = *i;
 
             if (!t->irrevocable() &&

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tm_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -69,11 +69,11 @@
 
             std::list<transaction*> txList;
 
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
             {
                 BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
                 transaction *t = *i;
 
                 if (!t->irrevocable() &&

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_def_tx_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -56,11 +56,11 @@
     std::list<transaction *> txList;
     std::set<thread_id_t> txThreadId;
 
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
     {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
         transaction *t = *i;
 
         // if this tx is part of this thread, skip it (it's an LiT)

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_full_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -64,11 +64,11 @@
         synchro::lock_guard<Mutex> lk_i(*inflight_lock());
 
         std::list<transaction*> txList;
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
         {
             BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
             transaction *t = *i;
 
             if (!t->irrevocable() &&
@@ -100,7 +100,7 @@
         // now we must stall until all in-flight transactions are gone, otherwise
         // global memory may still be in an inconsistent state
         //-----------------------------------------------------------------------
- while (!transactionsInFlight_.empty()) { SLEEP(10); }
+ while (!in_flight_transactions().empty()) { SLEEP(10); }
     }
 
     try {

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tm_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -71,11 +71,11 @@
             synchro::lock_guard<Mutex> lk_i(*inflight_lock());
 
             std::list<transaction*> txList;
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
             {
                 BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
                 transaction *t = *i;
 
                 if (!t->irrevocable() &&
@@ -107,7 +107,7 @@
             // now we must stall until all in-flight transactions are gone, otherwise
             // global memory may still be in an inconsistent state
             //-----------------------------------------------------------------------
- while (!transactionsInFlight_.empty()) { SLEEP(10); }
+ while (!in_flight_transactions().empty()) { SLEEP(10); }
         }
 
         latm::instance().latmLockedLocks_.insert(mutex);

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_dir_tx_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -58,11 +58,11 @@
     std::set<thread_id_t> txThreadId;
     //transaction *txToMakeIsolated = 0;
 
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
     {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
         transaction *t = *i;
 
         // if this tx is part of this thread, skip it (it's an LiT)
@@ -128,11 +128,11 @@
             synchro::unique_lock<Mutex> lk_g(*general_lock());
             synchro::unique_lock<Mutex> lk_i(*inflight_lock());
 
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
             {
                 BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
                 transaction *t = *i;
 
                 if (t->get_tx_conflicting_locks().find(mutex) != t->get_tx_conflicting_locks().end())

Modified: sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/latm_general_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -486,11 +486,11 @@
 {
    synchro::lock_guard_if<Mutex> lock_l(*general_lock(), !hasTxInFlightMutex);
 
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
       transaction *t = *i;
 
       //--------------------------------------------------------------------

Modified: sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transaction_impl.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -44,14 +44,14 @@
 //--------------------------------------------------------------------------
 inline bool transaction::isolatedTxInFlight()
 {
- BOOST_STM_INFO<<std::endl;
- assert_tx_type();
     //~ BOOST_STM_INFO<<std::endl;
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ //~ assert_tx_type();
+ //~ BOOST_STM_INFO<<std::endl;
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
 
     //~ BOOST_STM_INFO<<std::endl;
       // if this is our threadId, skip it
@@ -73,11 +73,11 @@
 //--------------------------------------------------------------------------
 inline bool transaction::irrevocableTxInFlight()
 {
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
       // if this is our threadId, skip it
       if ((*i)->threadId_ == this->threadId_) continue;
 
@@ -95,11 +95,11 @@
 //--------------------------------------------------------------------------
 inline bool transaction::abortAllInFlightTxs()
 {
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
       // if this is our threadId, skip it
       if ((*i)->threadId_ == this->threadId_) continue;
 
@@ -116,11 +116,11 @@
 //--------------------------------------------------------------------------
 inline bool transaction::canAbortAllInFlightTxs()
 {
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
       // if this is our threadId, skip it
       if ((*i)->threadId_ == this->threadId_) continue;
 
@@ -197,7 +197,7 @@
 //--------------------------------------------------------------------------
 inline bool transaction::irrevocable() const
 {
- BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
+ //~ BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
    switch (tx_type())
    {
    case eNormalTx: return false;
@@ -214,7 +214,7 @@
 //--------------------------------------------------------------------------
 inline bool transaction::isolated() const
 {
- BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<< const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
+ //~ BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<< const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
    switch (tx_type())
    {
    case eNormalTx: return false;
@@ -229,7 +229,7 @@
 
 inline void transaction::assert_tx_type() const
 {
- BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
+ //~ BOOST_STM_INFO << "tx_type="<<tx_type()<<"@"<<const_cast<transaction*>(this)->tx_type_ptr()<<std::endl;
    switch (tx_type())
    {
    case eNormalTx: return ;
@@ -428,6 +428,11 @@
 inline transaction::transaction() :
    threadId_(this_thread::get_id()),
    //transactionMutexLocker_(),
+#ifndef BOOST_STM_USE_STACK
+ parent_(current_transaction()),
+#else
+ nested_((current_transaction()!=0));
+#endif
    auto_general_lock_(*general_lock()),
 
 #if USE_SINGLE_THREAD_CONTEXT_MAP
@@ -526,7 +531,9 @@
    reads_(0),
    startTime_(time(0))
 {
- nested_=(current_transaction()!=0);
+#ifdef BOOST_STM_USE_STACK
+ nested_=(current_transaction()!=0);
+#endif
    auto_general_lock_.unlock();
    if (direct_updating()) doIntervalDeletions();
 #if PERFORMING_LATM
@@ -599,8 +606,8 @@
 //--------------------------------------------------------------------------
 inline bool transaction::restart()
 {
- BOOST_STM_INFO<<std::endl;
- assert_tx_type();
+ //~ BOOST_STM_INFO<<std::endl;
+ //~ assert_tx_type();
     //~ BOOST_STM_INFO<<std::endl;
    if (e_in_flight == state_) lock_and_abort();
     //~ BOOST_STM_INFO<<std::endl;
@@ -653,8 +660,8 @@
 #endif
 #endif
 
- BOOST_STM_INFO<<std::endl;
- assert_tx_type();
+ //~ BOOST_STM_INFO<<std::endl;
+ //~ assert_tx_type();
     //~ BOOST_STM_INFO<<std::endl;
    put_tx_inflight();
     //~ BOOST_STM_INFO<<std::endl;
@@ -720,8 +727,8 @@
 //--------------------------------------------------------------------------
 inline void transaction::put_tx_inflight()
 {
- BOOST_STM_INFO<<std::endl;
- assert_tx_type();
+ //~ BOOST_STM_INFO<<std::endl;
+ //~ assert_tx_type();
     //~ BOOST_STM_INFO<<std::endl;
 #if PERFORMING_LATM
    while (true)
@@ -738,7 +745,7 @@
       if (b1 && b2)
       {
     //~ BOOST_STM_INFO<<std::endl;
- transactionsInFlight_.insert(this);
+ in_flight_transactions().insert(this);
          state_ = e_in_flight;
          break;
       }
@@ -750,12 +757,12 @@
 #else
    synchro::lock_guard<Mutex> lock_i(*inflight_lock());
     //~ BOOST_STM_INFO<<std::endl;
- transactionsInFlight_.insert(this);
+ in_flight_transactions().insert(this);
     //~ BOOST_STM_INFO<<std::endl;
    state_ = e_in_flight;
 #endif
- BOOST_STM_INFO<<std::endl;
- assert_tx_type();
+ //~ BOOST_STM_INFO<<std::endl;
+ //~ assert_tx_type();
     //~ BOOST_STM_INFO<<std::endl;
 }
 
@@ -763,35 +770,35 @@
 //--------------------------------------------------------------------------
 inline transaction::~transaction()
 {
- BOOST_STM_INFO<<std::endl;
- assert_tx_type();
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
+ //~ assert_tx_type();
+ //~ BOOST_STM_INFO<<std::endl;
    // if we're not an inflight transaction - bail
    if (state_ != e_in_flight)
    {
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
       //if (hasLock()) unlock_tx();
       return;
    }
 
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
     //if (!hasLock())
     {
        synchro::lock_guard<Mutex> lock(*mutex());
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
         abort();
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
     }
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
     transactions().pop();
- BOOST_STM_INFO<<std::endl;
+ //~ BOOST_STM_INFO<<std::endl;
 
     // BUG not removed from the list because the test is inversed
     //~ if (alreadyRemovedFromInFlight)
 
     //~ synchro::lock(*inflight_lock());
     // if I'm the last transaction of this thread, reset abort to false
- //~ transactionsInFlight_.erase(this);
+ //~ in_flight_transactions().erase(this);
 
 
 }
@@ -910,7 +917,7 @@
 
    synchro::lock(*inflight_lock());// TBR
     //synchro::lock_guard<Mutex> lk_i(*inflight_lock());
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
 
    if (other_in_flight_same_thread_transactions())
    {
@@ -965,7 +972,7 @@
         {
         synchro::unique_lock<Mutex> lk_i(*inflight_lock());
 
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
 
 #if PERFORMING_COMPOSITION
         if (other_in_flight_same_thread_transactions())
@@ -997,9 +1004,9 @@
 
 
    //--------------------------------------------------------------------------
- // as much as I'd like to transactionsInFlight_.erase() here, we have
+ // as much as I'd like to in_flight_transactions().erase() here, we have
    // to do it inside of abort() because the contention managers must abort
- // the txs and therefore must do a transactionsInFlight_.erase(this)
+ // the txs and therefore must do a in_flight_transactions().erase(this)
    // anyway. so we actually lose performance by doing it here and then
    // doing it again inside abort()
    //--------------------------------------------------------------------------
@@ -1035,7 +1042,7 @@
        // BUG
       if (other_in_flight_same_thread_transactions())
       {
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
          state_ = e_hand_off;
          unlock_all_mutexes();//TBR
          synchro::unlock(*general_lock());//TBR
@@ -1103,7 +1110,7 @@
    lock_all_mutexes_but_this(threadId_);
 
    synchro::lock(*inflight_lock());
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
 
    if (other_in_flight_same_thread_transactions())
    {
@@ -1155,9 +1162,9 @@
    clock_t ms = clock();
 
    //--------------------------------------------------------------------------
- // as much as I'd like to transactionsInFlight_.erase() here, we have
+ // as much as I'd like to in_flight_transactions().erase() here, we have
    // to do it inside of abort() because the contention managers must abort
- // the txs and therefore must do a transactionsInFlight_.erase(this)
+ // the txs and therefore must do a in_flight_transactions().erase(this)
    // anyway. so we actually lose performance by doing it here and then
    // doing it again inside abort()
    //--------------------------------------------------------------------------
@@ -1180,7 +1187,7 @@
       if (is_only_reading())
       {
          synchro::lock(*inflight_lock());
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
 
          if (other_in_flight_same_thread_transactions())
          {
@@ -1224,7 +1231,7 @@
       lock_all_mutexes_but_this(threadId_);
 
       synchro::lock(*inflight_lock());
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
 
       if (other_in_flight_same_thread_transactions())
       {
@@ -1261,17 +1268,17 @@
 #ifndef ALWAYS_ALLOW_ABORT
    std::list<transaction*> aborted;
 #endif
- InflightTxes::iterator next;
+ in_flight_trans_cont::iterator next;
 
    // iterate through all our written memory
    for (WriteContainer::iterator i = writeList().begin(); writeList().end() != i; ++i)
    {
       // iterate through all the in flight transactions
- for (InflightTxes::iterator j = transactionsInFlight_.begin();
- j != transactionsInFlight_.end();)
+ for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
+ j != in_flight_transactions().end();)
       {
         BOOST_ASSERT(*j!=0);
- (*j)->assert_tx_type();
+ //~ (*j)->assert_tx_type();
          transaction *t = *j;
 
          // if we're already aborting for this transaction, skip it
@@ -1298,7 +1305,7 @@
 
             next = j;
             ++next;
- transactionsInFlight_.erase(j);
+ in_flight_transactions().erase(j);
             j = next;
 
 #else
@@ -1330,7 +1337,7 @@
    {
         BOOST_ASSERT(k!=0);
       (*k)->force_to_abort();
- transactionsInFlight_.erase(*k);
+ in_flight_transactions().erase(*k);
    }
 #endif
 }
@@ -1371,7 +1378,7 @@
       {
          synchro::lock(*inflight_lock());
          // if I'm the last transaction of this thread, reset abort to false
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
       }
 
 #ifdef USING_SHARED_FORCED_TO_ABORT
@@ -1422,7 +1429,7 @@
    {
       synchro::lock(*inflight_lock());
       // if I'm the last transaction of this thread, reset abort to false
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
 
 #ifdef USING_SHARED_FORCED_TO_ABORT
       if (!other_in_flight_same_thread_transactions())
@@ -1455,7 +1462,7 @@
 
       bookkeeping_.inc_commits();
 
- if (!transactionsInFlight_.empty())
+ if (!in_flight_transactions().empty())
       {
          forceOtherInFlightTransactionsReadingThisWriteMemoryToAbort();
       }
@@ -1545,7 +1552,7 @@
       //-----------------------------------------------------------------------
       // commit() already has the transactionsInFlightMutex
 
- if (transactionsInFlight_.size() > 1)
+ if (in_flight_transactions().size() > 1)
       {
          static int stalling_ = 0;
 
@@ -1581,7 +1588,7 @@
                synchro::lock(*inflight_lock());
 
                // if our stalling on tx is gone, continue
- if (transactionsInFlight_.end() == transactionsInFlight_.find(stallingOn))
+ if (in_flight_transactions().end() == in_flight_transactions().find(stallingOn))
                {
                   --stalling_;
                   wait = stalling_ * stalls_ < global_clock();
@@ -1611,10 +1618,10 @@
       }
 
       //BUG
- //~ transactionsInFlight_.erase(this);
+ //~ in_flight_transactions().erase(this);
       //~ synchro::unlock(*inflight_lock());
       synchro::unlock(*inflight_lock());
- transactionsInFlight_.erase(this);
+ in_flight_transactions().erase(this);
       synchro::unlock(*general_lock());
 
       deferredCommitWriteState();
@@ -1708,7 +1715,7 @@
 
       bookkeeping_.inc_commits();
 
- if (!transactionsInFlight_.empty())
+ if (!in_flight_transactions().empty())
       {
          forceOtherInFlightTransactionsReadingThisWriteMemoryToAbort();
       }
@@ -1954,11 +1961,11 @@
 
    clock_t secs = 0xffffffff;
 
- for (InflightTxes::iterator j = transactionsInFlight_.begin();
- j != transactionsInFlight_.end(); ++j)
+ for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
+ j != in_flight_transactions().end(); ++j)
    {
         BOOST_ASSERT(*j!=0);
- (*j)->assert_tx_type();
+ //~ (*j)->assert_tx_type();
       transaction *t = *j;
       //-----------------------------------------------------------------------
       // since this is called while direct_writes are occurring, the transaction
@@ -2154,11 +2161,11 @@
 inline bool transaction::otherInFlightTransactionsWritingThisMemory(base_transaction_object *obj)
 {
    // iterate through all the in flight transactions
- for (InflightTxes::iterator j = transactionsInFlight_.begin();
- j != transactionsInFlight_.end(); ++j)
+ for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
+ j != in_flight_transactions().end(); ++j)
    {
         BOOST_ASSERT(*j!=0);
- (*j)->assert_tx_type();
+ //~ (*j)->assert_tx_type();
       transaction *t = *j;
       //-----------------------------------------------------------------------
       // since this is called while direct_writes are occurring, the transaction
@@ -2212,11 +2219,11 @@
 #endif
 
    // iterate through all the in flight transactions
- for (InflightTxes::iterator j = transactionsInFlight_.begin();
- j != transactionsInFlight_.end(); ++j)
+ for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
+ j != in_flight_transactions().end(); ++j)
    {
         BOOST_ASSERT(*j!=0);
- (*j)->assert_tx_type();
+ //~ (*j)->assert_tx_type();
       transaction *t = *j;
       // if we're already aborting for this transaction, skip it
       if (t->forced_to_abort()) continue;
@@ -2337,11 +2344,11 @@
    std::list<transaction*> aborted;
 
    // iterate through all the in flight transactions
- for (InflightTxes::iterator j = transactionsInFlight_.begin();
- j != transactionsInFlight_.end(); ++j)
+ for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
+ j != in_flight_transactions().end(); ++j)
    {
         BOOST_ASSERT(*j!=0);
- (*j)->assert_tx_type();
+ //~ (*j)->assert_tx_type();
       transaction *t = *j;
       // if we're already aborting for this transaction, skip it
 #ifndef DISABLE_READ_SETS
@@ -2410,11 +2417,11 @@
 //-----------------------------------------------------------------------------
 inline bool transaction::other_in_flight_same_thread_transactions() const throw()
 {
- for (InflightTxes::iterator i = transactionsInFlight_.begin();
- i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin();
+ i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
       if (*i == this) continue;
       if (*i == 0) continue;
       // if this is not our threadId or this thread is not composable, skip it
@@ -2428,10 +2435,10 @@
 inline bool transaction::otherInFlightTransactionsOfSameThreadNotIncludingThis(transaction const * const rhs)
 {
    //////////////////////////////////////////////////////////////////////
- for (InflightTxes::iterator i = transactionsInFlight_.begin(); i != transactionsInFlight_.end(); ++i)
+ for (in_flight_trans_cont::iterator i = in_flight_transactions().begin(); i != in_flight_transactions().end(); ++i)
    {
         BOOST_ASSERT(*i!=0);
- (*i)->assert_tx_type();
+ //~ (*i)->assert_tx_type();
       if (*i == rhs) continue;
       // if this is not our threadId or this thread is not composable, skip it
       if ((*i)->threadId_ != this->threadId_) continue;

Modified: sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp
==============================================================================
--- sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp (original)
+++ sandbox/stm/branches/vbe/boost/stm/detail/transactions_stack.hpp 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -25,6 +25,7 @@
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 struct transactions_stack {
+#ifdef BOOST_STM_USE_STACK
     typedef std::stack<transaction*> cont_type;
     cont_type stack_;
     transactions_stack() {
@@ -35,8 +36,23 @@
     void pop() {stack_.pop();}
     std::size_t size() {return stack_.size();}
     transaction* top() {return stack_.top();}
+#else
+ transaction* inner_;
+ std::size_t count_;
+ transactions_stack() : inner_(0), count_(0)
+ {
+ // the stack at least one element (0) so we can always call to top, i.e. current transaction is 0
+ }
+ inline void push(transaction* ptr);
+ inline void pop();
+ std::size_t size() {return count_;}
+ transaction* top() {return inner_;}
+#endif
 };
 
+
+
+
 }
 
 typedef detail::transactions_stack TransactionsStack;

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 2010-03-13 09:06:46 EST (Sat, 13 Mar 2010)
@@ -110,7 +110,11 @@
    typedef std::map<thread_id_t, TxType*> ThreadTxTypeContainer;
 
    typedef std::set<transaction*> TContainer;
- typedef std::set<transaction*> InflightTxes;
+#ifdef BOOST_USE_INFLIGH_TRANSACTION_PTR_SET
+ typedef std::set<transaction**> in_flight_trans_cont;
+#else
+ typedef std::set<transaction*> in_flight_trans_cont;
+#endif
 
    typedef std::multimap<clock_t, MemoryContainerList > DeletionBuffer;
 
@@ -141,9 +145,6 @@
 
    typedef std::set<transaction*> LockedTransactionContainer;
 
- typedef InflightTxes in_flight_transaction_container;
- typedef in_flight_transaction_container in_flight_trans_cont;
-
     #ifdef USE_SINGLE_THREAD_CONTEXT_MAP
     struct tx_context
     {
@@ -258,14 +259,14 @@
 
    static bool do_early_conflict_detection()
    {
- if (!transactionsInFlight_.empty()) return false;
+ if (!in_flight_transactions().empty()) return false;
       if (deferred_updating()) return false;
       else return !(directLateWriteReadConflict_ = false);
    }
 
    static bool do_late_conflict_detection()
    {
- if (!transactionsInFlight_.empty()) return false;
+ if (!in_flight_transactions().empty()) return false;
       else return directLateWriteReadConflict_ = true;
    }
 
@@ -294,7 +295,7 @@
    //--------------------------------------------------------------------------
    static bool do_direct_updating()
    {
- if (!transactionsInFlight_.empty()) return false;
+ if (!in_flight_transactions().empty()) return false;
       else direct_updating_ref() = true;
       return true;
    }
@@ -304,7 +305,7 @@
    //--------------------------------------------------------------------------
    static bool do_deferred_updating()
    {
- if (!transactionsInFlight_.empty()) return false;
+ if (!in_flight_transactions().empty()) return false;
       else direct_updating_ref() = false;
       return true;
    }
@@ -387,7 +388,7 @@
 
    bool is_nested() const
    {
- return nested_;
+ return parent_!=0;
       //~ synchro::lock_guard<Mutex> lock_m(*inflight_lock());
       //~ return other_in_flight_same_thread_transactions();
    }
@@ -864,12 +865,12 @@
 #ifdef PERFORMING_COMPOSITION
 #ifndef USING_SHARED_FORCED_TO_ABORT
       // now set all txes of this threadid that are in-flight to force to abort
- for (InflightTxes::iterator j = transactionsInFlight_.begin();
- j != transactionsInFlight_.end(); ++j)
+ for (in_flight_trans_cont::iterator j = in_flight_transactions().begin();
+ j != in_flight_transactions().end(); ++j)
       {
         BOOST_ASSERT(*j!=0);
           
- (*j)->assert_tx_type();
+ //~ (*j)->assert_tx_type();
          transaction *t = *j;
 
          // if this is a parent or child tx, it must abort too
@@ -895,7 +896,8 @@
       }
    }
 
- inline static InflightTxes const & in_flight_transactions() { return transactionsInFlight_; }
+ inline static in_flight_trans_cont & in_flight_transactions() { return transactionsInFlight_; }
+ //~ inline static in_flight_trans_cont const & in_flight_transactions() const { return transactionsInFlight_; }
 
    inline void make_irrevocable();
    inline void make_isolated();
@@ -1740,7 +1742,7 @@
    //static latm::mutex_thread_id_set_map latmLockedLocksAndThreadIdsMap_;
    //static latm::mutex_thread_id_map latmLockedLocksOfThreadMap_;
    //static LatmType eLatmType_;
- static InflightTxes transactionsInFlight_;
+ static in_flight_trans_cont transactionsInFlight_;
 
    static Mutex deletionBufferMutex_;
    static Mutex transactionMutex_;
@@ -1810,8 +1812,6 @@
    //--------------------------------------------------------------------------
    thread_id_t threadId_;
 
- synchro::unique_lock<Mutex> auto_general_lock_;
-
    //--------------------------------------------------------------------------
    // ******** WARNING ******** MOVING threadId_ WILL BREAK TRANSACTION.
    // threadId_ MUST ALWAYS THE FIRST MEMBER OF THIS CLASS. THE MEMBER
@@ -1819,6 +1819,19 @@
    // ******** WARNING ******** MOVING threadId_ WILL BREAK TRANSACTION
    //--------------------------------------------------------------------------
 
+#ifndef BOOST_STM_USE_STACK
+ transaction* parent_;
+ public:
+ void set_parent(transaction* tx) {parent_=tx;};
+ transaction* parent() {return parent_;};
+ private:
+#else
+ bool nested_;
+#endif
+
+ synchro::unique_lock<Mutex> auto_general_lock_;
+
+
 #ifdef USE_SINGLE_THREAD_CONTEXT_MAP
 ////////////////////////////////////////
 #ifndef BOOST_STM_HAVE_SINGLE_TSS_CONTEXT_MAP
@@ -2309,7 +2322,6 @@
    transaction_state state_; // 2bits
    std::size_t reads_;
    mutable clock_t startTime_;
- bool nested_;
 
    inline transaction_state const & state() const { return state_; }
 
@@ -2377,9 +2389,24 @@
 #define before_retry catch (boost::stm::aborted_tx &)
 #define end_atom catch (boost::stm::aborted_tx &) {}
 
+namespace detail {
+
+#ifndef BOOST_STM_USE_STACK
+ void transactions_stack::push(transaction* ptr) {
+ ptr->set_parent(inner_);
+ inner_ = ptr;
+ ++count_;
+ }
+ void transactions_stack::pop() {
+ inner_ = inner_->parent();
+ --count_;
+ }
+#endif
+}
 } // stm namespace
 } // boost namespace
 
+
 #include <boost/stm/tx_memory_manager.hpp>
 #include <boost/stm/detail/transaction_impl.hpp>
 #include <boost/stm/detail/latm_general_impl.hpp>


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