diff --git a/regressions/ck_ht/benchmark/parallel_bytestring.c b/regressions/ck_ht/benchmark/parallel_bytestring.c index 1f4dac8..cab0838 100644 --- a/regressions/ck_ht/benchmark/parallel_bytestring.c +++ b/regressions/ck_ht/benchmark/parallel_bytestring.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,7 @@ enum state { static struct affinity affinerator = AFFINITY_INITIALIZER; static uint64_t accumulator[HT_STATE_COUNT]; +static ck_spinlock_t accumulator_mutex = CK_SPINLOCK_INITIALIZER; static int barrier[HT_STATE_COUNT]; static int state; @@ -245,7 +247,9 @@ reader(void *unused) n_state = ck_pr_load_int(&state); if (n_state != state_previous) { - ck_pr_add_64(&accumulator[state_previous], a / (j * keys_length)); + ck_spinlock_lock(&accumulator_mutex); + accumulator[state_previous] += a / (j * keys_length); + ck_spinlock_unlock(&accumulator_mutex); ck_pr_inc_int(&barrier[state_previous]); while (ck_pr_load_int(&barrier[state_previous]) != n_threads + 1) ck_pr_stall(); diff --git a/regressions/ck_ht/benchmark/parallel_direct.c b/regressions/ck_ht/benchmark/parallel_direct.c index 74294b9..18b461d 100644 --- a/regressions/ck_ht/benchmark/parallel_direct.c +++ b/regressions/ck_ht/benchmark/parallel_direct.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,7 @@ enum state { static struct affinity affinerator = AFFINITY_INITIALIZER; static uint64_t accumulator[HT_STATE_COUNT]; +static ck_spinlock_t accumulator_mutex = CK_SPINLOCK_INITIALIZER; static int barrier[HT_STATE_COUNT]; static int state; @@ -247,7 +249,9 @@ ht_reader(void *unused) n_state = ck_pr_load_int(&state); if (n_state != state_previous) { - ck_pr_add_64(&accumulator[state_previous], a / (j * keys_length)); + ck_spinlock_lock(&accumulator_mutex); + accumulator[state_previous] += a / (j * keys_length); + ck_spinlock_unlock(&accumulator_mutex); ck_pr_inc_int(&barrier[state_previous]); while (ck_pr_load_int(&barrier[state_previous]) != n_threads + 1) ck_pr_stall();