diff options
| author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-16 16:55:14 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-16 16:55:14 -0400 |
| commit | 6ea9939e0610a809f6f47d13ec68df00d1ca0afc (patch) | |
| tree | fe4a2eee3ddcf77e2367309dcd75a232b76dcd62 /dis/Neighborhood/neighborhood.c | |
| parent | e9285d0cdea756a2830f0ace378e4197b36869aa (diff) | |
Move the DIS benchmarks up a directory and update hardcoded paths
Note that this repo does not attempt to keep a copy of the original
DIS benchmark distributions. UNC real-time has another repo for that.
Diffstat (limited to 'dis/Neighborhood/neighborhood.c')
| -rw-r--r-- | dis/Neighborhood/neighborhood.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/dis/Neighborhood/neighborhood.c b/dis/Neighborhood/neighborhood.c new file mode 100644 index 0000000..1736d38 --- /dev/null +++ b/dis/Neighborhood/neighborhood.c | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | /* | ||
| 2 | * Sample code for the DIS Neighborhood Stressmark | ||
| 3 | * | ||
| 4 | * This source code is the completely correct source code based on | ||
| 5 | * the example codes provided by Atlantic Aerospace Division, Titan | ||
| 6 | * Systems Corporation, 2000. | ||
| 7 | * | ||
| 8 | * If you just compile and generate the executables from this source | ||
| 9 | * code, this code would be enough. However, if you wish to get a complete | ||
| 10 | * understanding of this stressmark, it is strongly suggested that you | ||
| 11 | * read the Benchmark Analysis and Specifications Document Version 1.0 | ||
| 12 | * before going on since the detailed comments are given in this documents. | ||
| 13 | * the comments are not repeated here. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #include <stdio.h> | ||
| 17 | #include <stdlib.h> | ||
| 18 | #include <time.h> | ||
| 19 | #include<assert.h> | ||
| 20 | #include "DISstressmarkRNG.h" | ||
| 21 | #include "utili.h" | ||
| 22 | #include "extra.h" | ||
| 23 | |||
| 24 | /* | ||
| 25 | * main() | ||
| 26 | */ | ||
| 27 | int main(int argc, char** argv) | ||
| 28 | { | ||
| 29 | long int seed; | ||
| 30 | int dimension; | ||
| 31 | int numberLines; | ||
| 32 | int minThickness; | ||
| 33 | int maxThickness; | ||
| 34 | int distanceShort; | ||
| 35 | int distanceLong; | ||
| 36 | int bitDepth; | ||
| 37 | int maxPixel; | ||
| 38 | Pixel *image; | ||
| 39 | Neighborhood values; | ||
| 40 | |||
| 41 | time_t beginTime; | ||
| 42 | time_t endTime; | ||
| 43 | SET_UP | ||
| 44 | |||
| 45 | assert(fscanf(stdin, "%ld %d %d %d %d %d %d %d", | ||
| 46 | &seed, &bitDepth, &dimension, &numberLines, | ||
| 47 | &minThickness, &maxThickness, | ||
| 48 | &distanceShort, &distanceLong) == 8); | ||
| 49 | |||
| 50 | assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); | ||
| 51 | assert((dimension > 0) && (dimension <= MAX_DIMENSION)); | ||
| 52 | assert((numberLines > 0) && (numberLines <= MAX_NUMBER_LINES)); | ||
| 53 | assert((minThickness > 0) && (minThickness < dimension)); | ||
| 54 | assert((maxThickness >= minThickness) && (maxThickness < dimension)); | ||
| 55 | assert((distanceShort > 0) && (distanceShort < dimension)); | ||
| 56 | assert((distanceLong > 0) && (distanceLong < dimension)); | ||
| 57 | assert((bitDepth >= MIN_BIT_DEPTH) && (bitDepth <= MAX_BIT_DEPTH)); | ||
| 58 | |||
| 59 | randInit(seed); | ||
| 60 | maxPixel = (1 << bitDepth) - 1; | ||
| 61 | image = createImage(dimension, maxPixel, numberLines, | ||
| 62 | minThickness, maxThickness); | ||
| 63 | assert (image != NULL); | ||
| 64 | |||
| 65 | beginTime = time(NULL); | ||
| 66 | START_LOOP | ||
| 67 | neighborhoodCalculation(image, dimension, | ||
| 68 | distanceShort, distanceLong, &values, maxPixel); | ||
| 69 | STOP_LOOP | ||
| 70 | endTime = time(NULL); | ||
| 71 | WRITE_TO_FILE | ||
| 72 | |||
| 73 | // printf(" end time is %d\n", endTime); | ||
| 74 | |||
| 75 | fprintf(stdout, "%9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e", | ||
| 76 | values.distShort.deg0.entropy, | ||
| 77 | values.distShort.deg0.energy, | ||
| 78 | values.distShort.deg45.entropy, | ||
| 79 | values.distShort.deg45.energy, | ||
| 80 | values.distShort.deg90.entropy, | ||
| 81 | values.distShort.deg90.energy, | ||
| 82 | values.distShort.deg135.entropy, | ||
| 83 | values.distShort.deg135.energy); | ||
| 84 | |||
| 85 | fprintf(stdout,"%9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e", | ||
| 86 | values.distLong.deg0.entropy, | ||
| 87 | values.distLong.deg0.energy,values.distShort.deg45.entropy, | ||
| 88 | values.distLong.deg45.energy, | ||
| 89 | values.distLong.deg90.entropy, | ||
| 90 | values.distLong.deg90.energy, | ||
| 91 | values.distLong.deg135.entropy, | ||
| 92 | values.distLong.deg135.energy); | ||
| 93 | |||
| 94 | fprintf(stderr, "time for neghborhood stressmark = %f\n", | ||
| 95 | difftime(endTime, beginTime)); | ||
| 96 | |||
| 97 | free((Pixel *)image); | ||
| 98 | return (SUCCESS); | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | |||
| 103 | |||
