Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/examples/quickSort.cfa

    r921cd82 r3aa1d22  
    1111// Created On       : Wed Dec  6 12:15:52 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Wed Feb 12 18:24:47 2020
    14 // Update Count     : 177
     13// Last Modified On : Fri Jun 21 08:27:45 2019
     14// Update Count     : 172
    1515//
    1616
     
    2727
    2828void ?{}( 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;
    3030} // Quicksort
    3131
     
    6666                        if ( depth > 0 ) {
    6767                                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
    7271                        } else {
    7372                                sort( values, low, right, 0 );                  // sequentially sort lower half
     
    163162                processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads
    164163
    165                 int * values = alloc( size );                                   // values to be sorted, too large to put on stack
    166                 for ( counter; size ) {                                                 // generate unsorted numbers
     164                int * values = alloc( size );                           // values to be sorted, too large to put on stack
     165                for ( counter; size ) {                                         // generate unsorted numbers
    167166                        values[counter] = size - counter;                       // descending values
    168                 } // for
    169                 for ( i; 200 ) {                                                                // random shuffle a few values
    170                         swap( values[rand() % size], values[rand() % size] );
    171167                } // for
    172168                {
     
    182178} // main
    183179
    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} ; done
    185 
    186180// Local Variables: //
    187181// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.