Ignore:
Timestamp:
Mar 30, 2023, 9:48:06 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, stuck-waitfor-destruct
Children:
0b66ef9
Parents:
70056ed (diff), 6e83384 (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

Location:
doc/theses/colby_parsons_MMAth/benchmarks/channels
Files:
19 added
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/benchmarks/channels/cfa/contend.cfa

    r70056ed reb47a80  
    88
    99// user defines this
    10 #define BIG 1
     10// #define BIG 1
    1111
    1212owner_lock o;
    1313
    14 unsigned long long total_operations = 0;
     14size_t total_operations = 0;
    1515
    1616struct bigObject {
     
    3636Channel * channels;
    3737
    38 volatile bool cons_done = false, prod_done = false;
     38bool cons_done = false, prod_done = false;
    3939volatile int cons_done_count = 0;
    4040size_t cons_check = 0, prod_check = 0;
     
    4848}
    4949void main(Consumer & this) {
    50     unsigned long long runs = 0;
     50    size_t runs = 0;
    5151    size_t my_check = 0;
    5252    for ( ;; ) {
     
    7878}
    7979void main(Producer & this) {
    80     unsigned long long runs = 0;
     80    size_t runs = 0;
    8181    size_t my_check = 0;
     82    size_t my_id = this.i;
    8283    for ( ;; ) {
    8384        if ( prod_done ) break;
    8485        #ifdef BIG
    8586        bigObject j{(size_t)runs};
    86         insert( channels[ this.i ], j );
     87        insert( channels[ my_id ], j );
    8788        my_check = my_check ^ (j.a + j.b + j.c + j.d + j.d + j.e + j.f + j.g + j.h);
    8889        #else
    89         insert( channels[ this.i ], (size_t)runs );
     90        insert( channels[ my_id ], (size_t)runs );
    9091        my_check = my_check ^ ((size_t)runs);
    9192        #endif
     
    99100}
    100101
    101 int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) {
    102     size_t Clusters = Processors;
     102static inline int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) {
     103    size_t Clusters = 1;
    103104    // create a cluster
    104105    cluster clus[Clusters];
    105106    processor * proc[Processors];
    106107    for ( i; Processors ) {
    107         (*(proc[i] = alloc())){clus[i % Clusters]};
     108        (*(proc[i] = malloc())){clus[i % Clusters]};
    108109    }
    109110
     
    120121    Producer * p[Producers * Channels];
    121122
    122     for ( i; Consumers * Channels ) {
    123         (*(c[i] = alloc())){ i % Channels, clus[i % Clusters] };
    124     }
    125 
    126     for ( i; Producers * Channels ) {
    127         (*(p[i] = alloc())){ i % Channels, clus[i % Clusters] };
     123    for ( j; Channels ) {
     124        for ( i; Producers ) {
     125            (*(p[i] = malloc())){ j, clus[j % Clusters] };
     126        }
     127
     128        for ( i; Consumers ) {
     129            (*(c[i] = malloc())){ j, clus[j % Clusters] };
     130        }
    128131    }
    129132
     
    148151            }
    149152        }
    150        
    151153    }
    152154
     
    185187
    186188int main( int argc, char * argv[] ) {
    187     size_t Processors = 10, Channels = 1, Producers = 10, Consumers = 10, ChannelSize = 128;
     189    size_t Processors = 1, Channels = 1, Producers = 1, Consumers = 1, ChannelSize = 128;
    188190    switch ( argc ) {
    189191          case 3:
     
    206208                exit( EXIT_FAILURE );
    207209        } // switch
    208     Producers = Processors;
    209     Consumers = Processors;
     210    Producers = Processors / 2;
     211    Consumers = Processors / 2;
    210212    test(Processors, Channels, Producers, Consumers, ChannelSize);
    211213}
  • doc/theses/colby_parsons_MMAth/benchmarks/channels/go/contend/contend.go

    r70056ed reb47a80  
    6464                case 3:
    6565                        if os.Args[2] != "d" {                                                  // default ?
    66                                 ChannelSize, _ = strconv.Atoi( os.Args[1] )
     66                                ChannelSize, _ = strconv.Atoi( os.Args[2] )
    6767                                        if ChannelSize < 0 { usage(); }
    6868                        } // if
     
    7878        } // switch
    7979        runtime.GOMAXPROCS( Processors );
    80         ProdsPerChan = Processors
    81         ConsPerChan = Processors
     80        ProdsPerChan = Processors /2
     81        ConsPerChan = Processors / 2
    8282
    8383        // fmt.Println("Processors: ",Processors," Channels: ",Channels," ProdsPerChan: ",ProdsPerChan," ConsPerChan: ",ConsPerChan," Channel Size: ",ChannelSize)
     
    108108        cons_done = true
    109109        for i := range chans {
    110                 J: for j := 0; j < ConsPerChan; j++ {
     110                L: for {
    111111                        select {
    112                                 case chans[i] <- 0:
    113                                        
     112                                case k := <-chans[i]:
     113                                        cons_check = cons_check ^ k
    114114                                default:
    115                                         break J
     115                                        break L
    116116                        }
    117117                }
    118118        }
     119        for i := range chans {
     120                close(chans[i])
     121        }
     122
    119123        for j := 0; j < ConsPerChan * Channels; j++{
    120124                <-consJoin
    121125        }
    122126       
    123         // for i := range chans {
    124         //      L: for {
    125         //              select {
    126         //                      case k := <-chans[i]:
    127         //                              cons_check = cons_check ^ k
    128         //                      default:
    129         //                              break L
    130         //              }
    131         //      }
    132         // }
     127       
    133128        if cons_check != prod_check {
    134129                fmt.Println("\nChecksum mismatch: Cons: %d, Prods: %d", cons_check, prod_check)
    135130        }
    136         for i := range chans {
    137                 close(chans[i])
    138         }
    139131    fmt.Println(total_operations)
    140132}
  • doc/theses/colby_parsons_MMAth/benchmarks/channels/plotData.py

    r70056ed reb47a80  
    3636    procs.append(int(val))
    3737
    38 # 3rd line has num locks args
    39 line = readfile.readline()
    40 locks = []
    41 for val in line.split():
    42     locks.append(int(val))
    43 
    44 # 4th line has number of variants
     38# 3rd line has number of variants
    4539line = readfile.readline()
    4640names = line.split()
     
    5044lines = (line for line in lines if line) # Non-blank lines
    5145
     46class Bench(Enum):
     47    Unset = 0
     48    Contend = 1
     49    Zero = 2
     50    Barrier = 3
     51    Churn = 4
     52    Daisy_Chain = 5
     53    Hot_Potato = 6
     54    Pub_Sub = 7
     55
    5256nameSet = False
    53 currLocks = -1 # default val
     57currBench = Bench.Unset # default val
    5458count = 0
    5559procCount = 0
    5660currVariant = 0
    57 name = "Aggregate Lock"
     61name = ""
    5862var_name = ""
    5963sendData = [0.0 for j in range(numVariants)]
     
    6468    # print(line)
    6569   
    66     if currLocks == -1:
    67         lineArr = line.split()
    68         currLocks = lineArr[-1]
     70    if currBench == Bench.Unset:
     71        if line == "contend:":
     72            name = "Contend"
     73            currBench = Bench.Contend
     74        elif line == "zero:":
     75            name = "Zero"
     76            currBench = Bench.Zero
     77        elif line == "barrier:":
     78            name = "Barrier"
     79            currBench = Bench.Barrier
     80        elif line == "churn:":
     81            name = "Churn"
     82            currBench = Bench.Churn
     83        elif line == "daisy_chain:":
     84            name = "Daisy_Chain"
     85            currBench = Bench.Daisy_Chain
     86        elif line == "hot_potato:":
     87            name = "Hot_Potato"
     88            currBench = Bench.Hot_Potato
     89        elif line == "pub_sub:":
     90            name = "Pub_Sub"
     91            currBench = Bench.Pub_Sub
     92        else:
     93            print("Expected benchmark name")
     94            print("Line: " + line)
     95            sys.exit()
    6996        continue
    7097
     
    95122            if currVariant == numVariants:
    96123                fig, ax = plt.subplots()
    97                 plt.title(name + " Benchmark: " + str(currLocks) + " Locks")
    98                 plt.ylabel("Throughput (entries)")
     124                plt.title(name + " Benchmark")
     125                plt.ylabel("Throughput (channel operations)")
    99126                plt.xlabel("Cores")
    100127                for idx, arr in enumerate(data):
    101128                    plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker='o' )
     129               
    102130                plt.yscale("log")
     131                # plt.ylim(1, None)
     132                # ax.get_yaxis().set_major_formatter(ticks.ScalarFormatter())
     133                # else:
     134                #     plt.ylim(0, None)
    103135                plt.xticks(procs)
    104136                ax.legend(names)
    105                 # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".png")
    106                 plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".pgf")
     137                # fig.savefig("plots/" + machineName + name + ".png")
     138                plt.savefig("plots/" + machineName + name + ".pgf")
    107139                fig.clf()
    108140
    109141                # reset
    110                 currLocks = -1
     142                currBench = Bench.Unset
    111143                currVariant = 0
  • doc/theses/colby_parsons_MMAth/benchmarks/channels/run

    r70056ed reb47a80  
    8585}
    8686
    87 numtimes=11
    88 
    89 # locks=('-DLOCKS=L1' '-DLOCKS=L2' '-DLOCKS=L3' '-DLOCKS=L4' '-DLOCKS=L5' '-DLOCKS=L6' '-DLOCKS=L7' '-DLOCKS=L8')
    90 # locks='1 2 3 4 5 6 7 8'
    91 lock_flags=('-DLOCKS=L2' '-DLOCKS=L4' '-DLOCKS=L8')
    92 locks=('2' '4' '8')
     87numtimes=5
    9388
    9489num_threads='2 4 8 16 24 32'
    95 # num_threads='2 4 8'
     90# num_threads='2'
    9691
    9792# toggle benchmarks
    98 order=${true}
    99 rand=${true}
    100 baseline=${true}
     93zero=${false}
     94contend=${true}
     95barrier=${false}
     96churn=${false}
     97daisy_chain=${false}
     98hot_potato=${false}
     99pub_sub=${false}
    101100
    102101runCFA=${true}
    103 runCPP=${true}
     102runGO=${true}
    104103# runCFA=${false}
    105 # runCPP=${false}
     104# runGO=${false}
    106105
    107106cfa=~/cfa-cc/driver/cfa
    108 cpp=g++
    109107
    110108# Helpers to minimize code duplication
     
    152150echo $num_threads
    153151
    154 for i in ${!locks[@]}; do
    155         echo -n ${locks[$i]}' '
    156 done
    157 echo ""
    158 
    159 if [ ${runCFA} -eq ${true} ] && [ ${order} -eq ${true} ]; then
    160     echo -n 'CFA-order '
    161 fi
    162 if [ ${runCPP} -eq ${true} ] && [ ${order} -eq ${true} ]; then
    163     echo -n 'CPP-order '
    164 fi
    165 if [ ${runCFA} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then
    166     echo -n 'CFA-baseline '
    167 fi
    168 if [ ${runCPP} -eq ${true} ] && [ ${baseline} -eq ${true} ]; then
    169     echo -n 'CPP-baseline '
    170 fi
    171 if [ ${runCFA} -eq ${true} ] && [ ${rand} -eq ${true} ]; then
    172     echo -n 'CFA-rand '
    173 fi
    174 if [ ${runCPP} -eq ${true} ] && [ ${rand} -eq ${true} ]; then
    175     echo -n 'CPP-rand '
     152if [ ${runCFA} -eq ${true} ]; then
     153    echo -n 'CFA '
     154fi
     155if [ ${runGO} -eq ${true} ]; then
     156    echo -n 'Go '
    176157fi
    177158echo ""
     
    182163cfa_flags='-quiet -O3 -nodebug -DNDEBUG'
    183164
    184 # cpp flagse
    185 cpp_flags='-O3 -std=c++17 -lpthread -pthread -DNDEBUG'
    186 
    187165# run the benchmarks
    188166
    189 run_order() {
     167run_contend() {
    190168    post_args=${1}
    191169
    192170    if [ ${runCFA} -eq ${true} ] ; then
    193171        cd cfa # CFA RUN
    194         print_header 'CFA-'${3}
    195         ${cfa} ${cfa_flags} ${2} ${3}.cfa -o a.${hostname} > /dev/null 2>&1
     172        print_header 'CFA'
     173        ${cfa} ${cfa_flags} ${2}.cfa -o a.${hostname} > /dev/null 2>&1
    196174        run_bench
    197175        rm a.${hostname}
     
    199177    fi # done CFA
    200178
    201     if [ ${runCPP} -eq ${true} ] ; then
    202         cd cpp # CPP RUN
    203         print_header 'CPP-'${3}
    204         ${cpp} ${cpp_flags} ${2} ${3}.cc -o a.${hostname} > /dev/null 2>&1
     179    if [ ${runGO} -eq ${true} ] ; then
     180        cd go/${2} # Go RUN
     181        print_header 'Go'
     182        go build -o a.${hostname} > /dev/null 2>&1
    205183        run_bench
    206184        rm a.${hostname}
    207185        cd - > /dev/null
    208     fi # done CPP
     186    fi # done Go
    209187}
    210188
    211189# /usr/bin/time -f "%Uu %Ss %Er %Mkb"
    212 
    213 for i in ${!locks[@]}; do
    214     echo "locks: "${locks[$i]}
    215     if [ ${order} -eq ${true} ] ; then
    216         run_order ${locks[$i]} ${lock_flags[$i]} 'order'
    217     fi
    218     if [ ${baseline} -eq ${true} ] ; then
    219         run_order ${locks[$i]} ${lock_flags[$i]} 'baseline'
    220     fi
    221     if [ ${rand} -eq ${true} ] ; then
    222         run_order ${locks[$i]} '-DLOCKS=L8' 'rand'
    223     fi
    224 done
    225 
    226 
     190if [ ${contend} -eq ${true} ] ; then
     191    echo "contend: "
     192    run_contend '128' 'contend'
     193fi
     194
     195if [ ${zero} -eq ${true} ] ; then
     196    echo "zero: "
     197    run_contend '0' 'contend'
     198fi
     199
     200if [ ${barrier} -eq ${true} ] ; then
     201    echo "barrier: "
     202    run_contend '' 'barrier'
     203fi
     204
     205if [ ${churn} -eq ${true} ] ; then
     206    echo "churn: "
     207    run_contend '' 'churn'
     208fi
     209
     210if [ ${daisy_chain} -eq ${true} ] ; then
     211    echo "daisy_chain: "
     212    run_contend '' 'daisy_chain'
     213fi
     214
     215if [ ${hot_potato} -eq ${true} ] ; then
     216    echo "hot_potato: "
     217    run_contend '' 'hot_potato'
     218fi
     219
     220if [ ${pub_sub} -eq ${true} ] ; then
     221    echo "pub_sub: "
     222    run_contend '' 'pub_sub'
     223fi
Note: See TracChangeset for help on using the changeset viewer.