Changeset cd3aee2


Ignore:
Timestamp:
Dec 19, 2017, 1:24:02 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
3eb4541
Parents:
f739788 (diff), 06088f9a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/tests/concurrent/examples
Files:
2 edited

Legend:

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

    rf739788 rcd3aee2  
    88// Created On       : Mon Oct 30 12:45:13 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Wed Dec 13 21:01:49 2017
    11 // Update Count     : 27
     10// Last Modified On : Thu Dec 14 21:28:52 2017
     11// Update Count     : 32
    1212//
    1313
     
    1818#include <unistd.h>                                                                             // getpid
    1919
    20 forall( otype T )
    2120monitor Buffer {
    2221        condition full, empty;
    2322        int front, back, count;
    24         T elements[20];
     23        int elements[20];
    2524};
    2625
    27 forall( otype T )
    28 void ?{}( Buffer(T) & buffer ) {
     26void ?{}( Buffer & buffer ) {
    2927        buffer.front = buffer.back = buffer.count = 0;
    3028}
    3129
    32 forall( otype T )
    33 int query( Buffer(T) & buffer ) { return buffer.count; }
     30int query( Buffer & buffer ) { return buffer.count; }
    3431
    35 forall( otype T )
    36 void insert( Buffer(T) & mutex buffer, T elem ) with( buffer ) {
     32void insert( Buffer & mutex buffer, int elem ) with( buffer ) {
    3733        if ( count == 20 ) wait( empty );
    3834        elements[back] = elem;
     
    4238}
    4339
    44 forall( otype T )
    45 T remove( Buffer(T) & mutex buffer ) with( buffer ) {
     40int remove( Buffer & mutex buffer ) with( buffer ) {
    4641        if ( count == 0 ) wait( full );
    47         T elem = elements[front];
     42        int elem = elements[front];
    4843        front = ( front + 1 ) % 20;
    4944        count -= 1;
     
    5348
    5449thread Producer {
    55         Buffer(int) & buffer;
     50        Buffer & buffer;
    5651        unsigned int N;
    5752};
     
    6358        insert( prod.buffer, -1 );
    6459}
    65 void ?{}( Producer & prod, Buffer(int) * buffer, unsigned int N ) {
     60void ?{}( Producer & prod, Buffer * buffer, unsigned int N ) {
    6661        &prod.buffer = buffer;
    6762        prod.N = N;
     
    6964
    7065thread Consumer {
    71         Buffer(int) & buffer;
     66        Buffer & buffer;
    7267        int & sum;                                              // summation of producer values
    7368};
     
    8176        } // for
    8277}
    83 void ?{}( Consumer & cons, Buffer(int) * buffer, int * sum ) {
     78void ?{}( Consumer & cons, Buffer * buffer, int * sum ) {
    8479        &cons.buffer = buffer;
    8580        &cons.sum = sum;
     
    8782
    8883int main() {
    89         Buffer(int) buffer;
     84        Buffer buffer;
    9085        enum { Prods = 5, Cons = 5 };
    9186        Producer * prods[Prods];
  • src/tests/concurrent/examples/quickSort.c

    rf739788 rcd3aee2  
    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.