Ignore:
Timestamp:
Dec 14, 2017, 9:36:19 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
06088f9a
Parents:
1edf37f
Message:

fix bugs in quickSort, still not working because thunk problem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/concurrent/examples/quickSort.c

    r1edf37f rfe4840a  
    99// Created On       : Wed Dec  6 12:15:52 2017
    1010// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Wed Dec 13 18:20:18 2017
    12 // Update Count     : 138
     11// Last Modified On : Thu Dec 14 11:20:40 2017
     12// Update Count     : 142
    1313//
    1414
     
    1919#include <string.h>                                                                             // strcmp
    2020
    21 forall( otype T | { T ?<?( T, T ); } )
     21forall( otype T | { int ?<?( T, T ); } )
    2222thread Quicksort {
    2323        T * values;                                                                                     // communication variables
     
    2525};
    2626
    27 forall( otype T | { T ?<?( T, T ); } )
     27forall( otype T | { int ?<?( T, T ); } )
    2828void ?{}( Quicksort(T) & qs, T values[], int size, int depth ) {
    2929        qs.values = values;  qs.low = 0;  qs.high = size;  qs.depth = depth;
    3030} // Quicksort
    3131
    32 forall( otype T | { T ?<?( T, T ); } )
     32forall( otype T | { int ?<?( T, T ); } )
    3333void main( Quicksort(T) & qs ) {
    3434        // nested routines: information hiding
     
    140140                        unsortedfile | size;                                            // read number of elements in the list
    141141                  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 );
    143145                        for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers
    144146                                unsortedfile | values[counter];
     
    165167                processor processors[ (1 << depth) - 1 ] __attribute__(( unused )); // create 2^depth-1 kernel threads
    166168
    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
    168171                for ( int counter = 0; counter < size; counter += 1 ) { // generate unsorted numbers
    169172                        values[counter] = size - counter;                       // descending values
Note: See TracChangeset for help on using the changeset viewer.