icc 14 produces wrong code with -O3

icc 14 produces wrong code with -O3

Hi,
below you find a small piece of code (which comes from code related to the well Cholesky decomposition, here a matrix with two 6x6 blocks on the diagonal).

  • icc 13.x produces correct code with -O2 and -O3
  • icc 14 produces correct code with -O2, but wrong code with -O3
  • this was tested on two independent icc 14 installations, so it does not seem to be cause by our particular installation

When the "buggy" binary is run, the output varies from run to run (the output vector after the matrix-vector multiplication differs).

Cheers,

Simon

#include <stdlib.h>
#include <stdio.h>
#include <complex.h>

// this multiplies a vector with LL^H, where L is a column-major upper-triangular matrix,
// which frequently arises when using Cholesky decompositions
void buggy_LLH_multiply(float complex *y, float complex *x, float complex *L) {
  int i, j;
  int n;
  float complex z[6];

  for( n=0; n<2; n++) {
    // z = L^H x
    for(j=0; j<6; j++) { // columns
      for(i=0; i<j; i++) { // rows
        z[i] += conjf(*L)*x[j];
        L++;
      }
      z[j] = conjf(*L)*x[j];
      L++;
    }
    L-=21;
    // y = L*z;
    for(i=0; i<6; i++) { // rows
      y[i] = *L * z[0];
      L++;
      for (j=1; j<=i; j++) { // columns
        y[i] += *L * z[j];
        L++;
      }
    }
    x+=6;
    y+=6;
  }
}

int main() {
  float complex matrix[42];
  float complex input_vector[12];
  float complex output_vector[12];
  int i;

  for(i=0; i<42; i++)
    matrix[i] = i;
  for(i=0; i<12; i++)
    input_vector[i] = i;

  buggy_LLH_multiply(output_vector, input_vector, matrix);

  for(i=0; i<12; i++)
    printf("%2d % e % e\n", i, creal(input_vector[i]), creal(output_vector[i]));

  return 0;
}

 

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Alexander Weggerle (Intel)'s picture

Hi Simon,

thanks for reporting this issue. I can reproduce it and unfortunately also for the actual icc 15.0 beta compiler. The issue is related to the vectorization. I will investigate more and escalate the issue to our engineering team. 

Thanks,
Alex

Alexander Weggerle (Intel)'s picture

Hi Simon,

the internal ID for this defect is: DPD200542049. 

The loop in line 15 is the one causing the issue. If you add a "#pragma novector" in front of this loop as temporary workaround the result is correct if you compile with -O3. 

Thanks,
Alex
 

Alexander Weggerle (Intel)'s picture

Hi Simon,

a fix for this issue will be included in the next 15.0 compiler update. 

Thanks again for reporting this and including such a nice reproducer!

Alex

Login to leave a comment.