Changeset 1eea589f


Ignore:
Timestamp:
Jul 27, 2025, 2:48:31 PM (7 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
b9d1242
Parents:
da10157 (diff), 7806f91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
69 added
2 deleted
13 edited

Legend:

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

    rda10157 r1eea589f  
    99# make results-latest.csv OP_MOVEMENTS=stack OP_POLARITIES=insfirst OP_ACCESSORS=allhead RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=thorough
    1010# cp results-latest.csv results-sizing.csv
     11# make results-latest.csv OP_MOVEMENTS=queue OP_POLARITIES=inslast OP_ACCESSORS=remelem RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=thorough
     12# cp results-latest.csv results-sizing-b.csv
     13# make results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=moderate FX_SOLUTIONS='lq-tailq lq-list cfa-cfa upp-upp'
     14# cp results-latest.csv results-intrsv-cube.csv
    1115
    1216CFA = cfa
     17CC = gcc-11
    1318CXX = g++-11
    1419UXX =  ~/u++/u++-7.0.0/bin/u++
     
    1823RUN_NUM_REPS=3
    1924RUN_DATA_SIZE_MODE=none
    20 RUN_DURATION_SEC=5
     25RUN_DURATION_SEC?=5
    2126RUN_TASKSET_CPULIST=6
    2227
     
    2530PERFFLAGS_CC  = -DNDEBUG -O3
    2631else ifeq "$(MODE)" "correctness"
    27 PERFFLAGS_CFA = -O0 -g -debug
     32PERFFLAGS_CFA = -O0 -g -nodebug -D__CFA_DEBUG__ # shortcut for not also building debug cfa
    2833PERFFLAGS_CC  = -O0 -g
    2934else
     
    6671OP_POLARITIES=insfirst inslast
    6772OP_ACCESSORS=allhead inselem remelem
    68 FX_SOLUTIONS=lq-tailq lq-list cfa-cfa upp-upp cpp-stlref
     73RUN_INTERLEAVE_PCTS=0
     74
     75
     76FX_SOLUTIONS=lq-tailq lq-list cfa-cfa cfa-mandHead cfa-noListed cfa-noIter cfa-likeLq cfa-strip upp-upp cpp-stlref
    6977
    7078OPS=$(call cross3,-,$(OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS))
     
    124132        $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD
    125133
    126 sayhi:
    127         echo $(PERFPROGS)
    128 
    129 
    130 ifeq "$(RUN_DATA_SIZE_MODE)" "common5"
    131 RUN_DATA_SIZES=\
     134
     135# troubleshooting, e.g. `make echo_DEMOS` runs `echo $(DEMOS)`
     136echo_% :
     137        @echo '$($(@:echo_%=%))'
     138
     139
     140
     141
     142# ifeq "$(RUN_DATA_SIZE_MODE)" "common5"
     143# RUN_DATA_SIZES=\
     144#   7-1000000 \
     145#   71-100000 \
     146#   809-10000 \
     147#   9051-1000 \
     148#   72421-100
     149# else ifeq "$(RUN_DATA_SIZE_MODE)" "thorough"
     150# RUN_DATA_SIZES=\
     151#   1-1000000 \
     152#   2-1000000 \
     153#   3-1000000 \
     154#   5-1000000 \
     155#   7-1000000 \
     156#   11-100000 \
     157#   13-100000 \
     158#   19-100000 \
     159#   29-100000 \
     160#   37-100000 \
     161#   53-100000 \
     162#   71-100000 \
     163#   101-10000 \
     164#   149-10000 \
     165#   211-10000 \
     166#   283-10000 \
     167#   401-10000 \
     168#   569-10000 \
     169#   809-10000 \
     170#   1151-1000 \
     171#   1601-1000 \
     172#   2267-1000 \
     173#   3203-1000 \
     174#   4547-1000 \
     175#   6473-1000 \
     176#   9051-1000 \
     177#   12809-100 \
     178#   18119-100 \
     179#   25601-100 \
     180#   36209-100 \
     181#   51203-100 \
     182#   72421-100 \
     183#   102407-10 \
     184#   144817-10 \
     185#   204803-10 \
     186#   289637-10 \
     187#   409609-10 \
     188#   579263-10 \
     189#   819229-10 \
     190#   1158613-1 \
     191#   1638431-1 \
     192#   2317057-1 \
     193#   3276803-1 \
     194#   4634111-1 \
     195#   6553621-1 \
     196#   9268211-1
     197# else ifeq "$(RUN_DATA_SIZE_MODE)" "bignquick"
     198# RUN_DATA_SIZES=\
     199#   3-1000000 \
     200#   29-100000 \
     201#   283-10000 \
     202#   3203-1000 \
     203#   25601-100 \
     204#   289637-10 \
     205#   1000000-1 \
     206#   3276803-1 \
     207#   10000000-1
     208# else ifeq "$(RUN_DATA_SIZE_MODE)" "bignthorough"
     209# RUN_DATA_SIZES=\
     210#   1-1000000 \
     211#   3-1000000 \
     212#   7-1000000 \
     213#   13-100000 \
     214#   29-100000 \
     215#   53-100000 \
     216#   101-10000 \
     217#   211-10000 \
     218#   401-10000 \
     219#   809-10000 \
     220#   1601-1000 \
     221#   3203-1000 \
     222#   6473-1000 \
     223#   12809-100 \
     224#   25601-100 \
     225#   51203-100 \
     226#   102407-10 \
     227#   204803-10 \
     228#   409609-10 \
     229#   819229-10 \
     230#   1638431-1 \
     231#   3276803-1 \
     232#   6553621-1 \
     233#   12809000-1 \
     234#   25601000-1 \
     235#   51203000-1 \
     236#   102407000-1 \
     237#   204803000-1 \
     238#   409609000-1
     239# else ifeq "$(RUN_DATA_SIZE_MODE)" "moderate"
     240# RUN_DATA_SIZES=\
     241#   1-1000000 \
     242#   3-1000000 \
     243#   7-1000000 \
     244#   13-100000 \
     245#   29-100000 \
     246#   53-100000 \
     247#   101-10000 \
     248#   211-10000 \
     249#   401-10000 \
     250#   1601-1000 \
     251#   6473-1000 \
     252#   25601-100
     253# else ifeq "$(RUN_DATA_SIZE_MODE)" "sweetspot"
     254# RUN_DATA_SIZES=\
     255#   1-1000000 \
     256#   2-1000000 \
     257#   3-1000000 \
     258#   5-1000000 \
     259#   7-1000000 \
     260#   11-100000 \
     261#   13-100000 \
     262#   19-100000 \
     263#   29-100000 \
     264#   37-100000 \
     265#   53-100000 \
     266#   71-100000 \
     267#   101-10000 \
     268#   149-10000
     269# else ifeq "$(RUN_DATA_SIZE_MODE)" "manual"
     270# ifeq "$(RUN_DATA_SIZES)" ""
     271# $(error RUN_DATA_SIZE_MODE is manual but RUN_DATA_SIZES not given)
     272# endif
     273# else ifeq "$(RUN_DATA_SIZE_MODE)" "none"
     274# # Assume user manages RUN_ARGS; empty RUN_ARGS just means run with compiled-in defaults
     275# RUN_DATA_SIZES=none
     276# else
     277# $(error Bad RUN_DATA_SIZE_MODE ($(RUN_DATA_SIZE_MODE)); should be common5, thorough or manual)
     278# endif
     279
     280
     281ifeq "$(RUN_DATA_SIZE_MODE)" "manual"
     282        ifeq "$(RUN_DATA_SIZES)" ""
     283        $(error RUN_DATA_SIZE_MODE is manual but RUN_DATA_SIZES not given)
     284        endif
     285endif
     286
     287RUN_DATA_SIZES = \
     288$(if $(filter $(RUN_DATA_SIZE_MODE),common5), \
    132289  7-1000000 \
    133290  71-100000 \
    134291  809-10000 \
    135292  9051-1000 \
    136   72421-100
    137 else ifeq "$(RUN_DATA_SIZE_MODE)" "thorough"
    138 RUN_DATA_SIZES=\
     293  72421-100 \
     294, $(if $(filter $(RUN_DATA_SIZE_MODE),thorough), \
     295  1-1000000 \
     296  2-1000000 \
     297  3-1000000 \
     298  5-1000000 \
    139299  7-1000000 \
    140300  11-100000 \
     
    178338  4634111-1 \
    179339  6553621-1 \
    180   9268211-1
    181 else ifeq "$(RUN_DATA_SIZE_MODE)" "manual"
    182 ifeq "$(RUN_DATA_SIZES)" ""
    183 $(error RUN_DATA_SIZE_MODE is manual but RUN_DATA_SIZES not given)
    184 endif
    185 else ifeq "$(RUN_DATA_SIZE_MODE)" "none"
    186 # Assume user manages RUN_ARGS; empty RUN_ARGS just means run with compiled-in defaults
    187 RUN_DATA_SIZES=none
    188 else
    189 $(error Bad RUN_DATA_SIZE_MODE ($(RUN_DATA_SIZE_MODE)); should be common5, thorough or manual)
    190 endif
     340  9268211-1 \
     341, $(if $(filter $(RUN_DATA_SIZE_MODE),bignquick), \
     342  3-1000000 \
     343  29-100000 \
     344  283-10000 \
     345  3203-1000 \
     346  25601-100 \
     347  289637-10 \
     348  1000000-1 \
     349  3276803-1 \
     350  10000000-1 \
     351, $(if $(filter $(RUN_DATA_SIZE_MODE),bignthorough), \
     352  1-1000000 \
     353  3-1000000 \
     354  7-1000000 \
     355  13-100000 \
     356  29-100000 \
     357  53-100000 \
     358  101-10000 \
     359  211-10000 \
     360  401-10000 \
     361  809-10000 \
     362  1601-1000 \
     363  3203-1000 \
     364  6473-1000 \
     365  12809-100 \
     366  25601-100 \
     367  51203-100 \
     368  102407-10 \
     369  204803-10 \
     370  409609-10 \
     371  819229-10 \
     372  1638431-1 \
     373  3276803-1 \
     374  6553621-1 \
     375  12809000-1 \
     376  25601000-1 \
     377  51203000-1 \
     378  102407000-1 \
     379  204803000-1 \
     380  409609000-1 \
     381, $(if $(filter $(RUN_DATA_SIZE_MODE),moderate), \
     382  1-1000000 \
     383  3-1000000 \
     384  7-1000000 \
     385  13-100000 \
     386  29-100000 \
     387  53-100000 \
     388  101-10000 \
     389  211-10000 \
     390  401-10000 \
     391  1601-1000 \
     392  6473-1000 \
     393  25601-100 \
     394, $(if $(filter $(RUN_DATA_SIZE_MODE),sweetspot), \
     395  1-1000000 \
     396  2-1000000 \
     397  3-1000000 \
     398  5-1000000 \
     399  7-1000000 \
     400  11-100000 \
     401  13-100000 \
     402  19-100000 \
     403  29-100000 \
     404  37-100000 \
     405  53-100000 \
     406  71-100000 \
     407  101-10000 \
     408  149-10000 \
     409, $(if $(filter $(RUN_DATA_SIZE_MODE),none), \
     410, $(error Bad RUN_DATA_SIZE_MODE ($(RUN_DATA_SIZE_MODE)); see list of accepted values in Makefile's RUN_DATA_SIZES defimition) \
     411)))))))
    191412
    192413RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)})              # 1 2 3
    193 RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv)       # run1.1csv run2.1cav run3.1csv
    194 
    195 RUN_LAUNCHES=$(call cross,--,$(RUN_DATA_SIZES),$(RUN_REP_EXTS))
    196 
     414RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv)       # run1.1csv run2.1csv run3.1csv
     415
     416RUN_LAUNCHES=$(call cross3,--,$(RUN_DATA_SIZES),$(RUN_INTERLEAVE_PCTS),$(RUN_REP_EXTS))
    197417
    198418
     
    207427%.1csv : NUMNODES=$(call proj,-,$(SIZING),1)
    208428%.1csv : CHECKDONE=$(call proj,-,$(SIZING),2)
    209 %.1csv : REP_ID=$(subst run,,$(call proj,--,$(LAUNCH),2))
    210 %.1csv : RUN_ARGS=$(if $(filter none,$(SIZING)),,$(RUN_DURATION_SEC) $(CHECKDONE) $(NUMNODES) -1 $(REP_ID))  # use REP_ID as seed
     429%.1csv : RUN_INTERLEAVE_PCT=$(call proj,--,$(LAUNCH),2)
     430%.1csv : RUN_INTERLEAVE_FRAC=$(shell echo "scale=2; $(RUN_INTERLEAVE_PCT) / 100" | bc)
     431%.1csv : REP_ID=$(subst run,,$(call proj,--,$(LAUNCH),3))
     432%.1csv : SEED=$(REP_ID)
     433%.1csv : RUN_ARGS=$(if $(filter none,$(SIZING)),,$(RUN_DURATION_SEC) $(CHECKDONE) $(NUMNODES) -1 $(SEED) $(RUN_INTERLEAVE_FRAC))  # use REP_ID as seed
    211434%.1csv : REP_TIME=$(shell date '+%F %H:%M:%S')
    212435%.1csv : perfprogs FORCE
    213         taskset --cpu-list $(RUN_TASKSET_CPULIST) ./perfexp--$(CORE) $(RUN_ARGS) | xargs -n 1 printf '%s,%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" "$(RUN_ARGS)" | tee $@
     436        taskset --cpu-list $(RUN_TASKSET_CPULIST) ./perfexp--$(CORE) $(RUN_ARGS) | xargs -n 1 printf '%s,%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" "$(RUN_ARGS)" | tee -a $(RESULT)
    214437
    215438
    216439BATCHTIME=$(shell date '+%F--%H-%M-%S')
    217 
    218 results--$(BATCHTIME).csv : $(RESULT1S_SHUFD)
    219         cat $^ | tee $@
    220         rm $^
    221 
    222 results-latest.csv : results--$(BATCHTIME).csv
     440RESULT=results--$(BATCHTIME).csv
     441
     442sub_make=$(MAKE) --no-print-directory $(1); cat $(1) >> $(2); rm $(1);
     443
     444
     445export RESULT1S_SHUFD    # used by sh loop in $(RESULT) recipe
     446export RUN_DURATION_SEC  # used by sub make; occurs free in %.1csv's variable bindings (not extracted from target name)
     447
     448
     449NTESTS=$(words $(RESULT1S_SHUFD))
     450RUNDUR = $(shell expr $(NTESTS) \* $(RUN_DURATION_SEC))
     451ETA = $(shell date -d "+$(RUNDUR) seconds" +"%H:%M:%S")
     452
     453$(RESULT) :
     454        @echo running $(NTESTS) tests, eta $(ETA)
     455        for r in $$RESULT1S_SHUFD; do $(MAKE) --no-print-directory RESULT=$(RESULT) $$r; done
     456
     457results-latest.csv : $(RESULT)
    223458        rm -f $@
    224459        ln -s $< $@
     
    237472
    238473-include *.d
     474
     475results-general.csv: FORCE
     476        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=sweetspot OP_ACCESSORS=remelem RUN_INTERLEAVE_PCTS='0 50' FX_SOLUTIONS='lq-tailq lq-list cfa-cfa cfa-mandHead'
     477        cat results-latest.csv >> $@
     478        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=sweetspot OP_ACCESSORS='allhead inselem' RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='lq-tailq lq-list cfa-cfa cfa-mandHead'
     479        cat results-latest.csv >> $@
     480        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=sweetspot OP_ACCESSORS=remelem RUN_INTERLEAVE_PCTS='0 50' FX_SOLUTIONS='cfa-noListed cfa-noIter cfa-likeLq'
     481        cat results-latest.csv >> $@
     482        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=sweetspot OP_ACCESSORS='allhead inselem' RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='cfa-noListed cfa-noIter cfa-likeLq'
     483        cat results-latest.csv >> $@
     484        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=sweetspot OP_ACCESSORS=remelem RUN_INTERLEAVE_PCTS='0 50' FX_SOLUTIONS='cfa-strip upp-upp cpp-stlref'
     485        cat results-latest.csv >> $@
     486        $(MAKE) results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=sweetspot OP_ACCESSORS='allhead inselem' RUN_INTERLEAVE_PCTS='0' FX_SOLUTIONS='cfa-strip upp-upp cpp-stlref'
     487        cat results-latest.csv >> $@
     488
     489results-zoomout-noshuf.csv: FORCE
     490        @echo Do we need to make for tiny user iters?  If so:
     491        @echo make clean
     492        @echo make perfprogs CFA=$$cfa EXTRA_COMP_FLAGS=-DTINY_USER_ITEMS -j8
     493        make results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=bignthorough OPS=stack-insfirst-allhead FX_SOLUTIONS='lq-tailq cfa-cfa upp-upp cpp-stlref cfa-strip' SEED=-1
     494        cp results-latest.csv $@
     495
     496results-zoomout-shuf.csv: FORCE
     497        @echo Do we need to make for tiny user iters?  If so:
     498        @echo make clean
     499        @echo make perfprogs CFA=$$cfa EXTRA_COMP_FLAGS=-DTINY_USER_ITEMS -j8
     500        make results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=bignthorough OPS=stack-insfirst-allhead FX_SOLUTIONS='lq-tailq cfa-cfa upp-upp cpp-stlref cfa-strip'
     501        cp results-latest.csv $@
     502
     503thesis: results-general.csv results-zoomout-noshuf.csv results-zoomout-shuf.csv
     504
     505# matches peter's "random"
     506results-smoketest.csv: RUN_DATA_SIZE_MODE=bignquick
     507results-smoketest.csv: RUN_NUM_REPS=1
     508results-smoketest.csv: RUN_DURATION_SEC=1
     509results-smoketest.csv: OP_MOVEMENTS=stack
     510results-smoketest.csv: OP_POLARITIES=insfirst
     511results-smoketest.csv: OP_ACCESSORS=allhead
     512results-smoketest.csv: $(RESULT)
     513        mv $< $@
  • doc/theses/mike_brooks_MMath/benchmarks/list/driver.c

    rda10157 r1eea589f  
    66#include "observation.h"
    77
     8#ifdef TINY_USER_ITEMS
     9  #define UDATA_T char
     10  #define UDATA_LEN 1
     11  #define UDATA_USE_POS 0
     12#else
     13  #define UDATA_T int
     14  #define UDATA_LEN 64
     15  #define UDATA_USE_POS 17
     16#endif
     17
    818typedef struct B_UserItem
    919    BFX_EXTRUSION_DECL(B_UserItem)
    1020{
    1121    BFX_INTRUSION(B_UserItem)
    12     int userdata[64];
     22    UDATA_T userdata[ UDATA_LEN ];
    1323}
    1424B_UserItem;
     
    1828#if defined(NDEBUG) || (defined(__cforall) && !defined(__CFA_DEBUG__))
    1929    enum { DefaultNumNodes = 1000, DefaultExperimentDurSec = 1, DefaultCheckDonePeriod = 1000, DefaultExperimentDurOpCount = -1, DefaultSeed = 5 };
     30    const double DefaultInterleaveFrac = 0.0;
    2031    #define TRACE(tp)
    2132#else
    2233    enum { DefaultNumNodes = 10, DefaultExperimentDurSec = 1, DefaultCheckDonePeriod = 2, DefaultExperimentDurOpCount = 20, DefaultSeed = 5 };
     34    const double DefaultInterleaveFrac = 0.5;
    2335    static const char * tp_filter
    2436    // = "";
     
    3951static BFX_LIST_HEAD_T(B_UserItem) lst;
    4052
    41 
    4253MAYBE_EXTERN_C (
    4354
     
    4556    volatile unsigned int bobs_prog_inserting     = 0;
    4657    volatile unsigned int bobs_prog_removing      = 0;
     58    volatile unsigned int bobs_prog_removing_end  = 0;
    4759    volatile unsigned int bobs_prog_rollover_flag = 0;
     60    //                    bobs_prog_rem_pos         (defined after BOP_REMPROGEND_IS_REMNO_BASED)
    4861
    4962    void bobs_seek(unsigned int i) {
     
    6881    int bobs_getCurrentVal() {
    6982        B_UserItem * curUI = BFX_DEREF_POS(B_UserItem, lst, observedItem);
    70         return curUI->userdata[17];
     83        return curUI->userdata[ UDATA_USE_POS ];
    7184    }
    7285
     
    7588)
    7689
     90
     91// Remove progress end (number) is based (upon) remove-number
     92// True when an OP's REMELEM used remNo to choose which element to remove
     93// False otherwise; notably including when REMELEM just bases upon first/last
     94// Default to false.
     95#ifndef BOP_REMPROGEND_IS_REMNO_BASED
     96#define BOP_REMPROGEND_IS_REMNO_BASED false
     97#endif
     98MAYBE_EXTERN_C (
     99    volatile unsigned int const * bobs_prog_rem_pos
     100        = BOP_REMPROGEND_IS_REMNO_BASED ? & bobs_prog_removing_end : & bobs_prog_removing;
     101)
     102
    77103unsigned int uDefaultPreemption() {
    78104        return 0;
     
    81107int main(int argc, const char *argv[]) {
    82108
    83     const char * usage_args = "[ExperimentDurSec [CheckDonePeriod [NumNodes [ExperimentDurOpCount [Seed]]]]]";
    84     const int static_arg_posns = 5;
     109    const char * usage_args = "[ExperimentDurSec [CheckDonePeriod [NumNodes [ExperimentDurOpCount [Seed [InterleaveFrac]]]]]]";
     110    const int static_arg_posns = 6;
    85111
    86112    unsigned int ExperimentDurSec     = DefaultExperimentDurSec;
     
    89115    size_t       ExperimentDurOpCount = DefaultExperimentDurOpCount;
    90116    unsigned int Seed                 = DefaultSeed;
     117    double       InterleaveFrac       = DefaultInterleaveFrac;
    91118
    92119    switch (((argc - 1) < static_arg_posns) ? (argc - 1) : static_arg_posns) {
     120      case 6: InterleaveFrac = atof(argv[6]);
    93121      case 5: Seed = atoi(argv[5]);
    94122      case 4: ExperimentDurOpCount = atol(argv[4]);
     
    98126    }
    99127
     128    // printf("ExperimentDurSec=%d, CheckDonePeriod=%d, NumNodes=%d, ExperimentDurOpCount=%zd, Seed=%d,\n",
     129    //     ExperimentDurSec, CheckDonePeriod, NumNodes, ExperimentDurOpCount, Seed );
     130
    100131    if (ExperimentDurSec == 0 || CheckDonePeriod == 0 || NumNodes == 0 || ExperimentDurOpCount == 0 || Seed == 0 ) {
    101132        printf("usage: %s %s\n", argv[0], usage_args);
     
    110141  #endif
    111142
     143    // Shuffling makes listed items' physical order in memory different from their order within to the list.
     144    // Affects insertion: next item to insert picked through insertOrdShuf.
    112145  #ifdef DISABLE_SHUFFLING_INDIRECTION
    113146    #define INSERTPOS(insertNum) insertNum
     
    138171  #endif
    139172
     173    // Interleaving affects the list position where an element-oriented operation occurs: at an end vs. in the middle.
     174    // Perterbs the sequence of logical insert/remove numbers presented to the OP cartridge, e.g. from [0 1 2 3 4 5 6]
     175    // to [3 0 4 1 5 2 6], which is [mid end mid end mid end solo], for a perfect-alternation interleave; except that the
     176    // end/mid interleave is atually selected randomly.
     177  #ifdef DISABLE_INTERLEAVING
     178    #define nextInterleave 0
     179    printf("interleave key %x\n", 0);
     180  #else
     181    const unsigned int INTRL_KEYLEN = 64;
     182    unsigned char interleaveKey[INTRL_KEYLEN];
     183    unsigned char nextInterleavePos = 0;
     184    {
     185        unsigned int numOnes = INTRL_KEYLEN * InterleaveFrac;
     186        unsigned int numZeros = INTRL_KEYLEN - numOnes;
     187        // generate randomly drawn 0/1
     188        memset( interleaveKey         , 0, numZeros );  // zeros then ones
     189        memset( interleaveKey+numZeros, 1, numOnes );
     190        for (unsigned int i = 0; i < 64; i++) { // shuffle it
     191            unsigned int nodesRemaining = 64 - i;
     192            unsigned int swapWith = i + rand() % nodesRemaining;
     193            unsigned char tempValue = interleaveKey[swapWith];
     194            interleaveKey[swapWith] = interleaveKey[i];
     195            interleaveKey[i] = tempValue;
     196        }
     197        #define nextInterleave (interleaveKey[nextInterleavePos = (nextInterleavePos + 1) % 64])
     198    }
     199    {
     200        unsigned int z = 0, o = 0;
     201        for ( int i = 0; i < INTRL_KEYLEN; i++ ) {
     202            if (interleaveKey[i]) o++;
     203            else z++;
     204        }
     205        // printf("Interleaving with %u in middle and %u at end\n", o, z);
     206    }
     207    // printf("interleave key begins %016llx\n", *(unsigned long long*)interleaveKey);
     208    // printf("interleave key begins %016llx\n", *(unsigned long long*)(interleaveKey+8));
     209    // printf("sample interleave value %d\n", nextInterleave);
     210    // printf("sample interleave value %d\n", nextInterleave);
     211    // printf("sample interleave value %d\n", nextInterleave);
     212    // printf("sample interleave value %d\n", nextInterleave);
     213    // printf("sample interleave value %d\n", nextInterleave);
     214    // printf("sample interleave value %d\n", nextInterleave);
     215    // printf("sample interleave value %d\n", nextInterleave);
     216    // printf("sample interleave value %d\n", nextInterleave);
     217    // printf("sample interleave value %d\n", nextInterleave);
     218    // printf("sample interleave value %d\n", nextInterleave);
     219    // printf("sample interleave value %d\n", nextInterleave);
     220    // printf("sample interleave value %d\n", nextInterleave);
     221  #endif
     222
    140223    ui = (B_UserItem*) malloc( (size_t)NumNodes * (size_t)sizeof(B_UserItem) );
    141224    if (!ui) {
     
    152235    memset(listedItems, 0, (size_t)NumNodes * (size_t)sizeof(BFX_LISTED_ELEM_T(B_UserItem)));
    153236
    154     // Fill with demo data
     237    // Construct and fill with demo data
    155238    for (unsigned int i = 0; i < NumNodes; i++) {
    156239        B_UserItem * curUI = & ui[INSERTPOS(i)];
    157         curUI->userdata[17] = i;
     240      #ifdef __cforall
     241        (*curUI){};
     242      #endif
     243        curUI->userdata[ UDATA_USE_POS ] = i;
    158244    }
    159245
     
    166252    //   lst    lvalue of the list head being added to / removed from
    167253    //   iters  array of ADD return values, in logical-insert order; on ADD, is valid at [0..insNo)
    168     //   insNo  counter of the ADD calls (logical insert number)
    169     //   remNo  counter of the REM calls (logical remove number)
     254    //   insNo  interleave-perterbed counter of the ADD calls (logical insert number)
     255    //   remNo  interleave-perterbed counter of the REM calls (logical remove number)
    170256    //   item   lvalue of the item being added
    171257    // Logical insert number 0 and remove number n-1 are given with a distinguished hook.
     
    186272    double elapsed_sec = 0;
    187273    clock_t start = clock();
     274 
     275    const unsigned int numMiddleNodes = (NumNodes-1) * InterleaveFrac;
     276    const unsigned int numEndNodes = NumNodes - numMiddleNodes - 1;
     277
     278    // printf("Running with %u in the middle and %u at end\n", numMiddleNodes, numEndNodes);
     279
     280    const unsigned int removeBase[] = {0, numEndNodes};
     281    const unsigned int removeLimit[] = {numEndNodes, numMiddleNodes};
    188282
    189283    size_t privateOpsCompleted = 0;
     
    191285    while (elapsed_sec <= (double) ExperimentDurSec && privateOpsCompleted < ExperimentDurOpCount) {
    192286        for ( int t = 0; t < CheckDonePeriod; t += 1 ) {
    193             TRACE('a')
     287            TRACE('a')              // insert special first
    194288            listedItems[0] =
    195289                BOP_INIT(lst, listedItems, 0, ui[INSERTPOS(0)]);
    196             TRACE('b')
     290            TRACE('b')              // insert general
    197291            for ( int privateCurInsert = 1;
    198292                  (bobs_prog_inserting = privateCurInsert, privateCurInsert < NumNodes);
     
    204298                TRACE('+')
    205299            }
    206             TRACE('c')
    207             for ( int privateCurRemove = 1;
    208                   (bobs_prog_removing = privateCurRemove, privateCurRemove < NumNodes);
    209                   privateCurRemove += 1
     300            TRACE('c')              // remove general
     301            int removeProgress[] = { 0, 0 };
     302            for ( int flip = 0;
     303                  (bobs_prog_removing = removeProgress[0] + removeProgress[1] + 1,
     304                     bobs_prog_removing_end = removeProgress[0] + 1,
     305                     flip = nextInterleave,
     306                     removeProgress[0] < removeLimit[0] && removeProgress[1] < removeLimit[1] );
     307                  removeProgress[flip] += 1
    210308                ) {
    211309                TRACE('-')
    212                 BOP_REMOVE( lst, listedItems, privateCurRemove-1 );
     310                BOP_REMOVE( lst, listedItems, removeBase[flip]+removeProgress[flip] );
    213311                TRACE('+')
    214312            }
    215             TRACE('D')
     313            TRACE('X')              // remove imbalanced
     314            // most work done under general; it stops when either flip-side's work finishes
     315            // now drain any any stragglers so both flip-sides' work finishes
     316            for ( int flip = 0; flip < 2; flip ++ ) {
     317                for ( ; (bobs_prog_removing = removeProgress[0] + removeProgress[1] + 1,
     318                         bobs_prog_removing_end = removeProgress[0] + 1,
     319                         removeProgress[flip] < removeLimit[flip] )
     320                      ;  removeProgress[flip] += 1
     321                    ) {
     322                    TRACE('-')
     323                    BOP_REMOVE( lst, listedItems, removeBase[flip]+removeProgress[flip] );
     324                    TRACE('+')
     325                }
     326            }
     327            TRACE('D')              // remove special last
    216328            BOP_TEARDOWN(lst, listedItems, NumNodes-1);
    217329            TRACE('d')
     
    222334            TRACE('e')
    223335            bobs_prog_inserting = 0;
    224             bobs_prog_removing = 0;           
     336            bobs_prog_removing = 0;
     337            bobs_prog_removing_end = 0;
    225338            bobs_ops_completed = privateOpsCompleted;
    226339            TRACE('f')
     
    245358    free(ui);
    246359    free(listedItems);
     360  #ifndef DISABLE_SHUFFLING_INDIRECTION
    247361    free(insertOrdShuf);
     362  #endif
    248363}
  • doc/theses/mike_brooks_MMath/benchmarks/list/fx-cfa-cfa.h

    rda10157 r1eea589f  
    1 #include <containers/list.hfa>
    2 
    3 #define BFX_INTRUSION(S)                         inline dlink(S);
    4 #define BFX_EXTRUSION_DECL(S)
    5 #define BFX_EXTRUSION_FOLLOWUP(S)                P9_EMBEDDED( S, dlink(S) )
    6 #define BFX_LIST_HEAD_T(S)                       dlist(S)
    7 #define BFX_LISTED_ELEM_T(S)                     S*
    8 
    9 #define BFX_INSERT_FIRST(S, lst, item)           (insert_first (lst, item), (S*)&(item))
    10 #define BFX_INSERT_LAST(S, lst, item)            (insert_last  (lst, item), (S*)&(item))
    11 #define BFX_INSERT_BEFORE(S, lst, item, refIter) (insert_before(*refIter, item), (S*)&(item))
    12 #define BFX_INSERT_AFTER(S, lst, item, refIter)  (insert_after (*refIter, item), (S*)&(item))
    13 #define BFX_REMOVE_FIRST(S, lst)                 remove( first( lst ) )
    14 #define BFX_REMOVE_LAST(S, lst)                  remove( last( lst ) )
    15 #define BFX_REMOVE_HERE(S, lst, refIter)         remove(*refIter)
    16 #define BFX_INIT(S, lst)
    17 
    18 #define BFX_GET_AFTER(S, lst, iter)              (&next( *iter))
    19 #define BFX_GET_BEFORE(S, lst, iter)             (&prev( *iter ))
    20 #define BFX_IS_VALID_POS(S, lst, iter)           ((iter)!=NULL)
    21 #define BFX_DEREF_POS(S, lst, iter)              (iter)
     1#include "libcfa-fork-list.hfa" // same folder: latest and greatest
     2#include "fx-cfa-GENERAL.h"
  • doc/theses/mike_brooks_MMath/benchmarks/list/fx-lq-list.h

    rda10157 r1eea589f  
    22#include <assert.h>
    33#include <stddef.h>
     4#include <stdbool.h>
    45
    56#define HEADNAME_(S)                             S ## Head
     
    1516#define BFX_INSERT_BEFORE(S, lst, item, refIter) ({LIST_INSERT_BEFORE(refIter, &item, xx); &item;})
    1617#define BFX_INSERT_AFTER(S, lst, item, refIter)  ({LIST_INSERT_AFTER(refIter, &item, xx); &item;})
    17 #define BFX_REMOVE_FIRST(S, lst)                 LIST_REMOVE( LIST_FIRST( &lst ), xx )
     18#define BFX_REMOVE_FIRST(S, lst)                 ({ S * first = LIST_FIRST( &lst ); LIST_REMOVE( first, xx ); })
    1819#define BFX_REMOVE_LAST(S, lst)                  assert(false&&"unimplemented REMOVE_LAST on lq-list")
    1920#define BFX_REMOVE_HERE(S, lst, refIter)         LIST_REMOVE( refIter, xx )
  • doc/theses/mike_brooks_MMath/benchmarks/list/fx-lq-tailq.h

    rda10157 r1eea589f  
    11#include <sys/queue.h>
     2#include <stdbool.h>
    23
    34#define HEADNAME_(S)                             S ## Head
  • doc/theses/mike_brooks_MMath/benchmarks/list/observation.c

    rda10157 r1eea589f  
    6161    printSuccs(leash - 1);
    6262}
    63 static void explore(int here) {
     63static void explore(int here, unsigned int leash) {
    6464    bobs_seek(here);
    6565    if (!bobs_hasCurrent()) {
     
    6868    }
    6969    bobs_movePrev();
    70     printPreds(2);
     70    printPreds(leash);
    7171
    7272    bobs_seek(here);
     
    7575
    7676    bobs_moveNext();
    77     printSuccs(2);
     77    printSuccs(leash);
    7878}
    7979static void exploreRange(int validFrom, int validTo) {
     
    9595    }
    9696
    97     explore(listFirstmost);
     97    printf(" v%d..%d ", listFirstmost, listLastmost);
     98
     99    explore(listFirstmost, 6);
    98100    printf(" ...");
    99     if (gapsize > 5) {
    100         explore(midpoint);
    101         printf(" ...");
    102     }
    103     explore(listLastmost);
     101    // if (gapsize > 5) {
     102    //     explore(midpoint);
     103    //     printf(" ...");
     104    // }
     105    explore(listLastmost, 6);
    104106}
    105107
     
    108110        printf("%8zd + ? (rolling over)\n", bobs_ops_completed);
    109111    } else {
    110         printf("%8zd + %6d/2 + %6d/2", bobs_ops_completed, bobs_prog_inserting, bobs_prog_removing);
     112        printf("%8zd + %6d/2 + %6d/2, %6d@e %6d_u", bobs_ops_completed, bobs_prog_inserting, bobs_prog_removing, bobs_prog_removing_end, *bobs_prog_rem_pos);
    111113
    112114        int validFrom, validTo;
     
    114116            case stack:
    115117                validFrom = 0;
    116                 validTo = MIN((signed)bobs_prog_inserting-1, (signed)NumNodes - (signed)bobs_prog_removing - 1);
     118                validTo = MIN((signed)bobs_prog_inserting-1, (signed)NumNodes - (signed)*bobs_prog_rem_pos - 1);
    117119                break;
    118120            case queue:
    119                 validFrom = (signed)bobs_prog_removing;
     121                validFrom = (signed)*bobs_prog_rem_pos;
    120122                validTo = (signed)bobs_prog_inserting-1;
    121123                break;
  • doc/theses/mike_brooks_MMath/benchmarks/list/observation.h

    rda10157 r1eea589f  
    1818    extern volatile unsigned int bobs_prog_inserting;
    1919    extern volatile unsigned int bobs_prog_removing;
     20    extern volatile unsigned int bobs_prog_removing_end;
    2021    extern volatile unsigned int bobs_prog_rollover_flag;
     22    extern volatile unsigned int const * bobs_prog_rem_pos;
    2123
    2224    // observation.c defines
  • doc/theses/mike_brooks_MMath/benchmarks/list/op-queue-insfirst-remelem.h

    rda10157 r1eea589f  
    77#define BOP_INSERT(lst, iters, insNo, item)  BFX_INSERT_FIRST(B_UserItem, lst, (item))
    88#define BOP_REMOVE(lst, iters, remNo)        BFX_REMOVE_HERE(B_UserItem, lst, iters[(remNo)])
     9
     10#define BOP_REMPROGEND_IS_REMNO_BASED true
  • doc/theses/mike_brooks_MMath/benchmarks/list/op-queue-inslast-remelem.h

    rda10157 r1eea589f  
    77#define BOP_INSERT(lst, iters, insNo, item) BFX_INSERT_LAST(B_UserItem, lst, (item))
    88#define BOP_REMOVE(lst, iters, remNo)       BFX_REMOVE_HERE(B_UserItem, lst, iters[(remNo)])
     9
     10#define BOP_REMPROGEND_IS_REMNO_BASED true
  • doc/theses/mike_brooks_MMath/benchmarks/list/op-stack-insfirst-remelem.h

    rda10157 r1eea589f  
    77#define BOP_INSERT(lst, iters, insNo, item)  BFX_INSERT_FIRST(B_UserItem, lst, (item))
    88#define BOP_REMOVE(lst, iters, remNo)        BFX_REMOVE_HERE(B_UserItem, lst, iters[NumNodes-(remNo)-1])
     9
     10#define BOP_REMPROGEND_IS_REMNO_BASED true
  • doc/theses/mike_brooks_MMath/benchmarks/list/op-stack-inslast-remelem.h

    rda10157 r1eea589f  
    77#define BOP_INSERT(lst, iters, insNo, item)  BFX_INSERT_LAST(B_UserItem, lst, (item))
    88#define BOP_REMOVE(lst, iters, remNo)        BFX_REMOVE_HERE(B_UserItem, lst, iters[NumNodes-(remNo)-1])
     9
     10#define BOP_REMPROGEND_IS_REMNO_BASED true
  • libcfa/src/collections/list.hfa

    rda10157 r1eea589f  
    8080// part), by failing fast.
    8181
    82 #if defined( __x86_64 )
    83         // Preferred case: tag in the most-significant bit.  Dereference has been shown to segfault consistently.
    84         // Maintenance should list more architectures as "ok" here, to let them use the preferred case, when valid.
    85         #define ORIGIN_TAG_BITNO ( 8 * sizeof( size_t ) - 1 )
    86 #else
    87         // Fallback case: tag in the least-significant bit.  Dereference will often give an alignment error, but may not,
    88         // e.g. if accessing a char-typed member.  32-bit x86 uses the most- significant bit for real room on the heap.
    89         #define ORIGIN_TAG_BITNO 0
     82#ifdef __EXPERIMENTAL_DISABLE_OTAG__ // Perf experimention alt mode
     83
     84    // With origin tagging disabled, iteration never reports "no more elements."
     85    // In this mode, the list API is buggy.
     86    // This mode is used to quantify the cost of the normal tagging scheme.
     87
     88    #define ORIGIN_TAG_SET(p)   (p)
     89    #define ORIGIN_TAG_CLEAR(p) (p)
     90    #define ORIGIN_TAG_QUERY(p) 0
     91    #define ORIGIN_TAG_ASGN(p, v) (p)
     92    #define ORIGIN_TAG_EITHER(p, v) (p)
     93    #define ORIGIN_TAG_NEQ(v1, v2) 0
     94
     95#else // Normal
     96
     97    #if defined( __x86_64 )
     98        // Preferred case: tag in the most-significant bit.  Dereference
     99        // has been shown to segfault consistently.  Maintenance should
     100        // list more architectures as "ok" here, to let them use the
     101        // preferred case, when valid.
     102        #define ORIGIN_TAG_BITNO ( 8 * sizeof( size_t ) - 1 )
     103    #else
     104        // Fallback case: tag in the least-significant bit.  Dereference
     105        // will often give an alignment error, but may not, e.g. if
     106        // accessing a char-typed member.  32-bit x86 uses the most-
     107        // significant bit for real room on the heap.
     108        #define ORIGIN_TAG_BITNO 0
     109    #endif
     110
     111    #define ORIGIN_TAG_MASK (((size_t)1) << ORIGIN_TAG_BITNO)
     112
     113    #define ORIGIN_TAG_SET(p) ((p) |  ORIGIN_TAG_MASK)
     114    #define ORIGIN_TAG_CLEAR(p) ((p) & ~ORIGIN_TAG_MASK)
     115    #define ORIGIN_TAG_QUERY(p) ((p) &  ORIGIN_TAG_MASK)
     116
     117    #define ORIGIN_TAG_ASGN(p, v) ( \
     118        verify( ! ORIGIN_TAG_QUERY(p) && "p had no tagbit" ), \
     119        ORIGIN_TAG_EITHER((p), (v)) \
     120    )
     121
     122    #define ORIGIN_TAG_EITHER(p, v) ( \
     123        verify( ! ORIGIN_TAG_CLEAR(v) && "v is a pure tagbit" ), \
     124        ( (p) | (v) ) \
     125    )
     126
     127    #define ORIGIN_TAG_NEQ(v1, v2) ( \
     128        verify( ! ORIGIN_TAG_CLEAR(v1) && "v1 is a pure tagbit" ), \
     129        verify( ! ORIGIN_TAG_CLEAR(v2) && "v2 is a pure tagbit" ), \
     130        ( (v1) ^ (v2) ) \
     131    )
     132
    90133#endif
    91 #define ORIGIN_TAG_MASK (((size_t)1) << ORIGIN_TAG_BITNO)
    92 
    93 #define ORIGIN_TAG_SET( p )   ((p) |  ORIGIN_TAG_MASK)
    94 #define ORIGIN_TAG_CLEAR( p ) ((p) & ~ORIGIN_TAG_MASK)
    95 #define ORIGIN_TAG_QUERY( p ) ((p) &  ORIGIN_TAG_MASK)
     134
     135
     136
     137#ifdef __EXPERIMENTAL_LOOSE_SINGLES__ // Perf experimention alt mode
     138
     139    // In loose-singles mode, the ability to answer an "is listed" query is disabled, as is "to insert an element,
     140    // it must not be listed already" checking.  The user must know separately whether an element is listed.
     141    // Other than inserting it, any list-api action on an unlisted element is undefined.  Notably, list iteration
     142    // starting from an unlisted element is not defined to respond "no more elements," and may instead continue
     143    // iterating from a formerly occupied list position.  This mode matches LQ usage.
     144
     145    #define NOLOOSE(...)
     146    #define LOOSEONLY(...) __VA_ARGS__
     147
     148#else // Normal
     149
     150    #define NOLOOSE(...) __VA_ARGS__
     151    #define LOOSEONLY(...)
     152
     153#endif
     154
     155
     156
     157
    96158
    97159forall( tE & ) {
     
    102164
    103165        static inline void ?{}( dlink( tE ) & this ) {
     166          NOLOOSE(
    104167                this.next = this.prev = 0p;
     168          )
    105169        }
    106170
     
    129193static inline forall( tE &, tLinks & | embedded( tE, tLinks, dlink( tE ) ) ) {
    130194        bool isListed( tE & node ) {
     195      NOLOOSE(
    131196                verify( &node != 0p );
    132197                dlink( tE ) & node_links = node`inner;
    133198                return (node_links.prev != 0p) || (node_links.next != 0p);
     199          )
     200          LOOSEONLY(
     201        verify(false && "isListed is undefined");
     202                return true;
     203          )
    134204        }
    135205
     
    157227
    158228                dlink( tE ) & linkToInsert = node`inner;
    159 
     229      NOLOOSE(
    160230                verify( linkToInsert.next == 0p );
    161231                verify( linkToInsert.prev == 0p );
     232          )
    162233
    163234                tE & list_pos_elem = *(tE *)ORIGIN_TAG_CLEAR( (size_t)&before );
     
    180251
    181252                dlink( tE ) & linkToInsert = node`inner;
    182 
     253      NOLOOSE(
    183254                verify( linkToInsert.prev == 0p );
    184255                verify( linkToInsert.next == 0p );
     256          )
    185257
    186258                tE & list_pos_elem = *(tE *)ORIGIN_TAG_CLEAR( (size_t)&after );
     
    211283                before_links.next = &after_raw;
    212284                after_links.prev = &before_raw;
     285
     286      NOLOOSE(
    213287                asm( "" : : : "memory" );
    214288                list_pos_links.prev = 0p;
    215289                list_pos_links.next = 0p;
    216290                asm( "" : : : "memory" );
     291          )
    217292                return node;
    218293        }
  • libcfa/src/stdhdr/assert.h

    rda10157 r1eea589f  
    3838        #define warnf( expr, fmt, ... ) ({ static bool check_once##__LINE__ = false; if( false == check_once##__LINE__ && false == (expr)) { check_once##__LINE__ = true; __assert_warn_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ ); } })
    3939#else
    40         #define verify(x)
    41         #define verifyf(x, ...)
    42         #define verifyfail(...)
    43         #define warnf( expr, fmt, ... )
     40        #define verify(x) 0
     41        #define verifyf(x, ...) 0
     42        #define verifyfail(...) 0
     43        #define warnf( expr, fmt, ... ) 0
    4444#endif
    4545
Note: See TracChangeset for help on using the changeset viewer.