diff --git a/Makefile b/Makefile index dc5c6fd..ad17b56 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ DIRS = $(sort $(wildcard src/*)) all: - for i in $(DIRS); do echo $$i; make -s -C $$i; done -t: all -# for i in $(DIRS); do echo $$i; $$i/t; done -b: all - for i in $(DIRS); do echo $$i; $$i/b; done + for i in $(DIRS); do printf "%-20s" $$i; make -s -C $$i; done +t: + @for i in $(DIRS); do printf "%-20s" $$i; make -s -C $$i 2>/dev/null; done +b: t + @for i in $(DIRS); do echo $$i; $$i/b; done clean: for i in $(DIRS); do make -s -C $$i clean; done diff --git a/Makefile.inc b/Makefile.inc index 4613e08..f0ebc00 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -9,7 +9,7 @@ OBJS = $(SRCS:.c=.o) AR=ar RANLIB=ranlib -CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall +CFLAGS += -g -D_POSIX_C_SOURCE=200809L -std=c99 -pipe -Wall -Wno-unused-function LDFLAGS += -g -lpthread -lrt -lm -include $(TROOT)/config.mak diff --git a/common/b.c b/common/b.c index 91f137e..07b299c 100644 --- a/common/b.c +++ b/common/b.c @@ -16,7 +16,7 @@ static int verbose = 1; void error__(const char *n, int l, const char *s, ...) { - fprintf(stderr, "use error in tests only\n"); + dprintf(1, "use error in tests only\n"); } static int N; @@ -32,7 +32,7 @@ static unsigned long long tic() { struct timespec ts; if (clock_gettime(CLOCK_REALTIME, &ts) < 0) { - fprintf(stderr, "bench: clock_gettime failed: %s\n", strerror(errno)); + dprintf(1, "bench: clock_gettime failed: %s\n", strerror(errno)); return 0; } return ts.tv_sec*SEC + ts.tv_nsec; @@ -98,17 +98,17 @@ void vmstats() { } } if (f) fclose(f); - fprintf(stderr, " %7zu virt %7zu res %7zu dirty", vm_size, vm_rss, vm_priv_dirty); + dprintf(1, " %7zu virt %7zu res %7zu dirty", vm_size, vm_rss, vm_priv_dirty); } void stats() { - if (dt/N > 100) - fprintf(stderr, "%10d N %10llu ns/op ", N, dt/N); + if (dt/N >= 100) + dprintf(1, "%10d N %10llu ns/op ", N, dt/N); else - fprintf(stderr, "%10d N %13.2f ns/op", N, (double)dt/N); + dprintf(1, "%10d N %13.2f ns/op", N, (double)dt/N); if (verbose) vmstats(); - fputc('\n', stderr); + dprintf(1, "\n"); } static void run(const char *name, void (*f)(int)) { @@ -116,23 +116,23 @@ static void run(const char *name, void (*f)(int)) { if (p) { int s; if (p<0 || wait(&s)<0 || !WIFEXITED(s) || WEXITSTATUS(s)) - fprintf(stderr, "benchmark %s failed\n", name); + dprintf(1, "benchmark %s failed\n", name); return; } - fprintf(stderr, "%-32s", name); + dprintf(1, "%-32s", name); for (N=1; ; N=nextN()) { // TODO: fork at each iteration and pass N,dt..? reset_timer(); start_timer(); f(N); stop_timer(); -// fprintf(stderr, "%10d%12llu next: %d\n", N, dt, nextN()); +// dprintf(1, "%10d%12llu next: %d\n", N, dt, nextN()); if (dt >= SEC/2 || N >= MAXN) { stats(); exit(0); } if (N <= 0) { - fprintf(stderr, "bench: fatal: N <= 0\n"); + dprintf(1, "bench: fatal: N <= 0\n"); exit(1); } } diff --git a/common/t.c b/common/t.c index ecaaf7f..2373b09 100644 --- a/common/t.c +++ b/common/t.c @@ -29,10 +29,12 @@ void reset_timer() { errtimer(); } void error__(const char *n, int l, const char *s, ...) { va_list ap; + if (failed == 0 && nfailed == 0) + dprintf(1, "FAIL\n", n); failed = 1; - fprintf(stderr, " ERROR %s %s:%d: ", name, n, l); + dprintf(1, " ERROR %s %s:%d: ", name, n, l); va_start(ap, s); - vfprintf(stderr, s, ap); + vdprintf(1, s, ap); va_end(ap); } @@ -44,7 +46,7 @@ static void run(const char *n, void (*f)()) { failed = 0; name = n; if (verbose) - fprintf(stderr, "running %s:\n", name); + dprintf(1, "running %s:\n", name); pid = fork(); if (pid == 0) { @@ -66,21 +68,21 @@ static void run(const char *n, void (*f)()) { if (failed) { nfailed++; - fprintf(stderr, "FAILED %s\n", name); + dprintf(1, "FAILED %s\n", name); } else if (verbose) - fprintf(stderr, "PASSED %s\n", name); + dprintf(1, "PASSED %s\n", name); } static int summary() { if (nfailed) - fprintf(stderr, "FAIL:%d (all: %d)\n", nfailed, count); + dprintf(1, "FAIL (%d out of %d tests)\n", nfailed, count); else - fprintf(stderr, "PASS (all: %d)\n", count); + dprintf(1, "ok (%d tests)\n", count); return !!nfailed; } static void usage() { - fprintf(stderr, "usage: ./t [-vs]\n"); + dprintf(1, "usage: ./t [-vs]\n"); exit(1); } diff --git a/src/udiv/udiv.c b/src/udiv/udiv.c index 945e144..42010ee 100644 --- a/src/udiv/udiv.c +++ b/src/udiv/udiv.c @@ -166,7 +166,7 @@ void test_udiv() } } -void bench_div(int N) +void bench_udiv(int N) { int i; volatile uint64_t r = 0; @@ -176,7 +176,7 @@ void bench_div(int N) r += ((uint64_t)i<<32) / d; } -void bench_mod(int N) +void bench_umod(int N) { int i; volatile uint64_t r = 0;