Debian Codegraph @

regressions/ck_pr/benchmark/fp.c

raw
1 #include <stdio.h>
2 #include <inttypes.h>
3 #include <stdint.h>
4
5 #include "../../common.h"
6
7 #ifndef IR
8 #define IR 3000000
9 #endif /* IR */
10
11 static int a CK_CC_CACHELINE;
12 static int b CK_CC_CACHELINE;
13
14 int
15 main(void)
16 {
17 uint64_t s, e;
18 unsigned int i;
19
20 s = rdtsc();
21 for (i = 0; i < IR; i++) {
22 ck_pr_load_int(&a);
23 ck_pr_fence_strict_load();
24 ck_pr_load_int(&b);
25 }
26 e = rdtsc();
27 printf("[A] fence_load: %" PRIu64 "\n", (e - s) / IR);
28
29 s = rdtsc();
30 for (i = 0; i < IR; i++) {
31 if (ck_pr_load_int(&a) == 0)
32 ck_pr_barrier();
33 ck_pr_fence_strict_lock();
34 ck_pr_load_int(&b);
35 }
36 e = rdtsc();
37 printf("[A] fence_lock: %" PRIu64 "\n", (e - s) / IR);
38
39 s = rdtsc();
40 for (i = 0; i < IR; i++) {
41 ck_pr_store_int(&a, 0);
42 ck_pr_fence_strict_store();
43 ck_pr_store_int(&b, 0);
44 }
45 e = rdtsc();
46 printf("[B] fence_store: %" PRIu64 "\n", (e - s) / IR);
47
48 s = rdtsc();
49 for (i = 0; i < IR; i++) {
50 ck_pr_store_int(&a, 0);
51 ck_pr_fence_strict_memory();
52 ck_pr_load_int(&b);
53 }
54 e = rdtsc();
55 printf("[C] fence_memory: %" PRIu64 "\n", (e - s) / IR);
56
57 s = rdtsc();
58 for (i = 0; i < IR; i++) {
59 ck_pr_store_int(&a, 0);
60 ck_pr_faa_int(&a, 0);
61 ck_pr_load_int(&b);
62 }
63 e = rdtsc();
64 printf("[C] atomic: %" PRIu64 "\n", (e - s) / IR);
65 return 0;
66 }