- File:
-
- 1 edited
-
tests/concurrent/examples/quickSort.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/quickSort.cfa
r921cd82 r3aa1d22 11 11 // Created On : Wed Dec 6 12:15:52 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Feb 12 18:24:47 202014 // Update Count : 17 713 // Last Modified On : Fri Jun 21 08:27:45 2019 14 // Update Count : 172 15 15 // 16 16 … … 27 27 28 28 void ?{}( Quicksort & qs, int values[], int size, int depth ) { 29 qs. [values, low, high, depth] = [values, 0, size, depth];29 qs.values = values; qs.low = 0; qs.high = size; qs.depth = depth; 30 30 } // Quicksort 31 31 … … 66 66 if ( depth > 0 ) { 67 67 depth -= 1; 68 Quicksort lqs = { values, low, right, depth }; // concurrently sort lower half 69 Quicksort rqs = { values, left, high, depth }; // concurrently sort upper half 70 // Quicksort lqs = { values, low, right, depth }; // concurrently sort lower half 71 // sort( values, left, high, depth ); // concurrently sort upper half 68 Quicksort rqs = { values, low, right, depth }; // concurrently sort upper half 69 //Quicksort lqs( values, left, high, depth ); // concurrently sort lower half 70 sort( values, left, high, depth ); // concurrently sort lower half 72 71 } else { 73 72 sort( values, low, right, 0 ); // sequentially sort lower half … … 163 162 processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads 164 163 165 int * values = alloc( size ); // values to be sorted, too large to put on stack166 for ( counter; size ) { // generate unsorted numbers164 int * values = alloc( size ); // values to be sorted, too large to put on stack 165 for ( counter; size ) { // generate unsorted numbers 167 166 values[counter] = size - counter; // descending values 168 } // for169 for ( i; 200 ) { // random shuffle a few values170 swap( values[rand() % size], values[rand() % size] );171 167 } // for 172 168 { … … 182 178 } // main 183 179 184 // for depth in 0 1 2 3 4 5 ; do echo "sort 500000000 values with ${depth} depth" ; time -f "%Uu %Ss %E %Mkb" a.out -t 500000000 ${depth} ; done185 186 180 // Local Variables: // 187 181 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.