Changeset fe4840a for src/tests/concurrent
- Timestamp:
- Dec 14, 2017, 9:36:19 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:
- 06088f9a
- Parents:
- 1edf37f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/concurrent/examples/quickSort.c
r1edf37f rfe4840a 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.