8337062: x86_64: Unordered add/mul reduction support for vector api

Reviewed-by: jbhateja, sgibbons
This commit is contained in:
Sandhya Viswanathan 2024-08-01 23:02:23 +00:00
parent 21e86d10a7
commit dc35f3e8a8
17 changed files with 416 additions and 127 deletions

View File

@ -1786,6 +1786,16 @@ void C2_MacroAssembler::reduce_operation_128(BasicType typ, int opcode, XMMRegis
}
}
void C2_MacroAssembler::unordered_reduce_operation_128(BasicType typ, int opcode, XMMRegister dst, XMMRegister src) {
switch (opcode) {
case Op_AddReductionVF: addps(dst, src); break;
case Op_AddReductionVD: addpd(dst, src); break;
case Op_MulReductionVF: mulps(dst, src); break;
case Op_MulReductionVD: mulpd(dst, src); break;
default: assert(false, "%s", NodeClassNames[opcode]);
}
}
void C2_MacroAssembler::reduce_operation_256(BasicType typ, int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2) {
int vector_len = Assembler::AVX_256bit;
@ -1834,6 +1844,18 @@ void C2_MacroAssembler::reduce_operation_256(BasicType typ, int opcode, XMMRegis
}
}
void C2_MacroAssembler::unordered_reduce_operation_256(BasicType typ, int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2) {
int vector_len = Assembler::AVX_256bit;
switch (opcode) {
case Op_AddReductionVF: vaddps(dst, src1, src2, vector_len); break;
case Op_AddReductionVD: vaddpd(dst, src1, src2, vector_len); break;
case Op_MulReductionVF: vmulps(dst, src1, src2, vector_len); break;
case Op_MulReductionVD: vmulpd(dst, src1, src2, vector_len); break;
default: assert(false, "%s", NodeClassNames[opcode]);
}
}
void C2_MacroAssembler::reduce_fp(int opcode, int vlen,
XMMRegister dst, XMMRegister src,
XMMRegister vtmp1, XMMRegister vtmp2) {
@ -1852,6 +1874,24 @@ void C2_MacroAssembler::reduce_fp(int opcode, int vlen,
}
}
void C2_MacroAssembler::unordered_reduce_fp(int opcode, int vlen,
XMMRegister dst, XMMRegister src,
XMMRegister vtmp1, XMMRegister vtmp2) {
switch (opcode) {
case Op_AddReductionVF:
case Op_MulReductionVF:
unorderedReduceF(opcode, vlen, dst, src, vtmp1, vtmp2);
break;
case Op_AddReductionVD:
case Op_MulReductionVD:
unorderedReduceD(opcode, vlen, dst, src, vtmp1, vtmp2);
break;
default: assert(false, "%s", NodeClassNames[opcode]);
}
}
void C2_MacroAssembler::reduceB(int opcode, int vlen,
Register dst, Register src1, XMMRegister src2,
XMMRegister vtmp1, XMMRegister vtmp2) {
@ -1954,6 +1994,45 @@ void C2_MacroAssembler::reduceD(int opcode, int vlen, XMMRegister dst, XMMRegist
}
}
void C2_MacroAssembler::unorderedReduceF(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2) {
switch (vlen) {
case 2:
assert(vtmp1 == xnoreg, "");
assert(vtmp2 == xnoreg, "");
unorderedReduce2F(opcode, dst, src);
break;
case 4:
assert(vtmp2 == xnoreg, "");
unorderedReduce4F(opcode, dst, src, vtmp1);
break;
case 8:
unorderedReduce8F(opcode, dst, src, vtmp1, vtmp2);
break;
case 16:
unorderedReduce16F(opcode, dst, src, vtmp1, vtmp2);
break;
default: assert(false, "wrong vector length");
}
}
void C2_MacroAssembler::unorderedReduceD(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2) {
switch (vlen) {
case 2:
assert(vtmp1 == xnoreg, "");
assert(vtmp2 == xnoreg, "");
unorderedReduce2D(opcode, dst, src);
break;
case 4:
assert(vtmp2 == xnoreg, "");
unorderedReduce4D(opcode, dst, src, vtmp1);
break;
case 8:
unorderedReduce8D(opcode, dst, src, vtmp1, vtmp2);
break;
default: assert(false, "wrong vector length");
}
}
void C2_MacroAssembler::reduce2I(int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2) {
if (opcode == Op_AddReductionVI) {
if (vtmp1 != src2) {
@ -2181,6 +2260,29 @@ void C2_MacroAssembler::reduce16F(int opcode, XMMRegister dst, XMMRegister src,
reduce8F(opcode, dst, vtmp1, vtmp1, vtmp2);
}
void C2_MacroAssembler::unorderedReduce2F(int opcode, XMMRegister dst, XMMRegister src) {
pshufd(dst, src, 0x1);
reduce_operation_128(T_FLOAT, opcode, dst, src);
}
void C2_MacroAssembler::unorderedReduce4F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp) {
pshufd(vtmp, src, 0xE);
unordered_reduce_operation_128(T_FLOAT, opcode, vtmp, src);
unorderedReduce2F(opcode, dst, vtmp);
}
void C2_MacroAssembler::unorderedReduce8F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2) {
vextractf128_high(vtmp1, src);
unordered_reduce_operation_128(T_FLOAT, opcode, vtmp1, src);
unorderedReduce4F(opcode, dst, vtmp1, vtmp2);
}
void C2_MacroAssembler::unorderedReduce16F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2) {
vextractf64x4_high(vtmp2, src);
unordered_reduce_operation_256(T_FLOAT, opcode, vtmp2, vtmp2, src);
unorderedReduce8F(opcode, dst, vtmp2, vtmp1, vtmp2);
}
void C2_MacroAssembler::reduce2D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp) {
reduce_operation_128(T_DOUBLE, opcode, dst, src);
pshufd(vtmp, src, 0xE);
@ -2199,6 +2301,23 @@ void C2_MacroAssembler::reduce8D(int opcode, XMMRegister dst, XMMRegister src, X
reduce4D(opcode, dst, vtmp1, vtmp1, vtmp2);
}
void C2_MacroAssembler::unorderedReduce2D(int opcode, XMMRegister dst, XMMRegister src) {
pshufd(dst, src, 0xE);
reduce_operation_128(T_DOUBLE, opcode, dst, src);
}
void C2_MacroAssembler::unorderedReduce4D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp) {
vextractf128_high(vtmp, src);
unordered_reduce_operation_128(T_DOUBLE, opcode, vtmp, src);
unorderedReduce2D(opcode, dst, vtmp);
}
void C2_MacroAssembler::unorderedReduce8D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2) {
vextractf64x4_high(vtmp2, src);
unordered_reduce_operation_256(T_DOUBLE, opcode, vtmp2, vtmp2, src);
unorderedReduce4D(opcode, dst, vtmp2, vtmp1);
}
void C2_MacroAssembler::evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, Address src, bool merge, int vector_len) {
MacroAssembler::evmovdqu(type, kmask, dst, src, merge, vector_len);
}

