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:
Scott Haseley
2016-04-27 18:46:44 -04:00
parent 4e93e0b105
commit 153c0267b6
6 changed files with 114 additions and 35 deletions

View File

@@ -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]);