summaryrefslogtreecommitdiffstats
path: root/regressions/ck_pr/benchmark/fp.c
blob: f7aa157017ed1f6afd7ee03314a9b68f8607e15e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <inttypes.h>
#include <stdint.h>

#include "../../common.h"

#ifndef IR
#define IR 3000000
#endif /* IR */

static int a CK_CC_CACHELINE;
static int b CK_CC_CACHELINE;

int
main(void)
{
	uint64_t s, e;
	unsigned int i;

	s = rdtsc();
	for (i = 0; i < IR; i++) {
		ck_pr_load_int(&a);
		ck_pr_fence_strict_load();
		ck_pr_load_int(&b);
	}
	e = rdtsc();
	printf("[A] fence_load: %" PRIu64 "\n", (e - s) / IR);

	s = rdtsc();
	for (i = 0; i < IR; i++) {
		if (ck_pr_load_int(&a) == 0)
			ck_pr_barrier();
		ck_pr_fence_strict_lock();
		ck_pr_load_int(&b);
	}
	e = rdtsc();
	printf("[A] fence_lock: %" PRIu64 "\n", (e - s) / IR);

	s = rdtsc();
	for (i = 0; i < IR; i++) {
		ck_pr_store_int(&a, 0);
		ck_pr_fence_strict_store();
		ck_pr_store_int(&b, 0);
	}
	e = rdtsc();
	printf("[B] fence_store: %" PRIu64 "\n", (e - s) / IR);

	s = rdtsc();
	for (i = 0; i < IR; i++) {
		ck_pr_store_int(&a, 0);
		ck_pr_fence_strict_memory();
		ck_pr_load_int(&b);
	}
	e = rdtsc();
	printf("[C] fence_memory: %" PRIu64 "\n", (e - s) / IR);

	s = rdtsc();
	for (i = 0; i < IR; i++) {
		ck_pr_store_int(&a, 0);
		ck_pr_faa_int(&a, 0);
		ck_pr_load_int(&b);
	}
	e = rdtsc();
	printf("[C] atomic: %" PRIu64 "\n", (e - s) / IR);
	return 0;
}