From b46703ec5ce074e2e0f5d24b1c6f65049f389651 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sun, 28 Jun 2015 16:28:13 -0400 Subject: [PATCH] regressions: Add stupid fast-path benchmark for fences. This is far from comprehensive but needed for some upcoming tests. --- regressions/ck_pr/benchmark/Makefile | 5 ++- regressions/ck_pr/benchmark/fp.c | 56 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 regressions/ck_pr/benchmark/fp.c diff --git a/regressions/ck_pr/benchmark/Makefile b/regressions/ck_pr/benchmark/Makefile index 6b6116e..ae44b33 100644 --- a/regressions/ck_pr/benchmark/Makefile +++ b/regressions/ck_pr/benchmark/Makefile @@ -1,6 +1,9 @@ .PHONY: clean -all: ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 +all: ck_pr_cas_64 ck_pr_fas_64 ck_pr_cas_64_2 fp + +fp: fp.c + $(CC) $(CFLAGS) -o fp fp.c ck_pr_cas_64_2: ck_pr_cas_64_2.c $(CC) $(CFLAGS) -o ck_pr_cas_64_2 ck_pr_cas_64_2.c -lm diff --git a/regressions/ck_pr/benchmark/fp.c b/regressions/ck_pr/benchmark/fp.c new file mode 100644 index 0000000..5720f96 --- /dev/null +++ b/regressions/ck_pr/benchmark/fp.c @@ -0,0 +1,56 @@ +#include +#include +#include + +#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("fence_load: %" 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_load_int(&b); + } + e = rdtsc(); + printf("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("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("atomic: %" PRIu64 "\n", (e - s) / IR); + return 0; +}