[cfe-dev] [test-suite] making polybench/symm succeed with "-Ofast" and "-ffp-contract=on"

Sebastian Pop via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 10 07:10:01 PDT 2016


Hi,

I would need some help to fix polybench/symm:

void kernel_symm(int ni, int nj,
DATA_TYPE alpha,
DATA_TYPE beta,
DATA_TYPE POLYBENCH_2D(C,NI,NJ,ni,nj),
DATA_TYPE POLYBENCH_2D(A,NJ,NJ,nj,nj),
DATA_TYPE POLYBENCH_2D(B,NI,NJ,ni,nj))
{
  int i, j, k;
  DATA_TYPE acc;

  /*  C := alpha*A*B + beta*C, A is symetric */
  for (i = 0; i < _PB_NI; i++)
    for (j = 0; j < _PB_NJ; j++)
      {
        acc = 0;
        for (k = 0; k < j - 1; k++)
          {
             C[k][j] += alpha * A[k][i] * B[i][j];
             acc += B[k][j] * A[k][i];
          }
        C[i][j] = beta * C[i][j] + alpha * A[i][i] * B[i][j] + alpha * acc;
      }
}

Compiling this kernel with __attribute__((optnone)) and outputing the
contents of the C[][] array does not match the reference output.
Furthermore, compiling this kernel at -Ofast and comparing against -O0
only passes for FP_ABSTOLERANCE=10.
All the 10 other polybench tests that I have transformed to check FP
are passing at FP_ABSTOLERANCE=1e-5 (and most likely they could pass
at an even more reduced tolerance.)

The symm benchmark seems to accumulate all the errors as it is a big
reduction from the first elements of the C[][] array into the last
elements.
I'm not sure we can rely on this benchmark to check FP correctness.

One option is to completely specify which optimization flags have been
used to compute the reference output and only use that to compile this
benchmark.

Please share your ideas on how to deal with this particular test.

Thanks,
Sebastian



More information about the cfe-dev mailing list