aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-07-01 21:55:03 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-07-01 22:08:07 +0200
commitd0f47b9bf9bb6b38dfe379b3aa19af09ff47a667 (patch)
treede552021a629ec1452ff3438ca79b01268a7a921
parent51310acce858b34b8131c560cb430d86cd7624b4 (diff)
downloadallocbench-d0f47b9bf9bb6b38dfe379b3aa19af09ff47a667.tar.gz
allocbench-d0f47b9bf9bb6b38dfe379b3aa19af09ff47a667.zip
add barrier to larson benchmark
The barrier prevents worker thread from doing work before the main thread starts the timing. This behaviour was mentioned in the paper: Mostly Lock-Free Malloc by Dave Dice, Alex Garthwaite
-rw-r--r--src/benchmarks/larson/larson.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/benchmarks/larson/larson.cc b/src/benchmarks/larson/larson.cc
index be8038f..3da7a12 100644
--- a/src/benchmarks/larson/larson.cc
+++ b/src/benchmarks/larson/larson.cc
@@ -172,6 +172,8 @@ typedef struct thr_data {
int cThreads ;
unsigned long cBytesAlloced ;
+ pthread_barrier_t *barrier;
+
volatile int finished ;
struct lran2_st rgen ;
@@ -436,6 +438,9 @@ void runthreads(long sleep_cnt, int min_threads, int max_threads, int chperthrea
nperthread = chperthread ;
stopflag = FALSE ;
+
+ pthread_barrier_t barrier;
+ pthread_barrier_init(&barrier, NULL, num_threads + 1);
for(i=0; i< num_threads; i++){
de_area[i].threadno = i+1 ;
@@ -450,6 +455,7 @@ void runthreads(long sleep_cnt, int min_threads, int max_threads, int chperthrea
de_area[i].cAllocs = 0 ;
de_area[i].cFrees = 0 ;
de_area[i].cThreads = 0 ;
+ de_area[i].barrier = &barrier ;
de_area[i].finished = FALSE ;
lran2_init(&de_area[i].rgen, de_area[i].seed) ;
@@ -461,6 +467,8 @@ void runthreads(long sleep_cnt, int min_threads, int max_threads, int chperthrea
}
+ pthread_barrier_wait(&barrier);
+
QueryPerformanceCounter( &start_cnt) ;
// printf ("Sleeping for %ld seconds.\n", sleep_cnt);
@@ -553,6 +561,8 @@ static void * exercise_heap( void *pinput)
pdea->cThreads++ ;
range = pdea->max_size - pdea->min_size ;
+ pthread_barrier_wait(pdea->barrier);
+
/* allocate NumBlocks chunks of random size */
for( cblks=0; cblks<pdea->NumBlocks; cblks++){
victim = lran2(&pdea->rgen)%pdea->asize ;