diff --git a/Makefile.in b/Makefile.in index 806b53a..03e2082 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -.PHONY: all clean distribution regressions install install-headers doc uninstall +.PHONY: all check clean distribution doc install install-headers regressions uninstall CFLAGS=@CFLAGS@ VERSION=@VERSION@ @@ -22,6 +22,11 @@ regressions: $(MAKE) -C regressions all || exit @echo ---[ Regressions have built successfully. +check: regressions + @echo ---[ Executing unit tests... + $(MAKE) -C regressions check + @echo ---[ Unit tests have completed successfully. + install-headers: mkdir -p $(DESTDIR)/$(HEADERS) || exit cp include/*.h $(DESTDIR)/$(HEADERS) || exit diff --git a/build/regressions.build.in b/build/regressions.build.in index 402eef6..22f2b58 100644 --- a/build/regressions.build.in +++ b/build/regressions.build.in @@ -1,6 +1,7 @@ CC=@CC@ MAKE=make -CFLAGS=@CFLAGS@ -I../../../include +CORES=@CORES@ +CFLAGS=@CFLAGS@ -I../../../include -DCORES=@CORES@ LD=@LD@ LDFLAGS=@LDFLAGS@ PTHREAD_CFLAGS=@PTHREAD_CFLAGS@ diff --git a/configure b/configure index f62bb4a..f8a2c08 100755 --- a/configure +++ b/configure @@ -85,6 +85,7 @@ generate() -e "s#@HEADERS@#$HEADERS#g" \ -e "s#@LIBRARY@#$LIBRARY#g" \ -e "s#@PREFIX@#$PREFIX#g" \ + -e "s#@CORES@#$CORES#g" \ -e "s#@LD@#$LD#g" \ -e "s#@LDFLAGS@#$LDFLAGS#g" \ -e "s#@PTHREAD_CFLAGS@#$PTHREAD_CFLAGS#g" \ @@ -108,6 +109,7 @@ generate_stdout() echo " LDFLAGS = $LDFLAGS" echo " GZIP = $GZIP" echo " POINTER_PACK = $POINTER_PACK_ENABLE" + echo " CORES = $CORES" echo echo "Headers will be installed in $HEADERS" echo "Libraries will be installed in $LIBRARY" @@ -129,6 +131,9 @@ for option in $*; do echo " --libdir=N Libraries directory (default is ${PREFIX}/lib)" echo " --mandir=N Manual pages directory (default is ${PREFIX}/man)" echo " --prefix=N Installs library files in N (default is $PREFIX)" + echo + echo "The following options will modify code generation." + echo " --cores=N Specify number of cores available on target machine" echo " --enable-pointer-packing Assumes 48-bit address encoding" echo echo "The following environment variables may be used:" @@ -143,6 +148,9 @@ for option in $*; do --enable-pointer-packing) POINTER_PACK_ENABLE="CK_MD_POINTER_PACK_ENABLE" ;; + --cores=*) + CORES=$value + ;; --profile=*) PROFILE=$value ;; @@ -200,6 +208,7 @@ if test "$PROFILE"; then exit $EXIT_SUCCESS fi +DCORES=2 printf "Detecting operating system......." SYSTEM=`uname -s 2> /dev/null` case "$SYSTEM" in @@ -207,21 +216,26 @@ case "$SYSTEM" in SYSTEM=solaris ;; "Linux"|"uClinux") + DCORES=`grep '^processor.*:.*' /proc/cpuinfo|wc -l` SYSTEM=linux ;; "FreeBSD"|"GNU/kFreeBSD") + DCORES=`sysctl -n hw.ncpu` SYSTEM=freebsd ;; "NetBSD") + DCORES=`sysctl -n hw.ncpu` SYSTEM=netbsd ;; "OpenBSD") SYSTEM=openbsd ;; "DragonFly") + DCORES=`sysctl -n hw.ncpu` SYSTEM=dragonflybsd ;; "Darwin") + DCORES=`sysctl -n hw.ncpu` SYSTEM=darwin ;; *) @@ -231,6 +245,7 @@ esac assert "$SYSTEM" "$SYSTEM" "unsupported" +CORES=${CORES:-${DCORES}} printf "Detecting machine architecture..." PLATFORM=`uname -m 2> /dev/null` case $PLATFORM in diff --git a/regressions/Makefile b/regressions/Makefile index 13c75e2..b4d7717 100644 --- a/regressions/Makefile +++ b/regressions/Makefile @@ -1,4 +1,22 @@ -.PHONY: all clean +DIR=backoff \ + bag \ + barrier \ + bitmap \ + brlock \ + bytelock \ + epoch \ + fifo \ + hp \ + ht \ + pr \ + queue \ + ring \ + rwlock \ + sequence \ + spinlock \ + stack + +.PHONY: all clean check all: $(MAKE) -C ./ck_bitmap/validate all @@ -60,3 +78,12 @@ clean: $(MAKE) -C ./ck_hp/benchmark clean $(MAKE) -C ./ck_bag/validate clean +check: all + rc=0; \ + for d in $(DIR) ; do \ + echo "----[ Testing $$d...."; \ + $(MAKE) -C ./ck_$$d/validate check || rc=1; \ + echo; \ + done; \ + exit $$rc + diff --git a/regressions/ck_backoff/validate/Makefile b/regressions/ck_backoff/validate/Makefile index 6892ec5..ac87155 100644 --- a/regressions/ck_backoff/validate/Makefile +++ b/regressions/ck_backoff/validate/Makefile @@ -1,10 +1,13 @@ -.PHONY: clean +.PHONY: check clean all: validate validate: validate.c ../../../include/ck_backoff.h $(CC) $(CFLAGS) -o validate validate.c +check: all + ./validate + clean: rm -rf validate *.dSYM diff --git a/regressions/ck_bag/validate/Makefile b/regressions/ck_bag/validate/Makefile index 1d1b1aa..3df6823 100644 --- a/regressions/ck_bag/validate/Makefile +++ b/regressions/ck_bag/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=order @@ -7,6 +7,9 @@ all: $(OBJECTS) order: order.c ../../../include/ck_bag.h ../../../src/ck_bag.c ../../../src/ck_epoch.c $(CC) $(CFLAGS) -o order order.c ../../../src/ck_bag.c ../../../src/ck_epoch.c +check: all + ./order + clean: rm -rf *.dSYM *~ *.o $(OBJECTS) diff --git a/regressions/ck_bag/validate/order.c b/regressions/ck_bag/validate/order.c index 4db4fc6..30802a5 100644 --- a/regressions/ck_bag/validate/order.c +++ b/regressions/ck_bag/validate/order.c @@ -35,7 +35,7 @@ #include "../../common.h" -#define NUM_READER_THREADS 8 +#define NUM_READER_THREADS 2 #define READ_LATENCY 8 static ck_bag_t bag; @@ -43,7 +43,7 @@ static ck_epoch_t epoch_bag; static ck_epoch_record_t epoch_wr; static int leave; static unsigned int barrier; -static unsigned int writer_max = 131072; +static unsigned int writer_max = 32768; struct bag_epoch { ck_epoch_entry_t epoch_entry; @@ -291,7 +291,7 @@ main(int argc, char **argv) pthread_create(&readers[i], NULL, reader, NULL); } - sleep(120); + sleep(30); ck_pr_store_int(&leave, 1); for (i = 0; i < NUM_READER_THREADS; i++) diff --git a/regressions/ck_barrier/validate/Makefile b/regressions/ck_barrier/validate/Makefile index 3cd122c..f11b70a 100644 --- a/regressions/ck_barrier/validate/Makefile +++ b/regressions/ck_barrier/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=barrier_centralized barrier_combining barrier_dissemination barrier_tournament barrier_mcs @@ -19,6 +19,14 @@ barrier_tournament: barrier_tournament.c ../../../include/ck_barrier.h ../../../ barrier_mcs: barrier_mcs.c ../../../include/ck_barrier.h ../../../src/ck_barrier_mcs.c $(CC) $(CFLAGS) -o barrier_mcs barrier_mcs.c ../../../src/ck_barrier_mcs.c +check: all + rc=0; \ + for d in $(OBJECTS) ; do \ + echo $$d; \ + ./$$d $(CORES) 1 1 || rc=1; \ + done; \ + exit $$rc + clean: rm -rf *.dSYM *~ *.o $(OBJECTS) diff --git a/regressions/ck_barrier/validate/barrier_centralized.c b/regressions/ck_barrier/validate/barrier_centralized.c index d363d8a..abb41b1 100644 --- a/regressions/ck_barrier/validate/barrier_centralized.c +++ b/regressions/ck_barrier/validate/barrier_centralized.c @@ -87,7 +87,7 @@ main(int argc, char *argv[]) pthread_t *threads; int i; - if (argc != 3) { + if (argc < 3) { fprintf(stderr, "Usage: correct \n"); exit(EXIT_FAILURE); } diff --git a/regressions/ck_barrier/validate/barrier_combining.c b/regressions/ck_barrier/validate/barrier_combining.c index b990900..9204697 100644 --- a/regressions/ck_barrier/validate/barrier_combining.c +++ b/regressions/ck_barrier/validate/barrier_combining.c @@ -98,7 +98,7 @@ main(int argc, char *argv[]) } ck_barrier_combining_init(&barrier, init_root); - if (argc != 4) { + if (argc < 4) { fprintf(stderr, "Usage: correct \n"); exit(EXIT_FAILURE); } diff --git a/regressions/ck_barrier/validate/barrier_dissemination.c b/regressions/ck_barrier/validate/barrier_dissemination.c index e7a25ac..a46f277 100644 --- a/regressions/ck_barrier/validate/barrier_dissemination.c +++ b/regressions/ck_barrier/validate/barrier_dissemination.c @@ -91,7 +91,7 @@ main(int argc, char *argv[]) pthread_t *threads; int i, size; - if (argc != 3) { + if (argc < 3) { fprintf(stderr, "Usage: correct \n"); exit(EXIT_FAILURE); } diff --git a/regressions/ck_barrier/validate/barrier_mcs.c b/regressions/ck_barrier/validate/barrier_mcs.c index 6f696ca..a47c367 100644 --- a/regressions/ck_barrier/validate/barrier_mcs.c +++ b/regressions/ck_barrier/validate/barrier_mcs.c @@ -91,7 +91,7 @@ main(int argc, char *argv[]) ck_barrier_mcs_t *barrier; int i; - if (argc != 3) { + if (argc < 3) { fprintf(stderr, "Usage: correct \n"); exit(EXIT_FAILURE); } diff --git a/regressions/ck_barrier/validate/barrier_tournament.c b/regressions/ck_barrier/validate/barrier_tournament.c index 481bfa4..4ec204a 100644 --- a/regressions/ck_barrier/validate/barrier_tournament.c +++ b/regressions/ck_barrier/validate/barrier_tournament.c @@ -95,7 +95,7 @@ main(int argc, char *argv[]) int i; unsigned int size; - if (argc != 3) { + if (argc < 3) { fprintf(stderr, "Usage: correct \n"); exit(EXIT_FAILURE); } diff --git a/regressions/ck_bitmap/validate/Makefile b/regressions/ck_bitmap/validate/Makefile index 2af2293..c96f924 100644 --- a/regressions/ck_bitmap/validate/Makefile +++ b/regressions/ck_bitmap/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean +.PHONY: check clean OBJECTS=serial @@ -10,5 +10,8 @@ serial: serial.c ../../../include/ck_bitmap.h clean: rm -rf *~ *.o $(OBJECTS) *.dSYM +check: all + ./serial + include ../../../build/regressions.build CFLAGS+=-D_GNU_SOURCE diff --git a/regressions/ck_brlock/validate/Makefile b/regressions/ck_brlock/validate/Makefile index 491f4b8..e233d69 100644 --- a/regressions/ck_brlock/validate/Makefile +++ b/regressions/ck_brlock/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=validate @@ -7,6 +7,9 @@ all: $(OBJECTS) validate: validate.c ../../../include/ck_brlock.h $(CC) $(CFLAGS) -o validate validate.c +check: all + ./validate $(CORES) 1 + clean: rm -rf *.dSYM *~ *.o $(OBJECTS) diff --git a/regressions/ck_bytelock/validate/Makefile b/regressions/ck_bytelock/validate/Makefile index d0ab180..e04a48b 100644 --- a/regressions/ck_bytelock/validate/Makefile +++ b/regressions/ck_bytelock/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=validate @@ -7,6 +7,9 @@ all: $(OBJECTS) validate: validate.c $(CC) $(CFLAGS) -o validate validate.c +check: all + ./validate $(CORES) 1 + clean: rm -rf *.dSYM *~ *.o $(OBJECTS) diff --git a/regressions/ck_epoch/validate/Makefile b/regressions/ck_epoch/validate/Makefile index 750bd8a..1d9aa82 100644 --- a/regressions/ck_epoch/validate/Makefile +++ b/regressions/ck_epoch/validate/Makefile @@ -1,9 +1,13 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=ck_stack ck_stack_read all: $(OBJECTS) +check: all + ./ck_stack $(CORES) 10 1 + ./ck_stack_read $(CORES) 10 1 + ck_stack_read: ck_stack_read.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c $(CC) $(CFLAGS) -o ck_stack_read ck_stack_read.c ../../../src/ck_epoch.c diff --git a/regressions/ck_fifo/validate/Makefile b/regressions/ck_fifo/validate/Makefile index cb53469..70496f8 100644 --- a/regressions/ck_fifo/validate/Makefile +++ b/regressions/ck_fifo/validate/Makefile @@ -1,8 +1,14 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=ck_fifo_spsc ck_fifo_mpmc ck_fifo_spsc_iterator ck_fifo_mpmc_iterator -all: ck_fifo_spsc ck_fifo_mpmc ck_fifo_spsc_iterator ck_fifo_mpmc_iterator +all: $(OBJECTS) + +check: all + ./ck_fifo_spsc $(CORES) 1 64000 + ./ck_fifo_mpmc $(CORES) 1 64000 + ./ck_fifo_spsc_iterator + ./ck_fifo_mpmc_iterator ck_fifo_spsc: ck_fifo_spsc.c $(CC) $(CFLAGS) -o ck_fifo_spsc ck_fifo_spsc.c diff --git a/regressions/ck_hp/validate/Makefile b/regressions/ck_hp/validate/Makefile index a668bd3..e25bce0 100644 --- a/regressions/ck_hp/validate/Makefile +++ b/regressions/ck_hp/validate/Makefile @@ -1,9 +1,15 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=ck_hp_stack nbds_haz_test serial ck_hp_fifo all: $(OBJECTS) +check: all + ./serial + ./ck_hp_stack $(CORES) 10 1 + ./ck_hp_fifo $(CORES) 1 64000 10 + ./nbds_haz_test $(CORES) 10 1 + ck_hp_stack: ../../../src/ck_hp.c ck_hp_stack.c ../../../include/ck_hp_stack.h $(CC) $(CFLAGS) ../../../src/ck_hp.c -o ck_hp_stack ck_hp_stack.c diff --git a/regressions/ck_ht/validate/Makefile b/regressions/ck_ht/validate/Makefile index 2535b6d..f89e117 100644 --- a/regressions/ck_ht/validate/Makefile +++ b/regressions/ck_ht/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=serial @@ -7,6 +7,9 @@ all: $(OBJECTS) serial: serial.c ../../../include/ck_ht.h ../../../src/ck_ht.c $(CC) $(CFLAGS) -o serial serial.c ../../../src/ck_ht.c +check: all + ./serial + clean: rm -rf *~ *.o $(OBJECTS) *.dSYM diff --git a/regressions/ck_pr/validate/Makefile b/regressions/ck_pr/validate/Makefile index 447a967..66a62cd 100644 --- a/regressions/ck_pr/validate/Makefile +++ b/regressions/ck_pr/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=ck_pr_cas ck_pr_faa ck_pr_inc ck_pr_dec ck_pr_bts \ ck_pr_btr ck_pr_btc ck_pr_load ck_pr_store \ @@ -8,6 +8,13 @@ OBJECTS=ck_pr_cas ck_pr_faa ck_pr_inc ck_pr_dec ck_pr_bts \ all: $(OBJECTS) +check: all + rc=0; \ + for d in $(OBJECTS) ; do \ + echo $$d; \ + ./$$d || exit 1; \ + done; + ck_pr_cas: ck_pr_cas.c $(CC) $(CFLAGS) -o ck_pr_cas ck_pr_cas.c diff --git a/regressions/ck_queue/validate/Makefile b/regressions/ck_queue/validate/Makefile index 6ccb97d..07ce22b 100644 --- a/regressions/ck_queue/validate/Makefile +++ b/regressions/ck_queue/validate/Makefile @@ -1,10 +1,14 @@ -.PHONY: clean distribution +.PHONY: check clean distribution HEADER=../../../include/ck_queue.h OBJECTS=ck_slist ck_list all: $(OBJECTS) +check: all + ./ck_slist $(CORES) 100000 + ./ck_list $(CORES) 100000 + ck_slist: $(HEADER) ck_slist.c $(CC) $(CFLAGS) -o ck_slist ck_slist.c diff --git a/regressions/ck_ring/validate/Makefile b/regressions/ck_ring/validate/Makefile index ee694da..1319556 100644 --- a/regressions/ck_ring/validate/Makefile +++ b/regressions/ck_ring/validate/Makefile @@ -1,9 +1,13 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=ck_ring_spsc ck_ring_spsc_template all: $(OBJECTS) +check: all + ./ck_ring_spsc $(CORES) 1 65536 + ./ck_ring_spsc_template $(CORES) 1 65536 + ck_ring_spsc_template: ck_ring_spsc_template.c ../../../include/ck_ring.h $(CC) $(CFLAGS) -o ck_ring_spsc_template ck_ring_spsc_template.c diff --git a/regressions/ck_rwlock/validate/Makefile b/regressions/ck_rwlock/validate/Makefile index 65105c9..2dbaa37 100644 --- a/regressions/ck_rwlock/validate/Makefile +++ b/regressions/ck_rwlock/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=validate @@ -7,6 +7,9 @@ all: $(OBJECTS) validate: validate.c ../../../include/ck_rwlock.h $(CC) $(CFLAGS) -o validate validate.c +check: all + ./validate $(CORES) 1 + clean: rm -rf *.dSYM *~ *.o $(OBJECTS) diff --git a/regressions/ck_sequence/validate/Makefile b/regressions/ck_sequence/validate/Makefile index 0849928..28e7db0 100644 --- a/regressions/ck_sequence/validate/Makefile +++ b/regressions/ck_sequence/validate/Makefile @@ -1,5 +1,4 @@ - -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=ck_sequence @@ -8,6 +7,9 @@ all: $(OBJECTS) ck_sequence: ck_sequence.c ../../../include/ck_sequence.h $(CC) $(CFLAGS) -o ck_sequence ck_sequence.c +check: all + ./ck_sequence $(CORES) 1 + clean: rm -rf *~ *.o $(OBJECTS) *.dSYM diff --git a/regressions/ck_spinlock/validate/Makefile b/regressions/ck_spinlock/validate/Makefile index a080ad5..964085b 100644 --- a/regressions/ck_spinlock/validate/Makefile +++ b/regressions/ck_spinlock/validate/Makefile @@ -1,8 +1,20 @@ -.PHONY: clean +.PHONY: check clean all: ck_ticket ck_mcs ck_dec ck_cas ck_fas ck_clh linux_spinlock \ ck_ticket_pb ck_anderson ck_spinlock +check: all + ./ck_ticket $(CORES) 1 + ./ck_mcs $(CORES) 1 + ./ck_dec $(CORES) 1 + ./ck_cas $(CORES) 1 + ./ck_fas $(CORES) 1 + ./ck_clh $(CORES) 1 + ./linux_spinlock $(CORES) 1 + ./ck_ticket_pb $(CORES) 1 + ./ck_anderson $(CORES) 1 + ./ck_spinlock $(CORES) 1 + linux_spinlock: linux_spinlock.c $(CC) $(CFLAGS) -o linux_spinlock linux_spinlock.c diff --git a/regressions/ck_stack/validate/Makefile b/regressions/ck_stack/validate/Makefile index 2a961e5..0916ac3 100644 --- a/regressions/ck_stack/validate/Makefile +++ b/regressions/ck_stack/validate/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean distribution +.PHONY: check clean distribution OBJECTS=serial mpnc_push mpmc_push upmc_push spinlock_push spinlock_eb_push \ mpmc_pop upmc_pop spinlock_pop spinlock_eb_pop \ @@ -7,6 +7,18 @@ OBJECTS=serial mpnc_push mpmc_push upmc_push spinlock_push spinlock_eb_push \ all: $(OBJECTS) +check: all + ./serial + ./mpmc_pair $(CORES) 1 0 + ./upmc_trypop $(CORES) 1 0 + ./mpmc_trypop $(CORES) 1 0 + ./mpmc_trypair $(CORES) 1 0 + ./mpmc_pop $(CORES) 1 0 + ./upmc_pop $(CORES) 1 0 + ./mpnc_push $(CORES) 1 0 + ./mpmc_push $(CORES) 1 0 + ./upmc_push $(CORES) 1 0 + serial: serial.c $(CC) $(CFLAGS) -o serial serial.c