Changeset 8f34661
- Timestamp:
- Aug 9, 2018, 9:20:15 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- b7c55277
- Parents:
- 3b2b37f
- Location:
- src/tests
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/alloc.c
r3b2b37f r8f34661 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 26 20:58:05 201813 // Update Count : 33 412 // Last Modified On : Thu Aug 9 06:21:35 2018 13 // Update Count : 337 14 14 // 15 15 … … 62 62 p = (int *)calloc( dim, sizeof( *p ) ); // C array calloc, type unsafe 63 63 printf( "C array calloc, fill 0\n" ); 64 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }64 for ( i; dim ) { printf( "%#x ", p[i] ); } 65 65 printf( "\n" ); 66 66 free( p ); … … 68 68 p = calloc( dim ); // CFA array calloc, type safe 69 69 printf( "CFA array calloc, fill 0\n" ); 70 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }70 for ( i; dim ) { printf( "%#x ", p[i] ); } 71 71 printf( "\n" ); 72 72 free( p ); 73 73 74 74 p = alloc( dim ); // CFA array alloc, type safe 75 for ( i nt i = 0; i < dim; i += 1) { p[i] = 0xdeadbeef; }75 for ( i; dim ) { p[i] = 0xdeadbeef; } 76 76 printf( "CFA array alloc, no fill\n" ); 77 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }77 for ( i; dim ) { printf( "%#x ", p[i] ); } 78 78 printf( "\n" ); 79 79 free( p ); … … 81 81 p = alloc( 2 * dim, fill ); // CFA array alloc, fill 82 82 printf( "CFA array alloc, fill %#hhx\n", fill ); 83 for ( i nt i = 0; i < 2 * dim; i += 1) { printf( "%#x ", p[i] ); }83 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 84 84 printf( "\n" ); 85 85 // do not free … … 90 90 91 91 p = (int *)realloc( p, dim * sizeof(*p) ); // C realloc 92 for ( i nt i = 0; i < dim; i += 1) { p[i] = 0xdeadbeef; }92 for ( i; dim ) { p[i] = 0xdeadbeef; } 93 93 printf( "C realloc\n" ); 94 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }94 for ( i; dim ) { printf( "%#x ", p[i] ); } 95 95 printf( "\n" ); 96 96 97 97 p = realloc( p, 2 * dim * sizeof(*p) ); // CFA realloc 98 for ( i nt i = dim; i < 2 * dim; i += 1) { p[i] = 0x1010101; }98 for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; } 99 99 printf( "CFA realloc\n" ); 100 for ( i nt i = 0; i < 2 * dim; i += 1) { printf( "%#x ", p[i] ); }100 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 101 101 printf( "\n" ); 102 102 // do not free … … 107 107 108 108 p = alloc( p, dim ); // CFA resize array alloc 109 for ( i nt i = 0; i < dim; i += 1) { p[i] = 0xdeadbeef; }109 for ( i; dim ) { p[i] = 0xdeadbeef; } 110 110 printf( "CFA resize alloc\n" ); 111 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }111 for ( i; dim ) { printf( "%#x ", p[i] ); } 112 112 printf( "\n" ); 113 113 114 114 p = alloc( p, 2 * dim ); // CFA resize array alloc 115 for ( i nt i = dim; i < 2 * dim; i += 1) { p[i] = 0x1010101; }115 for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; } 116 116 printf( "CFA resize array alloc\n" ); 117 for ( i nt i = 0; i < 2 * dim; i += 1) { printf( "%#x ", p[i] ); }117 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 118 118 printf( "\n" ); 119 119 120 120 p = alloc( p, dim ); // CFA array alloc 121 121 printf( "CFA resize array alloc\n" ); 122 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }122 for ( i; dim ) { printf( "%#x ", p[i] ); } 123 123 printf( "\n" ); 124 124 … … 128 128 p = alloc( p, dim, fill ); // CFA array alloc, fill 129 129 printf( "CFA resize array alloc, fill\n" ); 130 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] ); }130 for ( i; dim ) { printf( "%#x ", p[i] ); } 131 131 printf( "\n" ); 132 132 133 133 p = alloc( p, 2 * dim, fill ); // CFA array alloc, fill 134 134 printf( "CFA resize array alloc, fill\n" ); 135 for ( i nt i = 0; i < 2 * dim; i += 1) { printf( "%#x ", p[i] ); }135 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 136 136 printf( "\n" ); 137 137 138 138 p = alloc( p, dim, fill ); // CFA array alloc, fill 139 139 printf( "CFA resize array alloc, fill\n" ); 140 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x ", p[i] );; }140 for ( i; dim ) { printf( "%#x ", p[i] );; } 141 141 printf( "\n" ); 142 142 free( p ); … … 193 193 stp = align_alloc( Alignment, dim ); // CFA array memalign 194 194 assert( (uintptr_t)stp % Alignment == 0 ); 195 for ( i nt i = 0; i < dim; i += 1) { stp[i] = (Struct){ 42, 42.5 }; }195 for ( i; dim ) { stp[i] = (Struct){ 42, 42.5 }; } 196 196 printf( "CFA array align_alloc\n" ); 197 for ( i nt i = 0; i < dim; i += 1) { printf( "%d %g, ", stp[i].x, stp[i].y ); }197 for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); } 198 198 printf( "\n" ); 199 199 free( stp ); … … 202 202 assert( (uintptr_t)stp % Alignment == 0 ); 203 203 printf( "CFA array align_alloc, fill\n" ); 204 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x %a, ", stp[i].x, stp[i].y ); }204 for ( i; dim ) { printf( "%#x %a, ", stp[i].x, stp[i].y ); } 205 205 printf( "\n" ); 206 206 free( stp ); … … 221 221 amemset( sta, fill, dim ); // CFA array memset, type safe 222 222 printf( "CFA array memset\n" ); 223 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x %a, ", sta[i].x, sta[i].y ); }223 for ( i; dim ) { printf( "%#x %a, ", sta[i].x, sta[i].y ); } 224 224 printf( "\n" ); 225 225 226 226 amemcpy( sta1, sta, dim ); // CFA array memcpy, type safe 227 227 printf( "CFA array memcpy\n" ); 228 for ( i nt i = 0; i < dim; i += 1) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); }228 for ( i; dim ) { printf( "%#x %a, ", sta1[i].x, sta1[i].y ); } 229 229 printf( "\n" ); 230 230 … … 241 241 stp = anew( dim, 42, 42.5 ); 242 242 printf( "CFA array new initialize\n" ); 243 for ( i nt i = 0; i < dim; i += 1) { printf( "%d %g, ", stp[i].x, stp[i].y ); }243 for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); } 244 244 printf( "\n" ); 245 245 stp1 = anew( dim, 42, 42.5 ); 246 for ( i nt i = 0; i < dim; i += 1) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }246 for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); } 247 247 printf( "\n" ); 248 248 adelete( dim, stp, dim, stp1 ); -
src/tests/concurrent/examples/matrixSum.c
r3b2b37f r8f34661 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Fri May 25 09:34:27201814 // Update Count : 1 013 // Last Modified On : Thu Aug 9 09:17:30 2018 14 // Update Count : 13 15 15 // 16 16 … … 30 30 void main( Adder & adder ) with( adder ) { // thread starts here 31 31 subtotal = 0; 32 for ( int c = 0; c < cols; c += 1) {32 for ( c; cols ) { 33 33 subtotal += row[c]; 34 34 } // for … … 36 36 37 37 int main() { 38 constint rows = 10, cols = 1000;38 /* const */ int rows = 10, cols = 1000; 39 39 int matrix[rows][cols], subtotals[rows], total = 0; 40 40 processor p; // add kernel thread 41 41 42 for ( int r = 0; r < rows; r += 1) {43 for ( int c = 0; c < cols; c += 1) {42 for ( r; rows ) { 43 for ( c; cols ) { 44 44 matrix[r][c] = 1; 45 45 } // for 46 46 } // for 47 47 Adder * adders[rows]; 48 for ( int r = 0; r < rows; r += 1 ) {// start threads to sum rows48 for ( r; rows ) { // start threads to sum rows 49 49 adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] }; 50 50 // adders[r] = new( matrix[r], cols, &subtotals[r] ); 51 51 } // for 52 for ( int r = 0; r < rows; r += 1 ) {// wait for threads to finish52 for ( r; rows ) { // wait for threads to finish 53 53 delete( adders[r] ); 54 54 total += subtotals[r]; // total subtotals -
src/tests/searchsort.c
r3b2b37f r8f34661 10 10 // Created On : Thu Feb 4 18:17:50 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jan 2 08:01:17 201813 // Update Count : 10 012 // Last Modified On : Thu Aug 9 07:54:57 2018 13 // Update Count : 101 14 14 // 15 15 … … 24 24 int iarr[size]; 25 25 26 for ( unsigned int i = 0; i < size; i += 1) {26 for ( i; 0u ~ size ) { 27 27 iarr[i] = size - i; 28 28 sout | iarr[i] | ", "; … … 32 32 // ascending sort/search by changing < to > 33 33 qsort( iarr, size ); 34 for ( unsigned int i = 0; i < size; i += 1) {34 for ( i; 0u ~ size ) { 35 35 sout | iarr[i] | ", "; 36 36 } // for 37 37 sout | endl; 38 for ( unsigned int i = 0; i < size; i += 1) { // C version38 for ( i; 0u ~ size ) { // C version 39 39 int key = size - i; 40 40 int * v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp ); … … 43 43 sout | endl; 44 44 45 for ( unsigned int i = 0; i < size; i += 1) {45 for ( i; 0u ~ size ) { 46 46 int * v = bsearch( size - i, iarr, size ); 47 47 sout | size - i | ':' | *v | ", "; 48 48 } // for 49 49 sout | endl; 50 for ( unsigned int i = 0; i < size; i += 1) {50 for ( i; 0u ~ size ) { 51 51 unsigned int posn = bsearch( size - i, iarr, size ); 52 52 sout | size - i | ':' | iarr[posn] | ", "; … … 55 55 56 56 // descending sort/search by changing < to > 57 for ( unsigned int i = 0; i < size; i += 1) {57 for ( i; 0u ~ size ) { 58 58 iarr[i] = i + 1; 59 59 sout | iarr[i] | ", "; … … 63 63 int ?<?( int x, int y ) { return x > y; } 64 64 qsort( iarr, size ); 65 for ( unsigned int i = 0; i < size; i += 1) {65 for ( i; 0u ~ size ) { 66 66 sout | iarr[i] | ", "; 67 67 } // for 68 68 sout | endl; 69 for ( unsigned int i = 0; i < size; i += 1) {69 for ( i; 0u ~ size ) { 70 70 int * v = bsearch( size - i, iarr, size ); 71 71 sout | size - i | ':' | *v | ", "; 72 72 } // for 73 73 sout | endl; 74 for ( unsigned int i = 0; i < size; i += 1) {74 for ( i; 0u ~ size ) { 75 75 unsigned int posn = bsearch( size - i, iarr, size ); 76 76 sout | size - i | ':' | iarr[posn] | ", "; … … 80 80 81 81 double darr[size]; 82 for ( unsigned int i = 0; i < size; i += 1) {82 for ( i; 0u ~ size ) { 83 83 darr[i] = size - i + 0.5; 84 84 sout | darr[i] | ", "; … … 86 86 sout | endl; 87 87 qsort( darr, size ); 88 for ( unsigned int i = 0; i < size; i += 1) {88 for ( i; 0u ~ size ) { 89 89 sout | darr[i] | ", "; 90 90 } // for 91 91 sout | endl; 92 for ( unsigned int i = 0; i < size; i += 1) {92 for ( i; 0u ~ size ) { 93 93 double * v = bsearch( size - i + 0.5, darr, size ); 94 94 sout | size - i + 0.5 | ':' | *v | ", "; 95 95 } // for 96 96 sout | endl; 97 for ( unsigned int i = 0; i < size; i += 1) {97 for ( i; 0u ~ size ) { 98 98 unsigned int posn = bsearch( size - i + 0.5, darr, size ); 99 99 sout | size - i + 0.5 | ':' | darr[posn] | ", "; … … 104 104 int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; } 105 105 ofstream & ?|?( ofstream & os, S v ) { return os | v.i | ' ' | v.j; } 106 for ( unsigned int i = 0; i < size; i += 1) {106 for ( i; 0u ~ size ) { 107 107 sarr[i].i = size - i; 108 108 sarr[i].j = size - i + 1; … … 111 111 sout | endl; 112 112 qsort( sarr, size ); 113 for ( unsigned int i = 0; i < size; i += 1) {113 for ( i; 0u ~ size ) { 114 114 sout | sarr[i] | ", "; 115 115 } // for 116 116 sout | endl; 117 for ( unsigned int i = 0; i < size; i += 1) {117 for ( i; 0u ~ size ) { 118 118 S temp = { size - i, size - i + 1 }; 119 119 S * v = bsearch( temp, sarr, size ); … … 121 121 } // for 122 122 sout | endl; 123 for ( unsigned int i = 0; i < size; i += 1) {123 for ( i; 0u ~ size ) { 124 124 S temp = { size - i, size - i + 1 }; 125 125 unsigned int posn = bsearch( temp, sarr, size ); … … 129 129 { 130 130 unsigned int getKey( const S & s ) { return s.j; } 131 for ( unsigned int i = 0; i < size; i += 1) {131 for ( i; 0u ~ size ) { 132 132 sout | sarr[i] | ", "; 133 133 } // for 134 134 sout | endl; 135 for ( unsigned int i = 0; i < size; i += 1) {135 for ( i; 0u ~ size ) { 136 136 S * v = bsearch( size - i + 1, sarr, size ); 137 137 sout | size - i + 1 | ':' | *v | ", "; 138 138 } // for 139 139 sout | endl; 140 for ( unsigned int i = 0; i < size; i += 1) {140 for ( i; 0u ~ size ) { 141 141 unsigned int posn = bsearch( size - i + 1, sarr, size ); 142 142 sout | size - i + 1 | ':' | sarr[posn] | ", ";
Note: See TracChangeset
for help on using the changeset viewer.