diff --git a/.gitignore b/.gitignore index 7d8c142..3d53783 100644 --- a/.gitignore +++ b/.gitignore @@ -142,6 +142,6 @@ regressions/ck_queue/validate/ck_slist regressions/ck_cohort/validate/validate regressions/ck_cohort/benchmark/ck_cohort.LATENCY regressions/ck_cohort/benchmark/ck_cohort.THROUGHPUT -regressions/ck_cohort_rw/validate/validate -regressions/ck_cohort_rw/benchmark/latency -regressions/ck_cohort_rw/benchmark/throughput +regressions/ck_rw_cohort/validate/validate +regressions/ck_rw_cohort/benchmark/latency +regressions/ck_rw_cohort/benchmark/throughput diff --git a/include/ck_cohort_rw.h b/include/ck_rw_cohort.h similarity index 80% rename from include/ck_cohort_rw.h rename to include/ck_rw_cohort.h index e0ac1d1..30ee106 100644 --- a/include/ck_cohort_rw.h +++ b/include/ck_rw_cohort.h @@ -25,8 +25,8 @@ * SUCH DAMAGE. */ -#ifndef _CK_COHORT_RW_H -#define _CK_COHORT_RW_H +#ifndef _CK_RW_COHORT_H +#define _CK_RW_COHORT_H /* * This is an implementation of NUMA-aware reader-writer locks as described in: @@ -39,24 +39,24 @@ #include #include -#define CK_COHORT_RW_NAME(N) ck_cohort_rw_##N -#define CK_COHORT_RW_INSTANCE(N) struct CK_COHORT_RW_NAME(N) -#define CK_COHORT_RW_INIT(N, RW, WL) ck_cohort_rw_##N##_init(RW, WL) -#define CK_COHORT_RW_READ_LOCK(N, RW, C, GC, LC) ck_cohort_rw_##N##_read_lock(RW, C, GC, LC) -#define CK_COHORT_RW_READ_UNLOCK(N, RW) ck_cohort_rw_##N##_read_unlock(RW) -#define CK_COHORT_RW_WRITE_LOCK(N, RW, C, GC, LC) ck_cohort_rw_##N##_write_lock(RW, C, GC, LC) -#define CK_COHORT_RW_WRITE_UNLOCK(N, RW, C, GC, LC) ck_cohort_rw_##N##_write_unlock(RW, C, GC, LC) -#define CK_COHORT_RW_DEFAULT_WAIT_LIMIT 1000 +#define CK_RW_COHORT_NAME(N) ck_rw_cohort_##N +#define CK_RW_COHORT_INSTANCE(N) struct CK_RW_COHORT_NAME(N) +#define CK_RW_COHORT_INIT(N, RW, WL) ck_rw_cohort_##N##_init(RW, WL) +#define CK_RW_COHORT_READ_LOCK(N, RW, C, GC, LC) ck_rw_cohort_##N##_read_lock(RW, C, GC, LC) +#define CK_RW_COHORT_READ_UNLOCK(N, RW) ck_rw_cohort_##N##_read_unlock(RW) +#define CK_RW_COHORT_WRITE_LOCK(N, RW, C, GC, LC) ck_rw_cohort_##N##_write_lock(RW, C, GC, LC) +#define CK_RW_COHORT_WRITE_UNLOCK(N, RW, C, GC, LC) ck_rw_cohort_##N##_write_unlock(RW, C, GC, LC) +#define CK_RW_COHORT_DEFAULT_WAIT_LIMIT 1000 -#define CK_COHORT_RW_PROTOTYPE(N) \ - CK_COHORT_RW_INSTANCE(N) { \ +#define CK_RW_COHORT_PROTOTYPE(N) \ + CK_RW_COHORT_INSTANCE(N) { \ unsigned int read_counter; \ unsigned int write_barrier; \ unsigned int wait_limit; \ }; \ \ CK_CC_INLINE static void \ - ck_cohort_rw_##N##_init(CK_COHORT_RW_INSTANCE(N) *rw_cohort, \ + ck_rw_cohort_##N##_init(CK_RW_COHORT_INSTANCE(N) *rw_cohort, \ unsigned int wait_limit) \ { \ rw_cohort->read_counter = 0; \ @@ -67,7 +67,7 @@ } \ \ CK_CC_INLINE static void \ - ck_cohort_rw_##N##_write_lock(CK_COHORT_RW_INSTANCE(N) *rw_cohort, \ + ck_rw_cohort_##N##_write_lock(CK_RW_COHORT_INSTANCE(N) *rw_cohort, \ CK_COHORT_INSTANCE(N) *cohort, void *global_context, \ void *local_context) \ { \ @@ -85,7 +85,7 @@ } \ \ CK_CC_INLINE static void \ - ck_cohort_rw_##N##_write_unlock(CK_COHORT_RW_INSTANCE(N) *rw_cohort, \ + ck_rw_cohort_##N##_write_unlock(CK_RW_COHORT_INSTANCE(N) *rw_cohort, \ CK_COHORT_INSTANCE(N) *cohort, void *global_context, \ void *local_context) \ { \ @@ -94,7 +94,7 @@ } \ \ CK_CC_INLINE static void \ - ck_cohort_rw_##N##_read_lock(CK_COHORT_RW_INSTANCE(N) *rw_cohort, \ + ck_rw_cohort_##N##_read_lock(CK_RW_COHORT_INSTANCE(N) *rw_cohort, \ CK_COHORT_INSTANCE(N) *cohort, void *global_context, \ void *local_context) \ { \ @@ -122,15 +122,15 @@ } \ \ CK_CC_INLINE static void \ - ck_cohort_rw_##N##_read_unlock(CK_COHORT_RW_INSTANCE(N) *cohort) \ + ck_rw_cohort_##N##_read_unlock(CK_RW_COHORT_INSTANCE(N) *cohort) \ { \ ck_pr_dec_uint(&cohort->read_counter); \ } -#define CK_COHORT_RW_INITIALIZER { \ +#define CK_RW_COHORT_INITIALIZER { \ .read_counter = 0, \ .write_barrier = 0, \ .wait_limit = 0 \ } -#endif /* _CK_COHORT_RW_H */ +#endif /* _CK_RW_COHORT_H */ diff --git a/regressions/ck_cohort_rw/benchmark/Makefile b/regressions/ck_rw_cohort/benchmark/Makefile similarity index 72% rename from regressions/ck_cohort_rw/benchmark/Makefile rename to regressions/ck_rw_cohort/benchmark/Makefile index 8531fb9..6a751b5 100644 --- a/regressions/ck_cohort_rw/benchmark/Makefile +++ b/regressions/ck_rw_cohort/benchmark/Makefile @@ -4,10 +4,10 @@ OBJECTS=latency throughput all: $(OBJECTS) -latency: latency.c ../../../include/ck_cohort_rw.h +latency: latency.c ../../../include/ck_rw_cohort.h $(CC) $(CFLAGS) -o latency latency.c -throughput: throughput.c ../../../include/ck_cohort_rw.h +throughput: throughput.c ../../../include/ck_rw_cohort.h $(CC) $(CFLAGS) -o throughput throughput.c clean: diff --git a/regressions/ck_cohort_rw/benchmark/latency.c b/regressions/ck_rw_cohort/benchmark/latency.c similarity index 81% rename from regressions/ck_cohort_rw/benchmark/latency.c rename to regressions/ck_rw_cohort/benchmark/latency.c index 67e2803..d27fd41 100644 --- a/regressions/ck_cohort_rw/benchmark/latency.c +++ b/regressions/ck_rw_cohort/benchmark/latency.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -#include +#include #include #include #include @@ -60,7 +60,7 @@ ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) CK_COHORT_PROTOTYPE(fas_fas, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) -CK_COHORT_RW_PROTOTYPE(fas_fas) +CK_RW_COHORT_PROTOTYPE(fas_fas) int main(void) @@ -69,34 +69,34 @@ main(void) ck_spinlock_fas_t global_lock = CK_SPINLOCK_FAS_INITIALIZER; ck_spinlock_fas_t local_lock = CK_SPINLOCK_FAS_INITIALIZER; CK_COHORT_INSTANCE(fas_fas) cohort = CK_COHORT_INITIALIZER; - CK_COHORT_RW_INSTANCE(fas_fas) rw_cohort = CK_COHORT_RW_INITIALIZER; + CK_RW_COHORT_INSTANCE(fas_fas) rw_cohort = CK_RW_COHORT_INITIALIZER; CK_COHORT_INIT(fas_fas, &cohort, &global_lock, &local_lock, CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); - CK_COHORT_RW_INIT(fas_fas, &rw_cohort, CK_COHORT_RW_DEFAULT_WAIT_LIMIT); + CK_RW_COHORT_INIT(fas_fas, &rw_cohort, CK_RW_COHORT_DEFAULT_WAIT_LIMIT); for (i = 0; i < STEPS; i++) { - CK_COHORT_RW_WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - CK_COHORT_RW_WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); + CK_RW_COHORT_WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); + CK_RW_COHORT_WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); } s_b = rdtsc(); for (i = 0; i < STEPS; i++) { - CK_COHORT_RW_WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - CK_COHORT_RW_WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); + CK_RW_COHORT_WRITE_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); + CK_RW_COHORT_WRITE_UNLOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); } e_b = rdtsc(); printf("WRITE: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); for (i = 0; i < STEPS; i++) { - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); } s_b = rdtsc(); for (i = 0; i < STEPS; i++) { - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, &cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); } e_b = rdtsc(); printf("READ: rwlock %15" PRIu64 "\n", (e_b - s_b) / STEPS); diff --git a/regressions/ck_cohort_rw/benchmark/throughput.c b/regressions/ck_rw_cohort/benchmark/throughput.c similarity index 74% rename from regressions/ck_cohort_rw/benchmark/throughput.c rename to regressions/ck_rw_cohort/benchmark/throughput.c index 591351e..8a0c519 100644 --- a/regressions/ck_cohort_rw/benchmark/throughput.c +++ b/regressions/ck_rw_cohort/benchmark/throughput.c @@ -26,7 +26,7 @@ */ #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) CK_COHORT_PROTOTYPE(fas_fas, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) -CK_COHORT_RW_PROTOTYPE(fas_fas) +CK_RW_COHORT_PROTOTYPE(fas_fas) struct cohort_record { CK_COHORT_INSTANCE(fas_fas) cohort; @@ -86,7 +86,7 @@ struct cohort_record { static struct cohort_record *cohorts; static ck_spinlock_t global_lock = CK_SPINLOCK_INITIALIZER; -static CK_COHORT_RW_INSTANCE(fas_fas) rw_cohort = CK_COHORT_RW_INITIALIZER; +static CK_RW_COHORT_INSTANCE(fas_fas) rw_cohort = CK_RW_COHORT_INITIALIZER; static unsigned int n_cohorts; struct block { @@ -114,38 +114,38 @@ thread_rwlock(void *pun) for (i = 1, a = 0;; i++) { s_b = rdtsc(); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); e_b = rdtsc(); a += (e_b - s_b) >> 4; diff --git a/regressions/ck_cohort_rw/validate/Makefile b/regressions/ck_rw_cohort/validate/Makefile similarity index 83% rename from regressions/ck_cohort_rw/validate/Makefile rename to regressions/ck_rw_cohort/validate/Makefile index 2582598..e2552be 100644 --- a/regressions/ck_cohort_rw/validate/Makefile +++ b/regressions/ck_rw_cohort/validate/Makefile @@ -4,7 +4,7 @@ OBJECTS=validate all: $(OBJECTS) -validate: validate.c ../../../include/ck_cohort_rw.h +validate: validate.c ../../../include/ck_rw_cohort.h $(CC) $(CFLAGS) -o validate validate.c -g check: all diff --git a/regressions/ck_cohort_rw/validate/validate.c b/regressions/ck_rw_cohort/validate/validate.c similarity index 93% rename from regressions/ck_cohort_rw/validate/validate.c rename to regressions/ck_rw_cohort/validate/validate.c index 4854f65..871dcd3 100644 --- a/regressions/ck_cohort_rw/validate/validate.c +++ b/regressions/ck_rw_cohort/validate/validate.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include "../../common.h" @@ -75,10 +75,10 @@ ck_spinlock_fas_locked_with_context(ck_spinlock_fas_t *lock, void *context) CK_COHORT_PROTOTYPE(fas_fas, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context, ck_spinlock_fas_locked_with_context) -CK_COHORT_RW_PROTOTYPE(fas_fas) +CK_RW_COHORT_PROTOTYPE(fas_fas) static CK_COHORT_INSTANCE(fas_fas) *cohorts; -static CK_COHORT_RW_INSTANCE(fas_fas) rw_cohort = CK_COHORT_RW_INITIALIZER; +static CK_RW_COHORT_INSTANCE(fas_fas) rw_cohort = CK_RW_COHORT_INITIALIZER; static int n_cohorts; static void * @@ -97,7 +97,7 @@ thread(void *null CK_CC_UNUSED) cohort = cohorts + (core / (int)(a.delta)) % n_cohorts; while (i--) { - CK_COHORT_RW_WRITE_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_WRITE_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); { l = ck_pr_load_uint(&locked); if (l != 0) { @@ -132,16 +132,16 @@ thread(void *null CK_CC_UNUSED) ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); } } - CK_COHORT_RW_WRITE_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_WRITE_UNLOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); - CK_COHORT_RW_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); + CK_RW_COHORT_READ_LOCK(fas_fas, &rw_cohort, cohort, NULL, NULL); { l = ck_pr_load_uint(&locked); if (l != 0) { ck_error("ERROR [RD:%d]: %u != 0\n", __LINE__, l); } } - CK_COHORT_RW_READ_UNLOCK(fas_fas, &rw_cohort); + CK_RW_COHORT_READ_UNLOCK(fas_fas, &rw_cohort); } return (NULL);