Changeset 2b0e754 for doc/theses/mike_brooks_MMath/benchmarks/list/driver.c
- Timestamp:
- Jul 27, 2025, 3:25:11 PM (2 months ago)
- Branches:
- master
- Children:
- 5ba1356
- Parents:
- b9d1242
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/benchmarks/list/driver.c
rb9d1242 r2b0e754 4 4 #include <string.h> 5 5 6 #ifdef DISABLE_OBSERVATION 7 #include "proglang.h" 8 #define bobs_init(...) 9 #else 6 10 #include "observation.h" 11 #endif 7 12 8 13 #ifdef TINY_USER_ITEMS … … 20 25 { 21 26 BFX_INTRUSION(B_UserItem) 27 // BFX_LISTED_ELEM_T(B_UserItem) selfListed; 22 28 UDATA_T userdata[ UDATA_LEN ]; 23 29 } … … 51 57 static BFX_LIST_HEAD_T(B_UserItem) lst; 52 58 59 #ifdef DISABLE_OBSERVATION 60 MAYBE_EXTERN_C ( 61 void bobs_seek(unsigned int i) {} 62 void bobs_moveNext() {} 63 void bobs_movePrev() {} 64 int bobs_hasCurrent() { return 0; } 65 void * bobs_getCurrentLoc() { return NULL; } 66 int bobs_getCurrentVal() { return 0; } 67 // enum bobs_op_movement_t bobs_op_movement = OP_MOVEMENT; 68 // enum bobs_op_polarity_t bobs_op_polarity = OP_POLARITY; 69 ) 70 71 #else 72 53 73 MAYBE_EXTERN_C ( 54 74 … … 87 107 enum bobs_op_polarity_t bobs_op_polarity = OP_POLARITY; 88 108 ) 89 109 #endif 110 111 112 #ifndef DISABLE_OBSERVATION 90 113 91 114 // Remove progress end (number) is based (upon) remove-number … … 101 124 ) 102 125 126 #endif // ndef DISABLE_OBSERVATION 127 103 128 unsigned int uDefaultPreemption() { 104 129 return 0; 105 130 } 106 131 132 #ifdef DISABLE_ITERS_AR 133 // Saves on memory accesses, makes element-oriented removals and observation impossible (instead, they crash) 134 static inline BFX_LISTED_ELEM_T(B_UserItem) buhrdice_pass( BFX_LISTED_ELEM_T(B_UserItem) v ) { // prevent eliding, cheaper than volatile 135 __asm__ __volatile__ ( "" : "+r"(v) ); 136 return v ; 137 } // pass 138 #define ITERS_SAVE(i, insertElemExpr) buhrdice_pass(insertElemExpr) 139 #endif 140 107 141 int main(int argc, const char *argv[]) { 142 143 #ifdef DISABLE_OBSERVATION 144 // define the outbound dependencies as locals, for compiling into nops 145 size_t bobs_ops_completed = 0; 146 unsigned int bobs_prog_inserting = 0; 147 unsigned int bobs_prog_removing = 0; 148 unsigned int bobs_prog_removing_end = 0; 149 unsigned int bobs_prog_rollover_flag = 0; 150 #endif 108 151 109 152 const char * usage_args = "[ExperimentDurSec [CheckDonePeriod [NumNodes [ExperimentDurOpCount [Seed [InterleaveFrac]]]]]]"; … … 227 270 memset(ui, 0, (size_t)NumNodes * (size_t)sizeof(B_UserItem)); 228 271 272 #ifndef DISABLE_ITERS_AR 229 273 listedItems = (BFX_LISTED_ELEM_T(B_UserItem)*)malloc( (size_t)NumNodes * (size_t)sizeof(BFX_LISTED_ELEM_T(B_UserItem)) ); 230 274 if (!listedItems) { … … 233 277 } 234 278 memset(listedItems, 0, (size_t)NumNodes * (size_t)sizeof(BFX_LISTED_ELEM_T(B_UserItem))); 279 #define ITERS_SAVE(i, insertElemExpr) listedItems[i] = (insertElemExpr) 280 #endif 235 281 236 282 // Construct and fill with demo data … … 285 331 for ( int t = 0; t < CheckDonePeriod; t += 1 ) { 286 332 TRACE('a') // insert special first 287 listedItems[0] =288 BOP_INIT(lst, listedItems, 0, ui[INSERTPOS(0)]) ;333 ITERS_SAVE( 0, 334 BOP_INIT(lst, listedItems, 0, ui[INSERTPOS(0)]) ); 289 335 TRACE('b') // insert general 290 336 for ( int privateCurInsert = 1; … … 293 339 ) { 294 340 TRACE('-') 295 listedItems[privateCurInsert] =296 BOP_INSERT( lst, listedItems, privateCurInsert, ui[INSERTPOS(privateCurInsert)] ) ;341 ITERS_SAVE( privateCurInsert, 342 BOP_INSERT( lst, listedItems, privateCurInsert, ui[INSERTPOS(privateCurInsert)] ) ); 297 343 TRACE('+') 298 344 } 345 #ifdef DISABLE_INTERLEAVING 346 // interleaving off, simple removes 347 // (remove logic of 2b01f8eb0956) 348 TRACE('c') 349 for ( int privateCurRemove = 1; 350 (bobs_prog_removing = privateCurRemove, privateCurRemove < NumNodes); 351 privateCurRemove += 1 352 ) { 353 TRACE('-') 354 BOP_REMOVE( lst, listedItems, privateCurRemove-1 ); 355 TRACE('+') 356 } 357 #else 358 // interleaving on, complex removes 299 359 TRACE('c') // remove general 300 360 int removeProgress[] = { 0, 0 }; … … 324 384 } 325 385 } 386 #endif // DISABLE_INTERLEAVING 326 387 TRACE('D') // remove special last 327 388 BOP_TEARDOWN(lst, listedItems, NumNodes-1);
Note:
See TracChangeset
for help on using the changeset viewer.