regressions: Coverage for CK_SEQUENCE_READ.

ck_pring
Samy Al Bahra 11 years ago
parent 767adaa04c
commit 1898a8e450

@ -44,6 +44,7 @@ int
main(void) main(void)
{ {
unsigned int i = 0; unsigned int i = 0;
unsigned int version;
uint64_t a, s; uint64_t a, s;
/* Read-side latency. */ /* Read-side latency. */
@ -58,6 +59,17 @@ main(void)
} }
printf("read: %" PRIu64 "\n", a / STEPS); 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. */ /* Write-side latency. */
a = 0; a = 0;
for (i = 0; i < STEPS / 4; i++) { for (i = 0; i < STEPS / 4; i++) {

@ -48,6 +48,23 @@ static ck_sequence_t seqlock CK_CC_CACHELINE = CK_SEQUENCE_INITIALIZER;
static unsigned int barrier; static unsigned int barrier;
static struct affinity affinerator; 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 * static void *
consumer(void *unused CK_CC_UNUSED) consumer(void *unused CK_CC_UNUSED)
{ {
@ -77,14 +94,15 @@ consumer(void *unused CK_CC_UNUSED)
copy.c = ck_pr_load_uint(&global.c); copy.c = ck_pr_load_uint(&global.c);
retries++; retries++;
} while (ck_sequence_read_retry(&seqlock, version) == true); } while (ck_sequence_read_retry(&seqlock, version) == true);
validate(&copy);
if (copy.b != copy.a + 1000) { CK_SEQUENCE_READ(&seqlock, &version) {
ck_error("ERROR: Failed regression: copy.b (%u != %u + %u / %u)\n", copy.b, copy.a, 1000, copy.a + 1000); copy.a = ck_pr_load_uint(&global.a);
} copy.b = ck_pr_load_uint(&global.b);
copy.c = ck_pr_load_uint(&global.c);
if (copy.c != copy.a + copy.b) { retries++;
ck_error("ERROR: Failed regression: copy.c (%u != %u + %u / %u)\n", copy.c, copy.a, copy.b, copy.a + copy.b);
} }
validate(&copy);
} }
fprintf(stderr, "%u retries.\n", retries - STEPS); fprintf(stderr, "%u retries.\n", retries - STEPS);

Loading…
Cancel
Save