ispc/ispc — Issue #119: avx target correctness regression with v. 1.0.12 when using double precision
Author: dpephd
Created: 2011-10-31 01:14:04+00:00
State: open

Hello Matt,

I am experiencing what I believe to be a regression in 1.0.12 when using the avx target with double precision code (a 2D Poisson solver).

When running my five point 2D poisson solver compiled with v.1.0.9 with the compilation flags: "-O2 --target=avx --arch=x86-64 --cpu=corei7-avx" I obtain the following output:

```
[enright@jemez poisson2d_double]$ ./poisson2d_double
2D Jacobi Poisson Solver over square, regular grid
2D Five Pt Numerical Discretization Utilizing ISPC (double precision)
nx = 20, stop_tol = 5.14189e-06, max iterations = 1600
[stencil ispc]:	[0.000407116, 0.000411313] |residual|_inf, stopping_rel_err_bound
[stencil ispc]:	[0.00258985] theoretical error
[stencil ispc]:	[600] iterations
[stencil ispc]:	[8.527] millon cycles
Wrote image file poisson2d_5pt_jacobi_ispc.ppm
2D Five Pt Numerical Discretization (double_precision)
nx = 20, stop_tol = 5.14189e-06, max iterations = 1600
[stencil gcc]:	[0.000407116, 0.000411313] |residual|_inf, stopping_rel_err_bound
[stencil gcc]:	[0.00258985] theoretical error
[stencil gcc]:	[600] iterations
[stencil gcc]:	[5.047] millon cycles
(0.59x speedup from ISPC)
Wrote image file poisson2d_5pt_jacobi_gcc.ppm
```
This output indicates that the ispc compiled implementation is generating the same output as the g++ compiled version, so the --target=avx is working correctly.

However, when compiling the almost same code (I had to take into account the new multi-target compilation scheme but this should not produce any difference whatsoever in the calculation performed) with v.1.0.12 and the same set of ispc compilation flags, I obtain the following:

```
[enright@jemez poisson2d_double]$ ./poisson2d_double
2D Jacobi Poisson Solver over square, regular grid
2D Five Pt Numerical Discretization Utilizing ISPC (double precision)
nx = 20, stop_tol = 5.14189e-06, max iterations = 1600
[stencil ispc]:	[6.4146e-06, 6.42574e-06] |residual|_inf, stopping_rel_err_bound
[stencil ispc]:	[4.567] theoretical error
[stencil ispc]:	[1456] iterations
[stencil ispc]:	[10.920] millon cycles
Wrote image file poisson2d_5pt_jacobi_ispc.ppm
2D Five Pt Numerical Discretization (double_precision)
nx = 20, stop_tol = 5.14189e-06, max iterations = 1600
[stencil gcc]:	[0.000407116, 0.000411313] |residual|_inf, stopping_rel_err_bound
[stencil gcc]:	[0.00258985] theoretical error
[stencil gcc]:	[600] iterations
[stencil gcc]:	[4.896] millon cycles
(0.45x speedup from ISPC)
Wrote image file poisson2d_5pt_jacobi_gcc.ppm
```

Notice that the g++ result is numerically the same as previously displayed result using v. 1.0.9. The ispc result significantly differs from the g++ result and the avx target result when using ispc 1.0.9.

Given the above results, I believe that there has been a correctness regression in v. 1.0.12 when compiling double precision code.

Could you please look into this? I would be willing to make my implementation available to assist in understanding this correctness regression. As another data point, when using a sse4 target instead of avx, the ispc compiled code runs correctly with v.1.0.12, so something has happened to the avx code generation between v.1.0.9 and v.1.0.12. Also, I have NOT encountered this issue with my single precision implementation.

Thanks.

Doug