From 9e31d0f0084e781405056c347aa4a8c53f676096 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 12 Jun 2009 15:16:29 -0400 Subject: [PATCH] Add runall.sh test Signed-off-by: Mathieu Desnoyers --- runall.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++ runtests.sh | 28 ------------------- test_mutex.c | 12 ++++---- test_perthreadlock.c | 12 ++++---- test_qsbr.c | 12 ++++---- test_rwlock.c | 12 ++++---- test_urcu.c | 12 ++++---- 7 files changed, 96 insertions(+), 58 deletions(-) create mode 100755 runall.sh diff --git a/runall.sh b/runall.sh new file mode 100755 index 0000000..6320ad9 --- /dev/null +++ b/runall.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +#run all tests + +#set to number of active CPUS +NUM_CPUS=8 + +#extra options, e.g. for setting affinity on even CPUs : +#EXTRA_OPTS=$(for a in $(seq 0 2 63); do echo -n "-a ${a} "; done) + + +#Vary update fraction +#x: vary update fraction from 0 to 0.0001 + #fix number of readers and reader C.S. length, vary delay between updates +#y: ops/s + +echo Executing update fraction test + +NR_READERS=$((${NUM_CPUS} - 1)) +NR_WRITERS=1 +DURATION=10 +WDELAY_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 + 65536 131072 262144 524288 1048576 2097152" + +rm -f update-fraction.log + +for WDELAY in ${WDELAY_ARRAY}; do + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} -d ${WDELAY} ${EXTRA_OPTS} | tee -a update-fraction.log +done + + +#Test scalability : +# x: vary number of readers from 0 to num cpus +# y: ops/s +# 0 writer. + +echo Executing scalability test + +NR_WRITERS=0 +DURATION=10 + +rm -f scalability.log + +for NR_READERS in $(seq 1 ${NUM_CPUS}); do + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS}| tee -a scalability.log +done + + +# x: Vary reader C.S. length from 0 to 100 us +# y: ops/s +# 8 readers +# 0 writers + +echo Executing reader C.S. length test + +NR_READERS=8 +NR_WRITERS=0 +DURATION=10 +#in loops. +READERCSLEN_ARRAY="0 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768" + +rm -f readercslen.log + +for READERCSLEN in ${READERCSLEN_ARRAY}; do + ./runtests.sh ${NR_READERS} ${NR_WRITERS} ${DURATION} ${EXTRA_OPTS} -c ${READERCSLEN} | tee -a readercslen.log +done diff --git a/runtests.sh b/runtests.sh index 05e55ee..d7f9c88 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,35 +1,7 @@ #!/bin/sh -#add urcu mb - for a in test_urcu test_urcu_mb test_qsbr test_rwlock test_perthreadlock \ test_mutex; do ./${a} $* done - -#Vary update fraction -#x: vary update fraction from 0 to 0.0001 - #fix number of readers, vary delay between updates -#y: ops/s - -echo Execution update fraction test - - -#Test scalability : -# x: vary number of readers from 0 to num cpus -# y: ops/s -# 0 writer. - -echo Executing scalability test - -# x: Vary reader C.S. length from 0 to 10us -# y: ops/s -# 8 readers -# 0 writers - -echo Executing reader C.S. length test - - - - diff --git a/test_mutex.c b/test_mutex.c index 140bf64..d481810 100644 --- a/test_mutex.c +++ b/test_mutex.c @@ -65,7 +65,7 @@ static pthread_mutex_t lock; static volatile int test_go, test_stop; -static int wdelay; +static unsigned long wdelay; static volatile struct test_array test_array = { 8 }; @@ -183,7 +183,7 @@ void *thr_writer(void *data) if (unlikely(!test_duration_write())) break; if (unlikely(wdelay)) - usleep(wdelay); + loop_sleep(wdelay); } printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", @@ -270,14 +270,14 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } - rduration = atoi(argv[++i]); + rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { show_usage(argc, argv); return -1; } - wdelay = atoi(argv[++i]); + wdelay = atol(argv[++i]); break; case 'v': verbose_mode = 1; @@ -287,7 +287,7 @@ int main(int argc, char **argv) printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); - printf_verbose("Writer delay : %u us.\n", wdelay); + printf_verbose("Writer delay : %lu loops.\n", wdelay); printf_verbose("Reader duration : %lu loops.\n", rduration); printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -343,7 +343,7 @@ int main(int argc, char **argv) tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " "nr_writers %3u " - "wdelay %4u nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", argv[0], duration, nr_readers, rduration, nr_writers, wdelay, tot_reads, tot_writes, tot_reads + tot_writes); diff --git a/test_perthreadlock.c b/test_perthreadlock.c index 7b74819..7d72231 100644 --- a/test_perthreadlock.c +++ b/test_perthreadlock.c @@ -69,7 +69,7 @@ static struct per_thread_lock *per_thread_lock; static volatile int test_go, test_stop; -static int wdelay; +static unsigned long wdelay; static volatile struct test_array test_array = { 8 }; @@ -192,7 +192,7 @@ void *thr_writer(void *data) if (unlikely(!test_duration_write())) break; if (unlikely(wdelay)) - usleep(wdelay); + loop_sleep(wdelay); } printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", @@ -279,14 +279,14 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } - rduration = atoi(argv[++i]); + rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { show_usage(argc, argv); return -1; } - wdelay = atoi(argv[++i]); + wdelay = atol(argv[++i]); break; case 'v': verbose_mode = 1; @@ -296,7 +296,7 @@ int main(int argc, char **argv) printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); - printf_verbose("Writer delay : %u us.\n", wdelay); + printf_verbose("Writer delay : %lu loops.\n", wdelay); printf_verbose("Reader duration : %lu loops.\n", rduration); printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -353,7 +353,7 @@ int main(int argc, char **argv) tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " "nr_writers %3u " - "wdelay %4u nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", argv[0], duration, nr_readers, rduration, nr_writers, wdelay, tot_reads, tot_writes, tot_reads + tot_writes); diff --git a/test_qsbr.c b/test_qsbr.c index ed95759..dc871dc 100644 --- a/test_qsbr.c +++ b/test_qsbr.c @@ -59,7 +59,7 @@ struct test_array { static volatile int test_go, test_stop; -static int wdelay; +static unsigned long wdelay; static struct test_array *test_rcu_pointer; @@ -231,7 +231,7 @@ void *thr_writer(void *_count) if (unlikely(!test_duration_write())) break; if (unlikely(wdelay)) - usleep(wdelay); + loop_sleep(wdelay); } printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", @@ -317,14 +317,14 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } - rduration = atoi(argv[++i]); + rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { show_usage(argc, argv); return -1; } - wdelay = atoi(argv[++i]); + wdelay = atol(argv[++i]); break; case 'v': verbose_mode = 1; @@ -334,7 +334,7 @@ int main(int argc, char **argv) printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); - printf_verbose("Writer delay : %u us.\n", wdelay); + printf_verbose("Writer delay : %lu loops.\n", wdelay); printf_verbose("Reader duration : %lu loops.\n", rduration); printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -389,7 +389,7 @@ int main(int argc, char **argv) tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " "nr_writers %3u " - "wdelay %4u nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", argv[0], duration, nr_readers, rduration, nr_writers, wdelay, tot_reads, tot_writes, tot_reads + tot_writes); diff --git a/test_rwlock.c b/test_rwlock.c index e4e058c..915027d 100644 --- a/test_rwlock.c +++ b/test_rwlock.c @@ -65,7 +65,7 @@ pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER; static volatile int test_go, test_stop; -static int wdelay; +static unsigned long wdelay; static volatile struct test_array test_array = { 8 }; @@ -180,7 +180,7 @@ void *thr_writer(void *_count) if (unlikely(!test_duration_write())) break; if (unlikely(wdelay)) - usleep(wdelay); + loop_sleep(wdelay); } printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", @@ -267,14 +267,14 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } - rduration = atoi(argv[++i]); + rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { show_usage(argc, argv); return -1; } - wdelay = atoi(argv[++i]); + wdelay = atol(argv[++i]); break; case 'v': verbose_mode = 1; @@ -284,7 +284,7 @@ int main(int argc, char **argv) printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); - printf_verbose("Writer delay : %u us.\n", wdelay); + printf_verbose("Writer delay : %lu loops.\n", wdelay); printf_verbose("Reader duration : %lu loops.\n", rduration); printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -337,7 +337,7 @@ int main(int argc, char **argv) tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " "nr_writers %3u " - "wdelay %4u nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", argv[0], duration, nr_readers, rduration, nr_writers, wdelay, tot_reads, tot_writes, tot_reads + tot_writes); diff --git a/test_urcu.c b/test_urcu.c index 87da703..696c09e 100644 --- a/test_urcu.c +++ b/test_urcu.c @@ -63,7 +63,7 @@ struct test_array { static volatile int test_go, test_stop; -static int wdelay; +static unsigned long wdelay; static struct test_array *test_rcu_pointer; @@ -232,7 +232,7 @@ void *thr_writer(void *_count) if (unlikely(!test_duration_write())) break; if (unlikely(wdelay)) - usleep(wdelay); + loop_sleep(wdelay); } printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", @@ -318,14 +318,14 @@ int main(int argc, char **argv) show_usage(argc, argv); return -1; } - rduration = atoi(argv[++i]); + rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { show_usage(argc, argv); return -1; } - wdelay = atoi(argv[++i]); + wdelay = atol(argv[++i]); break; case 'v': verbose_mode = 1; @@ -335,7 +335,7 @@ int main(int argc, char **argv) printf_verbose("running test for %lu seconds, %u readers, %u writers.\n", duration, nr_readers, nr_writers); - printf_verbose("Writer delay : %u us.\n", wdelay); + printf_verbose("Writer delay : %lu loops.\n", wdelay); printf_verbose("Reader duration : %lu loops.\n", rduration); printf_verbose("thread %-6s, thread id : %lx, tid %lu\n", "main", pthread_self(), (unsigned long)gettid()); @@ -390,7 +390,7 @@ int main(int argc, char **argv) tot_writes); printf("SUMMARY %-25s testdur %4lu nr_readers %3u rdur %6lu " "nr_writers %3u " - "wdelay %4u nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", + "wdelay %6lu nr_reads %12llu nr_writes %12llu nr_ops %12llu\n", argv[0], duration, nr_readers, rduration, nr_writers, wdelay, tot_reads, tot_writes, tot_reads + tot_writes); -- 2.34.1