From 153c0267b66ded073535f1429c58e42e4e5824eb Mon Sep 17 00:00:00 2001 From: Scott Haseley Date: Wed, 27 Apr 2016 18:46:44 -0400 Subject: [PATCH] Changes to userland progress to tweak progress output for test161. We needed more periodic progress in some cases due to the large slow down that happens when swapping is implemented (ASST3.3). --- userland/include/test/test.h | 13 +++++ userland/testbin/bigfork/bigfork.c | 15 ++++-- userland/testbin/huge/huge.c | 20 +++---- userland/testbin/matmult/matmult.c | 14 ++--- userland/testbin/parallelvm/parallelvm.c | 19 ++++--- userland/testbin/sort/sort.c | 68 ++++++++++++++++++++++-- 6 files changed, 114 insertions(+), 35 deletions(-) diff --git a/userland/include/test/test.h b/userland/include/test/test.h index 778cfbd..0ecc1fd 100644 --- a/userland/include/test/test.h +++ b/userland/include/test/test.h @@ -78,4 +78,17 @@ nsay(const char *fmt, ...) #endif } +static +inline +void +lsay(const char *fmt, ...) +{ + char buf[256]; + va_list ap; + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + write(STDOUT_FILENO, buf, strlen(buf)); +} + #endif /* _TEST_TEST_H_ */ diff --git a/userland/testbin/bigfork/bigfork.c b/userland/testbin/bigfork/bigfork.c index 52315fd..44546b0 100644 --- a/userland/testbin/bigfork/bigfork.c +++ b/userland/testbin/bigfork/bigfork.c @@ -56,6 +56,8 @@ */ #define DIM 64 +#define PROGRESS_INTERVAL 25000 + static int m1[DIM*DIM], m2[DIM*DIM], m3[DIM*DIM], m4[DIM*DIM]; static const int right[BRANCHES] = { 536763422, @@ -78,7 +80,7 @@ init(void) for (j=0; j 0; ) { diff --git a/userland/testbin/huge/huge.c b/userland/testbin/huge/huge.c index 3ed3db6..3fda277 100644 --- a/userland/testbin/huge/huge.c +++ b/userland/testbin/huge/huge.c @@ -40,12 +40,15 @@ #include #include #include +#include #define PageSize 4096 #define NumPages 512 int sparse[NumPages][PageSize]; /* use only the first element in the row */ +#define PROGRESS_INTERVAL 20 + int main(void) { @@ -55,36 +58,33 @@ main(void) /* move number in so that sparse[i][0]=i */ for (i=0; i=0; i--) { - TEST161_TPROGRESS(i); + TEST161_LPROGRESS_N(i, PROGRESS_INTERVAL); if (sparse[i][0]!=i+5) { - tprintf("BAD NEWS!!! - your VM mechanism has a bug!\n"); + lsay("BAD NEWS!!! - your VM mechanism has a bug!\n"); success(TEST161_FAIL, SECRET, "/testbin/huge"); exit(1); } } - nprintf("\n"); success(TEST161_SUCCESS, SECRET, "/testbin/huge"); return 0; diff --git a/userland/testbin/matmult/matmult.c b/userland/testbin/matmult/matmult.c index a64d85d..7dabbd1 100644 --- a/userland/testbin/matmult/matmult.c +++ b/userland/testbin/matmult/matmult.c @@ -61,7 +61,7 @@ main(void) for (i = 0; i < Dim; i++) { /* first initialize the matrices */ for (j = 0; j < Dim; j++) { - TEST161_TPROGRESS_N(i*Dim + j, 1000); + TEST161_LPROGRESS_N(i*Dim + j, 1000); A[i][j] = i; B[i][j] = j; C[i][j] = 0; @@ -72,7 +72,7 @@ main(void) for (i = 0; i < Dim; i++) { /* then multiply them together */ for (j = 0; j < Dim; j++) { for (k = 0; k < Dim; k++) { - TEST161_TPROGRESS_N(i*j*Dim*Dim + k, 50000); + TEST161_LPROGRESS_N(i*j*Dim*Dim + k, 50000); T[i][j][k] = A[i][k] * B[k][j]; } } @@ -82,7 +82,7 @@ main(void) for (i = 0; i < Dim; i++) { for (j = 0; j < Dim; j++) { for (k = 0; k < Dim; k++) { - TEST161_TPROGRESS_N(i*j*Dim*Dim + k, 50000); + TEST161_LPROGRESS_N(i*j*Dim*Dim + k, 50000); C[i][j] += T[i][j][k]; } } @@ -93,15 +93,15 @@ main(void) for (i = 0; i < Dim; i++) r += C[i][i]; - tprintf("matmult finished.\n"); - tprintf("answer is: %d (should be %d)\n", r, RIGHT); + nprintf("matmult finished.\n"); + nprintf("answer is: %d (should be %d)\n", r, RIGHT); if (r != RIGHT) { - tprintf("FAILED\n"); + nprintf("FAILED\n"); success(TEST161_FAIL, SECRET, "/testbin/matmult"); return 1; } - tprintf("Passed.\n"); + nprintf("Passed.\n"); success(TEST161_SUCCESS, SECRET, "/testbin/matmult"); return 0; } diff --git a/userland/testbin/parallelvm/parallelvm.c b/userland/testbin/parallelvm/parallelvm.c index e5333ea..31b2e58 100644 --- a/userland/testbin/parallelvm/parallelvm.c +++ b/userland/testbin/parallelvm/parallelvm.c @@ -54,6 +54,8 @@ #define NMATS 11 #define JOBSIZE ((NMATS+1)*DIM*DIM*sizeof(int)) +#define PROGRESS_INTERVAL 25000 + static const int right_answers[NJOBS] = { -1337312809, 356204544, @@ -93,18 +95,20 @@ static void multiply(struct matrix *res, const struct matrix *m1, const struct matrix *m2) { - int i, j, k; + int i, j, k, tot; + tot = 0; for (i=0; im_data[i][k]*m2->m_data[k][j]; + TEST161_LPROGRESS_N(tot, PROGRESS_INTERVAL); + tot++; } res->m_data[i][j] = val; } } - TEST161_TPROGRESS(0); } static @@ -186,7 +190,7 @@ go(int mynum) { int r; - tsay("Process %d (pid %d) starting computation...\n", mynum, + lsay("Process %d (pid %d) starting computation...\n", mynum, (int) getpid()); computeall(mynum); r = answer(); @@ -198,8 +202,7 @@ go(int mynum) exit(1); } - tsay("Process %d answer %d: passed\n", mynum, r); - nsay("\nProc %d OK\n", mynum); + lsay("\nProcess %d: OK\n", mynum, r); exit(0); } @@ -328,7 +331,7 @@ makeprocs(bool dowait) if (pids[i]==0) { /* child */ if (dowait) { - tsay("Process %d forked\n", i); + //tsay("Process %d forked\n", i); semopen(&s1); semopen(&s2); semV(&s1, 1); @@ -343,9 +346,9 @@ makeprocs(bool dowait) if (dowait) { semopen(&s1); semopen(&s2); - tsay("Waiting for fork...\n"); + //tsay("Waiting for fork...\n"); semP(&s1, NJOBS); - tsay("Starting computation.\n"); + //tsay("Starting computation.\n"); semV(&s2, NJOBS); } diff --git a/userland/testbin/sort/sort.c b/userland/testbin/sort/sort.c index ed9fdf8..331e5d6 100644 --- a/userland/testbin/sort/sort.c +++ b/userland/testbin/sort/sort.c @@ -35,7 +35,7 @@ * Once the virtual memory assignment is complete, your system * should survive this. */ - +#include #include #include #include @@ -44,6 +44,8 @@ /* Larger than physical memory */ #define SIZE (144*1024) +#define PROGRESS_INTERVAL 8000 +#define NEWLINE_FREQ 100 /* * Quicksort. @@ -55,7 +57,60 @@ * Also, quicksort has somewhat more interesting memory usage patterns. */ -static int iters; +static unsigned iters; + +static inline +void +progress() { + TEST161_LPROGRESS_N(iters, PROGRESS_INTERVAL); + if (iters > 0 && (iters % (PROGRESS_INTERVAL * NEWLINE_FREQ)) == 0) { + printf("\n"); + } + ++iters; +} + +static void * +local_memcpy(void *dst, const void *src, size_t len) +{ + size_t i; + + /* + * memcpy does not support overlapping buffers, so always do it + * forwards. (Don't change this without adjusting memmove.) + * + * For speedy copying, optimize the common case where both pointers + * and the length are word-aligned, and copy word-at-a-time instead + * of byte-at-a-time. Otherwise, copy by bytes. + * + * The alignment logic below should be portable. We rely on + * the compiler to be reasonably intelligent about optimizing + * the divides and modulos out. Fortunately, it is. + */ + + if ((uintptr_t)dst % sizeof(long) == 0 && + (uintptr_t)src % sizeof(long) == 0 && + len % sizeof(long) == 0) { + + long *d = dst; + const long *s = src; + + for (i=0; i A[i+1]) { errx(1, "Failed: A[%d] is %d, A[%d] is %d", i, A[i], i+1, A[i+1]);