Changes in / [64b272a:e706bfd]
- Files:
-
- 3 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
src/benchmark/Makefile.am
r64b272a re706bfd 97 97 98 98 mutex-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} 100 100 101 101 mutex-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} 103 103 104 104 mutex-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} 106 106 107 107 mutex-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} 109 109 110 110 mutex-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} 112 112 113 113 mutex-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} 115 115 116 116 ## ========================================================================================================= … … 122 122 123 123 signal-upp$(EXEEXT): 124 u++ schedint/upp.cc -DBENCH_N=5000000 0-I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags}124 u++ schedint/upp.cc -DBENCH_N=5000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 125 125 126 126 signal-cfa1$(EXEEXT): -
src/benchmark/Makefile.in
r64b272a re706bfd 510 510 511 511 mutex-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} 513 513 514 514 mutex-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} 516 516 517 517 mutex-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} 519 519 520 520 mutex-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} 522 522 523 523 mutex-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} 525 525 526 526 mutex-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} 528 528 529 529 signal$(EXEEXT) :\ … … 534 534 535 535 signal-upp$(EXEEXT): 536 u++ schedint/upp.cc -DBENCH_N=5000000 0-I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags}536 u++ schedint/upp.cc -DBENCH_N=5000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 537 537 538 538 signal-cfa1$(EXEEXT): -
src/benchmark/mutex/function.c
r64b272a re706bfd 3 3 #include "bench.h" 4 4 5 void __attribute__((noinline)) call() {} 5 void __attribute__((noinline)) do_call() { 6 asm volatile (""); 7 } 6 8 7 9 int main(int argc, char* argv[]) { 8 10 BENCH( 9 11 for (size_t i = 0; i < n; i++) { 10 call();12 do_call(); 11 13 }, 12 14 result -
src/benchmark/schedext/cfa1.c
r64b272a re706bfd 40 40 argc = margc; 41 41 argv = margv; 42 processor p;43 42 T t; 44 43 return wait(m1); -
src/benchmark/schedext/cfa2.c
r64b272a re706bfd 40 40 argc = margc; 41 41 argv = margv; 42 processor p;43 42 T t; 44 43 return wait(m1, m2); -
src/benchmark/schedext/cfa4.c
r64b272a re706bfd 40 40 argc = margc; 41 41 argv = margv; 42 processor p;43 42 T t; 44 43 return wait(m1, m2, m3, m4); -
src/benchmark/schedext/upp.cc
r64b272a re706bfd 39 39 argc = margc; 40 40 argv = margv; 41 uProcessor p;42 41 T t; 43 42 return m.wait(); -
src/benchmark/schedint/cfa1.c
r64b272a re706bfd 43 43 argc = margc; 44 44 argv = margv; 45 processor p;46 45 T t; 47 46 return wait(m1); -
src/benchmark/schedint/cfa2.c
r64b272a re706bfd 43 43 argc = margc; 44 44 argv = margv; 45 processor p;46 45 T t; 47 46 return wait(m1, m2); -
src/benchmark/schedint/cfa4.c
r64b272a re706bfd 43 43 argc = margc; 44 44 argv = margv; 45 processor p;46 45 T t; 47 46 return wait(m1, m2, m3, m4); -
src/benchmark/schedint/upp.cc
r64b272a re706bfd 42 42 argc = margc; 43 43 argv = margv; 44 uProcessor p;45 44 T t; 46 45 return m.wait(); -
src/driver/cfa.cc
r64b272a re706bfd 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Sep 26 23:12:38201713 // Update Count : 1 5912 // Last Modified On : Tue Oct 31 11:40:44 2017 13 // Update Count : 160 14 14 // 15 15 … … 305 305 } // if 306 306 307 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list 308 nargs += 1; 307 309 if ( CFA_flag ) { 310 args[sargs] = "-D__CFA_FLAG__=-N"; 308 311 args[nargs] = "-D__CFA_PREPROCESS_"; 309 312 nargs += 1; 310 } // if 313 } else { 314 args[sargs] = "-D__CFA_FLAG__=-L"; 315 } // if 316 sargs += 1; 311 317 312 318 if ( debug ) { -
src/libcfa/concurrency/monitor.c
r64b272a re706bfd 21 21 #include "kernel_private.h" 22 22 23 #include "bits/algorithms.h" 24 23 25 //----------------------------------------------------------------------------- 24 26 // Forward declarations … … 291 293 292 294 // 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); 294 296 295 297 // Save previous thread context … … 492 494 set_owner( monitors, count, signallee ); 493 495 496 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : signal_block condition %p (s: %p)\n", this, signallee ); 497 494 498 //Everything is ready to go to sleep 495 499 BlockInternal( locks, count, &signallee, 1 ); … … 498 502 // WE WOKE UP 499 503 504 505 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : signal_block returned\n" ); 500 506 501 507 //We are back, restore the masks and recursions … … 869 875 short size = 0; 870 876 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 ); 872 878 for( int j = 0; j < mask.clauses[i].size; j++) { 873 879 insert_unique( storage, size, mask.clauses[i].list[j] ); … … 875 881 } 876 882 // TODO insertion sort instead of this 877 qsort( storage, size );883 __libcfa_small_sort( storage, size ); 878 884 return size; 879 885 } -
src/libcfa/stdlib
r64b272a re706bfd 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 20:29:47201713 // Update Count : 2 2412 // Last Modified On : Tue Oct 31 13:47:24 2017 13 // Update Count : 245 14 14 // 15 15 … … 27 27 // allocation, non-array types 28 28 static inline forall( dtype T | sized(T) ) T * malloc( void ) { 29 // printf( "X1\n" );29 // printf( "* malloc\n" ); 30 30 return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc 31 31 } // 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 32 39 33 40 extern "C" { void * calloc( size_t dim, size_t size ); } // default C routine … … 206 213 //--------------------------------------- 207 214 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 ); 215 void random_seed( long int s ); 216 char random( void ); 217 char random( char l, char u ); 218 int random( void ); 219 unsigned int random( void ); 220 unsigned int random( unsigned int u ); 221 unsigned int random( unsigned int l, unsigned int u ); 222 //long int random( void ); 223 unsigned long int random( void ); 224 unsigned long int random( unsigned long int u ); 225 unsigned long int random( unsigned long int l, unsigned long int u ); 226 float random( void ); 227 double random( void ); 228 float _Complex random( void ); 229 double _Complex random( void ); 230 long double _Complex random( void ); 219 231 220 232 //--------------------------------------- -
src/libcfa/stdlib.c
r64b272a re706bfd 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 20:30:44201713 // Update Count : 29 212 // Last Modified On : Mon Oct 30 22:43:02 2017 13 // Update Count : 297 14 14 // 15 15 … … 275 275 //--------------------------------------- 276 276 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); } 277 void random_seed( long int s ) { srand48( s ); } 278 char random( void ) { return mrand48(); } 279 char random( char l, char u ) { return lrand48() % (u - l) + l; } 280 int random( void ) { return mrand48(); } 281 unsigned int random( void ) { return lrand48(); } 282 unsigned int random( unsigned int u ) { return lrand48() % u; } 283 unsigned int random( unsigned int l, unsigned int u ) { return lrand48() % (u - l) + l; } 284 //long int random( void ) { return mrand48(); } 285 unsigned long int random( void ) { return lrand48(); } 286 unsigned long int random( unsigned long int u ) { return lrand48() % u; } 287 unsigned long int random( unsigned long int l, unsigned long int u ) { return lrand48() % (u - l) + l; } 288 float random( void ) { return (float)drand48(); } // otherwise float uses lrand48 289 double random( void ) { return drand48(); } 290 float _Complex random( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); } 291 double _Complex random( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); } 292 long double _Complex random( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); } 288 293 289 294 //--------------------------------------- -
src/main.cc
r64b272a re706bfd 10 10 // Author : Richard C. Bilson 11 11 // Created On : Fri May 15 23:12:02 2015 12 // Last Modified By : Andrew Beach13 // Last Modified On : Wed Jul 26 14:38:00 201714 // Update Count : 44 312 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Oct 31 12:22:40 2017 14 // Update Count : 445 15 15 // 16 16 … … 81 81 expraltp = false, 82 82 libcfap = false, 83 preludep = false, 83 84 nopreludep = false, 84 85 noprotop = false, … … 378 379 379 380 void 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, }; 381 382 382 383 static struct option long_opts[] = { … … 390 391 { "grammar", no_argument, 0, Grammar }, 391 392 { "libcfa", no_argument, 0, LibCFA }, 393 { "preamble", no_argument, 0, Preamble }, 392 394 { "no-preamble", no_argument, 0, Nopreamble }, 393 395 { "parse", no_argument, 0, Parse }, … … 405 407 406 408 int c; 407 while ( (c = getopt_long( argc, argv, "abBcCdefglLmn pqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {409 while ( (c = getopt_long( argc, argv, "abBcCdefglLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) { 408 410 switch ( c ) { 409 411 case Ast: … … 451 453 case 'n': // do not read preamble 452 454 nopreludep = true; 455 break; 456 case Preamble: 457 case 'N': // read preamble 458 preludep = true; 453 459 break; 454 460 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 1 14 #include <stdlib> 2 #include <fstream> 15 #include <fstream> // random 3 16 #include <kernel> 4 17 #include <thread> 5 #include <unistd.h> // getpid18 #include <unistd.h> // getpid 6 19 7 20 monitor Buffer { 8 9 10 21 condition full, empty; 22 int front, back, count; 23 int elements[20]; 11 24 }; 12 25 13 26 void ?{}( Buffer & buffer ) { 14 27 buffer.front = buffer.back = buffer.count = 0; 15 28 } 16 29 … … 18 31 19 32 void insert( Buffer & mutex buffer, int elem ) { 20 21 22 23 24 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 ); 25 38 } 26 39 int remove( Buffer & mutex buffer ) { 27 28 29 30 31 32 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; 33 46 } 34 47 35 48 thread Producer { 36 Buffer *buffer;37 49 Buffer & buffer; 50 unsigned int N; 38 51 }; 39 52 void main( Producer & prod ) { 40 41 yield( (unsigned int)rand48() % 5);42 insert( *prod.buffer, 1 );43 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 ); 45 58 } 46 59 void ?{}( Producer & prod, Buffer * buffer, unsigned int N ) { 47 48 49 }60 &prod.buffer = buffer; 61 prod.N = N; 62 } 50 63 51 64 thread Consumer { 52 Buffer *buffer;53 int *sum; // summation of producer values65 Buffer & buffer; 66 int & sum; // summation of producer values 54 67 }; 55 68 void main( Consumer & cons ) { 56 *cons.sum = 0;57 58 yield( (unsigned int)rand48() % 5);59 int item = remove( *cons.buffer );60 61 *cons.sum += item;62 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 63 76 } 64 77 void ?{}( Consumer & cons, Buffer * buffer, int * sum ) { 65 66 78 &cons.buffer = buffer; 79 &cons.sum = sum; 67 80 } 68 81 69 82 int main() { 70 71 72 73 74 75 76 77 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; 78 91 79 //rand48seed( getpid() );80 rand48seed( 1003 );92 //random_seed( getpid() ); 93 random_seed( 1003 ); 81 94 82 83 cons[i] = new( &buffer, &sums[i] );84 85 86 prods[i] = new( &buffer, 100000u );87 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 88 101 89 90 delete( prods[i] );91 92 93 insert( buffer, Sentinel );94 95 96 97 delete( cons[i] );98 sum += sums[i];99 100 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; 101 114 } 115 116 // Local Variables: // 117 // tab-width: 4 // 118 // compile-command: "cfa boundedBuffer.c" // 119 // End: // -
src/tests/matrixSum.c
r64b272a re706bfd 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Mon Oct 9 08:30:08 201714 // Update Count : 113 // Last Modified On : Sun Oct 29 21:08:48 2017 14 // Update Count : 2 15 15 // 16 16 … … 20 20 21 21 thread Adder { 22 int * row, cols, * subtotal; // communication22 int * row, cols, * subtotal; // communication 23 23 }; 24 24 … … 32 32 *adder.subtotal = 0; 33 33 for ( int c = 0; c < adder.cols; c += 1 ) { 34 *adder.subtotal += adder.row[c];34 *adder.subtotal += adder.row[c]; 35 35 } // for 36 36 } … … 39 39 const int rows = 10, cols = 1000; 40 40 int matrix[rows][cols], subtotals[rows], total = 0; 41 processor p; // extra kernel thread41 processor p; // extra kernel thread 42 42 43 43 for ( int r = 0; r < rows; r += 1 ) { 44 for ( int c = 0; c < cols; c += 1 ) {45 46 } // for44 for ( int c = 0; c < cols; c += 1 ) { 45 matrix[r][c] = 1; 46 } // for 47 47 } // for 48 48 Adder * adders[rows]; 49 for ( int r = 0; r < rows; r += 1 ) { // start threads to sum rows50 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] ); 52 52 } // for 53 for ( int r = 0; r < rows; r += 1 ) { // wait for threads to finish54 delete( adders[r] );55 total += subtotals[r];// total subtotals53 for ( int r = 0; r < rows; r += 1 ) { // wait for threads to finish 54 delete( adders[r] ); 55 total += subtotals[r]; // total subtotals 56 56 } // for 57 57 sout | total | endl; -
src/tests/prodcons.c
r64b272a re706bfd 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Sep 20 17:03:28201713 // Update Count : 4 012 // Last Modified On : Mon Oct 30 23:06:05 2017 13 // Update Count : 42 14 14 // 15 15 16 16 #include <fstream> 17 17 #include <coroutine> 18 #include <stdlib> // rand 4818 #include <stdlib> // random 19 19 #include <unistd.h> // getpid 20 20 … … 30 30 // 1st resume starts here 31 31 for ( int i = 0; i < prod.N; i += 1 ) { 32 int p1 = (unsigned int)rand48() % 100; // non-negative33 int p2 = (unsigned int)rand48() % 100;32 int p1 = random( 100 ); 33 int p2 = random( 100 ); 34 34 sout | p1 | " " | p2 | endl; 35 35 int status = delivery( *prod.c, p1, p2 ); … … 90 90 Prod prod; 91 91 Cons cons = { prod }; 92 rand 48seed( /* getpid() */ 103 ); // fixed seed for testing92 random_seed( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 94 sout | "main stops" | endl; -
src/tests/random.c
r64b272a re706bfd 10 10 // Created On : Tue Jul 5 21:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 6 18:00:29 201613 // Update Count : 312 // Last Modified On : Mon Oct 30 23:06:49 2017 13 // Update Count : 6 14 14 // 15 15 … … 19 19 20 20 int main() { 21 // rand48seed( getpid() ); // set random seed22 rand 48seed( 1003 );// fixed seed for repeatable tests21 //srandom( getpid() ); // set random seed 22 random_seed( 1003 ); // fixed seed for repeatable tests 23 23 24 24 // test polymorphic calls to random and stream 25 char c = rand 48();25 char c = random(); 26 26 sout | c | endl; 27 int i = rand 48();27 int i = random(); 28 28 sout | i | endl; 29 unsigned int ui = rand 48();29 unsigned int ui = random(); 30 30 sout | ui | endl; 31 long int li = rand 48();31 long int li = random(); 32 32 sout | li | endl; 33 unsigned long int uli = rand 48();33 unsigned long int uli = random(); 34 34 sout | uli | endl; 35 float f = rand 48();35 float f = random(); 36 36 sout | f | endl; 37 double d = rand 48();37 double d = random(); 38 38 sout | d | endl; 39 float _Complex fc = rand 48();39 float _Complex fc = random(); 40 40 sout | fc | endl; 41 double _Complex dc = rand 48();41 double _Complex dc = random(); 42 42 sout | dc | endl; 43 long double _Complex ldc = rand 48();43 long double _Complex ldc = random(); 44 44 sout | ldc | endl; 45 45 } // main -
src/tests/rational.c
r64b272a re706bfd 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 21:40:11201713 // Update Count : 6 612 // Last Modified On : Tue Oct 10 23:25:04 2017 13 // Update Count : 67 14 14 // 15 15 -
src/tests/sched-ext-barge.c
r64b272a re706bfd 42 42 void main( barger_t & this ) { 43 43 yield(); 44 while( barge( global ) ) { yield( ((unsigned)rand48()) % 10); }44 while( barge( global ) ) { yield(random( 10 )); } 45 45 } 46 46 47 47 bool do_call( global_t & mutex this ) { 48 yield( ((unsigned)rand48()) % 10);48 yield(random( 10 )); 49 49 if( this.state != WAITFOR && !this.done && this.started ) { 50 50 serr | "Barging before caller detected" | endl; … … 57 57 thread caller_t {}; 58 58 void main( caller_t & this ) { 59 while( do_call(global) ) { yield( ((unsigned)rand48()) % 10); }59 while( do_call(global) ) { yield(random( 10 )); } 60 60 } 61 61 … … 63 63 this.started = true; 64 64 for( int i = 0; i < N; i++) { 65 yield( ((unsigned)rand48()) % 10);65 yield(random( 10 )); 66 66 this.state = WAITFOR; 67 67 waitfor(do_call, this) { -
src/tests/sched-ext-dtor.c
r64b272a re706bfd 45 45 46 46 void main( dummy_t & this ) { 47 yield( ((unsigned)rand48()) % 10);47 yield(random( 10 )); 48 48 set_state( this, MAIN ); 49 49 waitfor( ^?{}, this ) { … … 58 58 for( int i = 0; i < N; i++ ){ 59 59 dummy_t dummy[4]; 60 yield( ((unsigned)rand48()) % 100);60 yield( random( 100 ) ); 61 61 } 62 62 sout | "Stopping" | endl; -
src/tests/sched-ext-recurse.c
r64b272a re706bfd 15 15 static const unsigned long N = 5_000ul; 16 16 17 static inline void rand_yield() { yield( ((unsigned)rand48()) % 10); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 enum state_t { FIRST, SECOND, THIRD, LAST, STOP }; … … 23 23 for (i = 0; i < 4; i++) 24 24 { 25 int j = ((unsigned)rand48()) % 4;25 int j = random( 4 ); 26 26 enum state_t t = array[j]; 27 27 array[j] = array[i]; … … 131 131 132 132 int main() { 133 rand 48seed( time(NULL) );133 random_seed( time(NULL) ); 134 134 sout | "Starting" | endl; 135 135 { -
src/tests/sched-ext-when.c
r64b272a re706bfd 15 15 static const unsigned long N = 4_998ul; 16 16 17 static inline void rand_yield() { yield( ((unsigned)rand48()) % 10); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 monitor global_t { … … 77 77 78 78 int main() { 79 rand 48seed( time(NULL) );79 random_seed( time(NULL) ); 80 80 sout | "Starting" | endl; 81 81 { -
src/tests/sched-ext.c
r64b272a re706bfd 26 26 volatile bool done; 27 27 28 unsigned rand10() {29 return (unsigned)rand48() % 10;30 }31 32 28 //---------------------------------------------------------------------------------------------------- 33 29 // Acceptor … … 36 32 void do_wait( global_t * mutex a ) { 37 33 sout | "Waiting to accept" | endl; 38 yield( rand 10() );34 yield( random( 10 ) ); 39 35 40 36 sout | "Accepting" | endl; … … 48 44 49 45 sout | "Accepted" | endl; 50 yield( rand 10() );46 yield( random( 10 ) ); 51 47 } 52 48 … … 68 64 void main( Acceptee* this ) { 69 65 while( !done ) { 70 yield( rand 10() );66 yield( random( 10 ) ); 71 67 do_notify( &globalA ); 72 yield( rand 10() );68 yield( random( 10 ) ); 73 69 } 74 70 } … … 78 74 int main(int argc, char* argv[]) { 79 75 done = false; 80 rand 48seed( time( NULL ) );76 random_seed( time( NULL ) ); 81 77 printf("%p\n", &globalA); 82 78 sout | "Starting" | endl; -
src/tests/sched-int-barge.c
r64b272a re706bfd 64 64 65 65 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 ); 69 69 70 70 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl; … … 109 109 110 110 int main(int argc, char* argv[]) { 111 rand 48seed(0);111 random_seed(0); 112 112 processor p; 113 113 { -
src/tests/sched-int-block.c
r64b272a re706bfd 49 49 wait( &cond, (uintptr_t)this_thread ); 50 50 51 yield( ((unsigned)rand48()) % 10);51 yield( random( 10 ) ); 52 52 53 53 if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) { … … 58 58 a.last_thread = b.last_thread = this_thread; 59 59 60 yield( ((unsigned)rand48()) % 10);60 yield( random( 10 ) ); 61 61 } 62 62 … … 70 70 //------------------------------------------------------------------------------ 71 71 void signal_op( global_data_t & mutex a, global_data_t & mutex b ) { 72 yield( ((unsigned)rand48()) % 10);72 yield( random( 10 ) ); 73 73 74 74 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread; … … 83 83 } 84 84 85 yield( ((unsigned)rand48()) % 10);85 yield( random( 10 ) ); 86 86 87 87 if(a.last_thread != next || b.last_thread != next) { … … 118 118 119 119 int main(int argc, char* argv[]) { 120 rand 48seed( time( NULL ) );120 random_seed( time( NULL ) ); 121 121 done = false; 122 122 processor p; -
src/tests/sched-int-disjoint.c
r64b272a re706bfd 88 88 signal( &cond, a, data ); 89 89 90 yield( (unsigned)rand48() % 10);90 yield( random( 10 ) ); 91 91 92 92 //This is technically a mutual exclusion violation but the mutex monitor protects us … … 109 109 // Main loop 110 110 int main(int argc, char* argv[]) { 111 rand 48seed( time( NULL ) );111 random_seed( time( NULL ) ); 112 112 all_done = false; 113 113 processor p; -
src/tests/sched-int-wait.c
r64b272a re706bfd 62 62 63 63 while( waiter_left != 0 ) { 64 unsigned action = (unsigned)rand48() % 4;64 unsigned action = random( 4 ); 65 65 switch( action ) { 66 66 case 0: … … 127 127 // Main 128 128 int main(int argc, char* argv[]) { 129 rand 48seed( time( NULL ) );129 random_seed( time( NULL ) ); 130 130 waiter_left = 4; 131 131 processor p[2]; -
tools/stat.py
r64b272a re706bfd 14 14 content.remove(max(content)) 15 15 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 ) 17 20 18 21
Note: See TracChangeset
for help on using the changeset viewer.