From dbe49215ac3b2a3c2f8a8c053c8e339a8208e89c Mon Sep 17 00:00:00 2001 From: Brendon Scheinman Date: Tue, 19 Feb 2013 21:38:06 -0600 Subject: [PATCH] testing: Added validation test for cohorts. --- include/ck_cohort.h | 31 +++- regressions/ck_cohort/validate/Makefile | 17 +++ regressions/ck_cohort/validate/validate | Bin 0 -> 28724 bytes regressions/ck_cohort/validate/validate.c | 169 ++++++++++++++++++++++ regressions/common.h | 32 ++++ 5 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 regressions/ck_cohort/validate/Makefile create mode 100755 regressions/ck_cohort/validate/validate create mode 100644 regressions/ck_cohort/validate/validate.c diff --git a/include/ck_cohort.h b/include/ck_cohort.h index 78557f6..0bf636a 100644 --- a/include/ck_cohort.h +++ b/include/ck_cohort.h @@ -1,8 +1,34 @@ +/* + * Copyright 2013 Samy Al Bahra. + * Copyright 2013 Brendon Scheinman. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #ifndef _CK_COHORT_H #define _CK_COHORT_H #include -#include #include #include @@ -101,7 +127,4 @@ { NULL, NULL, RELEASE_STATE_GLOBAL, 0, 0, DEFAULT_LOCAL_PASS_LIMIT } -CK_CREATE_COHORT(test, ck_spinlock_fas_t, ck_spinlock_fas_t) - - #endif /* _CK_COHORT_H */ \ No newline at end of file diff --git a/regressions/ck_cohort/validate/Makefile b/regressions/ck_cohort/validate/Makefile new file mode 100644 index 0000000..7f34311 --- /dev/null +++ b/regressions/ck_cohort/validate/Makefile @@ -0,0 +1,17 @@ +.PHONY: check clean distribution + +OBJECTS=validate + +all: $(OBJECTS) + +validate: validate.c ../../../include/ck_cohort.h + $(CC) $(CFLAGS) -o validate validate.c + +check: all + ./validate $(CORES) 1 + +clean: + rm -rf *.dSYM *~ *.o $(OBJECTS) + +include ../../../build/regressions.build +CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE diff --git a/regressions/ck_cohort/validate/validate b/regressions/ck_cohort/validate/validate new file mode 100755 index 0000000000000000000000000000000000000000..221acb63d5bc6a82d22bd89b4b21329f1dfdc7a5 GIT binary patch literal 28724 zcmeHwdw5jUx%b+$XTp#$Nk{;Lf((!dh#3+tF(Be_pI{W^qM+bp$V|eNB$H-lxOf3H zpiUzit!=HJ2;N$&_UPj|wH~Vw6vd;h#XCoPELx;Nu_9iIwVLnuuD#wpGkYf5^YDDn z^ZmijlfBmazQ6afZu_>@-m`Ib?Hrq?3EpgCnjorQu2-^*y$}m7lceHRi@w4u%ESnf z1C9g#UMZo}$Z>jHnda1~a5_>u{;O>UquS<`8BT{7Y{4law>#d zGDweNEjeA1Nb6*V)1@koPL;AAk)-EUdS0c+=?)bbr(8ZN8~ra<_7>Z`posQ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F4L=Ed4PVLP>mowYMjtvULOs-}`s8!S zWs+}TQup+A61=&VvC-%0-T0c9b^P81ej)lZUk|b3{nAe6@$DhWXH+tM5&ZtPVnIJj zkh;Cq3;s*+3$w(dqk!4sF9F}3YFOn*^@2YK{QkBQu}ZZUtNMs9lE-Im$4jIg9Ou#;otc(tO#+v!dvV4#|qEq7yjxN-PdRH`&cjh=X>EF z0N>3)q@Zgpwe#|Mls^z(NAKCRHicrLpr>jQ-qa(3KO9^~)C6HX(hA0# zn`t$?^fUXyS<=m%h0`yX?PrSIa6aipKKzniQdVtaWw7xsfm-AoNPV5a_}D!!|CTH5 z(^mWY=?NSjh_&G@1GzkT*0KwyUr;j>(WOY_&pZkL+}imwrq}xC&zZAm_G16y=`(6) zQw7PNRH~20@fHG};HCe}lh>R2154?@%9NDR4=&N;I^&0#gg+#o-5K^We()(>O|=i# zm5jysRVrEnoy5}bJNf-7PSj6ASrKVJYei2+BTZIFFdFgWGyg%n5J4-f>|PWkn#q#9L^@hezK9+iiyntnnnU6Sqhxah~U(ox25 PWu^0Ev#Z7F>5~5oLhGub literal 0 HcmV?d00001 diff --git a/regressions/ck_cohort/validate/validate.c b/regressions/ck_cohort/validate/validate.c new file mode 100644 index 0000000..cd1608e --- /dev/null +++ b/regressions/ck_cohort/validate/validate.c @@ -0,0 +1,169 @@ +/* + * Copyright 2013 Samy Al Bahra. + * Copyright 2013 Brendon Scheinman. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "../../common.h" + +#ifndef ITERATE +#define ITERATE 1000000 +#endif + +static struct affinity a; +static unsigned int locked; +static int nthr; +static ck_spinlock_fas_t global_lock = CK_SPINLOCK_FAS_INITIALIZER; +typedef ck_spinlock_fas_t ck_spinlock_fas; +CK_CREATE_COHORT(fas_fas, ck_spinlock_fas, ck_spinlock_fas) +static struct ck_cohort_fas_fas *cohorts; +static int n_cohorts; + +static void * +thread(void *null CK_CC_UNUSED) +{ + int i = ITERATE; + unsigned int l; + unsigned int core; + struct ck_cohort_fas_fas *cohort; + + if (aff_iterate_core(&a, &core)) { + perror("ERROR: Could not affine thread"); + exit(EXIT_FAILURE); + } + + cohort = cohorts + core % n_cohorts; + + while (i--) { + ck_cohort_fas_fas_lock(cohort); + { + l = ck_pr_load_uint(&locked); + if (l != 0) { + ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); + } + + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + ck_pr_inc_uint(&locked); + + l = ck_pr_load_uint(&locked); + if (l != 8) { + ck_error("ERROR [WR:%d]: %u != 2\n", __LINE__, l); + } + + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + ck_pr_dec_uint(&locked); + + l = ck_pr_load_uint(&locked); + if (l != 0) { + ck_error("ERROR [WR:%d]: %u != 0\n", __LINE__, l); + } + } + ck_cohort_fas_fas_unlock(cohort); + } + + return (NULL); +} + +int +main(int argc, char *argv[]) +{ + pthread_t *threads; + int threads_per_cohort; + ck_spinlock_fas_t *local_lock; + int i; + + if (argc != 4) { + ck_error("Usage: validate \n"); + } + + n_cohorts = atoi(argv[1]); + if (n_cohorts <= 0) { + ck_error("ERROR: Number of cohorts must be greater than 0\n"); + } + + threads_per_cohort = atoi(argv[2]); + if (threads_per_cohort <= 0) { + ck_error("ERROR: Threads per cohort must be greater than 0\n"); + } + + nthr = n_cohorts * threads_per_cohort; + + threads = malloc(sizeof(pthread_t) * nthr); + if (threads == NULL) { + ck_error("ERROR: Could not allocate thread structures\n"); + } + + a.delta = atoi(argv[3]); + + fprintf(stderr, "Creating cohorts..."); + cohorts = malloc(sizeof(struct ck_cohort_fas_fas) * n_cohorts); + for (i = 0 ; i < n_cohorts ; i++) { + local_lock = malloc(sizeof(ck_spinlock_fas_t)); + ck_cohort_fas_fas_init(cohorts + i, &global_lock, local_lock); + } + fprintf(stderr, "done\n"); + + fprintf(stderr, "Creating threads..."); + for (i = 0; i < nthr; i++) { + if (pthread_create(&threads[i], NULL, thread, NULL)) { + ck_error("ERROR: Could not create thread %d\n", i); + } + } + fprintf(stderr, "done\n"); + + fprintf(stderr, "Waiting for threads to finish correctness regression..."); + for (i = 0; i < nthr; i++) + pthread_join(threads[i], NULL); + fprintf(stderr, "done (passed)\n"); + + return (0); +} + diff --git a/regressions/common.h b/regressions/common.h index 9994563..c06a145 100644 --- a/regressions/common.h +++ b/regressions/common.h @@ -229,6 +229,18 @@ aff_iterate(struct affinity *acb) return sched_setaffinity(gettid(), sizeof(s), &s); } + +CK_CC_UNUSED static int +aff_iterate_core(struct affinity *acb, unsigned int *core) +{ + cpu_set_t s; + + *core = ck_pr_faa_uint(&acb->request, acb->delta); + CPU_ZERO(&s); + CPU_SET((*core) % CORES, &s); + + return sched_setaffinity(gettid(), sizeof(s), &s); +} #elif defined(__MACH__) CK_CC_UNUSED static int aff_iterate(struct affinity *acb) @@ -243,6 +255,19 @@ aff_iterate(struct affinity *acb) (thread_policy_t)&policy, THREAD_AFFINITY_POLICY_COUNT); } + +CK_CC_UNUSED static int +aff_iterate_core(struct affinity *acb, unsigned int *core) +{ + thread_affinity_policy_data_t policy; + + *core = ck_pr_faa_uint(&acb->request, acb->delta) % CORES; + policy.affinity_tag = *core; + return thread_policy_set(mach_thread_self(), + THREAD_AFFINITY_POLICY, + (thread_policy_t)&policy, + THREAD_AFFINITY_POLICY_COUNT); +} #else CK_CC_UNUSED static int aff_iterate(struct affinity *acb CK_CC_UNUSED) @@ -250,6 +275,13 @@ aff_iterate(struct affinity *acb CK_CC_UNUSED) return (0); } + +CK_CC_UNUSED static int +aff_iterate_core(struct affinity *acb CK_CC_UNUSED, unsigned int *core) +{ + *core = 0; + return (0); +} #endif CK_CC_INLINE static uint64_t