- /* Now, analyze the times to see that they are nearly independent
- * of size */
- for (i = 0; i < NUM_SIZES; i++) {
- /* The difference between the value and the mean is more than
- * a "FRACTION" of mean. */
- if (fabs(t[i] - tmean) > (FRACTION * tmean))
- errs++;
- }
+ /* Now, analyze the times to see that they do not grow too fast
+ * as a function of size. As that is a vague criteria, we do the
+ * following as a simple test:
+ * Compute the mean of the first half and the second half of the
+ * data
+ * Compare the two means
+ * If the mean of the second half is more than FRACTION times the
+ * mean of the first half, then the time may be growing too fast.
+ */
+ tMeanLower = tMeanHigher = 0;
+ for (i = 0; i < NUM_SIZES / 2; i++)
+ tMeanLower += t[i];
+ tMeanLower /= (NUM_SIZES / 2);
+ for (i = NUM_SIZES / 2; i < NUM_SIZES; i++)
+ tMeanHigher += t[i];
+ tMeanHigher /= (NUM_SIZES - NUM_SIZES / 2);
+ /* A large value (even 1 or greater) is a good choice for
+ * FRACTION here - the goal is to detect significant growth in
+ * execution time as the size increases, and there is no MPI
+ * standard requirement here to meet.
+ *
+ * If the times were too small, then the test also passes - the
+ * goal is to find implementation problems that lead to excessive
+ * time in these routines.
+ */
+ if (tMeanLower > 0 && tMeanHigher > (1 + FRACTION) * tMeanLower)
+ errs++;