Changeset 9d3dc40


Ignore:
Timestamp:
Jan 19, 2026, 11:38:54 AM (2 weeks ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
79a8c2a
Parents:
5a95560
Message:

Various changes motivated by improving CFA score on len-1 queues.

No such CFA score improvement achieved. Each change helped only on stripped-down, "try to isolate an important factor" tests. Generally, the changes are benign refactorings. (Results substantiating "don't hurt" are forthcoming.)

Libcfa changes are

  • move a read action from between the memory breaks to before them
  • make the memory breaks conditionally excluded (default included, as before)

Harness changes are

  • add width, a compiled-in number of lists to use in round-robin order; defaults to 1, which is what was happening all along
  • make the analysis scripts tolerate (so far, ignore) the width column
  • rename CLI arg NumNodes to Length (now NumNodes is Length * Width)
  • factor core testing loops into helper function runtest
  • switch to signal-based termination (and add uC++ work-around)
  • put "iterator threading" into ITERS_SAVE, joining preexisting "save iter into elem's self ref"; make iterator threading conditional on iterators-active
  • disable insertion loop counter and obs_*-variable declarations (and thus writes) when observation disabled
  • generalize observation to work on multiple lists
  • make observation and assertion-check-enabled mode work on stripped CFA list implementations like tagging-disabled
  • through this observation, ensure correctness of multi-list versions
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/benchmarks/list/Makefile

    r5a95560 r9d3dc40  
    1313CC = gcc-11
    1414CXX = g++-11
    15 UXX ?=  ~/u++/u++-7.0.0/bin/u++
     15UXX ?=  ~/usys1/uCPP/source/bin/u++
    1616
    1717hi:
     
    412412        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_REP_IDS=4 RUN_DATA_SIZE_MODE=sweetspot RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='lq-tailq lq-list cfa-cfa cfa-mandHead cfa-noListed cfa-noIter cfa-likeLq cfa-strip upp-upp cpp-stlref' MAKE_DISABLE_OBSERVATION=yes EXTRA_COMP_FLAGS=-DDISABLE_INTERLEAVING
    413413        cat results-latest.csv >> $@
    414         $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_REP_IDS=4 RUN_DATA_SIZE_MODE=sweetspot RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='lq-tailq lq-list cfa-cfa cfa-mandHead cfa-noListed cfa-noIter cfa-likeLq cfa-strip upp-upp cpp-stlref' MAKE_DISABLE_OBSERVATION=yes EXTRA_COMP_FLAGS=-DDISABLE_INTERLEAVING
     414        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_REP_IDS=5 RUN_DATA_SIZE_MODE=sweetspot RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='lq-tailq lq-list cfa-cfa cfa-mandHead cfa-noListed cfa-noIter cfa-likeLq cfa-strip upp-upp cpp-stlref' MAKE_DISABLE_OBSERVATION=yes EXTRA_COMP_FLAGS=-DDISABLE_INTERLEAVING
    415415        cat results-latest.csv >> $@
     416
     417SHORT_SEMIPERIM=7
     418
     419results-short-once.phony: MAKE_DISABLE_OBSERVATION=yes
     420results-short-once.phony: LEN_LIMIT=$(strip $(shell echo $$(($(SHORT_SEMIPERIM)-$(WIDTH)+1))))
     421results-short-once.phony: LEN_VALS=$(strip $(shell echo {1..$(LEN_LIMIT)}))
     422results-short-once.phony: RUN_DATA_SIZES= $(call cross,-,$(LEN_VALS),1000000)
     423results-short-once.phony: EXTRA_COMP_FLAGS+= -DDISABLE_INTERLEAVING -DWIDTH=$(WIDTH)
     424results-short-once.phony: FX_SOLUTIONS=lq-tailq cfa-cfa
     425results-short-once.phony: OP_MOVEMENTS=queue
     426results-short-once.phony: OP_ACCESSORS=allhead
     427results-short-once.phony: FORCE cleanbuild
     428        $(MAKE) results-latest.csv RUN_DATA_SIZE_MODE=manual RUN_DATA_SIZES="$(RUN_DATA_SIZES)" RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='lq-tailq cfa-cfa' EXTRA_COMP_FLAGS=-DDISABLE_INTERLEAVING OP_MOVEMENTS=queue OP_ACCESSORS=allhead MAKE_DISABLE_OBSERVATION=yes
     429
     430results-short.csv: FORCE
     431        rm -f $@
     432        for i in {1..$(SHORT_SEMIPERIM)}; do    $(MAKE) results-short-once.phony WIDTH=$$i; cat results-latest.csv >> $@; done
    416433
    417434results-zoomout-noshuf.csv: MAKE_DISABLE_OBSERVATION=yes
     
    455472results-smoketest.csv: OP_POLARITIES=insfirst
    456473results-smoketest.csv: OP_ACCESSORS=allhead
     474results-smoketest.csv: EXTRA_COMP_FLAGS+= -DDISABLE_INTERLEAVING
    457475results-smoketest.csv: $(RESULT)
    458476        mv $< $@
     
    469487export FX_SOLUTIONS
    470488export MAKE_DISABLE_OBSERVATION
     489export WIDTH
     490export EXTRA_COMP_FLAGS
    471491
    472492cleanbuild: FORCE clean
  • doc/theses/mike_brooks_MMath/benchmarks/list/driver.c

    r5a95560 r9d3dc40  
    55#include <stdint.h>
    66#include <assert.h>
     7#include <signal.h>                                                                             // signal
     8#include <unistd.h>                                                                             // alarm
     9#include <sys/param.h> // MIN
    710
    811#ifdef DISABLE_OBSERVATION
     
    1619  #define UDATA_T float
    1720  #define UDATA_LEN 17
     21#endif
     22
     23#ifndef DISABLE_INTERLEAVING
     24#error You must disable interleaving---no longer maintained
    1825#endif
    1926
     
    5562
    5663#if defined(NDEBUG) || (defined(__cforall) && !defined(__CFA_DEBUG__))
    57     enum { DefaultNumNodes = 1000, DefaultExperimentDurSec = 1, DefaultCheckDonePeriod = 1000, DefaultExperimentDurOpCount = -1, DefaultSeed = 5 };
     64    enum { DefaultListLen = 1000, DefaultExperimentDurSec = 1, DefaultCheckDonePeriod = 1000, DefaultExperimentDurOpCount = -1, DefaultSeed = 5 };
    5865    const double DefaultInterleaveFrac = 0.0;
    5966    #define TRACE(tp)
    6067#else
    61     enum { DefaultNumNodes = 10, DefaultExperimentDurSec = 1, DefaultCheckDonePeriod = 2, DefaultExperimentDurOpCount = 20, DefaultSeed = 5 };
     68    enum { DefaultListLen = 10, DefaultExperimentDurSec = 1, DefaultCheckDonePeriod = 2, DefaultExperimentDurOpCount = 20, DefaultSeed = 5 };
    6269    const double DefaultInterleaveFrac = 0.0;
    6370    static const char * tp_filter
     
    7279#endif
    7380
     81// Number of lists used in experiment
     82// General tests use one
     83// Greater values help explain away poor len-1 IPC
     84// Value always compiled in
     85#ifndef WIDTH
     86#define WIDTH 1
     87#endif
     88
    7489static B_UserItem *ui = NULL;
    7590
    7691static BFX_LISTED_ELEM_T(B_UserItem) observedItem;
    7792
    78 static BFX_LIST_HEAD_T(B_UserItem) lst;
     93static BFX_LIST_HEAD_T(B_UserItem) lst[ WIDTH ];
    7994
    8095B_UserItem * seekUi( size_t i ) {
     
    104119MAYBE_EXTERN_C (
    105120
    106     volatile size_t       bobs_ops_completed      = 0;
     121    volatile size_t bobs_ops_completed      = 0;
    107122    volatile size_t bobs_prog_inserting     = 0;
    108123    volatile size_t bobs_prog_removing      = 0;
    109124    volatile size_t bobs_prog_removing_end  = 0;
    110125    volatile size_t bobs_prog_rollover_flag = 0;
    111     //                    bobs_prog_rem_pos         (defined after BOP_REMPROGEND_IS_REMNO_BASED)
     126    //              bobs_prog_rem_pos         (declared obs.h; defined after BOP_REMPROGEND_IS_REMNO_BASED)
     127
     128    volatile size_t bobs_priv_active_list_no = -1;
     129    volatile size_t bobs_priv_list_len = -1;
    112130
    113131    void bobs_seek(size_t i) {
     
    118136
    119137    void bobs_moveNext() {
    120         observedItem = BFX_GET_AFTER(B_UserItem, lst, observedItem);
     138        observedItem = BFX_GET_AFTER(B_UserItem, lst[bobs_priv_active_list_no], observedItem);
    121139    }
    122140
    123141    void bobs_movePrev() {
    124         observedItem = BFX_GET_BEFORE(B_UserItem, lst, observedItem);
     142        observedItem = BFX_GET_BEFORE(B_UserItem, lst[bobs_priv_active_list_no], observedItem);
    125143    }
    126144
    127145    bool bobs_hasCurrent() {
    128         return BFX_IS_VALID_POS(B_UserItem, lst, observedItem);
     146        return BFX_IS_VALID_POS(B_UserItem, lst[bobs_priv_active_list_no], observedItem);
    129147    }
    130148
    131149    void * bobs_getCurrentLoc() {
    132         return BFX_DEREF_POS(B_UserItem, lst, observedItem);
     150        return BFX_DEREF_POS(B_UserItem, lst[bobs_priv_active_list_no], observedItem);
    133151    }
    134152    size_t bobs_getCurrentVal() {
    135         B_UserItem * curUI = BFX_DEREF_POS(B_UserItem, lst, observedItem);
     153        B_UserItem * curUI = BFX_DEREF_POS(B_UserItem, lst[bobs_priv_active_list_no], observedItem);
    136154        return curUI->self_ord;
    137155    }
     
    139157    enum bobs_op_movement_t bobs_op_movement = OP_MOVEMENT;
    140158    enum bobs_op_polarity_t bobs_op_polarity = OP_POLARITY;
     159
     160     static inline ssize_t signDiv( ssize_t num, size_t denom ) {
     161      if ( num >= 0 ) return num / denom;
     162      else return -1 - ( ((-num)-1) / denom );
     163    }
     164
     165    // Abstracts progress on all insertions and on queue removals into one treatment.
     166    // `nodeProgress` is a count of nodes inserted or removed, stepping (quickly) through [0..NumNodes]
     167    // (rather than steppling slowly through [0..Length]).
     168    // Returns the position congruent to the active list number (mod WIDTH)
     169    // that is maximally less than `nodeProgress`.
     170    // A negative return means no such position is yet reached.
     171    // Interpreting this result as last listed (last inserted) vs first unlisted (last removed),
     172    // and interpreting `nodeProgress` as advancing from 0 (eg inslast-stack remove) vs
     173    // receding from NumNodes-1 (eg insfirst-stack remove), are left to the caller.
     174    static ssize_t lastActiveNodeReached( size_t nodeProgress ) {
     175        assert( signDiv(  20, 5 ) ==  4 );
     176        assert( signDiv(  19, 5 ) ==  3 );
     177        assert( signDiv(   6, 5 ) ==  1 );
     178        assert( signDiv(   5, 5 ) ==  1 );
     179        assert( signDiv(   4, 5 ) ==  0 );
     180        assert( signDiv(   3, 5 ) ==  0 );
     181        assert( signDiv(   2, 5 ) ==  0 );
     182        assert( signDiv(   1, 5 ) ==  0 );
     183        assert( signDiv(   0, 5 ) ==  0 );
     184        assert( signDiv(  -1, 5 ) == -1 );
     185        assert( signDiv(  -2, 5 ) == -1 );
     186        assert( signDiv(  -2, 5 ) == -1 );
     187        assert( signDiv(  -3, 5 ) == -1 );
     188        assert( signDiv(  -4, 5 ) == -1 );
     189        assert( signDiv(  -6, 5 ) == -2 );
     190        assert( signDiv(  -7, 5 ) == -2 );
     191        assert( signDiv( -20, 5 ) == -4 );
     192        assert( signDiv( -21, 5 ) == -5 );
     193        ssize_t activeLenProgress = signDiv( (ssize_t)nodeProgress - (ssize_t)bobs_priv_active_list_no, WIDTH ); // IDW
     194        ssize_t activeNodeProgress = activeLenProgress * WIDTH + (ssize_t)bobs_priv_active_list_no; // IWA
     195        if ( activeNodeProgress == nodeProgress ) return activeNodeProgress - WIDTH;
     196        else return activeNodeProgress;
     197    }
     198
     199    ssize_t bobs_first_valid() {
     200        switch(bobs_op_movement) {
     201            case stack: return (ssize_t)bobs_priv_active_list_no;
     202            case queue: return lastActiveNodeReached( *bobs_prog_rem_pos ) + WIDTH;
     203        }
     204        assert(0 && "unsupported bobs_op_movement value");
     205        return -1;
     206    }
     207    ssize_t bobs_last_valid() {
     208        switch(bobs_op_movement) {
     209            case stack: return lastActiveNodeReached( MIN( (ssize_t)bobs_prog_inserting - (ssize_t)WIDTH, (ssize_t)bobs_priv_list_len - (ssize_t)*bobs_prog_rem_pos - (ssize_t)WIDTH ) )  + WIDTH;
     210            case queue: return lastActiveNodeReached( bobs_prog_inserting );
     211        }
     212        assert(0 && "unsupported bobs_op_movement value");
     213        return -1;
     214    }
    141215)
    142216#endif
     
    192266// end: copied from https://stackoverflow.com/a/33021408
    193267
     268#ifdef DISABLE_OBSERVATION
     269#define OBS(...)
     270#else
     271#define OBS(...) __VA_ARGS__
     272#endif
     273
     274static volatile bool stop = false;
     275static void sigAlarm( int p __attribute__(( unused )) ) { stop = true; }
     276
     277void runtest(const char * argv0, size_t NumNodes, size_t ExperimentDurOpCount );
     278
    194279int main(int argc, const char *argv[]) {
    195280
    196   #ifdef DISABLE_OBSERVATION
    197     // define the outbound dependencies as locals, for compiling into nops
    198     size_t       bobs_ops_completed      = 0;
    199     size_t bobs_prog_inserting     = 0;
    200     size_t bobs_prog_removing      = 0;
    201     size_t bobs_prog_removing_end  = 0;
    202     size_t bobs_prog_rollover_flag = 0;
    203   #endif
    204 
    205     const char * usage_args = "[ExperimentDurSec [CheckDonePeriod [NumNodes [ExperimentDurOpCount [Seed [InterleaveFrac]]]]]]";
     281    const char * usage_args = "[ExperimentDurSec [CheckDonePeriod [ListLen [ExperimentDurOpCount [Seed [InterleaveFrac]]]]]]";
    206282    const int static_arg_posns = 6;
    207283
    208284    size_t ExperimentDurSec     = DefaultExperimentDurSec;
    209285    size_t CheckDonePeriod      = DefaultCheckDonePeriod;
    210     size_t NumNodes             = DefaultNumNodes;
     286    size_t ListLen             = DefaultListLen;
    211287    size_t ExperimentDurOpCount = DefaultExperimentDurOpCount;
    212288    size_t Seed                 = DefaultSeed;
     
    217293      case 5: Seed = atoi(argv[5]);
    218294      case 4: ExperimentDurOpCount = atol(argv[4]);
    219       case 3: NumNodes = atoi(argv[3]);
     295      case 3: ListLen = atoi(argv[3]);
    220296      case 2: CheckDonePeriod = atoi(argv[2]);
    221297      case 1: ExperimentDurSec = atoi(argv[1]);
    222298    }
    223299
    224     // printf("ExperimentDurSec=%d, CheckDonePeriod=%d, NumNodes=%d, ExperimentDurOpCount=%zd, Seed=%d,\n",
    225     //     ExperimentDurSec, CheckDonePeriod, NumNodes, ExperimentDurOpCount, Seed );
    226 
    227     if (ExperimentDurSec == 0 || CheckDonePeriod == 0 || NumNodes == 0 || ExperimentDurOpCount == 0 || Seed == 0 ) {
     300    // printf("ExperimentDurSec=%d, CheckDonePeriod=%d, ListLen=%d, ExperimentDurOpCount=%zd, Seed=%d,\n",
     301    //     ExperimentDurSec, CheckDonePeriod, ListLen, ExperimentDurOpCount, Seed );
     302
     303    if (ExperimentDurSec == 0 || CheckDonePeriod == 0 || ListLen == 0 || ExperimentDurOpCount == 0 || Seed == 0 ) {
    228304        printf("usage: %s %s\n", argv[0], usage_args);
    229305        return -1;
     
    236312    }
    237313  #endif
     314
     315    OBS( bobs_priv_list_len = ListLen );
     316    const size_t NumNodes = ListLen * WIDTH;
    238317
    239318    ui = (B_UserItem*) malloc( (size_t)NumNodes * (size_t)sizeof(B_UserItem) );
     
    436515
    437516  #ifndef DISABLE_ITERS
    438     #define ITERS_SAVE(lastInsertedElemPtr, lastInsertedIter) (lastInsertedElemPtr)->selfListed = lastInsertedIter
    439   #endif
    440 
    441     BFX_INIT(B_UserItem, lst);
     517    #define ITERS_SAVE(lastInsertedElemPtr, lastInsertedIter) \
     518        lastInserted[listno] = (lastInsertedElemPtr)->selfListed = lastInsertedIter
     519  #endif
     520
     521    for ( size_t listno = 0; listno < WIDTH; listno ++ )
     522        BFX_INIT(B_UserItem, lst[ listno ]);
    442523
    443524    bobs_init(NumNodes);
     
    465546    #endif
    466547
     548  #ifdef __U_CPLUSPLUS__
     549    // uC++ doesn't implement `alarm`---it crashes with "not implemented" at runtime
     550    // so, here is an equivalent timer task
     551    _Task timer_t {
     552        size_t alarmDurSec;
     553        void main() {
     554          _Accept( ~timer_t );
     555          or _Timeout( uDuration( alarmDurSec ) ) { sigAlarm(0); }
     556        }
     557      public:
     558        timer_t( size_t alarmDurSec ) : alarmDurSec(alarmDurSec) {}
     559    };
     560    timer_t timer ( ExperimentDurSec );
     561  #else
     562    signal( SIGALRM, sigAlarm );      // setup signal handler
     563    alarm( ExperimentDurSec );        // trigger in N seconds
     564  #endif
     565
     566    runtest( argv[0], NumNodes, ExperimentDurOpCount );
     567
     568    free(ui);
     569}
     570
     571
     572void runtest(const char * argv0, const size_t NumNodes, size_t ExperimentDurOpCount ) {
     573
     574  assert( NumNodes >= WIDTH );
     575  assert( NumNodes % WIDTH == 0 );
    467576
    468577    size_t privateOpsCompleted = 0;
     
    471580    clock_t start = clock();
    472581
    473     while (elapsed_sec <= (double) ExperimentDurSec && privateOpsCompleted < ExperimentDurOpCount) {
    474         for ( size_t t = 0; t < CheckDonePeriod; t += 1 ) {
    475             TRACE('a')              // insert special first
    476             ITERS_SAVE( &ui[0],
    477                 BOP_INIT(lst, ui[0]) );
    478             TRACE('b')              // insert general
    479             // Keep lastInserted even on DISABLE_ITERS because it's communication to the remove phase
    480             BFX_LISTED_ELEM_T(B_UserItem) lastInserted = BFX_GET_FIRST(B_UserItem, lst);
    481             B_UserItem * insertNow = seekUi(1);
    482             for ( size_t privateCurInsert = 1;
    483                   (bobs_prog_inserting = privateCurInsert, privateCurInsert < NumNodes);
    484                   privateCurInsert += 1
    485                 ) {
    486                 assert( insertNow->self_ord == privateCurInsert );
     582    while ( ! stop && privateOpsCompleted < ExperimentDurOpCount ) {
     583
     584            B_UserItem * insertNow = & ui[ 0 ];
     585
     586              #ifdef DISABLE_ITERS
     587            #define INSERTION_NEIGHBOUR NOT_SUPPORTED
     588              #else
     589            BFX_LISTED_ELEM_T(B_UserItem) lastInserted[ WIDTH ];
     590            #define INSERTION_NEIGHBOUR lastInserted[ listno ]
     591              #endif
     592
     593              #ifdef DISABLE_SHUFFLING_INDIRECTION
     594            #define HAS_NEXT  ( (void*)insertNow < (void*)&ui[NumNodes] )
     595            #define MOVE_NEXT ( insertNow++ )
     596              #else
     597            #define HAS_NEXT  ( insertNow->self_ord != 0 )
     598            #define MOVE_NEXT ( insertNow = & ui[ insertNow->succ_pos ] )
     599              #endif
     600
     601            // insert special first
     602            for ( size_t listno = 0; listno < WIDTH; listno ++ ) {
     603                OBS( bobs_priv_active_list_no = bobs_prog_inserting = listno; )
     604                TRACE('a')
     605                ITERS_SAVE( insertNow,
     606                    BOP_INIT( lst[listno], (*insertNow) ) );
     607                MOVE_NEXT;
     608                TRACE('b')
     609            }
     610            // insert general
     611            for ( OBS( size_t privateCurInsert = WIDTH ); HAS_NEXT; ) {
     612              for ( size_t listno = 0; listno < WIDTH; (listno ++) ) {
     613                OBS( bobs_prog_inserting = privateCurInsert; )
     614                OBS( bobs_priv_active_list_no = listno; )
    487615                TRACE('-')
    488                 lastInserted =
    489                     BOP_INSERT( lst, lastInserted, (*insertNow) );
     616                ITERS_SAVE( insertNow,
     617                    BOP_INSERT( lst[listno], INSERTION_NEIGHBOUR, (*insertNow) ) );
    490618                TRACE('+')
    491                 ITERS_SAVE( insertNow, lastInserted );
    492               #ifdef DISABLE_SHUFFLING_INDIRECTION
    493                 insertNow++;
    494               #else
    495                 insertNow = & ui[ insertNow->succ_pos ];
     619                OBS( privateCurInsert += 1; )
     620                MOVE_NEXT;
     621              }
     622              OBS( bobs_prog_inserting = privateCurInsert; )
     623            }
     624              #ifndef DISABLE_ITERS
     625            BFX_LISTED_ELEM_T(B_UserItem) nextRemoval = BOP_SWITCH_REMDIR (
     626                ui[0].selfListed,           // forward starts from first insert
     627                lastInserted[ WIDTH - 1 ]   // backward starts from last insert
     628            );
    496629              #endif
    497             }
    498           #ifdef DISABLE_INTERLEAVING
    499             // interleaving off, simple removes
    500             // (remove logic of 2b01f8eb0956)
    501           #ifndef DISABLE_ITERS
    502             BFX_LISTED_ELEM_T(B_UserItem) nextRemoval = BOP_SWITCH_REMDIR (
    503                 ui[0].selfListed,  // forward starts from first insert
    504                 lastInserted       // backward starts from last insert
    505             );
    506           #endif
    507             TRACE('c')
    508             for ( size_t privateCurRemove = 1;
    509                   (bobs_prog_removing = privateCurRemove, privateCurRemove < NumNodes);
    510                   privateCurRemove += 1
    511                 ) {
    512               #ifdef DISABLE_ITERS
    513                 #define curRemovalI ERROR_REQD_ITER_NOT_PROVIDED
    514               #else
    515                 BFX_LISTED_ELEM_T(B_UserItem) curRemovalI = nextRemoval;
    516                 B_UserItem * curRemovalE = BFX_DEREF_POS(B_UserItem, lst, nextRemoval);
    517                #ifdef DISABLE_SHUFFLING_INDIRECTION
    518                 nextRemoval = (BOP_SWITCH_REMDIR( curRemovalE + 1, curRemovalE - 1 ))->selfListed;
    519                #else
    520                 nextRemoval = ui[ curRemovalE->BOP_SWITCH_REMDIR(succ_pos, pred_pos) ].selfListed;
    521                #endif
    522               #endif
    523                 TRACE('-')
    524                 BOP_REMOVE( lst, curRemovalI );
    525                 TRACE('+')
    526             }
    527           #else
    528             // interleaving on, complex removes
    529             TRACE('c')              // remove general
    530             size_t removeProgress  [N_INTERLEAVE_ACTION] = { 0, 0 };
    531             #define startItem BOP_SWITCH_REMDIR( iactFwdStartItem, iactRevStartItem )
    532             B_UserItem * removeItem[N_INTERLEAVE_ACTION] =
    533                 { startItem[OuterActn], startItem[InnerActn] };
    534             for ( InterleaveAction flip = OuterActn
    535                 ; (bobs_prog_removing = removeProgress[0] + removeProgress[1] + 1,
    536                      bobs_prog_removing_end = removeProgress[0] + 1,
    537                      removeProgress[0] + removeProgress[1] < NumNodes - 1 )
    538                 ;
    539                 ) {
    540 //printf("--- flip=%d removeProgress[0]=%zd removeProgress[1]=%zd removeItem[flip]->self_ord=%zd\n", flip, removeProgress[0], removeProgress[1], removeItem[flip]->self_ord);
    541                 TRACE('-')
    542                 BOP_REMOVE( lst, removeItem[flip]->selfListed );
    543                 TRACE('+')
    544 
    545                 InterleaveAction nextFlip = removeItem[flip]->later_flip;
    546                 removeProgress[flip] += 1;
    547                 removeItem[flip] = & ui[ removeItem[flip]-> BOP_SWITCH_REMDIR(succ_pos, pred_pos) ];
    548                 flip = nextFlip;
    549             }
    550 
    551 //             for ( InterleaveAction flip = OuterActn;
    552 //                   (bobs_prog_removing = removeProgress[0] + removeProgress[1] + 1,
    553 //                      bobs_prog_removing_end = removeProgress[0] + 1,
    554 //                      removeProgress[0] < numNodesItlv[0] && removeProgress[1] < numNodesItlv[1] );
    555 //                 ) {
    556 //                 TRACE('-')
    557 //                 BOP_REMOVE( lst, removeItem[flip]->selfListed );
    558 //                 TRACE('+')
    559 
    560 //                 InterleaveAction nextFlip = removeItem[flip]->later_flip;
    561 //                 removeProgress[flip] += 1;
    562 //                 removeItem[flip] = & ui[ removeItem[flip]-> BOP_SWITCH_REMDIR(succ_pos, pred_pos) ];
    563 //                 flip = nextFlip;
    564 //             }
    565 //             TRACE('X')              // remove imbalanced
    566 //             // most work done under general; it stops when either flip-side's work finishes
    567 //             // now drain any any stragglers so both flip-sides' work finishes
    568 //             for ( InterleaveAction flip = 0; flip < N_INTERLEAVE_ACTION; flip ++ ) {
    569 //                 for ( ; (bobs_prog_removing = removeProgress[0] + removeProgress[1] + 1,
    570 //                          bobs_prog_removing_end = removeProgress[0] + 1,
    571 //                          removeProgress[flip] < numNodesItlv[flip] )
    572 //                       ;
    573 //                     ) {
    574 // //printf("--- flip=%d removeProgress[flip]=%zd numNodesItlv[flip]=%zd removeItem[flip]->self_ord=%zd\n", flip, removeProgress[flip], numNodesItlv[flip], removeItem[flip]->self_ord);
    575 //                     TRACE('-')
    576 //                     BOP_REMOVE( lst, removeItem[flip]->selfListed );
    577 //                     TRACE('+')
    578 
    579 //                     removeProgress[flip] += 1;
    580 //                     removeItem[flip] = & ui[ removeItem[flip]-> BOP_SWITCH_REMDIR(succ_pos, pred_pos) ];
    581 //                 }
    582 //             }
    583           #endif // DISABLE_INTERLEAVING
    584             TRACE('D')              // remove special last
    585             BOP_TEARDOWN(lst);
    586             TRACE('d')
     630            for ( size_t listno = 0; listno < WIDTH; listno += 1 ) {
     631                OBS( bobs_priv_active_list_no = listno; )
     632                TRACE('c')
     633            }
     634            // remove general
     635            size_t privateCurRemove = 1; // count 1/<= to observe from the item not yet being removed
     636            while ( privateCurRemove <= NumNodes - WIDTH ) // -WIDTH to stop before special last
     637                for ( size_t listno = 0; listno < WIDTH; listno += 1 ) {
     638                    OBS( bobs_prog_removing = privateCurRemove;  )
     639                    OBS( bobs_priv_active_list_no = listno; )
     640                  #ifdef DISABLE_ITERS
     641                    #define curRemovalI ERROR_REQD_ITER_NOT_PROVIDED
     642                  #else
     643                    BFX_LISTED_ELEM_T(B_UserItem) curRemovalI = nextRemoval;
     644                    B_UserItem * curRemovalE = BFX_DEREF_POS(B_UserItem, lst[listno], nextRemoval);
     645                  #ifdef DISABLE_SHUFFLING_INDIRECTION
     646                    nextRemoval = (BOP_SWITCH_REMDIR( curRemovalE + 1, curRemovalE - 1 ))->selfListed;
     647                  #else
     648                    nextRemoval = ui[ curRemovalE->BOP_SWITCH_REMDIR(succ_pos, pred_pos) ].selfListed;
     649                  #endif
     650                  #endif
     651                    TRACE('-')
     652                    BOP_REMOVE( lst[listno], curRemovalI );
     653                    TRACE('+')
     654                    privateCurRemove += 1;
     655                }
     656            // remove special last
     657            for ( size_t listno = 0; listno < WIDTH; listno += 1 ) {
     658                OBS( bobs_prog_removing = privateCurRemove; )
     659                OBS( bobs_priv_active_list_no = listno; )
     660                TRACE('D')
     661                BOP_TEARDOWN(lst[listno]);
     662                TRACE('d')
     663                privateCurRemove += 1;
     664            }
     665            OBS( bobs_prog_removing = privateCurRemove;  )
    587666
    588667            privateOpsCompleted += NumNodes;
    589 
     668          OBS(
    590669            bobs_prog_rollover_flag = 1;
    591670            TRACE('e')
     
    596675            TRACE('f')
    597676            bobs_prog_rollover_flag = 0;
    598             TRACE('g')
    599         }
    600       #ifndef DISABLE_CLOCK_RECHECK
    601         clock_t end = clock();
    602         elapsed_sec = ((double)(end - start)) / ((double)CLOCKS_PER_SEC);
    603       #endif
    604     }
    605     #ifdef DISABLE_CLOCK_RECHECK
    606     {
    607         clock_t end = clock();
    608         elapsed_sec = ((double)(end - start)) / ((double)CLOCKS_PER_SEC);
    609     }
    610     #endif
    611 
    612     double mean_op_dur_ns = elapsed_sec / ((double)bobs_ops_completed) * 1000 * 1000 * 1000;
    613     printf("%s,%zd,%f,%f\n", argv[0], bobs_ops_completed, elapsed_sec, mean_op_dur_ns);
    614 
    615     free(ui);
     677            TRACE('g') )
     678    }
     679
     680    clock_t end = clock();
     681    elapsed_sec = ((double)(end - start)) / ((double)CLOCKS_PER_SEC);
     682
     683    double mean_op_dur_ns = elapsed_sec / ((double)privateOpsCompleted) * 1000 * 1000 * 1000;
     684    printf("%s,%d,%zd,%f,%f\n", argv0, WIDTH, privateOpsCompleted, elapsed_sec, mean_op_dur_ns);
    616685}
  • doc/theses/mike_brooks_MMath/benchmarks/list/fx-cfa-GENERAL.h

    r5a95560 r9d3dc40  
    3737#define BFX_GET_AFTER(S, lst, iter)              ( & next( * (iter) ) )
    3838#define BFX_GET_BEFORE(S, lst, iter)             ( & prev( * (iter) ) )
     39#define BFX_DEREF_POS(S, lst, iter)              (iter)
     40
     41#ifdef __EXPERIMENTAL_DISABLE_OTAG__
     42// alt list impl, no tagging: next/prev accessors don't known when "no more elems"
     43// so hack around it in harness: look for leaked abstraction of list head being reported as a regular neighbour
     44#define BFX_IS_VALID_POS(S, lst, iter)           ((void*)(iter)!=(void*)(&lst))
     45#else
     46// normal list impl: next/prev accessors return *0p on "no more elems"
    3947#define BFX_IS_VALID_POS(S, lst, iter)           ((iter)!=NULL)
    40 #define BFX_DEREF_POS(S, lst, iter)              (iter)
     48#endif
  • doc/theses/mike_brooks_MMath/benchmarks/list/observation.c

    r5a95560 r9d3dc40  
    77#include <stdio.h>
    88#include <stddef.h>
    9 #include <sys/param.h>
    109
    1110#include "observation.h"
     
    113112        printf("%8zd + %6zd/2 + %6zd/2, %6zd@e %6zd_u", bobs_ops_completed, bobs_prog_inserting, bobs_prog_removing, bobs_prog_removing_end, *bobs_prog_rem_pos);
    114113
    115         // signed arithmetic allows representating empty range as from=0, to=-1
    116         ptrdiff_t validFrom, validTo;
    117         switch(bobs_op_movement) {
    118             case stack:
    119                 validFrom = 0;
    120                 validTo = MIN( (ptrdiff_t)bobs_prog_inserting  -1, (ptrdiff_t)NumNodes - (ptrdiff_t)*bobs_prog_rem_pos - 1 );
    121                 break;
    122             case queue:
    123                 validFrom = (ptrdiff_t)*bobs_prog_rem_pos;
    124                 validTo = (ptrdiff_t)bobs_prog_inserting-1;
    125                 break;
    126             default:
    127                 assert(0 && "unsupported bobs_op_movement value");
    128         }
     114        ptrdiff_t validFrom = bobs_first_valid();
     115        ptrdiff_t validTo = bobs_last_valid();
    129116
    130117        printf("  ");
  • doc/theses/mike_brooks_MMath/benchmarks/list/observation.h

    r5a95560 r9d3dc40  
    11#include "proglang.h"
    22#include <stdbool.h>
     3#include <stddef.h>
    34
    45
     
    2425    extern volatile size_t const * bobs_prog_rem_pos;
    2526
     27    // signed values allows representating empty range as from=0, to=-1
     28    ptrdiff_t bobs_first_valid();
     29    ptrdiff_t bobs_last_valid();
     30
    2631    // observation.c defines
    2732
  • doc/theses/mike_brooks_MMath/benchmarks/list/results-smoketest.csv

    r5a95560 r9d3dc40  
    1 2025-07-25 14:33:37,1,1 10 289637 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,14481850,1.124100,77.621298
    2 2025-07-25 14:33:38,1,1 10000 283 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,127350000,1.001588,7.864845
    3 2025-07-25 14:33:39,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,73669000,1.031389,14.000312
    4 2025-07-25 14:33:40,1,1 10000 283 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,124520000,1.002236,8.048795
    5 2025-07-25 14:33:41,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,11000000,1.074396,97.672364
    6 2025-07-25 14:33:42,1,1 1000000 3 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,150000000,1.018578,6.790520
    7 2025-07-25 14:33:43,1,1 1 1000000 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,11000000,1.058028,96.184364
    8 2025-07-25 14:33:45,1,1 100 25601 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,51202000,1.008144,19.689543
    9 2025-07-25 14:33:46,1,1 10 289637 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,28963700,1.083887,37.422256
    10 2025-07-25 14:33:47,1,1 10000 283 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,124520000,1.012447,8.130798
    11 2025-07-25 14:33:48,1,1 1 1000000 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,26000000,1.011152,38.890462
    12 2025-07-25 14:33:49,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,11000000,1.071608,97.418909
    13 2025-07-25 14:33:50,1,1 1000 3203 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,32030000,1.022850,31.934124
    14 2025-07-25 14:33:52,1,1 10 289637 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,14481850,1.096347,75.704900
    15 2025-07-25 14:33:53,1,1 100000 29 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,162400000,1.009615,6.216841
    16 2025-07-25 14:33:54,1,1 100000 29 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,139200000,1.009525,7.252335
    17 2025-07-25 14:33:55,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,11000000,1.055844,95.985818
    18 2025-07-25 14:33:56,1,1 100 25601 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,33281300,1.054635,31.688516
    19 2025-07-25 14:33:57,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,9830409,1.156687,117.664179
    20 2025-07-25 14:33:59,1,1 100000 29 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,171100000,1.010629,5.906657
    21 2025-07-25 14:34:00,1,1 10 289637 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,14481850,1.068056,73.751351
    22 2025-07-25 14:34:01,1,1 1 10000000 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,10000000,1.513156,151.315600
    23 2025-07-25 14:34:05,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,120000000,1.005410,8.378417
    24 2025-07-25 14:34:06,1,1 1000 3203 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,73669000,1.027758,13.951024
    25 2025-07-25 14:34:07,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,10000000,1.528870,152.887000
    26 2025-07-25 14:34:11,1,1 100 25601 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,51202000,1.006337,19.654252
    27 2025-07-25 14:34:12,1,1 10000 283 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,124520000,1.017963,8.175096
    28 2025-07-25 14:34:13,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,9830409,1.149980,116.981908
    29 2025-07-25 14:34:15,1,1 100000 29 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,150800000,1.014836,6.729682
    30 2025-07-25 14:34:16,1,1 1 3276803 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,9830409,1.132979,115.252478
    31 2025-07-25 14:34:18,1,1 10 289637 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,14481850,1.067593,73.719380
    32 2025-07-25 14:34:19,1,1 1 1000000 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,11000000,1.057079,96.098091
    33 2025-07-25 14:34:20,1,1 1000 3203 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,73669000,1.005406,13.647613
    34 2025-07-25 14:34:21,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,129000000,1.010534,7.833597
    35 2025-07-25 14:34:22,1,1 1000000 3 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,162000000,1.005930,6.209444
    36 2025-07-25 14:34:23,1,1 1 3276803 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,9830409,1.135083,115.466508
    37 2025-07-25 14:34:25,1,1 10 289637 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,14481850,1.067839,73.736367
    38 2025-07-25 14:34:26,1,1 100000 29 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,156600000,1.002060,6.398851
    39 2025-07-25 14:34:27,1,1 100 25601 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,48641900,1.005337,20.668128
    40 2025-07-25 14:34:28,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,76872000,1.016555,13.223996
    41 2025-07-25 14:34:29,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,9830409,1.136574,115.618180
    42 2025-07-25 14:34:31,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,123000000,1.004886,8.169805
    43 2025-07-25 14:34:32,1,1 10 289637 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,14481850,1.089222,75.212904
    44 2025-07-25 14:34:33,1,1 1 3276803 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,9830409,1.191476,121.203095
    45 2025-07-25 14:34:35,1,1 10000 283 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,110370000,1.002689,9.084797
    46 2025-07-25 14:34:36,1,1 10 289637 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,14481850,1.071031,73.956780
    47 2025-07-25 14:34:37,1,1 100 25601 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,48641900,1.022545,21.021897
    48 2025-07-25 14:34:38,1,1 10 289637 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,14481850,1.101408,76.054372
    49 2025-07-25 14:34:40,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,9830409,1.151480,117.134496
    50 2025-07-25 14:34:41,1,1 10000 283 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,124520000,1.007859,8.093953
    51 2025-07-25 14:34:42,1,1 10 289637 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,14481850,1.101968,76.093041
    52 2025-07-25 14:34:44,1,1 10000 283 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,124520000,1.018063,8.175899
    53 2025-07-25 14:34:45,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,9830409,1.137307,115.692745
    54 2025-07-25 14:34:46,1,1 100 25601 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,53762100,1.044294,19.424353
    55 2025-07-25 14:34:48,1,1 100000 29 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,34800000,1.009267,29.001925
    56 2025-07-25 14:34:49,1,1 100 25601 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,51202000,1.037505,20.262978
    57 2025-07-25 14:34:50,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,9830409,1.150686,117.053726
    58 2025-07-25 14:34:51,1,1 1 10000000 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,10000000,1.570977,157.097700
    59 2025-07-25 14:34:55,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,73669000,1.004851,13.640079
    60 2025-07-25 14:34:56,1,1 100 25601 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,48641900,1.007154,20.705482
    61 2025-07-25 14:34:57,1,1 100 25601 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,51202000,1.021808,19.956408
    62 2025-07-25 14:34:58,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,162000000,1.018332,6.286000
    63 2025-07-25 14:34:59,1,1 100000 29 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,139200000,1.001096,7.191782
    64 2025-07-25 14:35:00,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,10000000,1.509163,150.916300
    65 2025-07-25 14:35:04,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,10000000,1.523187,152.318700
    66 2025-07-25 14:35:08,1,1 1 10000000 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,30000000,1.291843,43.061433
    67 2025-07-25 14:35:12,1,1 100000 29 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,133400000,1.017233,7.625435
    68 2025-07-25 14:35:13,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,10000000,1.529335,152.933500
    69 2025-07-25 14:35:17,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,153000000,1.013427,6.623706
    70 2025-07-25 14:35:18,1,1 100 25601 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,51202000,1.019527,19.911859
    71 2025-07-25 14:35:19,1,1 100000 29 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,147900000,1.009347,6.824523
    72 2025-07-25 14:35:20,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,10000000,1.529478,152.947800
    73 2025-07-25 14:35:24,1,1 1 1000000 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,10000000,1.009042,100.904200
    74 2025-07-25 14:35:25,1,1 1000 3203 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,70466000,1.008914,14.317742
    75 2025-07-25 14:35:26,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,73669000,1.007051,13.669943
    76 2025-07-25 14:35:27,1,1 1 10000000 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,10000000,1.508540,150.854000
    77 2025-07-25 14:35:31,1,1 10000 283 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,36790000,1.070702,29.103071
    78 2025-07-25 14:35:32,1,1 10000 283 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,124520000,1.007902,8.094298
    79 2025-07-25 14:35:33,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,10000000,1.514299,151.429900
    80 2025-07-25 14:35:37,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,11000000,1.080953,98.268455
    81 2025-07-25 14:35:38,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,11000000,1.055062,95.914727
    82 2025-07-25 14:35:39,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,73669000,1.038104,14.091463
    83 2025-07-25 14:35:40,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,76872000,1.023905,13.319609
    84 2025-07-25 14:35:41,1,1 100000 29 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,153700000,1.018344,6.625530
    85 2025-07-25 14:35:42,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,123000000,1.015098,8.252829
    86 2025-07-25 14:35:44,1,1 1 3276803 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,26214424,1.063951,40.586473
    87 2025-07-25 14:35:45,1,1 1000000 3 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,42000000,1.048904,24.973905
    88 2025-07-25 14:35:46,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,11000000,1.077116,97.919636
    89 2025-07-25 14:35:48,1,1 1000000 3 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,123000000,1.016081,8.260821
    90 2025-07-25 14:35:49,1,1 10000 283 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,113200000,1.017333,8.987041
     12026-01-14 13:31:15,1,1 10000 283 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,218531185,0.997842,4.566131
     22026-01-14 13:31:16,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,254103891,0.997786,3.926685
     32026-01-14 13:31:18,1,1 10 289637 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,10137295,1.005258,99.164323
     42026-01-14 13:31:19,1,1 100000 29 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,240960565,0.997563,4.139943
     52026-01-14 13:31:20,1,1 10000 283 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,190404381,0.997883,5.240862
     62026-01-14 13:31:21,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,10000000,2.755017,275.501700
     72026-01-14 13:31:26,1,1 1 1000000 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,8000000,1.042393,130.299125
     82026-01-14 13:31:27,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,10000000,2.772334,277.233400
     92026-01-14 13:31:32,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,257335470,0.997170,3.874981
     102026-01-14 13:31:33,1,1 100 25601 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,48539496,0.996439,20.528417
     112026-01-14 13:31:34,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,105990473,0.997352,9.409827
     122026-01-14 13:31:35,1,1 1000000 3 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,220198293,0.997419,4.529640
     132026-01-14 13:31:36,1,1 100000 29 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,56787974,0.997062,17.557626
     142026-01-14 13:31:37,1,1 10 289637 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,15350761,1.013997,66.055162
     152026-01-14 13:31:39,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,102092422,0.997564,9.771186
     162026-01-14 13:31:40,1,1 100000 29 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,220075548,0.997592,4.532952
     172026-01-14 13:31:41,1,1 100000 29 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,225015408,0.997433,4.432732
     182026-01-14 13:31:42,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,10000000,2.766565,276.656500
     192026-01-14 13:31:47,1,1 1000 3203 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,59710326,0.996931,16.696124
     202026-01-14 13:31:48,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,10000000,2.769569,276.956900
     212026-01-14 13:31:53,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,5000000,0.999754,199.950800
     222026-01-14 13:31:54,1,1 1 10000000 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,10000000,2.798025,279.802500
     232026-01-14 13:31:59,1,1 1 1000000 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,5000000,1.114745,222.949000
     242026-01-14 13:32:00,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,6553606,1.652167,252.100447
     252026-01-14 13:32:03,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,5000000,1.010957,202.191400
     262026-01-14 13:32:04,1,1 100 25601 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,49589137,0.997162,20.108477
     272026-01-14 13:32:05,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,5000000,1.027244,205.448800
     282026-01-14 13:32:06,1,1 1 1000000 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,5000000,1.097968,219.593600
     292026-01-14 13:32:08,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,102355068,0.997254,9.743084
     302026-01-14 13:32:09,1,1 100 25601 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,40423979,0.997596,24.678323
     312026-01-14 13:32:10,1,1 1 1000000 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,5000000,1.095872,219.174400
     322026-01-14 13:32:11,1,1 10000 283 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,229888258,0.996748,4.335793
     332026-01-14 13:32:12,1,1 100 25601 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,48129880,0.997287,20.720746
     342026-01-14 13:32:13,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,5000000,1.016024,203.204800
     352026-01-14 13:32:14,1,1 100 25601 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,40167969,0.996992,24.820573
     362026-01-14 13:32:15,1,1 1 3276803 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,6553606,1.701438,259.618598
     372026-01-14 13:32:18,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,6553606,1.659565,253.229291
     382026-01-14 13:32:20,1,1 1 10000000 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,10000000,1.712096,171.209600
     392026-01-14 13:32:24,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,5000000,1.010222,202.044400
     402026-01-14 13:32:25,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,6553606,1.652375,252.132185
     412026-01-14 13:32:28,1,1 1 10000000 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,10000000,2.800626,280.062600
     422026-01-14 13:32:33,1,1 1 3276803 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,9830409,1.457078,148.221503
     432026-01-14 13:32:35,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,102367880,0.996927,9.738670
     442026-01-14 13:32:36,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,10000000,2.776255,277.625500
     452026-01-14 13:32:41,1,1 10000 283 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,210731705,0.997105,4.731633
     462026-01-14 13:32:42,1,1 10000 283 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,183331079,1.007402,5.494988
     472026-01-14 13:32:43,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,6553606,1.659047,253.150250
     482026-01-14 13:32:45,1,1 10 289637 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,11295843,1.001223,88.636413
     492026-01-14 13:32:46,1,1 100000 29 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,257539111,0.996702,3.870100
     502026-01-14 13:32:48,1,1 10 289637 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,17378220,1.013402,58.314488
     512026-01-14 13:32:49,1,1 100000 29 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,193986481,1.007222,5.192228
     522026-01-14 13:32:50,1,1 1 3276803 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,6553606,1.694047,258.490822
     532026-01-14 13:32:52,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,106320382,0.997101,9.378268
     542026-01-14 13:32:53,1,1 1 10000000 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,10000000,2.826834,282.683400
     552026-01-14 13:32:58,1,1 10 289637 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,15930035,1.008439,63.304255
     562026-01-14 13:32:59,1,1 1000000 3 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,218307684,0.997486,4.569175
     572026-01-14 13:33:01,1,1 1000 3203 -1 1 0  ,./perfexp--lq-list--stack-insfirst-allhead,1,108383114,0.997610,9.204478
     582026-01-14 13:33:02,1,1 100000 29 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,202317746,0.997714,4.931421
     592026-01-14 13:33:03,1,1 10000 283 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,224146754,0.997379,4.449670
     602026-01-14 13:33:04,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,278978787,0.997312,3.574867
     612026-01-14 13:33:05,1,1 100000 29 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,220330197,0.997615,4.527818
     622026-01-14 13:33:06,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,6553606,1.651677,252.025679
     632026-01-14 13:33:08,1,1 10 289637 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,17667857,1.006085,56.944371
     642026-01-14 13:33:09,1,1 10 289637 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,10426932,1.028608,98.649152
     652026-01-14 13:33:10,1,1 10 289637 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,10137295,1.004726,99.111844
     662026-01-14 13:33:11,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,183649596,0.996584,5.426552
     672026-01-14 13:33:13,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,257244321,0.997290,3.876820
     682026-01-14 13:33:14,1,1 1000000 3 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,232135437,1.007686,4.340940
     692026-01-14 13:33:15,1,1 1000000 3 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,188214108,0.996753,5.295846
     702026-01-14 13:33:16,1,1 100 25601 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,46824229,0.998110,21.316101
     712026-01-14 13:33:17,1,1 10000 283 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,235627498,0.997451,4.233169
     722026-01-14 13:33:18,1,1 100 25601 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,38196692,1.005921,26.335291
     732026-01-14 13:33:19,1,1 10 289637 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,16219672,1.000400,61.678189
     742026-01-14 13:33:20,1,1 1 1000000 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,5000000,1.004890,200.978000
     752026-01-14 13:33:21,1,1 10000 283 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,218309030,0.997505,4.569234
     762026-01-14 13:33:23,1,1 1000 3203 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,106051330,0.997313,9.404059
     772026-01-14 13:33:24,1,1 1 3276803 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,6553606,1.650389,251.829146
     782026-01-14 13:33:26,1,1 1000000 3 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,59182548,0.996826,16.843242
     792026-01-14 13:33:27,1,1 1000 3203 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,108770677,0.997598,9.171571
     802026-01-14 13:33:28,1,1 100 25601 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,38094288,0.996921,26.169829
     812026-01-14 13:33:29,1,1 1 3276803 -1 1 0  ,./perfexp--lq-tailq--stack-insfirst-allhead,1,6553606,1.694205,258.514931
     822026-01-14 13:33:31,1,1 100000 29 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,252794392,0.997021,3.944000
     832026-01-14 13:33:32,1,1 100 25601 -1 1 0  ,./perfexp--cfa-strip--stack-insfirst-allhead,1,49000314,0.997295,20.352829
     842026-01-14 13:33:34,1,1 100000 29 -1 1 0  ,./perfexp--cfa-cfa--stack-insfirst-allhead,1,240746864,0.997096,4.141678
     852026-01-14 13:33:35,1,1 1 10000000 -1 1 0  ,./perfexp--cfa-noIter--stack-insfirst-allhead,1,10000000,2.761402,276.140200
     862026-01-14 13:33:40,1,1 10000 283 -1 1 0  ,./perfexp--cpp-stlref--stack-insfirst-allhead,1,58884942,0.997327,16.936877
     872026-01-14 13:33:41,1,1 100 25601 -1 1 0  ,./perfexp--cfa-noListed--stack-insfirst-allhead,1,49307526,0.996337,20.206591
     882026-01-14 13:33:42,1,1 1000 3203 -1 1 0  ,./perfexp--upp-upp--stack-insfirst-allhead,1,100151404,1.007291,10.057682
     892026-01-14 13:33:43,1,1 10000 283 -1 1 0  ,./perfexp--cfa-mandHead--stack-insfirst-allhead,1,232844476,0.997456,4.283786
     902026-01-14 13:33:44,1,1 10 289637 -1 1 0  ,./perfexp--cfa-likeLq--stack-insfirst-allhead,1,16509309,1.005273,60.891283
  • doc/theses/mike_brooks_MMath/plots/ListCommon.py

    r5a95560 r9d3dc40  
    1414        timings = pd.read_csv(
    1515            process.stdout,
    16             names=['RunMoment', 'RunIdx', 'Args', 'Program', 'expt_ops_completed', 'expt_elapsed_sec', 'mean_op_dur_ns'],
     16            names=['RunMoment', 'RunIdx', 'Args', 'Program', 'Width',
     17                   'expt_ops_completed', 'expt_elapsed_sec', 'mean_op_dur_ns'],
    1718            dtype={'RunMoment':       str,
    1819                'RunIdx':             np.int64,
    1920                'Args':               str,
    2021                'Program':            str,
     22                'Width':              np.int64,
    2123                'expt_ops_completed': np.int64,
    2224                'expt_elapsed_sec':   np.float64,
  • libcfa/src/collections/list2.hfa

    r5a95560 r9d3dc40  
    108108    #define ORIGIN_TAG_NEQ(v1, v2) 0
    109109
     110    #define TAGSONLY(...)
     111    #define NOTAGS(...) __VA_ARGS__
     112
    110113#else // Normal
    111114
     
    146149    )
    147150
     151    #define TAGSONLY(...) __VA_ARGS__
     152    #define NOTAGS(...)
     153
    148154#endif
    149155
     
    270276}
    271277
     278// Compile-time memory (cmem) barrier
     279// Prevents the optimizer from reordering instructions across it
     280// Originally included for correctness, though a broken state is not known to be reproducible.
     281// Found to have a critical impact on performance:
     282// - in the positions given by default: generally optimal
     283// - absent: sometimes much slower, depending on the test harness
     284// - in positions (that my be influenced by a principle but) that are arbitrary wrt microarchitecture: typically, much slower
     285#ifdef __EXPERIMENTAL_DISABLE_CMEM_BARRIER__
     286// upon request, disable cmem barriers
     287#define MAYBE_CMEM_BARRIER
     288#else
     289// by default, enable cmem barriers
     290#define MAYBE_CMEM_BARRIER asm( "" : : : "memory" )
     291#endif
     292
     293// Insert read (location)
     294// One of the read operations that occurs during an insert operation was found to be performace-critical under certain harnesses.
     295// Arguably, the position should not matter if cmem barriers are off.  Treating the factors as independent allows for measuring this idea.
     296#ifdef __EXPERIMENTAL_DELAY_INSERT_READ__
     297// upon request: do the read late (between the cmem barriers); this location is where the read was originally found when this insert read first became a performance-perterbing hypothesis
     298#define MAYBE_INSERT_READ_EARLY(...)
     299#define MAYBE_INSERT_READ_LATE(...) __VA_ARGS__
     300#else
     301// by default: do the read early (before the first cmem barrier); better performance has been seen here
     302#define MAYBE_INSERT_READ_EARLY(...) __VA_ARGS__
     303#define MAYBE_INSERT_READ_LATE(...)
     304#endif
     305
    272306forall( tE &, tLinks & | embedded( tE, tLinks, dlink(tE) ) ) {
    273307
     
    283317        dlink(tE) & linkToInsert = to_insert`inner;
    284318      NOLOOSE(
     319       TAGSONLY(
    285320                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.prev));
    286321                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.next));
     322       )
    287323                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.prev) == (size_t)&linkToInsert);
    288324                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.next) == (size_t)&linkToInsert);
    289325      )
    290326        dlink(tE) & list_pos_links = list_pos_real`inner;
    291         asm( "" : : : "memory" );
     327      MAYBE_INSERT_READ_EARLY(
     328        dlink(tE) & afterLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.next );
     329      )
     330        MAYBE_CMEM_BARRIER;
    292331        size_t list_pos_links_num = (size_t)(& list_pos_links);
    293332        size_t to_insert_prev_num = ORIGIN_TAG_ASGN(list_pos_links_num, list_pos_tag);
     
    295334                linkToInsert.prev = to_insert_prev;
    296335                linkToInsert.next = list_pos_links.next;
     336      MAYBE_INSERT_READ_LATE(
    297337        dlink(tE) & afterLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.next );
     338      )
    298339        size_t afterLinks_prev_tag = ORIGIN_TAG_QUERY((size_t)afterLinks.prev);
    299340        size_t linkToInsert_num = (size_t)(& linkToInsert);
     
    301342        afterLinks.prev = (dlink(tE)*)(afterLinks_prev_num);
    302343                list_pos_links.next = &linkToInsert;
    303         asm( "" : : : "memory" );
     344        MAYBE_CMEM_BARRIER;
    304345        }
    305346
     
    315356        dlink(tE) & linkToInsert = to_insert`inner;
    316357      NOLOOSE(
     358       TAGSONLY(
    317359                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.prev));
    318360                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.next));
     361       )
    319362                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.prev) == (size_t)&linkToInsert);
    320363                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.next) == (size_t)&linkToInsert);
    321364      )
    322365        dlink(tE) & list_pos_links = list_pos_real`inner;
    323         asm( "" : : : "memory" );
     366      MAYBE_INSERT_READ_EARLY(
     367        dlink(tE) & beforeLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.prev );
     368      )
     369        MAYBE_CMEM_BARRIER;
    324370        size_t list_pos_links_num = (size_t)(& list_pos_links);
    325371        size_t to_insert_next_num = ORIGIN_TAG_ASGN(list_pos_links_num, list_pos_tag);
     
    327373                linkToInsert.next = to_insert_next;
    328374                linkToInsert.prev = list_pos_links.prev;
     375      MAYBE_INSERT_READ_LATE(
    329376        dlink(tE) & beforeLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.prev );
     377      )
    330378        size_t beforeLinks_next_tag = ORIGIN_TAG_QUERY((size_t)beforeLinks.next);
    331379        size_t linkToInsert_num = (size_t)(& linkToInsert);
     
    333381        beforeLinks.next = (dlink(tE)*)(beforeLinks_next_num);
    334382                list_pos_links.prev = &linkToInsert;
    335         asm( "" : : : "memory" );
     383        MAYBE_CMEM_BARRIER;
    336384        }
    337385
     
    355403
    356404      NOLOOSE(
    357         asm( "" : : : "memory" );
     405        MAYBE_CMEM_BARRIER;
    358406        size_t list_pos_links_num = (size_t) &list_pos_links;
    359407        size_t list_pos_links_tagged_num = ORIGIN_TAG_ENABL( list_pos_links_num );
    360408                list_pos_links.next = list_pos_links.prev = (dlink(tE)*) list_pos_links_tagged_num;
    361         asm( "" : : : "memory" );
     409        MAYBE_CMEM_BARRIER;
    362410      )
    363411        return list_pos;
     
    482530    static inline void insert_first( dlist(tE, tLinks) &lst, tE & e ) {
    483531        dlink(tE) & linkToInsert = e`inner;
     532      NOLOOSE(
     533       TAGSONLY(
    484534                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.prev));
    485535                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.next));
     536       )
    486537                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.prev) == (size_t)&linkToInsert);
    487538                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.next) == (size_t)&linkToInsert);
     539      )
    488540        dlink(tE) & list_pos_links = lst;
    489         asm( "" : : : "memory" );
     541      MAYBE_INSERT_READ_EARLY(
     542        dlink(tE) & afterLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.next );
     543      )
     544        MAYBE_CMEM_BARRIER;
    490545        size_t list_pos_links_num = (size_t)(& list_pos_links);
    491546        size_t to_insert_prev_num = ORIGIN_TAG_ENABL(list_pos_links_num);
     
    493548                linkToInsert.prev = to_insert_prev;
    494549                linkToInsert.next = list_pos_links.next;
     550      MAYBE_INSERT_READ_LATE(
    495551        dlink(tE) & afterLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.next );
     552      )
    496553        size_t linkToInsert_num = (size_t)(& linkToInsert);
    497554        size_t afterLinks_prev_num = linkToInsert_num;
    498555        afterLinks.prev = (dlink(tE)*)(afterLinks_prev_num);
    499556                list_pos_links.next = &linkToInsert;
    500         asm( "" : : : "memory" );
     557        MAYBE_CMEM_BARRIER;
    501558    }
    502559
    503560    static inline void insert_last( dlist(tE, tLinks) &lst, tE & e ) {
    504         // insert_before(iter(lst), e);
    505561        dlink(tE) & linkToInsert = e`inner;
     562      NOLOOSE(
     563       TAGSONLY(
    506564                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.next));
    507565                verify(ORIGIN_TAG_QUERY((size_t)linkToInsert.prev));
     566       )
    508567                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.next) == (size_t)&linkToInsert);
    509568                verify(ORIGIN_TAG_CLEAR((size_t)linkToInsert.prev) == (size_t)&linkToInsert);
     569      )
    510570        dlink(tE) & list_pos_links = lst;
    511         asm( "" : : : "memory" );
     571      MAYBE_INSERT_READ_EARLY(
     572        dlink(tE) & beforeLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.prev );
     573      )
     574        MAYBE_CMEM_BARRIER;
    512575        size_t list_pos_links_num = (size_t)(& list_pos_links);
    513576        size_t to_insert_next_num = ORIGIN_TAG_ENABL(list_pos_links_num);
     
    515578                linkToInsert.next = to_insert_next;
    516579                linkToInsert.prev = list_pos_links.prev;
     580      MAYBE_INSERT_READ_LATE(
    517581        dlink(tE) & beforeLinks = * (dlink(tE) *) ORIGIN_TAG_CLEAR( (size_t) list_pos_links.prev );
     582      )
    518583        size_t linkToInsert_num = (size_t)(& linkToInsert);
    519584        size_t beforeLinks_next_num = linkToInsert_num;
    520585        beforeLinks.next = (dlink(tE)*)(beforeLinks_next_num);
    521586                list_pos_links.prev = &linkToInsert;
    522         asm( "" : : : "memory" );
     587        MAYBE_CMEM_BARRIER;
    523588    }
    524589
     
    526591                verify (&lst != 0p);
    527592        dlink(tE) & list_links = lst;
    528         verify (! ORIGIN_TAG_QUERY( (size_t) (& list_links) ) );
    529593        // call is valid on empty list; when so, list_links.next and after_links.prev have otags set
    530594
     
    541605        after_links.prev = (dlink(tE) *) after_links_prev_rslt;
    542606
    543         asm( "" : : : "memory" );
     607        MAYBE_CMEM_BARRIER;
    544608        size_t list_pos_links_num = (size_t) &fst_links;
    545609        size_t list_pos_links_tagged_num = ORIGIN_TAG_ENABL( list_pos_links_num );
    546610                fst_links.next = fst_links.prev = (dlink(tE)*) list_pos_links_tagged_num;
    547         asm( "" : : : "memory" );
     611        MAYBE_CMEM_BARRIER;
    548612
    549613        tytagref( tLinks, dlink(tE) ) retExt = { fst_links };
     
    568632        before_links.next = (dlink(tE) *) before_links_next_rslt;
    569633
    570         asm( "" : : : "memory" );
     634        MAYBE_CMEM_BARRIER;
    571635        size_t list_pos_links_num = (size_t) &last_links;
    572636        size_t list_pos_links_tagged_num = ORIGIN_TAG_ENABL( list_pos_links_num );
    573637                last_links.prev = last_links.next = (dlink(tE)*) list_pos_links_tagged_num;
    574         asm( "" : : : "memory" );
     638        MAYBE_CMEM_BARRIER;
    575639
    576640        tytagref( tLinks, dlink(tE) ) lpLnkTagged = { last_links };
     
    630694
    631695}
    632 
Note: See TracChangeset for help on using the changeset viewer.