Commit 374fbaf0 authored by Matthias Braun's avatar Matthias Braun
Browse files

make fehler68 deterministic

[r15575]
parent a3c0f216
...@@ -29,6 +29,8 @@ main() ...@@ -29,6 +29,8 @@ main()
float *aa = (float *) ca; float *aa = (float *) ca;
float *ab = (float *) cb; float *ab = (float *) cb;
srand(0);
printf("Scalar product\n==============\n\n"); printf("Scalar product\n==============\n\n");
//printf("Array Position: %u, %u, %u, %u\n", a, b, aa, ba/*(unsigned int) &aa[0] % 16, (unsigned int) &ba[0] % 16*/); //printf("Array Position: %u, %u, %u, %u\n", a, b, aa, ba/*(unsigned int) &aa[0] % 16, (unsigned int) &ba[0] % 16*/);
...@@ -42,7 +44,6 @@ main() ...@@ -42,7 +44,6 @@ main()
//printf("(%g * %g) + ", a[i], b[i]); //printf("(%g * %g) + ", a[i], b[i]);
} }
//for(i = 0; i < max_elements - 4; i += 4)
res = scalar_product(aa, ab, max_elements); res = scalar_product(aa, ab, max_elements);
printf("\nResult: %g\n", res); printf("\nResult: %g\n", res);
...@@ -51,19 +52,15 @@ main() ...@@ -51,19 +52,15 @@ main()
float scalar_product(float * a, float * b, unsigned int max_elements) float scalar_product(float * a, float * b, unsigned int max_elements)
{ {
float res; float res = 0;
int i; int i;
/*for(i = 0; i < 4; i++) for(i = 0; i < max_elements; i += 4) {
{ res += a[i] * b[i];
a[i] = (float) (rand() % 10); res += a[i + 1] * b[i + 1];
b[i] = (float) (rand() % 10); res += a[i + 2] * b[i + 2];
res += a[i + 3] * b[i + 3];
printf("(%g * %g) + ", a[i], b[i]); }
}*/
for(i = 0; i < max_elements; i += 4)
res += a[i] * b[i] + a[i + 1] * b[i + 1] + a[i + 2] * b[i + 2] + a[i + 3] * b[i + 3];
return(res); return res;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment