Changeset 76a8400


Ignore:
Timestamp:
Mar 30, 2023, 4:01:02 PM (13 months ago)
Author:
caparson <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
e2f827f
Parents:
a45e21c
Message:

added all cfa benchmarks, contend is the only one used in the thesis, but other may be used later so Im keeping them around

Location:
doc/theses/colby_parsons_MMAth/benchmarks/channels/cfa
Files:
6 added
1 edited

Legend:

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

    ra45e21c r76a8400  
    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}
Note: See TracChangeset for help on using the changeset viewer.