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).
This commit is contained in:
parent
4e93e0b105
commit
153c0267b6
@ -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_ */
|
||||
|
@ -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<DIM; j++) {
|
||||
m1[i*DIM+j] = random() % 11 - 5;
|
||||
}
|
||||
TEST161_TPROGRESS(0);
|
||||
TEST161_LPROGRESS(0);
|
||||
}
|
||||
nprintf("\n");
|
||||
}
|
||||
@ -100,12 +102,15 @@ static
|
||||
void
|
||||
mul(int *x, const int *a, const int *b)
|
||||
{
|
||||
unsigned i, j, k;
|
||||
unsigned i, j, k, tot;
|
||||
|
||||
tot = 0;
|
||||
for (i=0; i<DIM; i++) {
|
||||
for (j=0; j<DIM; j++) {
|
||||
x[i*DIM+j] = 0;
|
||||
for (k=0; k<DIM; k++) {
|
||||
TEST161_LPROGRESS_N(tot, PROGRESS_INTERVAL);
|
||||
tot++;
|
||||
x[i*DIM+j] += a[i*DIM+k] * b[k*DIM+j];
|
||||
}
|
||||
}
|
||||
@ -214,15 +219,15 @@ dotest(void)
|
||||
grind();
|
||||
t = trace();
|
||||
if (t == right[i]) {
|
||||
tsay("Stage %u #%u done: %d\n", i, me, trace());
|
||||
lsay("\nStage %u #%u done: %d\n", i, me, trace());
|
||||
}
|
||||
else {
|
||||
tsay("Stage %u #%u FAILED: got %d, expected %d\n",
|
||||
lsay("Stage %u #%u FAILED: got %d, expected %d\n",
|
||||
i, me, t, right[i]);
|
||||
success(TEST161_FAIL, SECRET, "/testbin/bigfork");
|
||||
failures++;
|
||||
}
|
||||
TEST161_TPROGRESS(0);
|
||||
TEST161_LPROGRESS(0);
|
||||
}
|
||||
|
||||
for (i=BRANCHES; i-- > 0; ) {
|
||||
|
@ -40,12 +40,15 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <test161/test161.h>
|
||||
#include <test/test.h>
|
||||
|
||||
#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<NumPages; i++) {
|
||||
TEST161_TPROGRESS(i);
|
||||
TEST161_LPROGRESS_N(i, PROGRESS_INTERVAL);
|
||||
sparse[i][0]=i;
|
||||
}
|
||||
|
||||
tprintf("stage [1] done\n");
|
||||
nprintf("\n");
|
||||
lsay("\nstage [1] done\n");
|
||||
|
||||
/* increment each location 5 times */
|
||||
for (j=0; j<5; j++) {
|
||||
for (i=0; i<NumPages; i++) {
|
||||
TEST161_TPROGRESS(i);
|
||||
TEST161_LPROGRESS_N(i, PROGRESS_INTERVAL);
|
||||
sparse[i][0]++;
|
||||
}
|
||||
tprintf("stage [2.%d] done\n", j);
|
||||
nprintf("\n");
|
||||
lsay("\nstage [2.%d] done\n", j);
|
||||
}
|
||||
|
||||
tprintf("stage [2] done\n");
|
||||
lsay("\nstage [2] done\n");
|
||||
|
||||
/* check if the numbers are sane */
|
||||
for (i=NumPages-1; 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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; i<DIM; i++) {
|
||||
for (j=0; j<DIM; j++) {
|
||||
int val=0;
|
||||
for (k=0; k<DIM; k++) {
|
||||
val += m1->m_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);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
* Once the virtual memory assignment is complete, your system
|
||||
* should survive this.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
@ -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<len/sizeof(long); i++) {
|
||||
progress();
|
||||
d[i] = s[i];
|
||||
}
|
||||
}
|
||||
else {
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
|
||||
for (i=0; i<len; i++) {
|
||||
progress();
|
||||
d[i] = s[i];
|
||||
}
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
@ -67,8 +122,6 @@ sort(int *arr, int size)
|
||||
if (size<2) {
|
||||
return;
|
||||
}
|
||||
TEST161_LPROGRESS_N(iters, 4000);
|
||||
++iters;
|
||||
|
||||
pivot = size/2;
|
||||
sort(arr, pivot);
|
||||
@ -78,6 +131,7 @@ sort(int *arr, int size)
|
||||
j = pivot;
|
||||
k = 0;
|
||||
while (i<pivot && j<size) {
|
||||
progress();
|
||||
if (arr[i] < arr[j]) {
|
||||
tmp[k++] = arr[i++];
|
||||
}
|
||||
@ -86,13 +140,15 @@ sort(int *arr, int size)
|
||||
}
|
||||
}
|
||||
while (i<pivot) {
|
||||
progress();
|
||||
tmp[k++] = arr[i++];
|
||||
}
|
||||
while (j<size) {
|
||||
progress();
|
||||
tmp[k++] = arr[j++];
|
||||
}
|
||||
|
||||
memcpy(arr, tmp, size*sizeof(int));
|
||||
local_memcpy(arr, tmp, size*sizeof(int));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -121,7 +177,9 @@ check(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\nChecking...");
|
||||
for (i=0; i<SIZE-1; i++) {
|
||||
TEST161_LPROGRESS_N(i, PROGRESS_INTERVAL);
|
||||
if (A[i] > A[i+1]) {
|
||||
errx(1, "Failed: A[%d] is %d, A[%d] is %d",
|
||||
i, A[i], i+1, A[i+1]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user