Skip to content

Commit

Permalink
regressions/ck_sequence: Work-around LLVM bug.
Browse files Browse the repository at this point in the history
For some reason, load operations were being re-ordered with respect
to read begin operation (even with explicit compiler barriers).
  • Loading branch information
sbahra committed Aug 7, 2012
1 parent 7657df2 commit a56cac3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions regressions/ck_sequence/validate/ck_sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ consumer(void *unused CK_CC_UNUSED)
{
struct example copy;
uint32_t version;
unsigned int counter = 0;
unsigned int retries = 0;
unsigned int i;

unused = NULL;
Expand All @@ -72,22 +72,24 @@ consumer(void *unused CK_CC_UNUSED)
*/
do {
version = ck_sequence_read_begin(&seqlock);
copy = global;
counter++;
} while (ck_sequence_read_retry(&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++;
} while (ck_sequence_read_retry(&seqlock, version) == true);

if (copy.b != copy.a + 1000) {
fprintf(stderr, "ERROR: Failed regression: copy.b\n");
fprintf(stderr, "ERROR: Failed regression: copy.b (%u != %u + %u / %u)\n", copy.b, copy.a, 1000, copy.a + 1000);
exit(EXIT_FAILURE);
}

if (copy.c != copy.a + copy.b) {
fprintf(stderr, "ERROR: Failed regression: copy.c\n");
fprintf(stderr, "ERROR: Failed regression: copy.c (%u != %u + %u / %u)\n", copy.c, copy.a, copy.b, copy.a + copy.b);
exit(EXIT_FAILURE);
}
}

fprintf(stderr, "%u retries.\n", counter - STEPS);
fprintf(stderr, "%u retries.\n", retries - STEPS);
ck_pr_dec_uint(&barrier);
return (NULL);
}
Expand Down Expand Up @@ -136,8 +138,8 @@ main(int argc, char *argv[])
*/
ck_sequence_write_begin(&seqlock);
global.a = counter++;
ck_pr_store_uint(&global.b, global.a + 1000);
ck_pr_store_uint(&global.c, global.b + global.a);
global.b = global.a + 1000;
global.c = global.b + global.a;
ck_sequence_write_end(&seqlock);

if (counter == 1)
Expand Down

0 comments on commit a56cac3

Please sign in to comment.