- Timestamp:
- Jan 9, 2023, 3:21:02 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 01a8954
- Parents:
- 5e180c2
- Location:
- tests/unified_locking
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/unified_locking/locks.cfa
r5e180c2 r0cee082 15 15 condition_variable( owner_lock ) c_o; 16 16 17 linear_backoff_then_block_lock l;18 condition_variable( linear_backoff_then_block_lock ) c_l;17 exp_backoff_then_block_lock l; 18 condition_variable( exp_backoff_then_block_lock ) c_l; 19 19 20 20 fast_block_lock f; -
tests/unified_locking/thread_test.cfa
r5e180c2 r0cee082 25 25 26 26 thread worker { 27 linear_backoff_then_block_lock * locks;27 exp_backoff_then_block_lock * locks; 28 28 bool improved; 29 29 }; 30 30 31 void ?{}( worker & w, linear_backoff_then_block_lock * locks, bool improved ) {31 void ?{}( worker & w, exp_backoff_then_block_lock * locks, bool improved ) { 32 32 w.locks = locks; 33 33 w.improved = improved; … … 39 39 for (int i = 0; i < workBufferSize; i += 1) buffer[i] = rand() % 1024; 40 40 unsigned int lck = rand() % lockCount; 41 linear_backoff_then_block_lock * curr_lock = &locks[lck];41 exp_backoff_then_block_lock * curr_lock = &locks[lck]; 42 42 for (unsigned int i = 0; i < num_times; i++) { 43 43 dowork(buffer, work_unlocked); … … 51 51 } 52 52 53 53 int doOne = 0; 54 54 int main(int argc, char* argv[]) { 55 55 switch (argc) { 56 case 8: 57 doOne = atoi(argv[7]); 56 58 case 7: 57 work_unlocked = atoi(argv[ 5]);59 work_unlocked = atoi(argv[6]); 58 60 case 6: 59 61 work_locked = atoi(argv[5]); 60 62 case 5: 61 num_times = atoi(argv[4]);63 total_times = atoi(argv[4]); 62 64 case 4: 63 65 lockCount = atoi(argv[3]); … … 72 74 } 73 75 processor p[threadCount]; 74 linear_backoff_then_block_lock locks[lockCount];76 exp_backoff_then_block_lock locks[lockCount]; 75 77 worker * worker_arr[taskCount]; 76 78 num_times = total_times / taskCount; 77 78 //printf("Start Test: martin lock simple\n"); 79 clock_t begin = clock(); 79 //printf("%d\n", doOne); 80 // 81 //clock_t begin = clock(); 82 if (doOne == 1) { 83 printf("Start Test: martin lock simple %d\n", num_times); 80 84 for (unsigned int i = 0; i < taskCount; i++) { 81 85 worker_arr[i] = new( locks, false ); … … 84 88 delete( worker_arr[i] ); 85 89 } 86 clock_t end = clock(); 87 double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 88 printf("norm: %f\n", time_spent); 90 } 91 //clock_t end = clock(); 92 //double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 93 //printf("norm: %f\n", time_spent); 89 94 90 95 //printf("Start Test: martin lock improved\n"); 91 begin = clock(); 96 //begin = clock(); 97 if (doOne == 2) { 92 98 for (unsigned int i = 0; i < taskCount; i++) { 93 99 worker_arr[i] = new( locks, true ); … … 96 102 delete( worker_arr[i] ); 97 103 } 98 end = clock(); 99 time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 100 printf("improved: %f\n", time_spent); 104 } 105 //end = clock(); 106 //time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 107 //printf("improved: %f\n", time_spent); 101 108 }
Note: See TracChangeset
for help on using the changeset viewer.