Changeset e706bfd


Ignore:
Timestamp:
Nov 2, 2017, 3:48:22 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bbeb908
Parents:
64b272a (diff), 0dc954b (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

Files:
3 added
31 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/Makefile.am

    r64b272a re706bfd  
    9797
    9898mutex-function$(EXEEXT):
    99         @BACKEND_CC@ mutex/function.c -DBENCH_N=500000000      -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     99        @BACKEND_CC@ mutex/function.c    -DBENCH_N=500000000   -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    100100
    101101mutex-pthread_lock$(EXEEXT):
    102         @BACKEND_CC@ mutex/pthreads.c -DBENCH_N=50000000       -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     102        @BACKEND_CC@ mutex/pthreads.c    -DBENCH_N=50000000    -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    103103
    104104mutex-upp$(EXEEXT):
    105         u++          mutex/upp.cc     -DBENCH_N=50000000       -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     105        u++          mutex/upp.cc        -DBENCH_N=50000000    -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    106106
    107107mutex-cfa1$(EXEEXT):
    108         ${CC}        mutex/cfa1.c     -DBENCH_N=5000000        -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     108        ${CC}        mutex/cfa1.c        -DBENCH_N=5000000     -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    109109
    110110mutex-cfa2$(EXEEXT):
    111         ${CC}        mutex/cfa2.c     -DBENCH_N=5000000        -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     111        ${CC}        mutex/cfa2.c        -DBENCH_N=5000000     -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    112112
    113113mutex-cfa4$(EXEEXT):
    114         ${CC}        mutex/cfa4.c     -DBENCH_N=5000000        -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     114        ${CC}        mutex/cfa4.c        -DBENCH_N=5000000     -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    115115
    116116## =========================================================================================================
     
    122122
    123123signal-upp$(EXEEXT):
    124         u++          schedint/upp.cc     -DBENCH_N=50000000    -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     124        u++          schedint/upp.cc     -DBENCH_N=5000000     -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    125125
    126126signal-cfa1$(EXEEXT):
  • src/benchmark/Makefile.in

    r64b272a re706bfd  
    510510
    511511mutex-function$(EXEEXT):
    512         @BACKEND_CC@ mutex/function.c -DBENCH_N=500000000      -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     512        @BACKEND_CC@ mutex/function.c    -DBENCH_N=500000000   -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    513513
    514514mutex-pthread_lock$(EXEEXT):
    515         @BACKEND_CC@ mutex/pthreads.c -DBENCH_N=50000000       -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     515        @BACKEND_CC@ mutex/pthreads.c    -DBENCH_N=50000000    -I. -lrt -pthread                    ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    516516
    517517mutex-upp$(EXEEXT):
    518         u++          mutex/upp.cc     -DBENCH_N=50000000       -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     518        u++          mutex/upp.cc        -DBENCH_N=50000000    -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    519519
    520520mutex-cfa1$(EXEEXT):
    521         ${CC}        mutex/cfa1.c     -DBENCH_N=5000000        -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     521        ${CC}        mutex/cfa1.c        -DBENCH_N=5000000     -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    522522
    523523mutex-cfa2$(EXEEXT):
    524         ${CC}        mutex/cfa2.c     -DBENCH_N=5000000        -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     524        ${CC}        mutex/cfa2.c        -DBENCH_N=5000000     -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    525525
    526526mutex-cfa4$(EXEEXT):
    527         ${CC}        mutex/cfa4.c     -DBENCH_N=5000000        -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     527        ${CC}        mutex/cfa4.c        -DBENCH_N=5000000     -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    528528
    529529signal$(EXEEXT) :\
     
    534534
    535535signal-upp$(EXEEXT):
    536         u++          schedint/upp.cc     -DBENCH_N=50000000    -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
     536        u++          schedint/upp.cc     -DBENCH_N=5000000     -I. -nodebug -lrt -quiet             ${AM_CFLAGS} ${CFLAGS} ${ccflags}
    537537
    538538signal-cfa1$(EXEEXT):
  • src/benchmark/mutex/function.c

    r64b272a re706bfd  
    33#include "bench.h"
    44
    5 void __attribute__((noinline)) call() {}
     5void __attribute__((noinline)) do_call() {
     6        asm volatile ("");
     7}
    68
    79int main(int argc, char* argv[]) {
    810        BENCH(
    911                for (size_t i = 0; i < n; i++) {
    10                         call();
     12                        do_call();
    1113                },
    1214                result
  • src/benchmark/schedext/cfa1.c

    r64b272a re706bfd  
    4040        argc = margc;
    4141        argv = margv;
    42         processor p;
    4342        T t;
    4443        return wait(m1);
  • src/benchmark/schedext/cfa2.c

    r64b272a re706bfd  
    4040        argc = margc;
    4141        argv = margv;
    42         processor p;
    4342        T t;
    4443        return wait(m1, m2);
  • src/benchmark/schedext/cfa4.c

    r64b272a re706bfd  
    4040        argc = margc;
    4141        argv = margv;
    42         processor p;
    4342        T t;
    4443        return wait(m1, m2, m3, m4);
  • src/benchmark/schedext/upp.cc

    r64b272a re706bfd  
    3939        argc = margc;
    4040        argv = margv;
    41         uProcessor p;
    4241        T t;
    4342        return m.wait();
  • src/benchmark/schedint/cfa1.c

    r64b272a re706bfd  
    4343        argc = margc;
    4444        argv = margv;
    45         processor p;
    4645        T t;
    4746        return wait(m1);
  • src/benchmark/schedint/cfa2.c

    r64b272a re706bfd  
    4343        argc = margc;
    4444        argv = margv;
    45         processor p;
    4645        T t;
    4746        return wait(m1, m2);
  • src/benchmark/schedint/cfa4.c

    r64b272a re706bfd  
    4343        argc = margc;
    4444        argv = margv;
    45         processor p;
    4645        T t;
    4746        return wait(m1, m2, m3, m4);
  • src/benchmark/schedint/upp.cc

    r64b272a re706bfd  
    4242        argc = margc;
    4343        argv = margv;
    44         uProcessor p;
    4544        T t;
    4645        return m.wait();
  • src/driver/cfa.cc

    r64b272a re706bfd  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Sep 26 23:12:38 2017
    13 // Update Count     : 159
     12// Last Modified On : Tue Oct 31 11:40:44 2017
     13// Update Count     : 160
    1414//
    1515
     
    305305        } // if
    306306
     307        shuffle( args, sargs, nargs, 1 );                                       // make room at front of argument list
     308        nargs += 1;
    307309        if ( CFA_flag ) {
     310                args[sargs] = "-D__CFA_FLAG__=-N";
    308311                args[nargs] = "-D__CFA_PREPROCESS_";
    309312                nargs += 1;
    310         } // if
     313        } else {
     314                args[sargs] = "-D__CFA_FLAG__=-L";
     315        } // if
     316        sargs += 1;
    311317
    312318        if ( debug ) {
  • src/libcfa/concurrency/monitor.c

    r64b272a re706bfd  
    2121#include "kernel_private.h"
    2222
     23#include "bits/algorithms.h"
     24
    2325//-----------------------------------------------------------------------------
    2426// Forward declarations
     
    291293
    292294        // Sort monitors based on address -> TODO use a sort specialized for small numbers
    293         qsort(this.m, count);
     295        __libcfa_small_sort(this.m, count);
    294296
    295297        // Save previous thread context
     
    492494        set_owner( monitors, count, signallee );
    493495
     496        LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : signal_block condition %p (s: %p)\n", this, signallee );
     497
    494498        //Everything is ready to go to sleep
    495499        BlockInternal( locks, count, &signallee, 1 );
     
    498502        // WE WOKE UP
    499503
     504
     505        LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel :   signal_block returned\n" );
    500506
    501507        //We are back, restore the masks and recursions
     
    869875        short size = 0;
    870876        for( int i = 0; i < mask.size; i++ ) {
    871                 qsort( mask.clauses[i].list, mask.clauses[i].size );
     877                __libcfa_small_sort( mask.clauses[i].list, mask.clauses[i].size );
    872878                for( int j = 0; j < mask.clauses[i].size; j++) {
    873879                        insert_unique( storage, size, mask.clauses[i].list[j] );
     
    875881        }
    876882        // TODO insertion sort instead of this
    877         qsort( storage, size );
     883        __libcfa_small_sort( storage, size );
    878884        return size;
    879885}
  • src/libcfa/stdlib

    r64b272a re706bfd  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 23 20:29:47 2017
    13 // Update Count     : 224
     12// Last Modified On : Tue Oct 31 13:47:24 2017
     13// Update Count     : 245
    1414//
    1515
     
    2727// allocation, non-array types
    2828static inline forall( dtype T | sized(T) ) T * malloc( void ) {
    29         //printf( "X1\n" );
     29        // printf( "* malloc\n" );
    3030        return (T *)(void *)malloc( (size_t)sizeof(T) );        // C malloc
    3131} // malloc
     32
     33// static inline forall( dtype T | sized(T) ) T & malloc( void ) {
     34//      int & p = *(T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
     35//      printf( "& malloc %p\n", &p );
     36//      return p;
     37// //   return (T &)*(T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc
     38// } // malloc
    3239
    3340extern "C" { void * calloc( size_t dim, size_t size ); } // default C routine
     
    206213//---------------------------------------
    207214
    208 void rand48seed( long int s );
    209 char rand48( void );
    210 int rand48( void );
    211 unsigned int rand48( void );
    212 long int rand48( void );
    213 unsigned long int rand48( void );
    214 float rand48( void );
    215 double rand48( void );
    216 float _Complex rand48( void );
    217 double _Complex rand48( void );
    218 long double _Complex rand48( void );
     215void random_seed( long int s );
     216char random( void );
     217char random( char l, char u );
     218int random( void );
     219unsigned int random( void );
     220unsigned int random( unsigned int u );
     221unsigned int random( unsigned int l, unsigned int u );
     222//long int random( void );
     223unsigned long int random( void );
     224unsigned long int random( unsigned long int u );
     225unsigned long int random( unsigned long int l, unsigned long int u );
     226float random( void );
     227double random( void );
     228float _Complex random( void );
     229double _Complex random( void );
     230long double _Complex random( void );
    219231
    220232//---------------------------------------
  • src/libcfa/stdlib.c

    r64b272a re706bfd  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 23 20:30:44 2017
    13 // Update Count     : 292
     12// Last Modified On : Mon Oct 30 22:43:02 2017
     13// Update Count     : 297
    1414//
    1515
     
    275275//---------------------------------------
    276276
    277 void rand48seed( long int s ) { srand48( s ); }
    278 char rand48( void ) { return mrand48(); }
    279 int rand48( void ) { return mrand48(); }
    280 unsigned int rand48( void ) { return lrand48(); }
    281 long int rand48( void ) { return mrand48(); }
    282 unsigned long int rand48( void ) { return lrand48(); }
    283 float rand48( void ) { return (float)drand48(); }               // otherwise float uses lrand48
    284 double rand48( void ) { return drand48(); }
    285 float _Complex rand48( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
    286 double _Complex rand48( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }
    287 long double _Complex rand48( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
     277void random_seed( long int s ) { srand48( s ); }
     278char random( void ) { return mrand48(); }
     279char random( char l, char u ) { return lrand48() % (u - l) + l; }
     280int random( void ) { return mrand48(); }
     281unsigned int random( void ) { return lrand48(); }
     282unsigned int random( unsigned int u ) { return lrand48() % u; }
     283unsigned int random( unsigned int l, unsigned int u ) { return lrand48() % (u - l) + l; }
     284//long int random( void ) { return mrand48(); }
     285unsigned long int random( void ) { return lrand48(); }
     286unsigned long int random( unsigned long int u ) { return lrand48() % u; }
     287unsigned long int random( unsigned long int l, unsigned long int u ) { return lrand48() % (u - l) + l; }
     288float random( void ) { return (float)drand48(); }               // otherwise float uses lrand48
     289double random( void ) { return drand48(); }
     290float _Complex random( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
     291double _Complex random( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); }
     292long double _Complex random( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
    288293
    289294//---------------------------------------
  • src/main.cc

    r64b272a re706bfd  
    1010// Author           : Richard C. Bilson
    1111// Created On       : Fri May 15 23:12:02 2015
    12 // Last Modified By : Andrew Beach
    13 // Last Modified On : Wed Jul 26 14:38:00 2017
    14 // Update Count     : 443
     12// Last Modified By : Peter A. Buhr
     13// Last Modified On : Tue Oct 31 12:22:40 2017
     14// Update Count     : 445
    1515//
    1616
     
    8181        expraltp = false,
    8282        libcfap = false,
     83        preludep = false,
    8384        nopreludep = false,
    8485        noprotop = false,
     
    378379
    379380void parse_cmdline( int argc, char * argv[], const char *& filename ) {
    380         enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
     381        enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Preamble, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };
    381382
    382383        static struct option long_opts[] = {
     
    390391                { "grammar", no_argument, 0, Grammar },
    391392                { "libcfa", no_argument, 0, LibCFA },
     393                { "preamble", no_argument, 0, Preamble },
    392394                { "no-preamble", no_argument, 0, Nopreamble },
    393395                { "parse", no_argument, 0, Parse },
     
    405407
    406408        int c;
    407         while ( (c = getopt_long( argc, argv, "abBcCdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
     409        while ( (c = getopt_long( argc, argv, "abBcCdefglLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {
    408410                switch ( c ) {
    409411                  case Ast:
     
    451453                  case 'n':                                                                             // do not read preamble
    452454                        nopreludep = true;
     455                        break;
     456                  case Preamble:
     457                  case 'N':                                                                             // read preamble
     458                        preludep = true;
    453459                        break;
    454460                  case Prototypes:
  • src/tests/boundedBuffer.c

    r64b272a re706bfd  
     1//
     2// The contents of this file are covered under the licence agreement in the
     3// file "LICENCE" distributed with Cforall.
     4//
     5// boundedBuffer.c --
     6//
     7// Author           : Peter A. Buhr
     8// Created On       : Mon Oct 30 12:45:13 2017
     9// Last Modified By : Peter A. Buhr
     10// Last Modified On : Mon Oct 30 23:02:46 2017
     11// Update Count     : 9
     12//
     13
    114#include <stdlib>
    2 #include <fstream>
     15#include <fstream>                                                                              // random
    316#include <kernel>
    417#include <thread>
    5 #include <unistd.h>                                     // getpid
     18#include <unistd.h>                                                                             // getpid
    619
    720monitor Buffer {
    8     condition full, empty;
    9     int front, back, count;
    10     int elements[20];
     21        condition full, empty;
     22        int front, back, count;
     23        int elements[20];
    1124};
    1225
    1326void ?{}( Buffer & buffer ) {
    14     buffer.front = buffer.back = buffer.count = 0;
     27        buffer.front = buffer.back = buffer.count = 0;
    1528}
    1629
     
    1831
    1932void insert( Buffer & mutex buffer, int elem ) {
    20     if ( buffer.count == 20 ) wait( &buffer.empty );
    21     buffer.elements[buffer.back] = elem;
    22     buffer.back = ( buffer.back + 1 ) % 20;
    23     buffer.count += 1;
    24     signal( &buffer.full );
     33        if ( buffer.count == 20 ) wait( &buffer.empty );
     34        buffer.elements[buffer.back] = elem;
     35        buffer.back = ( buffer.back + 1 ) % 20;
     36        buffer.count += 1;
     37        signal( &buffer.full );
    2538}
    2639int remove( Buffer & mutex buffer ) {
    27     if ( buffer.count == 0 ) wait( &buffer.full );
    28     int elem = buffer.elements[buffer.front];
    29     buffer.front = ( buffer.front + 1 ) % 20;
    30     buffer.count -= 1;
    31     signal( &buffer.empty );
    32     return elem;
     40        if ( buffer.count == 0 ) wait( &buffer.full );
     41        int elem = buffer.elements[buffer.front];
     42        buffer.front = ( buffer.front + 1 ) % 20;
     43        buffer.count -= 1;
     44        signal( &buffer.empty );
     45        return elem;
    3346}
    3447
    3548thread Producer {
    36     Buffer * buffer;
    37     unsigned int N;
     49        Buffer & buffer;
     50        unsigned int N;
    3851};
    3952void main( Producer & prod ) {
    40     for ( int i = 1; i <= prod.N; i += 1 ) {
    41         yield( (unsigned int)rand48() % 5 );
    42         insert( *prod.buffer, 1 );
    43     } // for
    44     insert( *prod.buffer, -1 );
     53        for ( int i = 1; i <= prod.N; i += 1 ) {
     54                yield( random( 5 ) );
     55                insert( prod.buffer, 1 );
     56        } // for
     57        insert( prod.buffer, -1 );
    4558}
    4659void ?{}( Producer & prod, Buffer * buffer, unsigned int N ) {
    47     prod.buffer = buffer;
    48     prod.N = N;
    49 }
     60        &prod.buffer = buffer;
     61        prod.N = N;
     62                }
    5063
    5164thread Consumer {
    52     Buffer * buffer;
    53     int * sum;                                          // summation of producer values
     65        Buffer & buffer;
     66        int & sum;                                              // summation of producer values
    5467};
    5568void main( Consumer & cons ) {
    56     *cons.sum = 0;
    57     for ( ;; ) {
    58         yield( (unsigned int)rand48() % 5 );
    59         int item = remove( *cons.buffer );
    60       if ( item == -1 ) break;                          // sentinel ?
    61         *cons.sum += item;
    62     } // for
     69        cons.sum = 0;
     70        for ( ;; ) {
     71                yield( random( 5 ) );
     72                int item = remove( cons.buffer );
     73                if ( item == -1 ) break;                                // sentinel ?
     74                cons.sum += item;
     75        } // for
    6376}
    6477void ?{}( Consumer & cons, Buffer * buffer, int * sum ) {
    65     cons.buffer = buffer;
    66     cons.sum = sum;
     78        &cons.buffer = buffer;
     79        &cons.sum = sum;
    6780}
    6881
    6982int main() {
    70     Buffer buffer;
    71     enum { Prods = 5, Cons = 5 };
    72     Producer * prods[Prods];
    73     Consumer * cons[Cons];
    74     const int Sentinel = -1;
    75     int sums[Cons];
    76     int i;
    77     processor p;
     83        Buffer buffer;
     84        enum { Prods = 5, Cons = 5 };
     85        Producer * prods[Prods];
     86        Consumer * cons[Cons];
     87        const int Sentinel = -1;
     88        int sums[Cons];
     89        int i;
     90        processor p;
    7891
    79     //rand48seed( getpid() );
    80     rand48seed( 1003 );
     92        //random_seed( getpid() );
     93        random_seed( 1003 );
    8194
    82     for ( i = 0; i < Cons; i += 1 ) {                   // create consumers
    83         cons[i] = new( &buffer, &sums[i] );
    84     } // for
    85     for ( i = 0; i < Prods; i += 1 ) {                  // create producers
    86         prods[i] = new( &buffer, 100000u );
    87     } // for
     95        for ( i = 0; i < Cons; i += 1 ) {                       // create consumers
     96                cons[i] = new( &buffer, &sums[i] );
     97        } // for
     98        for ( i = 0; i < Prods; i += 1 ) {                      // create producers
     99                prods[i] = new( &buffer, 100000u );
     100        } // for
    88101
    89     for ( i = 0; i < Prods; i += 1 ) {                  // wait for producers to finish
    90         delete( prods[i] );
    91     } // for
    92     for ( i = 0; i < Cons; i += 1 ) {                   // generate sentinal values to stop consumers
    93         insert( buffer, Sentinel );
    94     } // for
    95     int sum = 0;
    96     for ( i = 0; i < Cons; i += 1 ) {                   // wait for consumers to finish
    97         delete( cons[i] );
    98         sum += sums[i];
    99     } // for
    100     sout | "total:" | sum | endl;
     102        for ( i = 0; i < Prods; i += 1 ) {                      // wait for producers to finish
     103                delete( prods[i] );
     104        } // for
     105        for ( i = 0; i < Cons; i += 1 ) {                       // generate sentinal values to stop consumers
     106                insert( buffer, Sentinel );
     107        } // for
     108        int sum = 0;
     109        for ( i = 0; i < Cons; i += 1 ) {                       // wait for consumers to finish
     110                delete( cons[i] );
     111                sum += sums[i];
     112        } // for
     113        sout | "total:" | sum | endl;
    101114}
     115
     116// Local Variables: //
     117// tab-width: 4 //
     118// compile-command: "cfa boundedBuffer.c" //
     119// End: //
  • src/tests/matrixSum.c

    r64b272a re706bfd  
    1111// Created On       : Mon Oct  9 08:29:28 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Mon Oct  9 08:30:08 2017
    14 // Update Count     : 1
     13// Last Modified On : Sun Oct 29 21:08:48 2017
     14// Update Count     : 2
    1515//
    1616
     
    2020
    2121thread Adder {
    22     int * row, cols, * subtotal;                        // communication
     22    int * row, cols, * subtotal;                                                // communication
    2323};
    2424
     
    3232    *adder.subtotal = 0;
    3333    for ( int c = 0; c < adder.cols; c += 1 ) {
    34         *adder.subtotal += adder.row[c];
     34                *adder.subtotal += adder.row[c];
    3535    } // for
    3636}
     
    3939    const int rows = 10, cols = 1000;
    4040    int matrix[rows][cols], subtotals[rows], total = 0;
    41     processor p;                                        // extra kernel thread
     41    processor p;                                                                                // extra kernel thread
    4242
    4343    for ( int r = 0; r < rows; r += 1 ) {
    44         for ( int c = 0; c < cols; c += 1 ) {
    45             matrix[r][c] = 1;
    46         } // for
     44                for ( int c = 0; c < cols; c += 1 ) {
     45                        matrix[r][c] = 1;
     46                } // for
    4747    } // for
    4848    Adder * adders[rows];
    49     for ( int r = 0; r < rows; r += 1 ) {               // start threads to sum rows
    50         adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] };
    51 //      adders[r] = new( matrix[r], cols, &subtotals[r] );
     49    for ( int r = 0; r < rows; r += 1 ) {                               // start threads to sum rows
     50                adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] };
     51//              adders[r] = new( matrix[r], cols, &subtotals[r] );
    5252    } // for
    53     for ( int r = 0; r < rows; r += 1 ) {               // wait for threads to finish
    54         delete( adders[r] );
    55         total += subtotals[r];                          // total subtotals
     53    for ( int r = 0; r < rows; r += 1 ) {                               // wait for threads to finish
     54                delete( adders[r] );
     55                total += subtotals[r];                                                  // total subtotals
    5656    } // for
    5757    sout | total | endl;
  • src/tests/prodcons.c

    r64b272a re706bfd  
    1010// Created On       : Mon Sep 18 12:23:39 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Sep 20 17:03:28 2017
    13 // Update Count     : 40
     12// Last Modified On : Mon Oct 30 23:06:05 2017
     13// Update Count     : 42
    1414//
    1515
    1616#include <fstream>
    1717#include <coroutine>
    18 #include <stdlib>                                                                               // rand48
     18#include <stdlib>                                                                               // random
    1919#include <unistd.h>                                                                             // getpid
    2020
     
    3030        // 1st resume starts here
    3131        for ( int i = 0; i < prod.N; i += 1 ) {
    32                 int p1 = (unsigned int)rand48() % 100;                  // non-negative
    33                 int p2 = (unsigned int)rand48() % 100;
     32                int p1 = random( 100 );
     33                int p2 = random( 100 );
    3434                sout | p1 | " " | p2 | endl;
    3535                int status = delivery( *prod.c, p1, p2 );
     
    9090        Prod prod;
    9191        Cons cons = { prod };
    92         rand48seed( /* getpid() */ 103 );                                       // fixed seed for testing
     92        random_seed( /* getpid() */ 103 );                                      // fixed seed for testing
    9393        start( prod, 5, cons );
    9494        sout | "main stops" | endl;
  • src/tests/random.c

    r64b272a re706bfd  
    1010// Created On       : Tue Jul  5 21:29:30 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul  6 18:00:29 2016
    13 // Update Count     : 3
     12// Last Modified On : Mon Oct 30 23:06:49 2017
     13// Update Count     : 6
    1414//
    1515
     
    1919
    2020int main() {
    21         //rand48seed( getpid() );                                                               // set random seed
    22         rand48seed( 1003 );                                                                     // fixed seed for repeatable tests
     21        //srandom( getpid() );                                                          // set random seed
     22        random_seed( 1003 );                                                            // fixed seed for repeatable tests
    2323
    2424        // test polymorphic calls to random and stream
    25         char c = rand48();
     25        char c = random();
    2626        sout | c | endl;
    27         int i = rand48();
     27        int i = random();
    2828    sout | i | endl;
    29         unsigned int ui = rand48();
     29        unsigned int ui = random();
    3030    sout | ui | endl;
    31         long int li = rand48();
     31        long int li = random();
    3232    sout | li | endl;
    33         unsigned long int uli = rand48();
     33        unsigned long int uli = random();
    3434    sout | uli | endl;
    35     float f = rand48();
     35    float f = random();
    3636    sout | f | endl;
    37     double d = rand48();
     37    double d = random();
    3838    sout | d | endl;
    39     float _Complex fc = rand48();
     39    float _Complex fc = random();
    4040    sout | fc | endl;
    41     double _Complex dc = rand48();
     41    double _Complex dc = random();
    4242    sout | dc | endl;
    43     long double _Complex ldc = rand48();
     43    long double _Complex ldc = random();
    4444    sout | ldc | endl;
    4545} // main
  • src/tests/rational.c

    r64b272a re706bfd  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 23 21:40:11 2017
    13 // Update Count     : 66
     12// Last Modified On : Tue Oct 10 23:25:04 2017
     13// Update Count     : 67
    1414//
    1515
  • src/tests/sched-ext-barge.c

    r64b272a re706bfd  
    4242void main( barger_t & this ) {
    4343        yield();
    44         while( barge( global ) ) { yield(((unsigned)rand48()) % 10); }
     44        while( barge( global ) ) { yield(random( 10 )); }
    4545}
    4646
    4747bool do_call( global_t & mutex this ) {
    48         yield(((unsigned)rand48()) % 10);
     48        yield(random( 10 ));
    4949        if( this.state != WAITFOR && !this.done && this.started ) {
    5050                serr | "Barging before caller detected" | endl;
     
    5757thread caller_t {};
    5858void main( caller_t & this ) {
    59         while( do_call(global) ) { yield(((unsigned)rand48()) % 10); }
     59        while( do_call(global) ) { yield(random( 10 )); }
    6060}
    6161
     
    6363        this.started = true;
    6464        for( int i = 0; i < N; i++) {
    65                 yield(((unsigned)rand48()) % 10);
     65                yield(random( 10 ));
    6666                this.state = WAITFOR;
    6767                waitfor(do_call, this) {
  • src/tests/sched-ext-dtor.c

    r64b272a re706bfd  
    4545
    4646void main( dummy_t & this ) {
    47         yield(((unsigned)rand48()) % 10);
     47        yield(random( 10 ));
    4848        set_state( this, MAIN );
    4949        waitfor( ^?{}, this ) {
     
    5858        for( int i = 0; i < N; i++ ){
    5959                dummy_t dummy[4];
    60                 yield( ((unsigned)rand48()) % 100 );
     60                yield( random( 100 ) );
    6161        }
    6262        sout | "Stopping" | endl;
  • src/tests/sched-ext-recurse.c

    r64b272a re706bfd  
    1515static const unsigned long N = 5_000ul;
    1616
    17 static inline void rand_yield() { yield(((unsigned)rand48()) % 10); }
     17static inline void rand_yield() { yield(random( 10 )); }
    1818
    1919enum state_t { FIRST, SECOND, THIRD, LAST, STOP };
     
    2323        for (i = 0; i < 4; i++)
    2424        {
    25                 int j = ((unsigned)rand48()) % 4;
     25                int j = random( 4 );
    2626                enum state_t t = array[j];
    2727                array[j] = array[i];
     
    131131
    132132int main() {
    133         rand48seed( time(NULL) );
     133        random_seed( time(NULL) );
    134134        sout | "Starting" | endl;
    135135        {
  • src/tests/sched-ext-when.c

    r64b272a re706bfd  
    1515static const unsigned long N = 4_998ul;
    1616
    17 static inline void rand_yield() { yield(((unsigned)rand48()) % 10); }
     17static inline void rand_yield() { yield(random( 10 )); }
    1818
    1919monitor global_t {
     
    7777
    7878int main() {
    79         rand48seed( time(NULL) );
     79        random_seed( time(NULL) );
    8080        sout | "Starting" | endl;
    8181        {
  • src/tests/sched-ext.c

    r64b272a re706bfd  
    2626volatile bool done;
    2727
    28 unsigned rand10() {
    29         return (unsigned)rand48() % 10;
    30 }
    31 
    3228//----------------------------------------------------------------------------------------------------
    3329// Acceptor
     
    3632void do_wait( global_t * mutex a ) {
    3733        sout | "Waiting to accept" | endl;
    38         yield( rand10() );
     34        yield( random( 10 ) );
    3935
    4036        sout | "Accepting" | endl;
     
    4844
    4945        sout | "Accepted" | endl;
    50         yield( rand10() );
     46        yield( random( 10 ) );
    5147}
    5248
     
    6864void main( Acceptee* this ) {
    6965        while( !done ) {
    70                 yield( rand10() );
     66                yield( random( 10 ) );
    7167                do_notify( &globalA );
    72                 yield( rand10() );
     68                yield( random( 10 ) );
    7369        }
    7470}
     
    7874int main(int argc, char* argv[]) {
    7975        done = false;
    80         rand48seed( time( NULL ) );
     76        random_seed( time( NULL ) );
    8177        printf("%p\n", &globalA);
    8278        sout | "Starting" | endl;
  • src/tests/sched-int-barge.c

    r64b272a re706bfd  
    6464
    6565        if( action == 0 ) {
    66                 c.do_signal = max( ((unsigned)rand48()) % 10, 1);
    67                 c.do_wait1 = ((unsigned)rand48()) % (c.do_signal);
    68                 c.do_wait2 = ((unsigned)rand48()) % (c.do_signal);
     66                c.do_signal = max( random( 10 ), 1);
     67                c.do_wait1 = random( c.do_signal );
     68                c.do_wait2 = random( c.do_signal );
    6969
    7070                if(c.do_wait1 == c.do_wait2) sout | "Same" | endl;
     
    109109
    110110int main(int argc, char* argv[]) {
    111         rand48seed(0);
     111        random_seed(0);
    112112        processor p;
    113113        {
  • src/tests/sched-int-block.c

    r64b272a re706bfd  
    4949        wait( &cond, (uintptr_t)this_thread );
    5050
    51         yield( ((unsigned)rand48()) % 10 );
     51        yield( random( 10 ) );
    5252
    5353        if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) {
     
    5858        a.last_thread = b.last_thread = this_thread;
    5959
    60         yield( ((unsigned)rand48()) % 10 );
     60        yield( random( 10 ) );
    6161}
    6262
     
    7070//------------------------------------------------------------------------------
    7171void signal_op( global_data_t & mutex a, global_data_t & mutex b ) {
    72         yield( ((unsigned)rand48()) % 10 );
     72        yield( random( 10 ) );
    7373
    7474        [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread;
     
    8383                }
    8484
    85                 yield( ((unsigned)rand48()) % 10 );
     85                yield( random( 10 ) );
    8686
    8787                if(a.last_thread != next || b.last_thread != next) {
     
    118118
    119119int main(int argc, char* argv[]) {
    120         rand48seed( time( NULL ) );
     120        random_seed( time( NULL ) );
    121121        done = false;
    122122        processor p;
  • src/tests/sched-int-disjoint.c

    r64b272a re706bfd  
    8888        signal( &cond, a, data );
    8989
    90         yield( (unsigned)rand48() % 10 );
     90        yield( random( 10 ) );
    9191
    9292        //This is technically a mutual exclusion violation but the mutex monitor protects us
     
    109109// Main loop
    110110int main(int argc, char* argv[]) {
    111         rand48seed( time( NULL ) );
     111        random_seed( time( NULL ) );
    112112        all_done = false;
    113113        processor p;
  • src/tests/sched-int-wait.c

    r64b272a re706bfd  
    6262
    6363        while( waiter_left != 0 ) {
    64                 unsigned action = (unsigned)rand48() % 4;
     64                unsigned action = random( 4 );
    6565                switch( action ) {
    6666                        case 0:
     
    127127// Main
    128128int main(int argc, char* argv[]) {
    129         rand48seed( time( NULL ) );
     129        random_seed( time( NULL ) );
    130130        waiter_left = 4;
    131131        processor p[2];
  • tools/stat.py

    r64b272a re706bfd  
    1414                content.remove(max(content))
    1515                content.remove(min(content))
    16                 print "median {0} avg {1} stddev {2}".format( numpy.median(content), numpy.mean(content), numpy.std(content) )
     16                med = numpy.around( numpy.median(content), decimals=1)
     17                avg = numpy.around( numpy.mean  (content), decimals=2)
     18                std = numpy.around( numpy.std   (content), decimals=2)
     19                print "median {0} avg {1} stddev {2}".format( med, avg, std )
    1720
    1821
Note: See TracChangeset for help on using the changeset viewer.