diff options
author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-06-11 21:44:56 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-06-11 21:44:56 -0400 |
commit | e9285d0cdea756a2830f0ace378e4197b36869aa (patch) | |
tree | c936ca400ec6593b24aadb75f961229f0b238e01 | |
parent | 18b1585116344646e544d6e3a92f3690356026a9 (diff) |
Add initial instrumentation to and fix warnings in DIS stressmarks
Changes:
- Backpoint fix to randInt range
- Instrument benchmarks with time tracking
- assert inputs are correct length to fix compiler warnings
Problems:
- Timing on a per-loop basis is non representative of real-world
workloads, as we clear the cache after every loop. These all need
to be re-instrumented to record times for the whole benchmark,
rather than per-loop.
-rw-r--r-- | dis/original/Field/field.c | 9 | ||||
-rwxr-xr-x | dis/original/Matrix/ver2/matrix.c | 12 | ||||
-rw-r--r-- | dis/original/Neighborhood/neighborhood.c | 6 | ||||
-rw-r--r-- | dis/original/Pointer/pointer.c | 10 | ||||
-rw-r--r-- | dis/original/Transitive/transitive.c | 7 | ||||
-rw-r--r-- | dis/original/Update/update.c | 8 |
6 files changed, 32 insertions, 20 deletions
diff --git a/dis/original/Field/field.c b/dis/original/Field/field.c index a561f72..8565e8c 100644 --- a/dis/original/Field/field.c +++ b/dis/original/Field/field.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | 23 | ||
24 | #define MIN_FIELD_SIZE 16 | 24 | #define MIN_FIELD_SIZE 16 |
25 | #define MAX_FIELD_SIZE 16777216 | 25 | #define MAX_FIELD_SIZE (16777216*4) // This has been quadrupled from original |
26 | #define MIN_SEED -2147483647 | 26 | #define MIN_SEED -2147483647 |
27 | #define MAX_SEED -1 | 27 | #define MAX_SEED -1 |
28 | #define MIN_MOD_OFFSET 0 | 28 | #define MIN_MOD_OFFSET 0 |
@@ -62,7 +62,7 @@ int main(int argc, char** argv){ | |||
62 | 62 | ||
63 | unsigned int l; | 63 | unsigned int l; |
64 | 64 | ||
65 | fscanf(stdin, "%d %d %d %d", &f, &seed, &mod_offset, &n); | 65 | assert(fscanf(stdin, "%d %d %d %d", &f, &seed, &mod_offset, &n) == 4); |
66 | 66 | ||
67 | assert((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); | 67 | assert((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); |
68 | assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); | 68 | assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); |
@@ -72,12 +72,12 @@ int main(int argc, char** argv){ | |||
72 | int x; | 72 | int x; |
73 | int index; | 73 | int index; |
74 | index = 0; | 74 | index = 0; |
75 | fscanf(stdin,"%x", &x); | 75 | assert(fscanf(stdin,"%x", &x) == 1); |
76 | while(x!=0){ | 76 | while(x!=0){ |
77 | assert((x >= MIN_TOKEN_VALUE) && (x <= MAX_TOKEN_VALUE)); | 77 | assert((x >= MIN_TOKEN_VALUE) && (x <= MAX_TOKEN_VALUE)); |
78 | token[l].delimiter[index] = (unsigned char )x; | 78 | token[l].delimiter[index] = (unsigned char )x; |
79 | index++; | 79 | index++; |
80 | fscanf(stdin,"%x", &x); | 80 | assert(fscanf(stdin,"%x", &x) == 1); |
81 | } | 81 | } |
82 | assert((index >= MIN_TOKEN_LENGTH) && (index <= MAX_TOKEN_LENGTH)); | 82 | assert((index >= MIN_TOKEN_LENGTH) && (index <= MAX_TOKEN_LENGTH)); |
83 | token[l].length = index; | 83 | token[l].length = index; |
@@ -132,6 +132,7 @@ int main(int argc, char** argv){ | |||
132 | } | 132 | } |
133 | index++; | 133 | index++; |
134 | } | 134 | } |
135 | token[l].subfields++; | ||
135 | STOP_LOOP | 136 | STOP_LOOP |
136 | } | 137 | } |
137 | 138 | ||
diff --git a/dis/original/Matrix/ver2/matrix.c b/dis/original/Matrix/ver2/matrix.c index 56245a6..957d7c5 100755 --- a/dis/original/Matrix/ver2/matrix.c +++ b/dis/original/Matrix/ver2/matrix.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <time.h> | 41 | #include <time.h> |
42 | #include <assert.h> | 42 | #include <assert.h> |
43 | #include "DISstressmarkRNG.h" | 43 | #include "DISstressmarkRNG.h" |
44 | #include "extra.h" | ||
44 | 45 | ||
45 | #define MIN_SEED -2147483647 | 46 | #define MIN_SEED -2147483647 |
46 | #define MAX_SEED -1 | 47 | #define MAX_SEED -1 |
@@ -60,6 +61,8 @@ | |||
60 | */ | 61 | */ |
61 | 62 | ||
62 | static int dim; | 63 | static int dim; |
64 | int argc; | ||
65 | char** argv; | ||
63 | 66 | ||
64 | /* | 67 | /* |
65 | * matrix * vector | 68 | * matrix * vector |
@@ -329,6 +332,7 @@ void biConjugateGradient(double *value, | |||
329 | int i; | 332 | int i; |
330 | int l; | 333 | int l; |
331 | int ll; | 334 | int ll; |
335 | SET_UP | ||
332 | 336 | ||
333 | alpha = 0; | 337 | alpha = 0; |
334 | beta = 0; | 338 | beta = 0; |
@@ -365,6 +369,7 @@ void biConjugateGradient(double *value, | |||
365 | iteration = 0; | 369 | iteration = 0; |
366 | 370 | ||
367 | while ((iteration < maxIterations) && (error > errorTolerance)){ | 371 | while ((iteration < maxIterations) && (error > errorTolerance)){ |
372 | START_LOOP | ||
368 | 373 | ||
369 | /* | 374 | /* |
370 | * alpha = (transpose(vectorR) * vectorR) / | 375 | * alpha = (transpose(vectorR) * vectorR) / |
@@ -429,6 +434,7 @@ void biConjugateGradient(double *value, | |||
429 | error = vectorValue(tmpVector1)/vectorValue(vectorB); | 434 | error = vectorValue(tmpVector1)/vectorValue(vectorB); |
430 | 435 | ||
431 | iteration++; | 436 | iteration++; |
437 | STOP_LOOP | ||
432 | } | 438 | } |
433 | 439 | ||
434 | *actualError = error; | 440 | *actualError = error; |
@@ -440,6 +446,7 @@ void biConjugateGradient(double *value, | |||
440 | 446 | ||
441 | free(vectorR); | 447 | free(vectorR); |
442 | free(vectorP); | 448 | free(vectorP); |
449 | WRITE_TO_FILE | ||
443 | 450 | ||
444 | return; | 451 | return; |
445 | } | 452 | } |
@@ -508,9 +515,10 @@ void create_CRS(double *matrixA, | |||
508 | } | 515 | } |
509 | 516 | ||
510 | 517 | ||
511 | 518 | int main(int _argc, char** _argv) | |
512 | int main() | ||
513 | { | 519 | { |
520 | argc = _argc; | ||
521 | argv = _argv; | ||
514 | int seed; | 522 | int seed; |
515 | int numberNonzero; | 523 | int numberNonzero; |
516 | int maxIterations; | 524 | int maxIterations; |
diff --git a/dis/original/Neighborhood/neighborhood.c b/dis/original/Neighborhood/neighborhood.c index 2d50336..1736d38 100644 --- a/dis/original/Neighborhood/neighborhood.c +++ b/dis/original/Neighborhood/neighborhood.c | |||
@@ -42,10 +42,10 @@ int main(int argc, char** argv) | |||
42 | time_t endTime; | 42 | time_t endTime; |
43 | SET_UP | 43 | SET_UP |
44 | 44 | ||
45 | fscanf(stdin, "%ld %d %d %d %d %d %d %d", | 45 | assert(fscanf(stdin, "%ld %d %d %d %d %d %d %d", |
46 | &seed, &bitDepth, &dimension, &numberLines, | 46 | &seed, &bitDepth, &dimension, &numberLines, |
47 | &minThickness, &maxThickness, | 47 | &minThickness, &maxThickness, |
48 | &distanceShort, &distanceLong); | 48 | &distanceShort, &distanceLong) == 8); |
49 | 49 | ||
50 | assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); | 50 | assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); |
51 | assert((dimension > 0) && (dimension <= MAX_DIMENSION)); | 51 | assert((dimension > 0) && (dimension <= MAX_DIMENSION)); |
@@ -70,7 +70,7 @@ int main(int argc, char** argv) | |||
70 | endTime = time(NULL); | 70 | endTime = time(NULL); |
71 | WRITE_TO_FILE | 71 | WRITE_TO_FILE |
72 | 72 | ||
73 | printf(" end time is %d\n", endTime); | 73 | // printf(" end time is %d\n", endTime); |
74 | 74 | ||
75 | fprintf(stdout, "%9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e", | 75 | fprintf(stdout, "%9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e", |
76 | values.distShort.deg0.entropy, | 76 | values.distShort.deg0.entropy, |
diff --git a/dis/original/Pointer/pointer.c b/dis/original/Pointer/pointer.c index a0aa62e..5671697 100644 --- a/dis/original/Pointer/pointer.c +++ b/dis/original/Pointer/pointer.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include "extra.h" | 20 | #include "extra.h" |
21 | 21 | ||
22 | #define MIN_FIELD_SIZE 16 | 22 | #define MIN_FIELD_SIZE 16 |
23 | #define MAX_FIELD_SIZE 16777216 | 23 | #define MAX_FIELD_SIZE (16777216*4) // Modifed from original |
24 | #define MIN_WINDOW_SIZE 1 | 24 | #define MIN_WINDOW_SIZE 1 |
25 | #define MAX_WINDOW_SIZE 15 | 25 | #define MAX_WINDOW_SIZE 15 |
26 | #define MIN_HOP_LIMIT 1 | 26 | #define MIN_HOP_LIMIT 1 |
@@ -56,8 +56,8 @@ int main(int argc, char** argv){ | |||
56 | unsigned int l; | 56 | unsigned int l; |
57 | SET_UP | 57 | SET_UP |
58 | 58 | ||
59 | fscanf(stdin, "%lu %u %lu %ld %u", | 59 | assert(fscanf(stdin, "%lu %u %lu %ld %u", |
60 | &f, &l, &maxhops, &seed, &n); | 60 | &f, &l, &maxhops, &seed, &n) == 5); |
61 | 61 | ||
62 | assert ((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); | 62 | assert ((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); |
63 | w = (unsigned int) l; | 63 | w = (unsigned int) l; |
@@ -72,8 +72,8 @@ int main(int argc, char** argv){ | |||
72 | return (-1); | 72 | return (-1); |
73 | 73 | ||
74 | for (l=0; l<n; l++){ | 74 | for (l=0; l<n; l++){ |
75 | fscanf(stdin, "%lu %lu %lu", | 75 | assert(fscanf(stdin, "%lu %lu %lu", |
76 | &(thread[l].initial), &(thread[l].minStop), &(thread[l].maxStop)); | 76 | &(thread[l].initial), &(thread[l].minStop), &(thread[l].maxStop)) == 3); |
77 | assert ((thread[l].initial >= 0) && (thread[l].initial < f)); | 77 | assert ((thread[l].initial >= 0) && (thread[l].initial < f)); |
78 | assert ((thread[l].minStop >= 0) && (thread[l].minStop < f)); | 78 | assert ((thread[l].minStop >= 0) && (thread[l].minStop < f)); |
79 | assert ((thread[l].maxStop >= 0) && (thread[l].maxStop < f)); | 79 | assert ((thread[l].maxStop >= 0) && (thread[l].maxStop < f)); |
diff --git a/dis/original/Transitive/transitive.c b/dis/original/Transitive/transitive.c index ca16a31..5fa52e8 100644 --- a/dis/original/Transitive/transitive.c +++ b/dis/original/Transitive/transitive.c | |||
@@ -11,6 +11,9 @@ | |||
11 | * read the Benchmark Analysis and Specifications Document Version 1.0 | 11 | * read the Benchmark Analysis and Specifications Document Version 1.0 |
12 | * before going on since the detailed comments are given in this documents. | 12 | * before going on since the detailed comments are given in this documents. |
13 | * the comments are not repeated here. | 13 | * the comments are not repeated here. |
14 | * | ||
15 | * CHANGELOG: | ||
16 | * Joshua Bakita, 05/30/2020: Fixed out-of-bounds randInt call | ||
14 | */ | 17 | */ |
15 | 18 | ||
16 | #include <stdio.h> | 19 | #include <stdio.h> |
@@ -64,8 +67,8 @@ int main(int argc, char** argv){ | |||
64 | 67 | ||
65 | randInit(seed); | 68 | randInit(seed); |
66 | for (k=0; k<m; k++){ | 69 | for (k=0; k<m; k++){ |
67 | i = randInt(0, n); | 70 | i = randInt(0, n-1); |
68 | j = randInt(0, n); | 71 | j = randInt(0, n-1); |
69 | *(din + j*n + i) = randInt(MIN_EDGES, MAX_EDGES); | 72 | *(din + j*n + i) = randInt(MIN_EDGES, MAX_EDGES); |
70 | } | 73 | } |
71 | 74 | ||
diff --git a/dis/original/Update/update.c b/dis/original/Update/update.c index 92384cd..1fd8197 100644 --- a/dis/original/Update/update.c +++ b/dis/original/Update/update.c | |||
@@ -55,8 +55,8 @@ int main(int argc, char** argv){ | |||
55 | unsigned int hops; | 55 | unsigned int hops; |
56 | unsigned int l; | 56 | unsigned int l; |
57 | 57 | ||
58 | fscanf(stdin, "%u %u %u %d %u %u %u", | 58 | assert(fscanf(stdin, "%u %u %u %d %u %u %u", |
59 | &f, &l, &maxhops, &seed, &initial, &minStop, &maxStop); | 59 | &f, &l, &maxhops, &seed, &initial, &minStop, &maxStop) == 7); |
60 | 60 | ||
61 | assert((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); | 61 | assert((f >= MIN_FIELD_SIZE) && (f <= MAX_FIELD_SIZE)); |
62 | w = (unsigned int )l; | 62 | w = (unsigned int )l; |
@@ -92,7 +92,7 @@ int main(int argc, char** argv){ | |||
92 | unsigned int max, min; | 92 | unsigned int max, min; |
93 | unsigned int partition; | 93 | unsigned int partition; |
94 | unsigned int high; | 94 | unsigned int high; |
95 | START_LOOP | 95 | if (hops % 100 == 0) {START_LOOP} // These loops are too quick to sample individually |
96 | max = MAX_FIELD_SIZE; | 96 | max = MAX_FIELD_SIZE; |
97 | min = 0; | 97 | min = 0; |
98 | high = 0; | 98 | high = 0; |
@@ -125,7 +125,7 @@ int main(int argc, char** argv){ | |||
125 | field[index] = sum % (f-w); | 125 | field[index] = sum % (f-w); |
126 | index = (partition+hops)%(f-w); | 126 | index = (partition+hops)%(f-w); |
127 | hops++; | 127 | hops++; |
128 | STOP_LOOP | 128 | if (hops % 100 == 0) {STOP_LOOP} // These loops are too quick to sample individually |
129 | }/* end for loop */ | 129 | }/* end for loop */ |
130 | 130 | ||
131 | startTime = time(NULL) - startTime; | 131 | startTime = time(NULL) - startTime; |