Changeset 8f4f3e0


Ignore:
Timestamp:
May 22, 2020, 4:00:01 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
3bf812b
Parents:
95cb63b
Message:

bitmask discovery no use snzi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp

    r95cb63b r8f4f3e0  
    55#endif
    66
     7#include <cmath>
    78#include <memory>
    89#include <mutex>
     
    5657                : lists(new intrusive_queue_t[numLists])
    5758                , numLists(numLists)
    58                 #if defined(SIMPLE_SNZI)
    59                         , snzi(4)
     59                #if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK)
     60                        , snzi( std::log2( numLists / 8 ) )
    6061                #endif
    6162        {
     
    8990                        if( !lists[i].lock.try_lock() ) continue;
    9091
    91                         #if !defined(SIMPLE_SNZI)
     92                        #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
    9293                                __attribute__((unused)) int num = numNonEmpty;
    9394                        #endif
     
    100101                                        assert(qword == 0);
    101102                                        bts(tls.mask, bit);
     103                                        snzi.arrive(i);
    102104                                #elif defined(SIMPLE_SNZI)
    103105                                        snzi.arrive(i);
     
    114116                                #endif
    115117                        }
    116                         #if !defined(SIMPLE_SNZI)
     118                        #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
    117119                                assert(numNonEmpty <= (int)numLists);
    118120                        #endif
     
    123125                        #ifndef NO_STATS
    124126                                tls.pick.push.success++;
    125                                 #if !defined(SIMPLE_SNZI)
     127                                #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
    126128                                        tls.empty.push.value += num;
    127129                                        tls.empty.push.count += 1;
     
    135137                #if defined(DISCOVER_BITMASK)
    136138                        assert(numLists <= 64);
    137                         while(true) {
     139                        while(snzi.query()) {
    138140                                tls.pick.pop.mask_attempt++;
    139141                                unsigned i, j;
    140142                                {
    141                                         // Pick two lists at random
    142                                         unsigned num = ((numLists - 1) >> 6) + 1;
    143 
    144143                                        // Pick first list totally randomly
    145144                                        i = tls.rng.next() % numLists;
     
    245244                if( !list.lock.try_lock() ) return nullptr;
    246245
    247                 #if !defined(SIMPLE_SNZI)
     246                #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
    248247                        __attribute__((unused)) int num = numNonEmpty;
    249248                #endif
     
    267266                                assert(qword == 0);
    268267                                __attribute__((unused)) bool ret = btr(tls.mask, bit);
     268                                snzi.depart(w);
    269269                        #elif defined(SIMPLE_SNZI)
    270270                                snzi.depart(w);
     
    284284                // Unlock and return
    285285                list.lock.unlock();
    286                 #if !defined(SIMPLE_SNZI)
     286                #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
    287287                        assert(numNonEmpty >= 0);
    288288                #endif
    289289                #ifndef NO_STATS
    290290                        tls.pick.pop.success++;
    291                         #if !defined(SIMPLE_SNZI)
     291                        #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)
    292292                                tls.empty.pop.value += num;
    293293                                tls.empty.pop.count += 1;
     
    435435        const unsigned numLists;
    436436private:
    437         #if defined(SIMPLE_SNZI)
     437        #if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK)
    438438                snzi_t snzi;
    439439        #else
Note: See TracChangeset for help on using the changeset viewer.