Changes in / [5518719:5cdeecd]
- Location:
- benchmark
- Files:
-
- 2 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Makefile.am
r5518719 r5cdeecd 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Tue Jan 21 17:56:31202014 ## Update Count : 2 5013 ## Last Modified On : Mon Jan 20 11:50:13 2020 14 ## Update Count : 244 15 15 ############################################################################### 16 16 … … 75 75 .ONESHELL: # use one shell to execute recipe 76 76 .NOTPARALLEL: 77 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv s chedint.csv78 79 ## ========================================================================================================= 80 81 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) s chedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)77 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv signal.csv 78 79 ## ========================================================================================================= 80 81 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 82 82 83 83 basic_loop_DURATION = 15000000000 … … 91 91 ctxswitch_DURATION = 100000000 92 92 93 #mutex_java_DURATION = 1000000093 mutex_java_DURATION = 10000000 94 94 mutex_DURATION = 50000000 95 95 96 s chedint_pthread_DURATION = 100000097 s chedint_java_DURATION = $(schedint_pthread_DURATION)98 s chedint_rust_DURATION = $(schedint_pthread_DURATION)99 s chedint_DURATION = 10000000100 101 schedext_DURATION = 1000000096 signal_pthread_DURATION = 1000000 97 signal_java_DURATION = $(signal_pthread_DURATION) 98 signal_rust_DURATION = $(signal_pthread_DURATION) 99 signal_DURATION = 10000000 100 101 waitfor_DURATION = 10000000 102 102 103 103 creation_pthread_DURATION = 250000 104 creation_rust_thread_DURATION = ${creation_pthread_DURATION} 105 creation_java_thread_DURATION = ${creation_pthread_DURATION} 104 creation_rust_DURATION = ${creation_pthread_DURATION} 106 105 creation_cfa_coroutine_DURATION = 100000000 107 106 creation_cfa_coroutine_eager_DURATION = 10000000 … … 152 151 +make mutex.csv 153 152 -+make mutex.diff.csv 154 +make s chedint.csv155 -+make s chedint.diff.csv153 +make signal.csv 154 -+make signal.diff.csv 156 155 @DOifskipcompile@ 157 156 cat compile.csv … … 164 163 cat mutex.csv 165 164 -cat mutex.diff.csv 166 cat s chedint.csv167 -cat s chedint.diff.csv165 cat signal.csv 166 -cat signal.diff.csv 168 167 169 168 compile.csv: … … 199 198 $(srcdir)/fixcsv.sh $@ 200 199 201 s chedint.csv:202 echo "s chedint-1,schedint-2,schedext-1,schedext-2" > $@203 +make s chedint-cfa1.runquiet >> $@ && echo -n ',' >> $@204 +make s chedint-cfa2.runquiet >> $@ && echo -n ',' >> $@205 +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@206 +make schedext-cfa2.runquiet >> $@200 signal.csv: 201 echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@ 202 +make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@ 203 +make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@ 204 +make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@ 205 +make waitfor-cfa2.runquiet >> $@ 207 206 $(srcdir)/fixcsv.sh $@ 208 207 … … 352 351 ## ========================================================================================================= 353 352 354 schedint$(EXEEXT) : \ 355 schedint-cfa1.run \ 356 schedint-cfa2.run \ 357 schedint-cfa4.run \ 358 schedint-upp.run \ 359 schedint-rust.run \ 360 schedint-java.run \ 361 schedint-pthread.run 362 363 schedint-cfa1$(EXEEXT): 353 signal$(EXEEXT) : \ 354 signal-cfa1.run \ 355 signal-cfa2.run \ 356 signal-cfa4.run \ 357 signal-upp.run \ 358 signal-rust.run \ 359 signal-java.run \ 360 signal-pthread.run 361 362 signal-pthread$(EXEEXT): 363 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 364 365 signal-upp$(EXEEXT): 366 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 367 368 signal-cfa1$(EXEEXT): 364 369 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa 365 370 366 s chedint-cfa2$(EXEEXT):371 signal-cfa2$(EXEEXT): 367 372 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa 368 373 369 s chedint-cfa4$(EXEEXT):374 signal-cfa4$(EXEEXT): 370 375 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa 371 376 372 schedint-upp$(EXEEXT): 373 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 374 375 schedint-rust$(EXEEXT): 377 signal-rust$(EXEEXT): 376 378 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs 377 379 378 s chedint-java$(EXEEXT):380 signal-java$(EXEEXT): 379 381 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 380 382 echo "#!/bin/sh" > a.out … … 382 384 chmod a+x a.out 383 385 384 schedint-pthread$(EXEEXT): 385 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 386 387 ## ========================================================================================================= 388 389 schedext$(EXEEXT) : \ 390 schedext-cfa1.run \ 391 schedext-cfa2.run \ 392 schedext-cfa4.run \ 393 schedext-upp.run \ 394 schedext-goroutine.run 395 396 schedext-cfa1$(EXEEXT): 386 ## ========================================================================================================= 387 388 waitfor$(EXEEXT) : \ 389 waitfor-cfa1.run \ 390 waitfor-cfa2.run \ 391 waitfor-cfa4.run \ 392 waitfor-upp.run 393 394 waitfor-upp$(EXEEXT): 395 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc 396 397 waitfor-cfa1$(EXEEXT): 397 398 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa 398 399 399 schedext-cfa2$(EXEEXT):400 waitfor-cfa2$(EXEEXT): 400 401 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa 401 402 402 schedext-cfa4$(EXEEXT):403 waitfor-cfa4$(EXEEXT): 403 404 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa 404 405 405 schedext-upp$(EXEEXT):406 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc407 408 schedext-goroutine$(EXEEXT):409 $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go410 411 412 406 ## ========================================================================================================= 413 407 414 408 creation$(EXEEXT) : \ 415 creation-cfa_generator.run \416 409 creation-cfa_coroutine.run \ 417 410 creation-cfa_coroutine_eager.run \ … … 426 419 creation-pthread.run 427 420 428 creation-cfa_generator$(EXEEXT):429 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa430 431 421 creation-cfa_coroutine$(EXEEXT): 432 422 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa … … 460 450 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs 461 451 462 creation-java _thread$(EXEEXT):452 creation-java$(EXEEXT): 463 453 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 464 454 echo "#!/bin/sh" > a.out -
benchmark/Makefile.in
r5518719 r5cdeecd 427 427 ctxswitch_cfa_generator_DURATION = 5000000000 428 428 ctxswitch_DURATION = 100000000 429 430 #mutex_java_DURATION = 10000000 429 mutex_java_DURATION = 10000000 431 430 mutex_DURATION = 50000000 432 s chedint_pthread_DURATION = 1000000433 s chedint_java_DURATION = $(schedint_pthread_DURATION)434 s chedint_rust_DURATION = $(schedint_pthread_DURATION)435 s chedint_DURATION = 10000000436 schedext_DURATION = 10000000431 signal_pthread_DURATION = 1000000 432 signal_java_DURATION = $(signal_pthread_DURATION) 433 signal_rust_DURATION = $(signal_pthread_DURATION) 434 signal_DURATION = 10000000 435 waitfor_DURATION = 10000000 437 436 creation_pthread_DURATION = 250000 438 creation_rust_thread_DURATION = ${creation_pthread_DURATION} 439 creation_java_thread_DURATION = ${creation_pthread_DURATION} 437 creation_rust_DURATION = ${creation_pthread_DURATION} 440 438 creation_cfa_coroutine_DURATION = 100000000 441 439 creation_cfa_coroutine_eager_DURATION = 10000000 … … 786 784 .ONESHELL: # use one shell to execute recipe 787 785 .NOTPARALLEL: 788 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv s chedint.csv789 790 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) s chedint$(EXEEXT) schedext$(EXEEXT) creation$(EXEEXT)786 .PHONY: compile.csv basic.csv ctxswitch.csv mutex.csv signal.csv 787 788 all : basic$(EXEEXT) ctxswitch$(EXEEXT) mutex$(EXEEXT) signal$(EXEEXT) waitfor$(EXEEXT) creation$(EXEEXT) 791 789 792 790 %.run : %$(EXEEXT) ${REPEAT} … … 827 825 +make mutex.csv 828 826 -+make mutex.diff.csv 829 +make s chedint.csv830 -+make s chedint.diff.csv827 +make signal.csv 828 -+make signal.diff.csv 831 829 @DOifskipcompile@ 832 830 cat compile.csv … … 839 837 cat mutex.csv 840 838 -cat mutex.diff.csv 841 cat s chedint.csv842 -cat s chedint.diff.csv839 cat signal.csv 840 -cat signal.diff.csv 843 841 844 842 compile.csv: … … 874 872 $(srcdir)/fixcsv.sh $@ 875 873 876 s chedint.csv:877 echo "s chedint-1,schedint-2,schedext-1,schedext-2" > $@878 +make s chedint-cfa1.runquiet >> $@ && echo -n ',' >> $@879 +make s chedint-cfa2.runquiet >> $@ && echo -n ',' >> $@880 +make schedext-cfa1.runquiet >> $@ && echo -n ',' >> $@881 +make schedext-cfa2.runquiet >> $@874 signal.csv: 875 echo "signal-1,signal-2,waitfor-1,waitfor-2" > $@ 876 +make signal-cfa1.runquiet >> $@ && echo -n ',' >> $@ 877 +make signal-cfa2.runquiet >> $@ && echo -n ',' >> $@ 878 +make waitfor-cfa1.runquiet >> $@ && echo -n ',' >> $@ 879 +make waitfor-cfa2.runquiet >> $@ 882 880 $(srcdir)/fixcsv.sh $@ 883 881 … … 991 989 chmod a+x a.out 992 990 993 schedint$(EXEEXT) : \ 994 schedint-cfa1.run \ 995 schedint-cfa2.run \ 996 schedint-cfa4.run \ 997 schedint-upp.run \ 998 schedint-rust.run \ 999 schedint-java.run \ 1000 schedint-pthread.run 1001 1002 schedint-cfa1$(EXEEXT): 991 signal$(EXEEXT) : \ 992 signal-cfa1.run \ 993 signal-cfa2.run \ 994 signal-cfa4.run \ 995 signal-upp.run \ 996 signal-rust.run \ 997 signal-java.run \ 998 signal-pthread.run 999 1000 signal-pthread$(EXEEXT): 1001 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 1002 1003 signal-upp$(EXEEXT): 1004 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 1005 1006 signal-cfa1$(EXEEXT): 1003 1007 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa1.cfa 1004 1008 1005 s chedint-cfa2$(EXEEXT):1009 signal-cfa2$(EXEEXT): 1006 1010 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa2.cfa 1007 1011 1008 s chedint-cfa4$(EXEEXT):1012 signal-cfa4$(EXEEXT): 1009 1013 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedint/cfa4.cfa 1010 1014 1011 schedint-upp$(EXEEXT): 1012 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedint/upp.cc 1013 1014 schedint-rust$(EXEEXT): 1015 signal-rust$(EXEEXT): 1015 1016 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/schedint/rust.rs 1016 1017 1017 s chedint-java$(EXEEXT):1018 signal-java$(EXEEXT): 1018 1019 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/schedint/JavaThread.java 1019 1020 echo "#!/bin/sh" > a.out … … 1021 1022 chmod a+x a.out 1022 1023 1023 schedint-pthread$(EXEEXT): 1024 $(BENCH_V_CC)$(COMPILE) $(srcdir)/schedint/pthreads.c 1025 1026 schedext$(EXEEXT) : \ 1027 schedext-cfa1.run \ 1028 schedext-cfa2.run \ 1029 schedext-cfa4.run \ 1030 schedext-upp.run \ 1031 schedext-goroutine.run 1032 1033 schedext-cfa1$(EXEEXT): 1024 waitfor$(EXEEXT) : \ 1025 waitfor-cfa1.run \ 1026 waitfor-cfa2.run \ 1027 waitfor-cfa4.run \ 1028 waitfor-upp.run 1029 1030 waitfor-upp$(EXEEXT): 1031 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc 1032 1033 waitfor-cfa1$(EXEEXT): 1034 1034 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa1.cfa 1035 1035 1036 schedext-cfa2$(EXEEXT):1036 waitfor-cfa2$(EXEEXT): 1037 1037 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa2.cfa 1038 1038 1039 schedext-cfa4$(EXEEXT):1039 waitfor-cfa4$(EXEEXT): 1040 1040 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/schedext/cfa4.cfa 1041 1041 1042 schedext-upp$(EXEEXT):1043 $(BENCH_V_UPP)$(UPPCOMPILE) $(srcdir)/schedext/upp.cc1044 1045 schedext-goroutine$(EXEEXT):1046 $(BENCH_V_GOC)go build -o a.out $(srcdir)/schedext/goroutine.go1047 1048 1042 creation$(EXEEXT) : \ 1049 creation-cfa_generator.run \1050 1043 creation-cfa_coroutine.run \ 1051 1044 creation-cfa_coroutine_eager.run \ … … 1060 1053 creation-pthread.run 1061 1054 1062 creation-cfa_generator$(EXEEXT):1063 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_gen.cfa1064 1065 1055 creation-cfa_coroutine$(EXEEXT): 1066 1056 $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/creation/cfa_cor.cfa … … 1094 1084 $(BENCH_V_RUSTC)rustc -C opt-level=3 -o a.out $(srcdir)/creation/rust_thrd.rs 1095 1085 1096 creation-java _thread$(EXEEXT):1086 creation-java$(EXEEXT): 1097 1087 $(BENCH_V_JAVAC)javac -d $(builddir) $(srcdir)/creation/JavaThread.java 1098 1088 echo "#!/bin/sh" > a.out -
benchmark/creation/cfa_cor.cfa
r5518719 r5cdeecd 1 #include <stdio.h> 2 #include <coroutine.hfa> 3 1 4 #include "bench.h" 2 5 3 typedef struct { 4 void * next; 5 } C; 6 coroutine MyCoroutine {}; 7 void ?{}( MyCoroutine & this ) { 8 #ifdef EAGER 9 resume( this ); 10 #endif 11 } 12 void main( MyCoroutine & ) {} 6 13 7 14 int main( int argc, char * argv[] ) { … … 9 16 BENCH( 10 17 for ( times ) { 11 Cc;18 MyCoroutine c; 12 19 }, 13 20 result -
benchmark/schedext/cfa1.cfa
r5518719 r5cdeecd 6 6 #include "../bench.h" 7 7 8 volatile int go = 0; 9 8 10 monitor M {} m1; 9 11 10 12 void __attribute__((noinline)) call( M & mutex p1 ) {} 13 11 14 void __attribute__((noinline)) wait( M & mutex p1 ) { 15 go = 1; 12 16 for ( times ) { 13 17 waitfor( call : p1 ); 14 18 } 19 go = 0; 15 20 } 16 21 17 22 thread T {}; 18 23 void main( T & ) { 24 while ( go == 0 ) { yield(); } 19 25 BENCH( 20 for ( times) { call( m1 ); },26 while ( go == 1 ) { call( m1 ); }, 21 27 result 22 28 ) -
benchmark/schedext/cfa2.cfa
r5518719 r5cdeecd 4 4 #include <stdio.h> 5 5 6 #include "../bench.h" 6 #include "bench.h" 7 8 volatile int go = 0; 7 9 8 10 monitor M {} m1, m2; 9 11 10 12 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {} 13 11 14 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { 15 go = 1; 12 16 for ( times ) { 13 17 waitfor( call : p1, p2 ); 14 18 } 19 go = 0; 15 20 } 21 16 22 thread T {}; 17 23 void main( T & ) { 24 while( go == 0 ) { yield(); } 18 25 BENCH( 19 for ( times ) { 20 call( m1, m2 ); 21 }, 26 while ( go == 1 ) { call( m1, m2 ); }, 22 27 result 23 28 ) -
benchmark/schedext/cfa4.cfa
r5518719 r5cdeecd 4 4 #include <stdio.h> 5 5 6 #include "../bench.h" 6 #include "bench.h" 7 8 volatile int go = 0; 7 9 8 10 monitor M {} m1, m2, m3, m4; 9 11 10 12 void __attribute__((noinline)) call( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) {} 13 11 14 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) { 15 go = 1; 12 16 for ( times ) { 13 17 waitfor( call : p1, p2, p3, p4 ); 14 18 } 19 go = 0; 15 20 } 21 16 22 thread T {}; 17 23 void main( T & ) { 24 while( go == 0 ) { yield(); } 18 25 BENCH( 19 for ( times ) { 20 call( m1, m2, m3, m4 ); 21 }, 26 while( go == 1 ) { call( m1, m2, m3, m4 ); }, 22 27 result 23 28 ) -
benchmark/schedext/upp.cc
r5518719 r5cdeecd 3 3 #include "bench.h" 4 4 5 volatile int go = 0; 6 5 7 _Monitor M { 6 8 public: 7 9 void __attribute__((noinline)) call() {} 8 void __attribute__((noinline)) wait() { 10 11 int __attribute__((noinline)) wait() { 12 go = 1; 9 13 for ( size_t i = 0; i < times; i++ ) { 10 14 _Accept(call); 11 15 } 16 go = 0; 17 return 0; 12 18 } 13 19 } m; … … 15 21 _Task T { 16 22 void main() { 23 while ( go == 0 ) { yield(); } 17 24 BENCH( 18 for ( size_t i = 0; i < times; i++ ) { 19 m.call(); 20 }, 25 while ( go == 1 ) { m.call(); }, 21 26 result 22 27 ) … … 28 33 BENCH_START() 29 34 T t; 30 m.wait();35 return m.wait(); 31 36 } 32 37 -
benchmark/schedint/JavaThread.java
r5518719 r5cdeecd 63 63 synchronized(m) { 64 64 s.start(); 65 while( ! Monitor.go ) { // waiter must start first65 while( !Monitor.go ) { 66 66 Thread.yield(); 67 67 } -
benchmark/schedint/cfa1.cfa
r5518719 r5cdeecd 7 7 8 8 volatile int go = 0; 9 10 9 condition c; 11 10 monitor M {} m1; … … 14 13 signal( c ); 15 14 } 15 16 16 void __attribute__((noinline)) wait( M & mutex p1 ) { 17 17 go = 1; … … 19 19 wait( c ); 20 20 } 21 go = 0; 21 22 } 22 23 23 24 thread T {}; 24 25 void main( T & ) { 25 while ( go == 0 ) { yield(); } // waiter must start first26 while ( go == 0 ) { yield(); } 26 27 BENCH( 27 for ( times) { call( m1 ); },28 while ( go == 1 ) { call( m1 ); }, 28 29 result 29 30 ) -
benchmark/schedint/cfa2.cfa
r5518719 r5cdeecd 7 7 8 8 volatile int go = 0; 9 10 9 condition c; 11 10 monitor M {} m1, m2; … … 14 13 signal( c ); 15 14 } 15 16 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { 17 17 go = 1; … … 19 19 wait( c ); 20 20 } 21 go = 0; 21 22 } 22 23 23 24 thread T {}; 24 25 void main( T & ) { 25 while ( go == 0 ) { yield(); } // waiter must start first26 while ( go == 0 ) { yield(); } 26 27 BENCH( 27 for ( times) { call( m1, m2 ); },28 while ( go == 1 ) { call( m1, m2 ); }, 28 29 result 29 30 ) -
benchmark/schedint/cfa4.cfa
r5518719 r5cdeecd 4 4 #include <stdio.h> 5 5 6 #include " ../bench.h"6 #include "bench.h" 7 7 8 8 volatile int go = 0; 9 10 9 condition c; 11 10 monitor M {} m1, m2, m3, m4; … … 14 13 signal( c ); 15 14 } 15 16 16 void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2, M & mutex p3, M & mutex p4 ) { 17 17 go = 1; … … 19 19 wait( c ); 20 20 } 21 go = 0; 21 22 } 22 23 23 24 thread T {}; 24 25 void main( T & ) { 25 while ( go == 0 ) { yield(); } // waiter must start first26 while ( go == 0 ) { yield(); } 26 27 BENCH( 27 for ( times) { call( m1, m2, m3, m4 ); },28 while ( go == 1 ) { call( m1, m2, m3, m4 ); }, 28 29 result 29 30 ) -
benchmark/schedint/pthreads.c
r5518719 r5cdeecd 6 6 volatile int go = 0; 7 7 8 pthread_cond_t c; 8 9 pthread_mutex_t m; 9 pthread_cond_t c;10 10 11 11 void __attribute__((noinline)) call() { 12 pthread_mutex_lock( &m);13 pthread_cond_signal( &c);14 pthread_mutex_unlock( &m);12 pthread_mutex_lock(&m); 13 pthread_cond_signal(&c); 14 pthread_mutex_unlock(&m); 15 15 } 16 16 17 void__attribute__((noinline)) wait() {17 int __attribute__((noinline)) wait() { 18 18 pthread_mutex_lock(&m); 19 19 go = 1; 20 for ( size_t i = 0; i < times; i++ ) {21 pthread_cond_wait( &c, &m );22 }23 go = 0;24 pthread_mutex_unlock( &m );25 }26 27 void * thread_main( __attribute__((unused)) void * arg ) {28 while ( go == 0 ) { sched_yield(); } // waiter must start first29 // barging for lock acquire => may not execute N times30 20 BENCH( 31 while ( go == 1 ) { call(); }, 21 for (size_t i = 0; i < times; i++) { 22 pthread_cond_wait(&c, &m); 23 }, 32 24 result 33 25 ) 34 26 printf( "%g\n", result ); 27 go = 0; 28 pthread_mutex_unlock(&m); 29 return 0; 30 } 31 32 void* thread_main(__attribute__((unused)) void * arg ) { 33 while(go == 0) { sched_yield(); } 34 while(go == 1) { call(); } 35 35 return NULL; 36 36 } … … 39 39 BENCH_START() 40 40 pthread_t thread; 41 if ( pthread_create( &thread, NULL, thread_main, NULL ) < 0) {41 if (pthread_create(&thread, NULL, thread_main, NULL) < 0) { 42 42 perror( "failure" ); 43 43 return 1; 44 44 } 45 45 wait(); 46 if ( pthread_join( thread, NULL ) < 0) {46 if (pthread_join( thread, NULL) < 0) { 47 47 perror( "failure" ); 48 48 return 1; -
benchmark/schedint/rust.rs
r5518719 r5cdeecd 18 18 19 19 let th = thread::spawn( move || { 20 while *m2.lock().unwrap() == 0 { // waiter must start first20 while *m2.lock().unwrap() == 0 { 21 21 thread::yield_now(); 22 22 } -
benchmark/schedint/upp.cc
r5518719 r5cdeecd 11 11 cond.signal(); 12 12 } 13 void __attribute__((noinline)) wait() { 13 14 int __attribute__((noinline)) wait() { 14 15 go = 1; 15 for ( size_t i = 0; i < times; i++ ) {16 cond.wait();17 }18 }19 } m;20 21 _Task T {22 void main() {23 while ( go == 0 ) { yield(); } // waiter must start first24 16 BENCH( 25 for ( size_t i = 0; i < times; i++) {26 m.call();17 for (size_t i = 0; i < times; i++) { 18 cond.wait(); 27 19 }, 28 20 result 29 21 ) 30 22 printf( "%g\n", result ); 23 go = 0; 24 return 0; 25 } 26 }; 27 28 M m; 29 30 _Task T { 31 void main() { 32 while(go == 0) { yield(); } 33 while(go == 1) { m.call(); } 34 31 35 } 32 36 }; … … 35 39 BENCH_START() 36 40 T t; 37 m.wait();41 return m.wait(); 38 42 } 39 43
Note: See TracChangeset
for help on using the changeset viewer.