diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-19 10:50:11 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-19 10:50:11 -0400 |
| commit | 7e6ceb16b53fdbdb2a27cf3ade15d32177ff811f (patch) | |
| tree | d6cf9044570b8b9707e89260d7267bcd69e163e7 /dis/original/Neighborhood/neighborhood.c | |
| parent | 386b7d3366f1359a265da207a9cafa3edf553b64 (diff) | |
Add DIS benchmarks
Diffstat (limited to 'dis/original/Neighborhood/neighborhood.c')
| -rw-r--r-- | dis/original/Neighborhood/neighborhood.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/dis/original/Neighborhood/neighborhood.c b/dis/original/Neighborhood/neighborhood.c new file mode 100644 index 0000000..e3d4f69 --- /dev/null +++ b/dis/original/Neighborhood/neighborhood.c | |||
| @@ -0,0 +1,100 @@ | |||
| 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 | |||
| 23 | /* | ||
| 24 | * main() | ||
| 25 | */ | ||
| 26 | int main() | ||
| 27 | { | ||
| 28 | long int seed; | ||
| 29 | int dimension; | ||
| 30 | int numberLines; | ||
| 31 | int minThickness; | ||
| 32 | int maxThickness; | ||
| 33 | int distanceShort; | ||
| 34 | int distanceLong; | ||
| 35 | int bitDepth; | ||
| 36 | int maxPixel; | ||
| 37 | Pixel *image; | ||
| 38 | Neighborhood values; | ||
| 39 | |||
| 40 | time_t beginTime; | ||
| 41 | time_t endTime; | ||
| 42 | |||
| 43 | fscanf(stdin, "%ld %d %d %d %d %d %d %d", | ||
| 44 | &seed, &bitDepth, &dimension, &numberLines, | ||
| 45 | &minThickness, &maxThickness, | ||
| 46 | &distanceShort, &distanceLong); | ||
| 47 | |||
| 48 | assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); | ||
| 49 | assert((dimension > 0) && (dimension <= MAX_DIMENSION)); | ||
| 50 | assert((numberLines > 0) && (numberLines <= MAX_NUMBER_LINES)); | ||
| 51 | assert((minThickness > 0) && (minThickness < dimension)); | ||
| 52 | assert((maxThickness >= minThickness) && (maxThickness < dimension)); | ||
| 53 | assert((distanceShort > 0) && (distanceShort < dimension)); | ||
| 54 | assert((distanceLong > 0) && (distanceLong < dimension)); | ||
| 55 | assert((bitDepth >= MIN_BIT_DEPTH) && (bitDepth <= MAX_BIT_DEPTH)); | ||
| 56 | |||
| 57 | randInit(seed); | ||
| 58 | maxPixel = (1 << bitDepth) - 1; | ||
| 59 | image = createImage(dimension, maxPixel, numberLines, | ||
| 60 | minThickness, maxThickness); | ||
| 61 | assert (image != NULL); | ||
| 62 | |||
| 63 | beginTime = time(NULL); | ||
| 64 | |||
| 65 | neighborhoodCalculation(image, dimension, | ||
| 66 | distanceShort, distanceLong, &values, maxPixel); | ||
| 67 | |||
| 68 | endTime = time(NULL); | ||
| 69 | |||
| 70 | printf(" end time is %d\n", endTime); | ||
| 71 | |||
| 72 | fprintf(stdout, "%9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e", | ||
| 73 | values.distShort.deg0.entropy, | ||
| 74 | values.distShort.deg0.energy, | ||
| 75 | values.distShort.deg45.entropy, | ||
| 76 | values.distShort.deg45.energy, | ||
| 77 | values.distShort.deg90.entropy, | ||
| 78 | values.distShort.deg90.energy, | ||
| 79 | values.distShort.deg135.entropy, | ||
| 80 | values.distShort.deg135.energy); | ||
| 81 | |||
| 82 | fprintf(stdout,"%9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e %9.4e", | ||
| 83 | values.distLong.deg0.entropy, | ||
| 84 | values.distLong.deg0.energy,values.distShort.deg45.entropy, | ||
| 85 | values.distLong.deg45.energy, | ||
| 86 | values.distLong.deg90.entropy, | ||
| 87 | values.distLong.deg90.energy, | ||
| 88 | values.distLong.deg135.entropy, | ||
| 89 | values.distLong.deg135.energy); | ||
| 90 | |||
| 91 | fprintf(stderr, "time for neghborhood stressmark = %f\n", | ||
| 92 | difftime(endTime, beginTime)); | ||
| 93 | |||
| 94 | free((Pixel *)image); | ||
| 95 | return (SUCCESS); | ||
| 96 | } | ||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | |||
