Vector API reproducibility bug (?)

Paul Sandoz paul.sandoz at oracle.com
Tue Aug 16 19:24:49 UTC 2022


We are careful to allow some wiggle room, the documentation on VectorOperators states:


* <li>Lane-wise vector operations that apply to floating point vectors
* follow the accuracy and monotonicity specifications of the equivalent
* Java operation or method mentioned in its documentation unless specified otherwise.
…
/** Produce {@code acos(a)}.  Floating only.
 *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 */
public static final /*float*/ Unary ACOS = unary("ACOS", "acos", VectorSupport.VECTOR_OP_ACOS, VO_ONLYFP);


The reason for the wiggle room is to support more optimal vectorized implementations such as those provided by Intel’s SVML library, some implementations of which (such as acos) are included with the Vector API and applied on Intel CPUs for linux and windows OSs.

The SVML implementations are not guaranteed to be semi-monotonic, but should guarantee the same 1ulp accuracy (it would be a bug otherwise).

I think what you are observing for your whole project is the difference between execution of the Vector API expressions in the interpreter and execution of the optimized code produced by C2. In the former, Math::acos will be used, in the latter an SVML-derived implementation will be used.

(It may be possible to fix this difference between the interpreter and C2 for the vector operations, but it would some work to do so.)

Paul.

> On Aug 16, 2022, at 11:56 AM, Quân Anh Mai <anhmdq at gmail.com> wrote:
> 
> Hi, the simple reason is that results produced by `java.lang.Math` are not required to be reproducible. In particular, `java.lang.Math::acos` allows 1ulp of errors and only requires semi-monotonicity. As a result, different implementations (vector vs scalar implementation) are allowed to produce different results for the same input.
> 
> Regards



More information about the panama-dev mailing list