Changeset 76a8400 for doc/theses/colby_parsons_MMAth/benchmarks/channels
- Timestamp:
- Mar 30, 2023, 4:01:02 PM (17 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- e2f827f
- Parents:
- a45e21c
- 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 8 8 9 9 // user defines this 10 #define BIG 110 // #define BIG 1 11 11 12 12 owner_lock o; 13 13 14 unsigned long longtotal_operations = 0;14 size_t total_operations = 0; 15 15 16 16 struct bigObject { … … 36 36 Channel * channels; 37 37 38 volatilebool cons_done = false, prod_done = false;38 bool cons_done = false, prod_done = false; 39 39 volatile int cons_done_count = 0; 40 40 size_t cons_check = 0, prod_check = 0; … … 48 48 } 49 49 void main(Consumer & this) { 50 unsigned long longruns = 0;50 size_t runs = 0; 51 51 size_t my_check = 0; 52 52 for ( ;; ) { … … 78 78 } 79 79 void main(Producer & this) { 80 unsigned long longruns = 0;80 size_t runs = 0; 81 81 size_t my_check = 0; 82 size_t my_id = this.i; 82 83 for ( ;; ) { 83 84 if ( prod_done ) break; 84 85 #ifdef BIG 85 86 bigObject j{(size_t)runs}; 86 insert( channels[ this.i], j );87 insert( channels[ my_id ], j ); 87 88 my_check = my_check ^ (j.a + j.b + j.c + j.d + j.d + j.e + j.f + j.g + j.h); 88 89 #else 89 insert( channels[ this.i], (size_t)runs );90 insert( channels[ my_id ], (size_t)runs ); 90 91 my_check = my_check ^ ((size_t)runs); 91 92 #endif … … 99 100 } 100 101 101 int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) {102 size_t Clusters = Processors;102 static inline int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) { 103 size_t Clusters = 1; 103 104 // create a cluster 104 105 cluster clus[Clusters]; 105 106 processor * proc[Processors]; 106 107 for ( i; Processors ) { 107 (*(proc[i] = alloc())){clus[i % Clusters]};108 (*(proc[i] = malloc())){clus[i % Clusters]}; 108 109 } 109 110 … … 120 121 Producer * p[Producers * Channels]; 121 122 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 } 128 131 } 129 132 … … 148 151 } 149 152 } 150 151 153 } 152 154 … … 185 187 186 188 int main( int argc, char * argv[] ) { 187 size_t Processors = 1 0, Channels = 1, Producers = 10, Consumers = 10, ChannelSize = 128;189 size_t Processors = 1, Channels = 1, Producers = 1, Consumers = 1, ChannelSize = 128; 188 190 switch ( argc ) { 189 191 case 3: … … 206 208 exit( EXIT_FAILURE ); 207 209 } // switch 208 Producers = Processors ;209 Consumers = Processors ;210 Producers = Processors / 2; 211 Consumers = Processors / 2; 210 212 test(Processors, Channels, Producers, Consumers, ChannelSize); 211 213 }
Note: See TracChangeset
for help on using the changeset viewer.