View File

@ -149,6 +149,9 @@ public:
void reduce_fp(int opcode, int vlen,
XMMRegister dst, XMMRegister src,
XMMRegister vtmp1, XMMRegister vtmp2 = xnoreg);
void unordered_reduce_fp(int opcode, int vlen,
XMMRegister dst, XMMRegister src,
XMMRegister vtmp1 = xnoreg, XMMRegister vtmp2 = xnoreg);
void reduceB(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
void mulreduceB(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
void reduceS(int opcode, int vlen, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
@ -161,6 +164,8 @@ public:
private:
void reduceF(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
void reduceD(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
void unorderedReduceF(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
void unorderedReduceD(int opcode, int vlen, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
// Int Reduction
void reduce2I (int opcode, Register dst, Register src1, XMMRegister src2, XMMRegister vtmp1, XMMRegister vtmp2);
@ -197,14 +202,27 @@ public:
void reduce8F (int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
void reduce16F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
// Unordered Float Reduction
void unorderedReduce2F(int opcode, XMMRegister dst, XMMRegister src);
void unorderedReduce4F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp);
void unorderedReduce8F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
void unorderedReduce16F(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
// Double Reduction
void reduce2D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp);
void reduce4D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
void reduce8D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
// Unordered Double Reduction
void unorderedReduce2D(int opcode, XMMRegister dst, XMMRegister src);
void unorderedReduce4D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp);
void unorderedReduce8D(int opcode, XMMRegister dst, XMMRegister src, XMMRegister vtmp1, XMMRegister vtmp2);
// Base reduction instruction
void reduce_operation_128(BasicType typ, int opcode, XMMRegister dst, XMMRegister src);
void reduce_operation_256(BasicType typ, int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2);
void unordered_reduce_operation_128(BasicType typ, int opcode, XMMRegister dst, XMMRegister src);
void unordered_reduce_operation_256(BasicType typ, int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2);
public:
#ifdef _LP64

View File

@ -5109,7 +5109,7 @@ instruct reductionL_avx512dq(rRegL dst, rRegL src1, vec src2, vec vtmp1, vec vtm
// =======================Float Reduction==========================================
instruct reductionF128(regF dst, vec src, vec vtmp) %{
predicate(Matcher::vector_length(n->in(2)) <= 4); // src
predicate(n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) <= 4); // src
match(Set dst (AddReductionVF dst src));
match(Set dst (MulReductionVF dst src));
effect(TEMP dst, TEMP vtmp);
@ -5123,7 +5123,7 @@ instruct reductionF128(regF dst, vec src, vec vtmp) %{
%}
instruct reduction8F(regF dst, vec src, vec vtmp1, vec vtmp2) %{
predicate(Matcher::vector_length(n->in(2)) == 8); // src
predicate(n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 8); // src
match(Set dst (AddReductionVF dst src));
match(Set dst (MulReductionVF dst src));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
@ -5137,7 +5137,7 @@ instruct reduction8F(regF dst, vec src, vec vtmp1, vec vtmp2) %{
%}
instruct reduction16F(regF dst, legVec src, legVec vtmp1, legVec vtmp2) %{
predicate(Matcher::vector_length(n->in(2)) == 16); // src
predicate(n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 16); // src
match(Set dst (AddReductionVF dst src));
match(Set dst (MulReductionVF dst src));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
@ -5150,10 +5150,79 @@ instruct reduction16F(regF dst, legVec src, legVec vtmp1, legVec vtmp2) %{
ins_pipe( pipe_slow );
%}
instruct unordered_reduction2F(regF dst, regF src1, vec src2) %{
// Non-strictly ordered floating-point add/mul reduction for floats. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 2); // src2
match(Set dst (AddReductionVF src1 src2));
match(Set dst (MulReductionVF src1 src2));
effect(TEMP dst);
format %{ "vector_reduction_float $dst,$src1,$src2 ;" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
instruct unordered_reduction4F(regF dst, regF src1, vec src2, vec vtmp) %{
// Non-strictly ordered floating-point add/mul reduction for floats. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 4); // src2
match(Set dst (AddReductionVF src1 src2));
match(Set dst (MulReductionVF src1 src2));
effect(TEMP dst, TEMP vtmp);
format %{ "vector_reduction_float $dst,$src1,$src2 ; using $vtmp as TEMP" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister, $vtmp$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
instruct unordered_reduction8F(regF dst, regF src1, vec src2, vec vtmp1, vec vtmp2) %{
// Non-strictly ordered floating-point add/mul reduction for floats. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 8); // src2
match(Set dst (AddReductionVF src1 src2));
match(Set dst (MulReductionVF src1 src2));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
format %{ "vector_reduction_float $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister, $vtmp1$$XMMRegister, $vtmp2$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
instruct unordered_reduction16F(regF dst, regF src1, legVec src2, legVec vtmp1, legVec vtmp2) %{
// Non-strictly ordered floating-point add/mul reduction for floats. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 16); // src2
match(Set dst (AddReductionVF src1 src2));
match(Set dst (MulReductionVF src1 src2));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
format %{ "vector_reduction_float $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister, $vtmp1$$XMMRegister, $vtmp2$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
// =======================Double Reduction==========================================
instruct reduction2D(regD dst, vec src, vec vtmp) %{
predicate(Matcher::vector_length(n->in(2)) == 2); // src
predicate(n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 2); // src
match(Set dst (AddReductionVD dst src));
match(Set dst (MulReductionVD dst src));
effect(TEMP dst, TEMP vtmp);
@ -5167,7 +5236,7 @@ instruct reduction2D(regD dst, vec src, vec vtmp) %{
%}
instruct reduction4D(regD dst, vec src, vec vtmp1, vec vtmp2) %{
predicate(Matcher::vector_length(n->in(2)) == 4); // src
predicate(n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 4); // src
match(Set dst (AddReductionVD dst src));
match(Set dst (MulReductionVD dst src));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
@ -5181,7 +5250,7 @@ instruct reduction4D(regD dst, vec src, vec vtmp1, vec vtmp2) %{
%}
instruct reduction8D(regD dst, legVec src, legVec vtmp1, legVec vtmp2) %{
predicate(Matcher::vector_length(n->in(2)) == 8); // src
predicate(n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 8); // src
match(Set dst (AddReductionVD dst src));
match(Set dst (MulReductionVD dst src));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
@ -5194,6 +5263,57 @@ instruct reduction8D(regD dst, legVec src, legVec vtmp1, legVec vtmp2) %{
ins_pipe( pipe_slow );
%}
instruct unordered_reduction2D(regD dst, regD src1, vec src2) %{
// Non-strictly ordered floating-point add/mul reduction for doubles. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 2); // src2
match(Set dst (AddReductionVD src1 src2));
match(Set dst (MulReductionVD src1 src2));
effect(TEMP dst);
format %{ "vector_reduction_double $dst,$src1,$src2 ;" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
instruct unordered_reduction4D(regD dst, regD src1, vec src2, vec vtmp) %{
// Non-strictly ordered floating-point add/mul reduction for doubles. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 4); // src2
match(Set dst (AddReductionVD src1 src2));
match(Set dst (MulReductionVD src1 src2));
effect(TEMP dst, TEMP vtmp);
format %{ "vector_reduction_double $dst,$src1,$src2 ; using $vtmp as TEMP" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister, $vtmp$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
instruct unordered_reduction8D(regD dst, regD src1, legVec src2, legVec vtmp1, legVec vtmp2) %{
// Non-strictly ordered floating-point add/mul reduction for doubles. This rule is
// intended for the VectorAPI (which allows for non-strictly ordered add/mul reduction).
// src1 contains reduction identity
predicate(!n->as_Reduction()->requires_strict_order() && Matcher::vector_length(n->in(2)) == 8); // src2
match(Set dst (AddReductionVD src1 src2));
match(Set dst (MulReductionVD src1 src2));
effect(TEMP dst, TEMP vtmp1, TEMP vtmp2);
format %{ "vector_reduction_double $dst,$src1,$src2 ; using $vtmp1, $vtmp2 as TEMP" %}
ins_encode %{
int opcode = this->ideal_Opcode();
int vlen = Matcher::vector_length(this, $src2);
__ unordered_reduce_fp(opcode, vlen, $dst$$XMMRegister, $src2$$XMMRegister, $vtmp1$$XMMRegister, $vtmp2$$XMMRegister);
%}
ins_pipe( pipe_slow );
%}
// =======================Byte Reduction==========================================
#ifdef _LP64

View File

@ -63,8 +63,11 @@ public class Double128VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR = (double)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (double)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
@ -129,16 +132,16 @@ public class Double128VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(double[] r, double rc, double[] a,
FReductionOp f, FReductionAllOp fa,
double relativeError) {
double relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2194,7 +2197,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double128VectorTests::ADDReduce, Double128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Double128VectorTests::ADDReduce, Double128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2240,7 +2243,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double128VectorTests::ADDReduceMasked, Double128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double128VectorTests::ADDReduceMasked, Double128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double MULReduce(double[] a, int idx) {
@ -2283,7 +2286,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double128VectorTests::MULReduce, Double128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Double128VectorTests::MULReduce, Double128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2329,7 +2332,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double128VectorTests::MULReduceMasked, Double128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double128VectorTests::MULReduceMasked, Double128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MINReduce(double[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Double256VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR = (double)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (double)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
@ -129,16 +132,16 @@ public class Double256VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(double[] r, double rc, double[] a,
FReductionOp f, FReductionAllOp fa,
double relativeError) {
double relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2194,7 +2197,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double256VectorTests::ADDReduce, Double256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Double256VectorTests::ADDReduce, Double256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2240,7 +2243,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double256VectorTests::ADDReduceMasked, Double256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double256VectorTests::ADDReduceMasked, Double256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double MULReduce(double[] a, int idx) {
@ -2283,7 +2286,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double256VectorTests::MULReduce, Double256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Double256VectorTests::MULReduce, Double256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2329,7 +2332,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double256VectorTests::MULReduceMasked, Double256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double256VectorTests::MULReduceMasked, Double256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MINReduce(double[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Double512VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR = (double)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (double)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
@ -129,16 +132,16 @@ public class Double512VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(double[] r, double rc, double[] a,
FReductionOp f, FReductionAllOp fa,
double relativeError) {
double relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2194,7 +2197,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double512VectorTests::ADDReduce, Double512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Double512VectorTests::ADDReduce, Double512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2240,7 +2243,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double512VectorTests::ADDReduceMasked, Double512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double512VectorTests::ADDReduceMasked, Double512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double MULReduce(double[] a, int idx) {
@ -2283,7 +2286,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double512VectorTests::MULReduce, Double512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Double512VectorTests::MULReduce, Double512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2329,7 +2332,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double512VectorTests::MULReduceMasked, Double512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double512VectorTests::MULReduceMasked, Double512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MINReduce(double[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Double64VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR = (double)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (double)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
@ -129,16 +132,16 @@ public class Double64VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(double[] r, double rc, double[] a,
FReductionOp f, FReductionAllOp fa,
double relativeError) {
double relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2194,7 +2197,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double64VectorTests::ADDReduce, Double64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Double64VectorTests::ADDReduce, Double64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2240,7 +2243,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double64VectorTests::ADDReduceMasked, Double64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double64VectorTests::ADDReduceMasked, Double64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double MULReduce(double[] a, int idx) {
@ -2283,7 +2286,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Double64VectorTests::MULReduce, Double64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Double64VectorTests::MULReduce, Double64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2329,7 +2332,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Double64VectorTests::MULReduceMasked, Double64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Double64VectorTests::MULReduceMasked, Double64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MINReduce(double[] a, int idx) {

View File

@ -68,8 +68,11 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
private static final int Max = 256; // juts so we can do N/Max
// for floating point reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR = (double)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final double RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (double)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
@ -134,16 +137,16 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(double[] r, double rc, double[] a,
FReductionOp f, FReductionAllOp fa,
double relativeError) {
double relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2199,7 +2202,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
DoubleMaxVectorTests::ADDReduce, DoubleMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double ADDReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2245,7 +2248,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
DoubleMaxVectorTests::ADDReduceMasked, DoubleMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static double MULReduce(double[] a, int idx) {
@ -2288,7 +2291,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
DoubleMaxVectorTests::MULReduce, DoubleMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MULReduceMasked(double[] a, int idx, boolean[] mask) {
@ -2334,7 +2337,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
DoubleMaxVectorTests::MULReduceMasked, DoubleMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static double MINReduce(double[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Float128VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR = (float)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (float)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);
@ -129,16 +132,16 @@ public class Float128VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(float[] r, float rc, float[] a,
FReductionOp f, FReductionAllOp fa,
float relativeError) {
float relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2205,7 +2208,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float128VectorTests::ADDReduce, Float128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Float128VectorTests::ADDReduce, Float128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2251,7 +2254,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float128VectorTests::ADDReduceMasked, Float128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float128VectorTests::ADDReduceMasked, Float128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float MULReduce(float[] a, int idx) {
@ -2294,7 +2297,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float128VectorTests::MULReduce, Float128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Float128VectorTests::MULReduce, Float128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MULReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2340,7 +2343,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float128VectorTests::MULReduceMasked, Float128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float128VectorTests::MULReduceMasked, Float128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MINReduce(float[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Float256VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR = (float)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (float)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
@ -129,16 +132,16 @@ public class Float256VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(float[] r, float rc, float[] a,
FReductionOp f, FReductionAllOp fa,
float relativeError) {
float relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2205,7 +2208,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float256VectorTests::ADDReduce, Float256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Float256VectorTests::ADDReduce, Float256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2251,7 +2254,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float256VectorTests::ADDReduceMasked, Float256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float256VectorTests::ADDReduceMasked, Float256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float MULReduce(float[] a, int idx) {
@ -2294,7 +2297,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float256VectorTests::MULReduce, Float256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Float256VectorTests::MULReduce, Float256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MULReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2340,7 +2343,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float256VectorTests::MULReduceMasked, Float256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float256VectorTests::MULReduceMasked, Float256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MINReduce(float[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Float512VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR = (float)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (float)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512);
@ -129,16 +132,16 @@ public class Float512VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(float[] r, float rc, float[] a,
FReductionOp f, FReductionAllOp fa,
float relativeError) {
float relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2205,7 +2208,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float512VectorTests::ADDReduce, Float512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Float512VectorTests::ADDReduce, Float512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2251,7 +2254,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float512VectorTests::ADDReduceMasked, Float512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float512VectorTests::ADDReduceMasked, Float512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float MULReduce(float[] a, int idx) {
@ -2294,7 +2297,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float512VectorTests::MULReduce, Float512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Float512VectorTests::MULReduce, Float512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MULReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2340,7 +2343,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float512VectorTests::MULReduceMasked, Float512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float512VectorTests::MULReduceMasked, Float512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MINReduce(float[] a, int idx) {

View File

@ -63,8 +63,11 @@ public class Float64VectorTests extends AbstractVectorTest {
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
// for floating point reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR = (float)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (float)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64);
@ -129,16 +132,16 @@ public class Float64VectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(float[] r, float rc, float[] a,
FReductionOp f, FReductionAllOp fa,
float relativeError) {
float relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2205,7 +2208,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::ADDReduce, Float64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
Float64VectorTests::ADDReduce, Float64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2251,7 +2254,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::ADDReduceMasked, Float64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float64VectorTests::ADDReduceMasked, Float64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float MULReduce(float[] a, int idx) {
@ -2294,7 +2297,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
Float64VectorTests::MULReduce, Float64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
Float64VectorTests::MULReduce, Float64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MULReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2340,7 +2343,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Float64VectorTests::MULReduceMasked, Float64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
Float64VectorTests::MULReduceMasked, Float64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MINReduce(float[] a, int idx) {

View File

@ -68,8 +68,11 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
private static final int Max = 256; // juts so we can do N/Max
// for floating point reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR = (float)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final float RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (float)50.0;
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max);
@ -134,16 +137,16 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
static void assertReductionArraysEquals(float[] r, float rc, float[] a,
FReductionOp f, FReductionAllOp fa,
float relativeError) {
float relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
@ -2210,7 +2213,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
FloatMaxVectorTests::ADDReduce, FloatMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR);
FloatMaxVectorTests::ADDReduce, FloatMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2256,7 +2259,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
FloatMaxVectorTests::ADDReduceMasked, FloatMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR);
FloatMaxVectorTests::ADDReduceMasked, FloatMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD);
}
static float MULReduce(float[] a, int idx) {
@ -2299,7 +2302,7 @@ relativeError));
}
assertReductionArraysEquals(r, ra, a,
FloatMaxVectorTests::MULReduce, FloatMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR);
FloatMaxVectorTests::MULReduce, FloatMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MULReduceMasked(float[] a, int idx, boolean[] mask) {
@ -2345,7 +2348,7 @@ relativeError));
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
FloatMaxVectorTests::MULReduceMasked, FloatMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR);
FloatMaxVectorTests::MULReduceMasked, FloatMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL);
}
static float MINReduce(float[] a, int idx) {

View File

@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -221,7 +221,6 @@ function gen_op_tmpl {
replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke"
local gen_perf_tests=$generate_perf_tests
gen_perf_tests=true
if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] ||
[[ $template == *"Compare-Masked"* ]] || [[ $template == *"Compare-Broadcast"* ]]; then
gen_perf_tests=false

View File

@ -4,7 +4,7 @@
[[KERNEL]]
assertReductionArraysEqualsMasked(r, ra, a, mask,
#if[FP]
$vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked, RELATIVE_ROUNDING_ERROR);
$vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_[[TEST]]);
#else[FP]
$vectorteststype$::[[TEST]]ReduceMasked, $vectorteststype$::[[TEST]]ReduceAllMasked);
#end[FP]

View File

@ -4,7 +4,7 @@
[[KERNEL]]
assertReductionArraysEquals(r, ra, a,
#if[FP]
$vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll, RELATIVE_ROUNDING_ERROR);
$vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_[[TEST]]);
#else[FP]
$vectorteststype$::[[TEST]]Reduce, $vectorteststype$::[[TEST]]ReduceAll);
#end[FP]

View File

@ -96,8 +96,11 @@ public class $vectorteststype$ extends AbstractVectorTest {
private static final $type$ CONST_SHIFT = $Boxtype$.SIZE / 2;
#end[BITWISE]
#if[FP]
// for floating point reduction ops that may introduce rounding errors
private static final $type$ RELATIVE_ROUNDING_ERROR = ($type$)0.000001;
// for floating point addition reduction ops that may introduce rounding errors
private static final $type$ RELATIVE_ROUNDING_ERROR_FACTOR_ADD = ($type$)10.0;
// for floating point multiplication reduction ops that may introduce rounding errors
private static final $type$ RELATIVE_ROUNDING_ERROR_FACTOR_MUL = ($type$)50.0;
#end[FP]
static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / $bits$);
@ -177,16 +180,16 @@ public class $vectorteststype$ extends AbstractVectorTest {
static void assertReductionArraysEquals($type$[] r, $type$ rc, $type$[] a,
FReductionOp f, FReductionAllOp fa,
$type$ relativeError) {
$type$ relativeErrorFactor) {
int i = 0;
try {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError));
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor);
for (; i < a.length; i += SPECIES.length()) {
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError));
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor);
}
} catch (AssertionError e) {
Assert.assertEquals(rc, fa.apply(a), Math.abs(rc * relativeError), "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.abs(r[i] * relativeError), "at index #" + i);
Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!");
Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i);
}
}
#end[FP]