[J3] New reference BLAS NRM2 routines
Van Snyder
Van.Snyder at jpl.nasa.gov
Tue Oct 9 15:00:22 EDT 2018
On Tue, 2018-10-09 at 04:52 -0700, Robert Corbett wrote:
> I assume that the bad optimization
> you refer to is the one described in
> the final paragraph of Section 8.1
> of the article. I find the authors'
> analysis of the problem to be
> dubious. The article does not
> give enough information to allow
> a reader to check the authors'
> assertion that the Intel compiler
> does not honor parentheses in
> optimizations. The Fortran code
> is not present in the article.
There are two optimizations that would subvert the compensated
summation. Here's the algorithm:
! Input: Vector x(1:n), storage increment incx
sum = 0; s = 0
do i = 1, (n-1)*incx+1, incx
1 s = s + x(i)*x(i)
2 t = sum
3 sum = t + s
4 s = s + ( t - sum )
end do
! Result: sqrt(sum)
It is important that the processor respect parentheses in statement 4.
This is required by 18-007r1:148:16-17 (10.1.5.2.4p2).
It is important that the processor not exploit the mathematically
equivalent (but not computationally equivlaent) observation
(t - sum) == -s
to replace statement 4 with
4 s = 0
and thereafter replace statement 1 with
1 s = x(i)*x(i)
The permission to make mathematically equivalent transformations in
10.1.5.2.4p2 applies only within expressions, and only to itrinsic
operations. The second "optimization" is an inter-statement
optimization, for which there is no explicit permission. It is
unhelpful, and ought not to be done as a default associated with some
level of optimization. It ought to be necessary explicitly to request
it.
More information about the J3
mailing list