From a3886552003d031acb9039e920b7c9ddce946ad6 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Sat, 17 Oct 2020 14:43:46 -0400 Subject: DIS fixes used for (rejected) RTSS'20 submission - All: Output times to stderr and nothing to stdout - Field, Update, Pointer: change definition of a job to match other stressmark execution times more closely - Matrix: move all allocations into main() - Update: Use volatile to prevent computations from being optimized out - Transitive: Use volatile to prevent computations from being optimized out - Neighborhood: Use working version of drawLineSegment from original DIS sample code --- dis/Matrix/ver2/matrix.c | 79 +++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 41 deletions(-) (limited to 'dis/Matrix') diff --git a/dis/Matrix/ver2/matrix.c b/dis/Matrix/ver2/matrix.c index 957d7c5..ffa7cb7 100755 --- a/dis/Matrix/ver2/matrix.c +++ b/dis/Matrix/ver2/matrix.c @@ -48,7 +48,7 @@ #define MIN_DIM 1 #define MAX_DIM 32768 #define MAX_ITERATIONS 65536 -#define MIN_TOLERANCE 0.000007 +#define MIN_TOLERANCE 1e-7//0.000007 #define MAX_TOLERANCE 0.5 #define MIN_NUMBER -3.4e10/dim #define MAX_NUMBER 3.4e10/dim @@ -61,8 +61,6 @@ */ static int dim; -int argc; -char** argv; /* * matrix * vector @@ -312,7 +310,14 @@ void biConjugateGradient(double *value, int maxIterations, double *actualError, int *actualIteration, - int dim) + int dim, + // Start internal matrixes + double *vectorP, + double *vectorR, + double *nextVectorR, + double *tmpVector1, + double *tmpVector2, + double *tmpVector3) /* * in the code, we use a lot of temparary vectors and variables * this is just for simple and clear @@ -321,31 +326,18 @@ void biConjugateGradient(double *value, * */ { - double *vectorR; - double *vectorP, *matrixAvectorP, *nextVectorR; double error; int iteration; double alpha, beta; - double *tmpVector1, *tmpVector2, *tmpVector3; double tmpValue1, tmpValue2; int i; int l; int ll; - SET_UP alpha = 0; beta = 0; - vectorP = (double *)malloc(dim*sizeof(double)); - vectorR = (double *)malloc(dim*sizeof(double)); - nextVectorR = (double *)malloc(dim*sizeof(double)); - vectorX = (double *)malloc(dim*sizeof(double)); - - tmpVector1 = (double *)malloc(dim*sizeof(double)); - tmpVector2 = (double *)malloc(dim*sizeof(double)); - tmpVector3 = (double *)malloc(dim*sizeof(double)); - /* * vectorR = vectorB - matrixA*vectorX */ @@ -369,7 +361,6 @@ void biConjugateGradient(double *value, iteration = 0; while ((iteration < maxIterations) && (error > errorTolerance)){ - START_LOOP /* * alpha = (transpose(vectorR) * vectorR) / @@ -434,7 +425,6 @@ void biConjugateGradient(double *value, error = vectorValue(tmpVector1)/vectorValue(vectorB); iteration++; - STOP_LOOP } *actualError = error; @@ -446,7 +436,6 @@ void biConjugateGradient(double *value, free(vectorR); free(vectorP); - WRITE_TO_FILE return; } @@ -515,10 +504,8 @@ void create_CRS(double *matrixA, } -int main(int _argc, char** _argv) +int main(int argc, char** argv) { - argc = _argc; - argv = _argv; int seed; int numberNonzero; int maxIterations; @@ -536,18 +523,22 @@ int main(int _argc, char** _argv) double *value; int *col_ind; int *row_start; - int sum; + double sum; int k; + // Internal vects for biConj + double *vectorR, *vectorP, *nextVectorR; + double *tmpVector1, *tmpVector2, *tmpVector3; + SET_UP - fscanf(stdin, "%d %d %d %d %f", - &seed, &dim, &numberNonzero,&maxIterations,&errorTolerance); + assert(fscanf(stdin, "%d %d %d %d %f", + &seed, &dim, &numberNonzero,&maxIterations,&errorTolerance) == 5); assert((seed > MIN_SEED) && (seed < MAX_SEED)); assert((dim > MIN_DIM) && (dim < MAX_DIM)); assert((numberNonzero > dim) && (numberNonzero < dim*dim)); assert((maxIterations > 0) && (maxIterations < MAX_ITERATIONS)); assert((errorTolerance > MIN_TOLERANCE) && (errorTolerance < MAX_TOLERANCE)); - matrixA = (double *)malloc(dim*dim*sizeof(double )); + matrixA = (double *)malloc(dim*dim*sizeof(double)); vectorB = (double *)malloc(dim*sizeof(double)); vectorX = (double *)malloc(dim*sizeof(double)); @@ -555,40 +546,46 @@ int main(int _argc, char** _argv) col_ind = (int *)malloc((numberNonzero+dim)*sizeof(int)); row_start = (int *)malloc((dim+1)*sizeof(int)); + // Internal matricies for biConj + vectorP = (double *)malloc(dim*sizeof(double)); + vectorR = (double *)malloc(dim*sizeof(double)); + nextVectorR = (double *)malloc(dim*sizeof(double)); + tmpVector1 = (double *)malloc(dim*sizeof(double)); + tmpVector2 = (double *)malloc(dim*sizeof(double)); + tmpVector3 = (double *)malloc(dim*sizeof(double)); + randInit(seed); + START_LOOP initMatrix(matrixA, dim, numberNonzero); - + create_CRS(matrixA, value, col_ind, row_start, dim, numberNonzero); initVector(vectorB, dim); zeroVector(vectorX, dim); - printf(" after init\n"); beginTime = time(NULL); - + actualError = 0; actualIteration = 0; - + biConjugateGradient(value, col_ind, row_start, vectorB, vectorX, errorTolerance, maxIterations, - &actualError, &actualIteration, dim); - - - - endTime = time(NULL) - beginTime; - + &actualError, &actualIteration, dim, + vectorP, vectorR, nextVectorR, tmpVector1, tmpVector2, tmpVector3); + STOP_LOOP + endTime = time(NULL); sum = 0; for (k=1; k