From 1898a8e450ae90872aa7fa363fe0354014361317 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Fri, 26 Jul 2013 18:07:15 -0400 Subject: [PATCH] regressions: Coverage for CK_SEQUENCE_READ. --- .../ck_sequence/benchmark/ck_sequence.c | 12 ++++++++ .../ck_sequence/validate/ck_sequence.c | 30 +++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/regressions/ck_sequence/benchmark/ck_sequence.c b/regressions/ck_sequence/benchmark/ck_sequence.c index 4cb1acf..221166f 100644 --- a/regressions/ck_sequence/benchmark/ck_sequence.c +++ b/regressions/ck_sequence/benchmark/ck_sequence.c @@ -44,6 +44,7 @@ int main(void) { unsigned int i = 0; + unsigned int version; uint64_t a, s; /* Read-side latency. */ @@ -58,6 +59,17 @@ main(void) } printf("read: %" PRIu64 "\n", a / STEPS); + a = 0; + for (i = 0; i < STEPS / 4; i++) { + s = rdtsc(); + CK_SEQUENCE_READ(&seqlock, &version); + CK_SEQUENCE_READ(&seqlock, &version); + CK_SEQUENCE_READ(&seqlock, &version); + CK_SEQUENCE_READ(&seqlock, &version); + a += rdtsc() - s; + } + printf("READ %" PRIu64 "\n", a / STEPS); + /* Write-side latency. */ a = 0; for (i = 0; i < STEPS / 4; i++) { diff --git a/regressions/ck_sequence/validate/ck_sequence.c b/regressions/ck_sequence/validate/ck_sequence.c index ff6038e..f225d30 100644 --- a/regressions/ck_sequence/validate/ck_sequence.c +++ b/regressions/ck_sequence/validate/ck_sequence.c @@ -48,6 +48,23 @@ static ck_sequence_t seqlock CK_CC_CACHELINE = CK_SEQUENCE_INITIALIZER; static unsigned int barrier; static struct affinity affinerator; +static void +validate(struct example *copy) +{ + + if (copy->b != copy->a + 1000) { + ck_error("ERROR: Failed regression: copy->b (%u != %u + %u / %u)\n", + copy->b, copy->a, 1000, copy->a + 1000); + } + + if (copy->c != copy->a + copy->b) { + ck_error("ERROR: Failed regression: copy->c (%u != %u + %u / %u)\n", + copy->c, copy->a, copy->b, copy->a + copy->b); + } + + return; +} + static void * consumer(void *unused CK_CC_UNUSED) { @@ -77,14 +94,15 @@ consumer(void *unused CK_CC_UNUSED) copy.c = ck_pr_load_uint(&global.c); retries++; } while (ck_sequence_read_retry(&seqlock, version) == true); + validate(©); - if (copy.b != copy.a + 1000) { - ck_error("ERROR: Failed regression: copy.b (%u != %u + %u / %u)\n", copy.b, copy.a, 1000, copy.a + 1000); - } - - if (copy.c != copy.a + copy.b) { - ck_error("ERROR: Failed regression: copy.c (%u != %u + %u / %u)\n", copy.c, copy.a, copy.b, copy.a + copy.b); + CK_SEQUENCE_READ(&seqlock, &version) { + copy.a = ck_pr_load_uint(&global.a); + copy.b = ck_pr_load_uint(&global.b); + copy.c = ck_pr_load_uint(&global.c); + retries++; } + validate(©); } fprintf(stderr, "%u retries.\n", retries - STEPS);