summaryrefslogtreecommitdiffstats
path: root/dis/Field/field.c
diff options
context:
space:
mode:
Diffstat (limited to 'dis/Field/field.c')
-rw-r--r--dis/Field/field.c162
1 files changed, 81 insertions, 81 deletions
diff --git a/dis/Field/field.c b/dis/Field/field.c
index f83a403..248f779 100644
--- a/dis/Field/field.c
+++ b/dis/Field/field.c
@@ -1,28 +1,27 @@
1/* 1/*
2 * Sample code for the DIS Field Stressmark 2 * Sample code for the DIS Field Stressmark
3 * 3 *
4 * This source code is the completely correct source code based on 4 * This source code is the completely correct source code based on
5 * the example codes provided by Atlantic Aerospace Division, Titan 5 * the example codes provided by Atlantic Aerospace Division, Titan
6 * Systems Corporation, 2000. 6 * Systems Corporation, 2000.
7 * 7 *
8 * If you just compile and generate the executables from this source 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 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 10 * understanding of this stressmark, it is strongly suggested that you
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 */ 14 */
15 15
16#include <stdio.h>
17#include <time.h>
18#include <assert.h>
19#include <stdlib.h>
20#include "DISstressmarkRNG.h" 16#include "DISstressmarkRNG.h"
21#include "extra.h" 17#include "extra.h"
22 18#include <assert.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <time.h>
23 22
24#define MIN_FIELD_SIZE 16 23#define MIN_FIELD_SIZE 16
25#define MAX_FIELD_SIZE (16777216*4) // This has been quadrupled from original 24#define MAX_FIELD_SIZE (16777216 * 4) // This has been quadrupled from original
26#define MIN_SEED -2147483647 25#define MIN_SEED -2147483647
27#define MAX_SEED -1 26#define MAX_SEED -1
28#define MIN_MOD_OFFSET 0 27#define MIN_MOD_OFFSET 0
@@ -39,7 +38,7 @@
39 * main() 38 * main()
40 */ 39 */
41 40
42int main(int argc, char** argv){ 41int main(int argc, char **argv) {
43 SET_UP 42 SET_UP
44 unsigned char *field; 43 unsigned char *field;
45 unsigned int f; 44 unsigned int f;
@@ -48,17 +47,17 @@ int main(int argc, char** argv){
48 unsigned int n; 47 unsigned int n;
49 48
50 time_t startTime, endTime; 49 time_t startTime, endTime;
51 50
52 struct tokenS{ 51 struct tokenS {
53 unsigned char delimiter[MAX_TOKEN_LENGTH]; 52 unsigned char delimiter[MAX_TOKEN_LENGTH];
54 unsigned char length; 53 unsigned char length;
55 struct statisticS{ 54 struct statisticS {
56 unsigned int count; 55 unsigned int count;
57 unsigned char min; 56 unsigned char min;
58 unsigned char sum; 57 unsigned char sum;
59 }stat[MAX_SUBFIELDS]; 58 } stat[MAX_SUBFIELDS];
60 unsigned char subfields; 59 unsigned char subfields;
61 }token[MAX_TOKENS]; 60 } token[MAX_TOKENS];
62 61
63 unsigned int l; 62 unsigned int l;
64 63
@@ -68,91 +67,92 @@ int main(int argc, char** argv){
68 assert((seed >= MIN_SEED) && (seed <= MAX_SEED)); 67 assert((seed >= MIN_SEED) && (seed <= MAX_SEED));
69 assert((mod_offset >= MIN_MOD_OFFSET) && (mod_offset <= MAX_MOD_OFFSET)); 68 assert((mod_offset >= MIN_MOD_OFFSET) && (mod_offset <= MAX_MOD_OFFSET));
70 assert((n >= MIN_TOKENS) && (n <= MAX_TOKENS)); 69 assert((n >= MIN_TOKENS) && (n <= MAX_TOKENS));
71 for (l=0; l<n; l++){ 70 for (l = 0; l < n; l++) {
72 int x; 71 int x;
73 int index; 72 int index;
74 index = 0; 73 index = 0;
75 assert(fscanf(stdin,"%x", &x) == 1); 74 assert(fscanf(stdin, "%x", &x) == 1);
76 while(x!=0){ 75 while (x != 0) {
77 assert((x >= MIN_TOKEN_VALUE) && (x <= MAX_TOKEN_VALUE)); 76 assert((x >= MIN_TOKEN_VALUE) && (x <= MAX_TOKEN_VALUE));
78 token[l].delimiter[index] = (unsigned char )x; 77 token[l].delimiter[index] = (unsigned char)x;
79 index++; 78 index++;
80 assert(fscanf(stdin,"%x", &x) == 1); 79 assert(fscanf(stdin, "%x", &x) == 1);
81 }
82 assert((index >= MIN_TOKEN_LENGTH) && (index <= MAX_TOKEN_LENGTH));
83 token[l].length = index;
84 } 80 }
81 assert((index >= MIN_TOKEN_LENGTH) && (index <= MAX_TOKEN_LENGTH));
82 token[l].length = index;
83 }
85 84
86 if ((field = (unsigned char*)malloc(f*sizeof(unsigned char))) == NULL) 85 if ((field = (unsigned char *)malloc(f * sizeof(unsigned char))) == NULL)
87 return (-1); 86 return (-1);
88 87
89 randInit(seed); 88 randInit(seed);
90 for (l =0; l<f; l++){ 89 for (l = 0; l < f; l++) {
91 field[l] = randInt(MIN_TOKEN_VALUE, MAX_TOKEN_VALUE); 90 field[l] = randInt(MIN_TOKEN_VALUE, MAX_TOKEN_VALUE);
92 } 91 }
93 92
94 startTime = time(NULL); 93 startTime = time(NULL);
95 START_LOOP 94 START_LOOP
96 95
97 for (l =0; l<n; l++){ 96 for (l = 0; l < n; l++) {
98 unsigned int index; 97 unsigned int index;
99 98
100 token[l].subfields = 0; 99 token[l].subfields = 0;
101 token[l].stat[0].count = 0; 100 token[l].stat[0].count = 0;
102 token[l].stat[0].sum = 0; 101 token[l].stat[0].sum = 0;
103 token[l].stat[0].min = MAX_TOKEN_VALUE; 102 token[l].stat[0].min = MAX_TOKEN_VALUE;
104 103
105 index = 0; 104 index = 0;
106 while ((index < f) && (token[l].subfields < MAX_SUBFIELDS)){ 105 while ((index < f) && (token[l].subfields < MAX_SUBFIELDS)) {
107 unsigned char offset; 106 unsigned char offset;
108 offset = 0; 107 offset = 0;
109 while ((field[index+offset] == token[l].delimiter[offset]) && 108 while ((field[index + offset] == token[l].delimiter[offset]) &&
110 (offset < token[l].length)){ 109 (offset < token[l].length)) {
111 offset++; 110 offset++;
112 } 111 }
113 112
114 if (offset == token[l].length){ 113 if (offset == token[l].length) {
115 for (offset=0; offset<token[l].length; offset++){ 114 for (offset = 0; offset < token[l].length; offset++) {
116 field[index+offset] = (field[index+offset] + 115 field[index + offset] = (field[index + offset] +
117 field[(index+offset+mod_offset) % f]) 116 field[(index + offset + mod_offset) % f]) %
118 %(MAX_TOKEN_VALUE+1); 117 (MAX_TOKEN_VALUE + 1);
119 } 118 }
120 index += token[l].length-1; 119 index += token[l].length - 1;
121 token[l].subfields++; 120 token[l].subfields++;
122 token[l].stat[token[l].subfields].count = 0; 121 token[l].stat[token[l].subfields].count = 0;
123 token[l].stat[token[l].subfields].sum = 0; 122 token[l].stat[token[l].subfields].sum = 0;
124 token[l].stat[token[l].subfields].min = MAX_TOKEN_VALUE; 123 token[l].stat[token[l].subfields].min = MAX_TOKEN_VALUE;
125 } 124 }
126 125
127 else{ 126 else {
128 token[l].stat[token[l].subfields].count++; 127 token[l].stat[token[l].subfields].count++;
129 token[l].stat[token[l].subfields].sum += field[index]; 128 token[l].stat[token[l].subfields].sum += field[index];
130 if (token[l].stat[token[l].subfields].min > field[index]) 129 if (token[l].stat[token[l].subfields].min > field[index])
131 token[l].stat[token[l].subfields].min = field[index]; 130 token[l].stat[token[l].subfields].min = field[index];
132 } 131 }
133 index++; 132 index++;
134 } 133 }
135 token[l].subfields++; 134 token[l].subfields++;
136 } 135 }
137 136
138 STOP_LOOP 137 STOP_LOOP
139 endTime = time(NULL); 138 endTime = time(NULL);
140 139
141 volatile int sumAll = 0; 140 volatile int sumAll = 0;
142 for (l = 0; l< n; l++){ 141 for (l = 0; l < n; l++) {
143 unsigned int ll; 142 unsigned int ll;
144 //fprintf(stdout, "%d subfields for token %d \n", token[l].subfields, l); 143 // fprintf(stdout, "%d subfields for token %d \n", token[l].subfields, l);
145 sumAll += token[l].subfields + l; 144 sumAll += token[l].subfields + l;
146 for ( ll =0; ll<token[l].subfields; ll++) { 145 for (ll = 0; ll < token[l].subfields; ll++) {
147 sumAll += ll + token[l].stat[ll].count + token[l].stat[ll].min + token[l].stat[ll].sum; 146 sumAll += ll + token[l].stat[ll].count + token[l].stat[ll].min +
148 /*fprintf(stdout, "subfields %d:\tcount = %d\tmin= %x\tsum= %x\n", 147 token[l].stat[ll].sum;
149 ll, token[l].stat[ll].count, 148 /*fprintf(stdout, "subfields %d:\tcount = %d\tmin= %x\tsum= %x\n",
150 token[l].stat[ll].min, token[l].stat[ll].sum);*/ 149 ll, token[l].stat[ll].count,
151 } 150 token[l].stat[ll].min, token[l].stat[ll].sum);*/
152 } 151 }
153 fprintf(stderr, "time for field stressmark = %f seconds.\n",
154 difftime(endTime, startTime));
155 free(field);
156 WRITE_TO_FILE
157 return(0);
158 } 152 }
153 fprintf(stderr, "time for field stressmark = %f seconds.\n",
154 difftime(endTime, startTime));
155 free(field);
156 WRITE_TO_FILE
157 return (0);
158}