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)
{
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++) {

@ -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(&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);
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(&copy);
}
fprintf(stderr, "%u retries.\n", retries - STEPS);

Loading…
Cancel
Save