summaryrefslogtreecommitdiffstats
path: root/dis
diff options
context:
space:
mode:
Diffstat (limited to 'dis')
-rw-r--r--dis/Field/field.c78
-rwxr-xr-xdis/Matrix/ver2/matrix.c40
-rw-r--r--dis/Neighborhood/neighborhood.c14
-rw-r--r--dis/Pointer/pointer.c121
-rw-r--r--dis/Transitive/transitive.c57
-rw-r--r--dis/Update/update.c107
-rwxr-xr-xdis/gen_input.py2
-rw-r--r--dis/inputs/Neighborhood/test1.in1
8 files changed, 211 insertions, 209 deletions
diff --git a/dis/Field/field.c b/dis/Field/field.c
index 248f779..900d47b 100644
--- a/dis/Field/field.c
+++ b/dis/Field/field.c
@@ -86,55 +86,55 @@ int main(int argc, char **argv) {
86 return (-1); 86 return (-1);
87 87
88 randInit(seed); 88 randInit(seed);
89 for (l = 0; l < f; l++) {
90 field[l] = randInt(MIN_TOKEN_VALUE, MAX_TOKEN_VALUE);
91 }
92 89
93 startTime = time(NULL); 90 for_each_job {
94 START_LOOP 91 for (l = 0; l < f; l++) {
92 field[l] = randInt(MIN_TOKEN_VALUE, MAX_TOKEN_VALUE);
93 }
95 94
96 for (l = 0; l < n; l++) { 95 startTime = time(NULL);
97 unsigned int index;
98 96
99 token[l].subfields = 0; 97 for (l = 0; l < n; l++) {
100 token[l].stat[0].count = 0; 98 unsigned int index;
101 token[l].stat[0].sum = 0;
102 token[l].stat[0].min = MAX_TOKEN_VALUE;
103 99
104 index = 0; 100 token[l].subfields = 0;
105 while ((index < f) && (token[l].subfields < MAX_SUBFIELDS)) { 101 token[l].stat[0].count = 0;
106 unsigned char offset; 102 token[l].stat[0].sum = 0;
107 offset = 0; 103 token[l].stat[0].min = MAX_TOKEN_VALUE;
108 while ((field[index + offset] == token[l].delimiter[offset]) &&
109 (offset < token[l].length)) {
110 offset++;
111 }
112 104
113 if (offset == token[l].length) { 105 index = 0;
114 for (offset = 0; offset < token[l].length; offset++) { 106 while ((index < f) && (token[l].subfields < MAX_SUBFIELDS)) {
115 field[index + offset] = (field[index + offset] + 107 unsigned char offset;
116 field[(index + offset + mod_offset) % f]) % 108 offset = 0;
117 (MAX_TOKEN_VALUE + 1); 109 while ((field[index + offset] == token[l].delimiter[offset]) &&
110 (offset < token[l].length)) {
111 offset++;
118 } 112 }
119 index += token[l].length - 1;
120 token[l].subfields++;
121 token[l].stat[token[l].subfields].count = 0;
122 token[l].stat[token[l].subfields].sum = 0;
123 token[l].stat[token[l].subfields].min = MAX_TOKEN_VALUE;
124 }
125 113
126 else { 114 if (offset == token[l].length) {
127 token[l].stat[token[l].subfields].count++; 115 for (offset = 0; offset < token[l].length; offset++) {
128 token[l].stat[token[l].subfields].sum += field[index]; 116 field[index + offset] = (field[index + offset] +
129 if (token[l].stat[token[l].subfields].min > field[index]) 117 field[(index + offset + mod_offset) % f]) %
130 token[l].stat[token[l].subfields].min = field[index]; 118 (MAX_TOKEN_VALUE + 1);
119 }
120 index += token[l].length - 1;
121 token[l].subfields++;
122 token[l].stat[token[l].subfields].count = 0;
123 token[l].stat[token[l].subfields].sum = 0;
124 token[l].stat[token[l].subfields].min = MAX_TOKEN_VALUE;
125 }
126
127 else {
128 token[l].stat[token[l].subfields].count++;
129 token[l].stat[token[l].subfields].sum += field[index];
130 if (token[l].stat[token[l].subfields].min > field[index])
131 token[l].stat[token[l].subfields].min = field[index];
132 }
133 index++;
131 } 134 }
132 index++; 135 token[l].subfields++;
133 } 136 }
134 token[l].subfields++;
135 } 137 }
136
137 STOP_LOOP
138 endTime = time(NULL); 138 endTime = time(NULL);
139 139
140 volatile int sumAll = 0; 140 volatile int sumAll = 0;
diff --git a/dis/Matrix/ver2/matrix.c b/dis/Matrix/ver2/matrix.c
index 2b075fb..5162579 100755
--- a/dis/Matrix/ver2/matrix.c
+++ b/dis/Matrix/ver2/matrix.c
@@ -407,13 +407,6 @@ void biConjugateGradient(double *value, int *col_ind, int *row_start,
407 *actualError = error; 407 *actualError = error;
408 *actualIteration = iteration; 408 *actualIteration = iteration;
409 409
410 free(tmpVector1);
411 free(tmpVector2);
412 free(tmpVector3);
413
414 free(vectorR);
415 free(vectorP);
416
417 return; 410 return;
418} 411}
419 412
@@ -525,27 +518,34 @@ int main(int argc, char **argv) {
525 518
526 randInit(seed); 519 randInit(seed);
527 520
528 START_LOOP 521 for_each_job {
529 initMatrix(matrixA, dim, numberNonzero); 522 initMatrix(matrixA, dim, numberNonzero);
530 523
531 create_CRS(matrixA, value, col_ind, row_start, dim, numberNonzero); 524 create_CRS(matrixA, value, col_ind, row_start, dim, numberNonzero);
532 525
533 initVector(vectorB, dim); 526 initVector(vectorB, dim);
534 zeroVector(vectorX, dim); 527 zeroVector(vectorX, dim);
535 528
536 beginTime = time(NULL); 529 beginTime = time(NULL);
537 530
538 actualError = 0; 531 actualError = 0;
539 actualIteration = 0; 532 actualIteration = 0;
540 533
541 biConjugateGradient(value, col_ind, row_start, vectorB, vectorX, 534 biConjugateGradient(value, col_ind, row_start, vectorB, vectorX,
542 errorTolerance, maxIterations, &actualError, 535 errorTolerance, maxIterations, &actualError,
543 &actualIteration, dim, vectorP, vectorR, nextVectorR, 536 &actualIteration, dim, vectorP, vectorR, nextVectorR,
544 tmpVector1, tmpVector2, tmpVector3); 537 tmpVector1, tmpVector2, tmpVector3);
545 538
546 STOP_LOOP 539 }
547 endTime = time(NULL); 540 endTime = time(NULL);
548 541
542 free(tmpVector1);
543 free(tmpVector2);
544 free(tmpVector3);
545
546 free(vectorR);
547 free(vectorP);
548
549 sum = 0; 549 sum = 0;
550 for (k = 1; k < dim; k++) { 550 for (k = 1; k < dim; k++) {
551 sum += sum + *(vectorX + k); 551 sum += sum + *(vectorX + k);
diff --git a/dis/Neighborhood/neighborhood.c b/dis/Neighborhood/neighborhood.c
index 614b8e8..2d401d3 100644
--- a/dis/Neighborhood/neighborhood.c
+++ b/dis/Neighborhood/neighborhood.c
@@ -63,14 +63,14 @@ int main(int argc, char **argv) {
63 image = malloc(sizeof(Pixel) * dimension * dimension); 63 image = malloc(sizeof(Pixel) * dimension * dimension);
64 assert(image != NULL); 64 assert(image != NULL);
65 65
66 beginTime = time(NULL); 66 for_each_job {
67 START_LOOP 67 beginTime = time(NULL);
68 createImage(image, dimension, maxPixel, numberLines, minThickness, 68 createImage(image, dimension, maxPixel, numberLines, minThickness,
69 maxThickness); 69 maxThickness);
70 70
71 neighborhoodCalculation(image, dimension, distanceShort, distanceLong, 71 neighborhoodCalculation(image, dimension, distanceShort, distanceLong,
72 &values, maxPixel); 72 &values, maxPixel);
73 STOP_LOOP 73 }
74 endTime = time(NULL); 74 endTime = time(NULL);
75 WRITE_TO_FILE 75 WRITE_TO_FILE
76 76
diff --git a/dis/Pointer/pointer.c b/dis/Pointer/pointer.c
index 3f3eefb..d97f276 100644
--- a/dis/Pointer/pointer.c
+++ b/dis/Pointer/pointer.c
@@ -82,68 +82,67 @@ int main(int argc, char **argv) {
82 return (-1); 82 return (-1);
83 83
84 randInit(seed); 84 randInit(seed);
85 for (l = 0; l < f; l++) { 85 for_each_job {
86 field[l] = randInt(0, f - w); 86 for (l = 0; l < f; l++) {
87 } 87 field[l] = rand