review: A couple more changes based on ck_cohort review

I added an extra argument to the CK_COHORT_INIT macro to allow users to specify custom pass limits
when using it.  I also added a reference to the paper on which the cohort implementation was based.
ck_pring
Brendon Scheinman 12 years ago
parent 0fdac3d1d4
commit 81a90e41a2

@ -28,6 +28,11 @@
#ifndef _CK_COHORT_H
#define _CK_COHORT_H
/* This is an implementation of lock cohorts as described in:
* Dice, D.; Marathe, V.; and Shavit, N. 2012.
* Lock Cohorting: A General Technique for Designing NUMA Locks
*/
#include <ck_cc.h>
#include <ck_pr.h>
#include <stddef.h>
@ -39,13 +44,13 @@
#define CK_COHORT_NAME(N) ck_cohort_##N
#define CK_COHORT_INSTANCE(N) struct CK_COHORT_NAME(N)
#define CK_COHORT_INIT(N, C, GL, LL) ck_cohort_##N##_init(C, GL, LL)
#define CK_COHORT_INIT(N, C, GL, LL, P) ck_cohort_##N##_init(C, GL, LL, P)
#define CK_COHORT_LOCK(N, C, GC, LC) ck_cohort_##N##_lock(C, GC, LC)
#define CK_COHORT_UNLOCK(N, C, GC, LC) ck_cohort_##N##_unlock(C, GC, LC)
#define CK_COHORT_PROTOTYPE(N, GT, GL, GU, LT, LL, LU) \
\
struct CK_COHORT_NAME(N) { \
CK_COHORT_INSTANCE(N) { \
GT *global_lock; \
LT *local_lock; \
unsigned int release_state; \
@ -56,16 +61,15 @@
\
CK_CC_INLINE static void \
ck_cohort_##N##_init(struct ck_cohort_##N *cohort, \
GT *global_lock, LT *local_lock) \
GT *global_lock, LT *local_lock, unsigned int pass_limit) \
{ \
ck_pr_store_ptr(&cohort->global_lock, global_lock); \
ck_pr_store_ptr(&cohort->local_lock, local_lock); \
ck_pr_store_uint(&cohort->release_state, \
CK_COHORT_RELEASE_STATE_GLOBAL); \
CK_COHORT_RELEASE_STATE_GLOBAL); \
ck_pr_store_uint(&cohort->waiting_threads, 0); \
ck_pr_store_uint(&cohort->acquire_count, 0); \
ck_pr_store_uint(&cohort->local_pass_limit, \
CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT); \
ck_pr_store_uint(&cohort->local_pass_limit, pass_limit); \
return; \
} \
\

@ -187,7 +187,8 @@ main(int argc, char *argv[])
fprintf(stderr, "Creating cohorts...");
for (i = 0 ; i < n_cohorts ; i++) {
CK_COHORT_INIT(ticket_ticket, cohorts + i, &global_ticket_lock, local_fas_locks + i);
CK_COHORT_INIT(ticket_ticket, cohorts + i, &global_ticket_lock, local_fas_locks + i,
CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT);
}
fprintf(stderr, "done\n");

@ -19,6 +19,7 @@
ck_spinlock_fas_t, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context,\
ck_spinlock_fas_t, ck_spinlock_fas_lock_with_context, ck_spinlock_fas_unlock_with_context)\
static CK_COHORT_INSTANCE(fas_fas) CK_CC_CACHELINE cohort = CK_COHORT_INITIALIZER
#define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock)
#define LOCK_INIT CK_COHORT_INIT(fas_fas, &cohort, &global_fas_lock, &local_fas_lock,\
CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT)
#define LOCK CK_COHORT_LOCK(fas_fas, &cohort, NULL, NULL)
#define UNLOCK CK_COHORT_UNLOCK(fas_fas, &cohort, NULL, NULL)

@ -157,7 +157,8 @@ main(int argc, char *argv[])
cohorts = malloc(sizeof(CK_COHORT_INSTANCE(fas_fas)) * n_cohorts);
for (i = 0 ; i < n_cohorts ; i++) {
local_lock = malloc(sizeof(ck_spinlock_fas_t));
CK_COHORT_INIT(fas_fas, cohorts + i, &global_fas_lock, local_lock);
CK_COHORT_INIT(fas_fas, cohorts + i, &global_fas_lock, local_lock,
CK_COHORT_DEFAULT_LOCAL_PASS_LIMIT);
}
fprintf(stderr, "done\n");

Loading…
Cancel
Save