- Timestamp:
- Jul 26, 2021, 2:42:34 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 0a061c0
- Parents:
- c86ee4c (diff), 98233b3 (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. - Location:
- tests
- Files:
-
- 2 added
- 9 edited
-
.expect/counter.txt (modified) (1 diff)
-
.expect/polymorphism.txt (modified) (1 diff)
-
.expect/rational.txt (modified) (2 diffs)
-
Makefile.am (modified) (1 diff)
-
counter.cfa (modified) (3 diffs)
-
polymorphism.cfa (modified) (2 diffs)
-
rational.cfa (modified) (3 diffs)
-
unified_locking/fast.cfa (modified) (1 diff)
-
unified_locking/lin_backoff.cfa (added)
-
unified_locking/mutex_test.hfa (added)
-
unified_locking/thread_test.cfa (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/.expect/counter.txt
rc86ee4c rd83b266 1 452 421 inc 45 2 dec 42 -
tests/.expect/polymorphism.txt
rc86ee4c rd83b266 1 1 123 456 456 2 2 5 5 3 === checkPlan9offsets 4 static: 5 offset of inner double: 8 6 offset of inner float: 16 7 dynamic: 8 offset of inner double: 8 9 offset of inner float: 16 -
tests/.expect/rational.txt
rc86ee4c rd83b266 1 1 constructor 2 3/1 4/1 0/1 0/1 1/1 3 1/2 5/7 4 2/3 -3/2 5 -2/3 3/2 6 logical 7 -2/1 -3/2 8 1 9 1 10 1 11 0 12 0 2 a : 3/1 b : 4/1 c : 0/1 d : 0/1 e : 1/1 3 a : 1/2 b : 5/7 4 a : 2/3 b : -3/2 5 a : -2/3 b : 3/2 6 7 comparison 8 a : -2/1 b : -3/2 9 a == 0 : 0 10 a == 1 : 0 11 a != 0 : 1 12 ! a : 0 13 a != b : 1 14 a < b : 1 15 a <= b : 1 16 a > b : 0 17 a >= b : 0 18 13 19 arithmetic 14 -2/1 -3/2 15 -7/2 16 -1/2 17 3/1 18 4/3 20 a : -2/1 b : -3/2 21 a + b : -7/2 22 a += b : -7/2 23 ++a : -5/2 24 a++ : -5/2 25 a : -3/2 26 a - b : 0/1 27 a -= b : 0/1 28 --a : -1/1 29 a-- : -1/1 30 a : -2/1 31 a * b : 3/1 32 a / b : 4/3 33 a \ 2 : 4/1 b \ 2 : 9/4 34 a \ -2 : 1/4 b \ -2 : 4/9 35 19 36 conversion 20 37 0.75 … … 24 41 1/7 25 42 355/113 26 decompose 43 27 44 more tests 28 45 -3/2 -
tests/Makefile.am
rc86ee4c rd83b266 82 82 concurrent/clib_tls.c \ 83 83 exceptions/with-threads.hfa \ 84 exceptions/except-io.hfa 84 exceptions/except-io.hfa \ 85 unified_locking/mutex_test.hfa 85 86 86 87 dist-hook: -
tests/counter.cfa
rc86ee4c rd83b266 10 10 // Created On : Thu Feb 22 15:27:00 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 6 17:50:23 201813 // Update Count : 212 // Last Modified On : Tue Jul 20 21:25:30 2021 13 // Update Count : 4 14 14 // 15 16 #include <fstream.hfa> 15 17 16 18 // Tests unified increment/decrement builtin functions. … … 19 21 struct counter { int x; }; 20 22 21 counter& ?+=?( counter& c, one_t ) { ++c.x; return c; } 22 23 counter& ?-=?( counter& c, one_t ) { --c.x; return c; } 23 counter ?+=?( counter & c, one_t ) { ++c.x; return c; } 24 counter ?-=?( counter & c, one_t ) { --c.x; return c; } 24 25 25 26 int main() { … … 28 29 ++c; 29 30 c++; 30 printf("%d\n", c.x);31 sout | "inc" | c.x; 31 32 c -= 1; 32 33 --c; 33 34 c--; 34 printf("%d\n", c.x);35 sout | "dec" | c.x; 35 36 } 36 37 -
tests/polymorphism.cfa
rc86ee4c rd83b266 54 54 b.i = s.i; 55 55 return b.j; 56 } 57 58 void checkPlan9offsets() { 59 60 forall( T ) 61 struct thing { 62 T q; // variable-sized padding 63 inline double; 64 inline float; 65 }; 66 67 #define SHOW_OFFSETS \ 68 double & x_inner_double = x; \ 69 float & x_inner_float = x; \ 70 printf(" offset of inner double: %ld\n", ((char *) & x_inner_double) - ((char *) & x) ); \ 71 printf(" offset of inner float: %ld\n", ((char *) & x_inner_float ) - ((char *) & x) ); 72 73 void showStatic( thing(long long int) & x ) { 74 printf("static:\n"); 75 SHOW_OFFSETS 76 } 77 78 forall( T ) 79 void showDynamic( thing(T) & x ) { 80 printf("dynamic:\n"); 81 SHOW_OFFSETS 82 } 83 84 #undef SHOW_OFFSETS 85 86 printf("=== checkPlan9offsets\n"); 87 thing(long long int) x; 88 showStatic(x); 89 showDynamic(x); 56 90 } 57 91 … … 114 148 assertf(ret == u.f2, "union operation fails in polymorphic context."); 115 149 } 150 151 checkPlan9offsets(); 116 152 } 117 153 -
tests/rational.cfa
rc86ee4c rd83b266 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 8 18:46:23 202013 // Update Count : 8612 // Last Modified On : Tue Jul 20 18:13:40 2021 13 // Update Count : 107 14 14 // 15 15 … … 26 26 sout | "constructor"; 27 27 RatInt a = { 3 }, b = { 4 }, c, d = 0, e = 1; 28 sout | a | b | c | d| e;28 sout | "a : " | a | "b : " | b | "c : " | c | "d : " | d | "e : " | e; 29 29 30 30 a = (RatInt){ 4, 8 }; 31 31 b = (RatInt){ 5, 7 }; 32 sout | a| b;32 sout | "a : " | a | "b : " | b; 33 33 a = (RatInt){ -2, -3 }; 34 34 b = (RatInt){ 3, -2 }; 35 sout | a| b;35 sout | "a : " | a | "b : " | b; 36 36 a = (RatInt){ -2, 3 }; 37 37 b = (RatInt){ 3, 2 }; 38 sout | a | b; 38 sout | "a : " | a | "b : " | b; 39 sout | nl; 39 40 40 sout | " logical";41 sout | "comparison"; 41 42 a = (RatInt){ -2 }; 42 43 b = (RatInt){ -3, 2 }; 43 sout | a | b; 44 // sout | a == 1; // FIX ME 45 sout | a != b; 46 sout | a < b; 47 sout | a <= b; 48 sout | a > b; 49 sout | a >= b; 44 sout | "a : " | a | "b : " | b; 45 sout | "a == 0 : " | a == (Rational(int)){0}; // FIX ME 46 sout | "a == 1 : " | a == (Rational(int)){1}; // FIX ME 47 sout | "a != 0 : " | a != 0; 48 sout | "! a : " | ! a; 49 sout | "a != b : " | a != b; 50 sout | "a < b : " | a < b; 51 sout | "a <= b : " | a <= b; 52 sout | "a > b : " | a > b; 53 sout | "a >= b : " | a >= b; 54 sout | nl; 50 55 51 56 sout | "arithmetic"; 52 sout | a | b; 53 sout | a + b; 54 sout | a - b; 55 sout | a * b; 56 sout | a / b; 57 // sout | a \ 2 | b \ 2; // FIX ME 58 // sout | a \ -2 | b \ -2; 57 sout | "a : " | a | "b : " | b; 58 sout | "a + b : " | a + b; 59 sout | "a += b : " | (a += b); 60 sout | "++a : " | ++a; 61 sout | "a++ : " | a++; 62 sout | "a : " | a; 63 sout | "a - b : " | a - b; 64 sout | "a -= b : " | (a -= b); 65 sout | "--a : " | --a; 66 sout | "a-- : " | a--; 67 sout | "a : " | a; 68 sout | "a * b : " | a * b; 69 sout | "a / b : " | a / b; 70 sout | "a \\ 2 : " | a \ 2u | "b \\ 2 : " | b \ 2u; 71 sout | "a \\ -2 : " | a \ -2 | "b \\ -2 : " | b \ -2; 72 sout | nl; 59 73 60 74 sout | "conversion"; … … 68 82 sout | narrow( 0.14285714285714, 16 ); 69 83 sout | narrow( 3.14159265358979, 256 ); 84 sout | nl; 70 85 71 sout | "decompose";72 int n, d;73 //[n, d] = a;74 //sout | a | n | d;86 // sout | "decompose"; 87 // int n, d; 88 // [n, d] = a; 89 // sout | a | n | d; 75 90 76 91 sout | "more tests"; -
tests/unified_locking/fast.cfa
rc86ee4c rd83b266 1 #include <fstream.hfa>2 1 #include <locks.hfa> 3 #include <thread.hfa>4 2 5 const unsigned int num_times = 50; 6 7 struct MutexObj { 8 fast_lock l; 9 thread$ * id; 10 uint32_t sum; 11 }; 12 13 MutexObj mo; 14 15 void trash() { 16 unsigned t[100]; 17 for(i; 100) { 18 t[i] = 0xDEADBEEF; 19 } 20 } 21 22 uint32_t cs() { 23 thread$ * me = active_thread(); 24 uint32_t value; 25 lock(mo.l); 26 { 27 uint32_t tsum = mo.sum; 28 mo.id = me; 29 yield(random(5)); 30 value = ((uint32_t)random()) ^ ((uint32_t)me); 31 if(mo.id != me) sout | "Intruder!"; 32 mo.sum = tsum + value; 33 } 34 unlock(mo.l); 35 return value; 36 } 37 38 thread LockCheck { 39 uint32_t sum; 40 }; 41 42 void main(LockCheck & this) { 43 this.sum = 0; 44 for(num_times) { 45 trash(); 46 this.sum += cs(); 47 trash(); 48 yield(random(10)); 49 } 50 } 3 #define LOCK fast_lock 4 #include "mutex_test.hfa" 51 5 52 6 int main() { 53 uint32_t sum = -32; 54 mo.sum = -32; 55 processor p[2]; 56 sout | "Starting"; 57 { 58 LockCheck checkers[13]; 59 for(i;13) { 60 sum += join(checkers[i]).sum; 61 } 62 } 63 sout | "Done!"; 64 if(sum == mo.sum) sout | "Match!"; 65 else sout | "No Match!" | sum | "vs" | mo.sum; 7 test(); 66 8 } -
tests/unified_locking/thread_test.cfa
rc86ee4c rd83b266 8 8 static unsigned int threadCount = 2; 9 9 static unsigned int lockCount = 1; 10 static unsigned int num_times = 10000; 10 static unsigned int total_times = 320000; 11 static unsigned int num_times; 11 12 static const int workBufferSize = 16; 12 13 static unsigned int work_unlocked = 10000; … … 25 26 thread worker { 26 27 linear_backoff_then_block_lock * locks; 28 bool improved; 27 29 }; 28 30 29 void ?{}( worker & w, linear_backoff_then_block_lock * locks ) {31 void ?{}( worker & w, linear_backoff_then_block_lock * locks, bool improved ) { 30 32 w.locks = locks; 33 w.improved = improved; 31 34 } 32 35 33 linear_backoff_then_block_lock norm_lock;34 36 35 37 void main( worker & this ) with(this) { … … 37 39 for (int i = 0; i < workBufferSize; i += 1) buffer[i] = rand() % 1024; 38 40 unsigned int lck = rand() % lockCount; 39 linear_backoff_then_block_lock * curr_lock = locks;//[lck];41 linear_backoff_then_block_lock * curr_lock = &locks[lck]; 40 42 for (unsigned int i = 0; i < num_times; i++) { 41 43 dowork(buffer, work_unlocked); 42 lock(*curr_lock); 43 //printf("lock: %d %p ENTER\n", i, &curr_lock); 44 //lock(norm_lock); 44 if (improved) lock_improved(*curr_lock); 45 else lock(*curr_lock); 45 46 dowork(buffer, work_locked); 46 //printf("lock: %d %p LEAVE\n", i, &curr_lock);47 47 unlock(*curr_lock); 48 //unlock(norm_lock);49 48 lck = rand() % lockCount; 50 //curr_lock =locks[lck];49 curr_lock = &locks[lck]; 51 50 } 52 51 } 53 52 53 54 54 int main(int argc, char* argv[]) { 55 55 switch (argc) { 56 case 7: 57 work_unlocked = atoi(argv[5]); 58 case 6: 59 work_locked = atoi(argv[5]); 56 60 case 5: 57 61 num_times = atoi(argv[4]); … … 68 72 } 69 73 processor p[threadCount]; 70 linear_backoff_then_block_lock locks;//[lockCount]; 71 printf("lock allocation address: %p \n", &locks); 74 linear_backoff_then_block_lock locks[lockCount]; 72 75 worker * worker_arr[taskCount]; 76 num_times = total_times / taskCount; 73 77 74 printf("Start Test: martin lock simple\n");78 //printf("Start Test: martin lock simple\n"); 75 79 clock_t begin = clock(); 76 80 for (unsigned int i = 0; i < taskCount; i++) { 77 worker_arr[i] = new( &locks);81 worker_arr[i] = new( locks, false ); 78 82 } 79 83 for (unsigned int i = 0; i < taskCount; i++) { 80 free( worker_arr[i] );84 delete( worker_arr[i] ); 81 85 } 82 86 clock_t end = clock(); 83 87 double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 84 printf("Done Test, time: %f\n", time_spent); 88 printf("norm: %f\n", time_spent); 89 90 //printf("Start Test: martin lock improved\n"); 91 begin = clock(); 92 for (unsigned int i = 0; i < taskCount; i++) { 93 worker_arr[i] = new( locks, true ); 94 } 95 for (unsigned int i = 0; i < taskCount; i++) { 96 delete( worker_arr[i] ); 97 } 98 end = clock(); 99 time_spent = (double)(end - begin) / CLOCKS_PER_SEC; 100 printf("improved: %f\n", time_spent); 85 101 }
Note:
See TracChangeset
for help on using the changeset viewer.