Community
cancel
Showing results for
Did you mean: Beginner
73 Views

## 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;

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 += conjf(*L)*x;
L++;
}
z = conjf(*L)*x;
L++;
}
L-=21;
// y = L*z;
for(i=0; i<6; i++) { // rows
y = *L * z;
L++;
for (j=1; j<=i; j++) { // columns
y += *L * z;
L++;
}
}
x+=6;
y+=6;
}
}

int main() {
float complex matrix;
float complex input_vector;
float complex output_vector;
int i;

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

buggy_LLH_multiply(output_vector, input_vector, matrix);

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

return 0;
}```

3 Replies Employee
73 Views

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 Employee
73 Views

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 Employee
73 Views

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 