Changeset cd3aee2 for src/tests/concurrent/examples/quickSort.c
- Timestamp:
- Dec 19, 2017, 1:24:02 PM (7 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 3eb4541
- Parents:
- f739788 (diff), 06088f9a (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/concurrent/examples/quickSort.c
rf739788 rcd3aee2 9 9 // Created On : Wed Dec 6 12:15:52 2017 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : Wed Dec 13 18:20:18201712 // Update Count : 1 3811 // Last Modified On : Thu Dec 14 11:20:40 2017 12 // Update Count : 142 13 13 // 14 14 … … 19 19 #include <string.h> // strcmp 20 20 21 forall( otype T | { T?<?( T, T ); } )21 forall( otype T | { int ?<?( T, T ); } ) 22 22 thread Quicksort { 23 23 T * values; // communication variables … … 25 25 }; 26 26 27 forall( otype T | { T?<?( T, T ); } )27 forall( otype T | { int ?<?( T, T ); } ) 28 28 void ?{}( Quicksort(T) & qs, T values[], int size, int depth ) { 29 29 qs.values = values; qs.low = 0; qs.high = size; qs.depth = depth; 30 30 } // Quicksort 31 31 32 forall( otype T | { T?<?( T, T ); } )32 forall( otype T | { int ?<?( T, T ); } ) 33 33 void main( Quicksort(T) & qs ) { 34 34 // nested routines: information hiding … … 140 140 unsortedfile | size; // read number of elements in the list 141 141 if ( eof( unsortedfile ) ) break; 142 ELEMTYPE * values = anew( size ); // values to be sorted, too large to put on stack 142 // ELEMTYPE * values = anew( size ); // values to be sorted, too large to put on stack 143 ELEMTYPE * values = alloc( size ); // values to be sorted, too large to put on stack 144 // ELEMTYPE * values = (ELEMTYPE *)malloc( sizeof(ELEMTYPE) * size ); 143 145 for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers 144 146 unsortedfile | values[counter]; … … 165 167 processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads 166 168 167 ELEMTYPE * values = anew( size ); // values to be sorted, too large to put on stack 169 // ELEMTYPE * values = anew( size ); // values to be sorted, too large to put on stack 170 ELEMTYPE * values = alloc( size ); // values to be sorted, too large to put on stack 168 171 for ( int counter = 0; counter < size; counter += 1 ) { // generate unsorted numbers 169 172 values[counter] = size - counter; // descending values
Note: See TracChangeset
for help on using the changeset viewer.