Changeset fdf4efb for tests/concurrent


Ignore:
Timestamp:
Oct 20, 2019, 11:10:55 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
1aa6ecb
Parents:
1f7324f
Message:

balance quicksort subdivisions across leaf tasks, and randomize 200 values in sort vector

File:
1 edited

Legend:

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

    r1f7324f rfdf4efb  
    1111// Created On       : Wed Dec  6 12:15:52 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Jun 21 08:27:45 2019
    14 // Update Count     : 172
     13// Last Modified On : Thu Oct 10 13:58:18 2019
     14// Update Count     : 176
    1515//
    1616
     
    6666                        if ( depth > 0 ) {
    6767                                depth -= 1;
    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
     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
    7172                        } else {
    7273                                sort( values, low, right, 0 );                  // sequentially sort lower half
     
    162163                processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads
    163164
    164                 int * values = alloc( size );                           // values to be sorted, too large to put on stack
    165                 for ( counter; size ) {                                         // generate unsorted numbers
     165                int * values = alloc( size );                                   // values to be sorted, too large to put on stack
     166                for ( counter; size ) {                                                 // generate unsorted numbers
    166167                        values[counter] = size - counter;                       // descending values
     168                } // for
     169                for ( int i = 0; i < 200; i +=1 ) {                             // random shuffle a few values
     170                        swap( values[rand() % size], values[rand() % size] );
    167171                } // for
    168172                {
     
    178182} // main
    179183
     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
    180186// Local Variables: //
    181187// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.