From 0a37da2d6418c4e37864400b4db7694a5a3709d1 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Mon, 27 Oct 2025 15:09:57 +0000 Subject: [PATCH 01/10] 8370691: Add new HalffloatVector type and enable intrinsification of float16 vector operations --- src/hotspot/share/classfile/vmIntrinsics.hpp | 33 +- src/hotspot/share/classfile/vmSymbols.hpp | 1 + src/hotspot/share/opto/vectorIntrinsics.cpp | 815 +-- src/hotspot/share/opto/vectornode.cpp | 1 + src/hotspot/share/opto/vectornode.hpp | 2 + src/hotspot/share/prims/vectorSupport.cpp | 38 +- src/hotspot/share/prims/vectorSupport.hpp | 9 +- .../misc/X-ScopedMemoryAccess.java.template | 34 +- .../jdk/internal/vm/vector/VectorSupport.java | 67 +- .../jdk/incubator/vector/AbstractMask.java | 38 +- .../jdk/incubator/vector/AbstractSpecies.java | 51 +- .../jdk/incubator/vector/AbstractVector.java | 25 + .../jdk/incubator/vector/Byte128Vector.java | 66 +- .../jdk/incubator/vector/Byte256Vector.java | 66 +- .../jdk/incubator/vector/Byte512Vector.java | 66 +- .../jdk/incubator/vector/Byte64Vector.java | 66 +- .../jdk/incubator/vector/ByteMaxVector.java | 66 +- .../jdk/incubator/vector/ByteVector.java | 95 +- .../jdk/incubator/vector/Double128Vector.java | 66 +- .../jdk/incubator/vector/Double256Vector.java | 66 +- .../jdk/incubator/vector/Double512Vector.java | 66 +- .../jdk/incubator/vector/Double64Vector.java | 66 +- .../jdk/incubator/vector/DoubleMaxVector.java | 66 +- .../jdk/incubator/vector/DoubleVector.java | 87 +- .../jdk/incubator/vector/Float128Vector.java | 66 +- .../jdk/incubator/vector/Float256Vector.java | 66 +- .../jdk/incubator/vector/Float512Vector.java | 66 +- .../jdk/incubator/vector/Float64Vector.java | 66 +- .../jdk/incubator/vector/FloatMaxVector.java | 66 +- .../jdk/incubator/vector/FloatVector.java | 87 +- .../incubator/vector/Halffloat128Vector.java | 1042 ++++ .../incubator/vector/Halffloat256Vector.java | 1058 ++++ .../incubator/vector/Halffloat512Vector.java | 1090 ++++ .../incubator/vector/Halffloat64Vector.java | 1034 ++++ .../incubator/vector/HalffloatMaxVector.java | 1027 ++++ .../jdk/incubator/vector/HalffloatVector.java | 4362 +++++++++++++++++ .../jdk/incubator/vector/Int128Vector.java | 66 +- .../jdk/incubator/vector/Int256Vector.java | 66 +- .../jdk/incubator/vector/Int512Vector.java | 66 +- .../jdk/incubator/vector/Int64Vector.java | 66 +- .../jdk/incubator/vector/IntMaxVector.java | 66 +- .../jdk/incubator/vector/IntVector.java | 91 +- .../jdk/incubator/vector/LaneType.java | 27 +- .../jdk/incubator/vector/Long128Vector.java | 66 +- .../jdk/incubator/vector/Long256Vector.java | 66 +- .../jdk/incubator/vector/Long512Vector.java | 66 +- .../jdk/incubator/vector/Long64Vector.java | 66 +- .../jdk/incubator/vector/LongMaxVector.java | 66 +- .../jdk/incubator/vector/LongVector.java | 91 +- .../jdk/incubator/vector/Short128Vector.java | 66 +- .../jdk/incubator/vector/Short256Vector.java | 66 +- .../jdk/incubator/vector/Short512Vector.java | 66 +- .../jdk/incubator/vector/Short64Vector.java | 66 +- .../jdk/incubator/vector/ShortMaxVector.java | 66 +- .../jdk/incubator/vector/ShortVector.java | 100 +- .../classes/jdk/incubator/vector/Vector.java | 15 +- .../incubator/vector/VectorIntrinsics.java | 7 + .../jdk/incubator/vector/VectorMask.java | 11 +- .../jdk/incubator/vector/VectorOperators.java | 27 +- .../jdk/incubator/vector/VectorShape.java | 3 + .../incubator/vector/X-Vector.java.template | 266 +- .../vector/X-VectorBits.java.template | 114 +- .../classes/jdk/incubator/vector/gen-src.sh | 62 +- .../incubator/vector/Byte128VectorTests.java | 60 +- .../incubator/vector/Byte256VectorTests.java | 60 +- .../incubator/vector/Byte512VectorTests.java | 60 +- .../incubator/vector/Byte64VectorTests.java | 60 +- .../incubator/vector/ByteMaxVectorTests.java | 60 +- .../vector/Double128VectorTests.java | 84 +- .../vector/Double256VectorTests.java | 84 +- .../vector/Double512VectorTests.java | 84 +- .../incubator/vector/Double64VectorTests.java | 84 +- .../vector/DoubleMaxVectorTests.java | 84 +- .../incubator/vector/Float128VectorTests.java | 84 +- .../incubator/vector/Float256VectorTests.java | 84 +- .../incubator/vector/Float512VectorTests.java | 84 +- .../incubator/vector/Float64VectorTests.java | 84 +- .../incubator/vector/FloatMaxVectorTests.java | 84 +- .../Halffloat128VectorLoadStoreTests.java | 1016 ++++ .../vector/Halffloat128VectorTests.java | 3262 ++++++++++++ .../Halffloat256VectorLoadStoreTests.java | 1016 ++++ .../vector/Halffloat256VectorTests.java | 3262 ++++++++++++ .../Halffloat512VectorLoadStoreTests.java | 1016 ++++ .../vector/Halffloat512VectorTests.java | 3262 ++++++++++++ .../Halffloat64VectorLoadStoreTests.java | 1016 ++++ .../vector/Halffloat64VectorTests.java | 3262 ++++++++++++ .../HalffloatMaxVectorLoadStoreTests.java | 1023 ++++ .../vector/HalffloatMaxVectorTests.java | 3251 ++++++++++++ .../incubator/vector/Int128VectorTests.java | 60 +- .../incubator/vector/Int256VectorTests.java | 60 +- .../incubator/vector/Int512VectorTests.java | 60 +- .../incubator/vector/Int64VectorTests.java | 60 +- .../incubator/vector/IntMaxVectorTests.java | 60 +- .../incubator/vector/Long128VectorTests.java | 62 +- .../incubator/vector/Long256VectorTests.java | 62 +- .../incubator/vector/Long512VectorTests.java | 62 +- .../incubator/vector/Long64VectorTests.java | 62 +- .../incubator/vector/LongMaxVectorTests.java | 62 +- .../incubator/vector/Short128VectorTests.java | 69 +- .../incubator/vector/Short256VectorTests.java | 69 +- .../incubator/vector/Short512VectorTests.java | 69 +- .../incubator/vector/Short64VectorTests.java | 69 +- .../incubator/vector/ShortMaxVectorTests.java | 69 +- test/jdk/jdk/incubator/vector/gen-template.sh | 476 +- test/jdk/jdk/incubator/vector/gen-tests.sh | 418 +- .../Kernel-Binary-Masked-mem-op.template | 2 +- .../templates/Kernel-Binary-mem-op.template | 2 +- .../Kernel-Binary-op-hf-math.template | 12 + .../Kernel-Unary-op-hf-math.template | 10 + .../Unit-Binary-Masked-mem-op.template | 2 - .../templates/Unit-Binary-mem-op.template | 2 - .../templates/Unit-Binary-op-hf-math.template | 14 + .../templates/Unit-Miscellaneous.template | 42 +- .../templates/Unit-Unary-op-hf-math.template | 14 + .../vector/templates/Unit-header.template | 252 +- .../templates/X-LoadStoreTest.java.template | 88 +- 116 files changed, 35495 insertions(+), 3110 deletions(-) create mode 100644 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java create mode 100644 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java create mode 100644 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java create mode 100644 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java create mode 100644 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java create mode 100644 src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat128VectorLoadStoreTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat256VectorLoadStoreTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat512VectorLoadStoreTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat64VectorLoadStoreTests.java create mode 100644 test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java create mode 100644 test/jdk/jdk/incubator/vector/HalffloatMaxVectorLoadStoreTests.java create mode 100644 test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java create mode 100644 test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template create mode 100644 test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template create mode 100644 test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template create mode 100644 test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp index 0895418ef848b..52a9b0389e095 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.hpp +++ b/src/hotspot/share/classfile/vmIntrinsics.hpp @@ -494,8 +494,8 @@ class methodHandle; \ do_class(com_sun_crypto_provider_galoisCounterMode, "com/sun/crypto/provider/GaloisCounterMode") \ do_intrinsic(_galoisCounterMode_AESCrypt, com_sun_crypto_provider_galoisCounterMode, gcm_crypt_name, aes_gcm_signature, F_S) \ - do_name(gcm_crypt_name, "implGCMCrypt0") \ - do_signature(aes_gcm_signature, "([BII[BI[BILcom/sun/crypto/provider/GCTR;Lcom/sun/crypto/provider/GHASH;)I") \ + do_name(gcm_crypt_name, "implGCMCrypt0") \ + do_signature(aes_gcm_signature, "([BII[BI[BILcom/sun/crypto/provider/GCTR;Lcom/sun/crypto/provider/GHASH;)I") \ \ /* support for sun.security.provider.MD5 */ \ do_class(sun_security_provider_md5, "sun/security/provider/MD5") \ @@ -1005,6 +1005,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljdk/internal/vm/vector/VectorSupport$UnaryOperation;)" \ @@ -1017,6 +1018,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorPayload;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorPayload;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ @@ -1053,6 +1055,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ @@ -1065,6 +1068,7 @@ class methodHandle; do_signature(vector_select_from_op_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ @@ -1076,6 +1080,7 @@ class methodHandle; do_signature(vector_frombits_coerced_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "J" \ "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorSpecies;" \ @@ -1087,6 +1092,7 @@ class methodHandle; do_signature(vector_load_op_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljava/lang/Object;" \ "J" \ "Z" \ @@ -1102,6 +1108,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljava/lang/Object;" \ "J" \ "Z" \ @@ -1118,6 +1125,7 @@ class methodHandle; do_signature(vector_store_op_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljava/lang/Object;" \ "J" \ "Z" \ @@ -1133,6 +1141,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljava/lang/Object;" \ "J" \ "Z" \ @@ -1150,6 +1159,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljdk/internal/vm/vector/VectorSupport$ReductionOperation;)" \ @@ -1161,6 +1171,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljava/util/function/BiFunction;)" \ @@ -1172,6 +1183,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ @@ -1182,7 +1194,9 @@ class methodHandle; do_intrinsic(_VectorCompare, jdk_internal_vm_vector_VectorSupport, vector_compare_name, vector_compare_sig, F_S) \ do_signature(vector_compare_sig, "(I" \ "Ljava/lang/Class;" \ - "Ljava/lang/Class;Ljava/lang/Class;" \ + "Ljava/lang/Class;" \ + "Ljava/lang/Class;" \ + "I" \ "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ @@ -1197,6 +1211,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorShuffle;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ @@ -1209,17 +1224,19 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorSelectFromOp;)" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;") \ - do_name(vector_select_from_name, "selectFromOp") \ + do_name(vector_select_from_name, "selectFromOp") \ \ do_intrinsic(_VectorExtract, jdk_internal_vm_vector_VectorSupport, vector_extract_name, vector_extract_sig, F_S) \ do_signature(vector_extract_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorPayload;" \ "I" \ "Ljdk/internal/vm/vector/VectorSupport$VecExtractOp;)" \ @@ -1230,6 +1247,7 @@ class methodHandle; do_signature(vector_insert_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "IJ" \ "Ljdk/internal/vm/vector/VectorSupport$VecInsertOp;)" \ @@ -1242,6 +1260,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ @@ -1268,6 +1287,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljava/lang/Class;" \ "I" \ "Ljava/lang/Object;" \ @@ -1289,6 +1309,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljava/lang/Class;" \ "I" \ "Ljava/lang/Object;" \ @@ -1311,6 +1332,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMaskOp;)" \ "J") \ @@ -1322,6 +1344,7 @@ class methodHandle; "Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "Ljdk/internal/vm/vector/VectorSupport$VectorMask;" \ "Ljdk/internal/vm/vector/VectorSupport$CompressExpandOperation;)" \ @@ -1332,6 +1355,7 @@ class methodHandle; do_signature(index_vector_op_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "Ljdk/internal/vm/vector/VectorSupport$Vector;" \ "I" \ "Ljdk/internal/vm/vector/VectorSupport$VectorSpecies;" \ @@ -1343,6 +1367,7 @@ class methodHandle; do_signature(index_partially_in_upper_range_sig, "(Ljava/lang/Class;" \ "Ljava/lang/Class;" \ "I" \ + "I" \ "J" \ "J" \ "Ljdk/internal/vm/vector/VectorSupport$IndexPartiallyInUpperRangeOperation;)" \ diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 06f27f09c5c01..b24522fc89072 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -99,6 +99,7 @@ class SerializeClosure; template(jdk_internal_vm_vector_VectorShuffle, "jdk/internal/vm/vector/VectorSupport$VectorShuffle") \ template(payload_name, "payload") \ template(ETYPE_name, "ETYPE") \ + template(CTYPE_name, "CTYPE") \ template(VLENGTH_name, "VLENGTH") \ \ template(jdk_internal_vm_FillerObject, "jdk/internal/vm/FillerObject") \ diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 85d9790c0eb54..6fa2ade909b80 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -35,13 +35,25 @@ static bool is_vector(ciKlass* klass) { return klass->is_subclass_of(ciEnv::current()->vector_VectorPayload_klass()); } +static const char* get_opertype_string(int operType) { + switch(operType) { + case VectorSupport::VECTOR_TYPE_PRIM: + return "VECTOR_TYPE_PRIM"; + case VectorSupport::VECTOR_TYPE_FP16: + return "VECTOR_TYPE_FP16"; + default: + ShouldNotReachHere(); + return nullptr; + } +} + static bool check_vbox(const TypeInstPtr* vbox_type) { assert(vbox_type->klass_is_exact(), ""); ciInstanceKlass* ik = vbox_type->instance_klass(); assert(is_vector(ik), "not a vector"); - ciField* fd1 = ik->get_field_by_name(ciSymbols::ETYPE_name(), ciSymbols::class_signature(), /* is_static */ true); + ciField* fd1 = ik->get_field_by_name(ciSymbols::CTYPE_name(), ciSymbols::class_signature(), /* is_static */ true); assert(fd1 != nullptr, "element type info is missing"); ciConstant val1 = fd1->constant_value(); @@ -287,46 +299,58 @@ static bool is_klass_initialized(const TypeInstPtr* vec_klass) { return klass->is_initialized(); } -// public static -// , -// M extends VectorMask, -// E> -// V unaryOp(int oprId, Class vmClass, Class maskClass, Class elementType, -// int length, V v, M m, -// UnaryOperation defaultImpl) // -// public static -// , -// E> -// V binaryOp(int oprId, Class vmClass, Class maskClass, Class elementType, -// int length, V v1, V v2, M m, -// BinaryOperation defaultImpl) +// public static +// , +// M extends VectorMask, +// E> +// V unaryOp(int oprId, +// Class vClass, Class mClass, Class cClass, int operType, +// int length, +// V v, M m, +// UnaryOperation defaultImpl) { +// +// public static +// , +// E> +// VM binaryOp(int oprId, +// Class vmClass, Class mClass, Class cClass, int operType, +// int length, +// VM v1, VM v2, M m, +// BinaryOperation defaultImpl) { +// +// +// public static +// , +// M extends VectorMask, +// E> +// V ternaryOp(int oprId, +// Class vClass, Class mClass, Class cClass, int operType, +// int length, +// V v1, V v2, V v3, M m, +// TernaryOperation defaultImpl) { // -// public static -// , -// M extends VectorMask, -// E> -// V ternaryOp(int oprId, Class vmClass, Class maskClass, Class elementType, -// int length, V v1, V v2, V v3, M m, -// TernaryOperation defaultImpl) // bool LibraryCallKit::inline_vector_nary_operation(int n) { const TypeInt* opr = gvn().type(argument(0))->isa_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* operType = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); if (opr == nullptr || !opr->is_con() || + operType == nullptr || !operType->is_con() || vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || vlen == nullptr || !vlen->is_con()) { - log_if_needed(" ** missing constant: opr=%s vclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: opr=%s vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(4)->Opcode()], + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } @@ -342,7 +366,7 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { // "argument(n + 5)" should be the mask object. We assume it is "null" when no mask // is used to control this operation. - const Type* vmask_type = gvn().type(argument(n + 5)); + const Type* vmask_type = gvn().type(argument(n + 6)); bool is_masked_op = vmask_type != TypePtr::NULL_PTR; if (is_masked_op) { if (mask_klass == nullptr || mask_klass->const_oop() == nullptr) { @@ -366,7 +390,7 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { bool is_unsigned = VectorSupport::is_unsigned_op(opr->get_con()); int num_elem = vlen->get_con(); - int opc = VectorSupport::vop2ideal(opr->get_con(), elem_bt); + int opc = VectorSupport::vop2ideal(opr->get_con(), elem_bt, operType->get_con()); int sopc = has_scalar_op ? VectorNode::opcode(opc, elem_bt) : opc; if (sopc == 0 || num_elem == 1) { log_if_needed(" ** operation not supported: arity=%d opc=%s[%d] vlen=%d etype=%s", @@ -401,28 +425,28 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { Node* opd1 = nullptr; Node* opd2 = nullptr; Node* opd3 = nullptr; switch (n) { case 3: { - opd3 = unbox_vector(argument(7), vbox_type, elem_bt, num_elem); + opd3 = unbox_vector(argument(8), vbox_type, elem_bt, num_elem); if (opd3 == nullptr) { log_if_needed(" ** unbox failed v3=%s", - NodeClassNames[argument(7)->Opcode()]); + NodeClassNames[argument(8)->Opcode()]); return false; } // fall-through } case 2: { - opd2 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); + opd2 = unbox_vector(argument(7), vbox_type, elem_bt, num_elem); if (opd2 == nullptr) { log_if_needed(" ** unbox failed v2=%s", - NodeClassNames[argument(6)->Opcode()]); + NodeClassNames[argument(7)->Opcode()]); return false; } // fall-through } case 1: { - opd1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + opd1 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); if (opd1 == nullptr) { log_if_needed(" ** unbox failed v1=%s", - NodeClassNames[argument(5)->Opcode()]); + NodeClassNames[argument(6)->Opcode()]); return false; } break; @@ -435,10 +459,10 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); assert(is_vector_mask(mbox_klass), "argument(2) should be a mask class"); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - mask = unbox_vector(argument(n + 5), mbox_type, elem_bt, num_elem); + mask = unbox_vector(argument(n + 6), mbox_type, elem_bt, num_elem); if (mask == nullptr) { log_if_needed(" ** unbox failed mask=%s", - NodeClassNames[argument(n + 5)->Opcode()]); + NodeClassNames[argument(n + 6)->Opcode()]); return false; } } @@ -477,37 +501,42 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { return true; } -// public static -// , E> -// V libraryUnaryOp(long address, Class vClass, Class elementType, int length, String debugName, -// V v, -// UnaryOperation defaultImpl) // -// public static -// -// V libraryBinaryOp(long address, Class vClass, Class elementType, int length, String debugName, -// V v1, V v2, -// BinaryOperation defaultImpl) +// public static +// , E> +// V libraryUnaryOp(long addr, Class vClass, Class cClass, int operType, int length, String debugName, +// V v, +// UnaryOperation defaultImpl) +// +// public static +// +// V libraryBinaryOp(long addr, Class vClass, Class cClass, int operType, int length, String debugName, +// V v1, V v2, +// BinaryOperation defaultImpl) +// bool LibraryCallKit::inline_vector_call(int arity) { assert(Matcher::supports_vector_calling_convention(), "required"); const TypeLong* entry = gvn().type(argument(0))->isa_long(); const TypeInstPtr* vector_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); - const TypeInstPtr* debug_name_oop = gvn().type(argument(5))->isa_instptr(); + const TypeInt* operType = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); + const TypeInstPtr* debug_name_oop = gvn().type(argument(6))->isa_instptr(); if (entry == nullptr || !entry->is_con() || vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || - vlen == nullptr || !vlen->is_con() || + operType == nullptr || !operType->is_con() || + vlen == nullptr || !vlen->is_con() || debug_name_oop == nullptr || debug_name_oop->const_oop() == nullptr) { - log_if_needed(" ** missing constant: opr=%s vclass=%s etype=%s vlen=%s debug_name=%s", + log_if_needed(" ** missing constant: opr=%s vclass=%s etype=%s operType=%s vlen=%s debug_name=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(2)->Opcode()], NodeClassNames[argument(3)->Opcode()], NodeClassNames[argument(4)->Opcode()], - NodeClassNames[argument(5)->Opcode()]); + NodeClassNames[argument(5)->Opcode()], + NodeClassNames[argument(6)->Opcode()]); return false; // not enough info for intrinsification } @@ -516,6 +545,11 @@ bool LibraryCallKit::inline_vector_call(int arity) { return false; } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type(); if (!elem_type->is_primitive_type()) { log_if_needed(" ** not a primitive bt=%d", elem_type->basic_type()); @@ -537,17 +571,17 @@ bool LibraryCallKit::inline_vector_call(int arity) { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); - Node* opd1 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); + Node* opd1 = unbox_vector(argument(7), vbox_type, elem_bt, num_elem); if (opd1 == nullptr) { - log_if_needed(" ** unbox failed v1=%s", NodeClassNames[argument(6)->Opcode()]); + log_if_needed(" ** unbox failed v1=%s", NodeClassNames[argument(7)->Opcode()]); return false; } Node* opd2 = nullptr; if (arity > 1) { - opd2 = unbox_vector(argument(7), vbox_type, elem_bt, num_elem); + opd2 = unbox_vector(argument(8), vbox_type, elem_bt, num_elem); if (opd2 == nullptr) { - log_if_needed(" ** unbox failed v2=%s", NodeClassNames[argument(7)->Opcode()]); + log_if_needed(" ** unbox failed v2=%s", NodeClassNames[argument(8)->Opcode()]); return false; } } @@ -579,24 +613,38 @@ bool LibraryCallKit::inline_vector_call(int arity) { return true; } -// -// long maskReductionCoerced(int oper, Class maskClass, Class elemClass, -// int length, M m, VectorMaskOp defaultImpl) +// +// public static +// , +// E> +// long maskReductionCoerced(int oper, +// Class mClass, Class cClass, int operType, +// int length, +// M m, +// VectorMaskOp defaultImpl) +// bool LibraryCallKit::inline_vector_mask_operation() { const TypeInt* oper = gvn().type(argument(0))->isa_int(); const TypeInstPtr* mask_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(3))->isa_int(); - Node* mask = argument(4); + const TypeInt* operType = gvn().type(argument(3))->isa_int(); + const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + Node* mask = argument(5); if (mask_klass == nullptr || mask_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() || oper == nullptr || !oper->is_con() || mask->is_top()) { return false; // dead code } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(mask_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -604,6 +652,12 @@ bool LibraryCallKit::inline_vector_mask_operation() { int num_elem = vlen->get_con(); ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type(); + if (!elem_type->is_primitive_type()) { + if (C->print_intrinsics()) { + tty->print_cr(" ** not a primitive bt=%d", elem_type->basic_type()); + } + return false; // should be primitive type + } BasicType elem_bt = elem_type->basic_type(); int mopc = VectorSupport::vop2ideal(oper->get_con(), elem_bt); @@ -618,7 +672,7 @@ bool LibraryCallKit::inline_vector_mask_operation() { Node* mask_vec = unbox_vector(mask, mask_box_type, elem_bt, num_elem); if (mask_vec == nullptr) { log_if_needed(" ** unbox failed mask=%s", - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(5)->Opcode()]); return false; } @@ -636,36 +690,48 @@ bool LibraryCallKit::inline_vector_mask_operation() { return true; } -// public static -// , -// E> -// M fromBitsCoerced(Class vmClass, Class elementType, int length, -// long bits, int mode, S s, -// BroadcastOperation defaultImpl) +// +// public static +// , +// E> +// VM fromBitsCoerced(Class vmClass, Class cClass, int operType, +// int length, +// long bits, int mode, S s, +// FromBitsCoercedOperation defaultImpl) +// bool LibraryCallKit::inline_vector_frombits_coerced() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); - const TypeLong* bits_type = gvn().type(argument(3))->isa_long(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeLong* bits_type = gvn().type(argument(4))->isa_long(); // Mode argument determines the mode of operation it can take following values:- // MODE_BROADCAST for vector Vector.broadcast and VectorMask.maskAll operations. // MODE_BITS_COERCED_LONG_TO_MASK for VectorMask.fromLong operation. - const TypeInt* mode = gvn().type(argument(5))->isa_int(); + const TypeInt* mode = gvn().type(argument(6))->isa_int(); if (vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() || bits_type == nullptr || mode == nullptr || !mode->is_con()) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s bitwise=%s", + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s bitwise=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], - NodeClassNames[argument(5)->Opcode()]); + NodeClassNames[argument(3)->Opcode()], + NodeClassNames[argument(6)->Opcode()]); return false; // not enough info for intrinsification } + + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -703,7 +769,7 @@ bool LibraryCallKit::inline_vector_frombits_coerced() { } Node* broadcast = nullptr; - Node* bits = argument(3); + Node* bits = argument(4); Node* elem = bits; if (opc == Op_VectorLongToMask) { @@ -766,41 +832,46 @@ static bool elem_consistent_with_arr(BasicType elem_bt, const TypeAryPtr* arr_ty } } +// // public static // > -// VM load(Class vmClass, Class eClass, +// VM load(Class vmClass, Class cClass, int operType, // int length, -// Object base, long offset, // Unsafe addressing -// boolean fromSegment, -// C container, long index, S s, // Arguments for default implementation -// LoadOperation defaultImpl) { +// Object base, long offset, boolean fromSegment, +// C container, long index, S s, +// LoadOperation defaultImpl) +// +// // public static // -// void store(Class vClass, Class eClass, +// void store(Class vClass, Class cClass, int operType, // int length, -// Object base, long offset, // Unsafe addressing -// boolean fromSegment, -// V v, C container, long index, // Arguments for default implementation -// StoreVectorOperation defaultImpl) { +// Object base, long offset, boolean fromSegment, +// V v, C container, long index, +// StoreVectorOperation defaultImpl) +// bool LibraryCallKit::inline_vector_mem_operation(bool is_store) { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); - const TypeInt* from_ms = gvn().type(argument(6))->isa_int(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeInt* from_ms = gvn().type(argument(7))->isa_int(); if (vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() || from_ms == nullptr || !from_ms->is_con()) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s from_ms=%s", + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s from_ms=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], - NodeClassNames[argument(6)->Opcode()]); + NodeClassNames[argument(3)->Opcode()], + NodeClassNames[argument(7)->Opcode()]); return false; // not enough info for intrinsification } if (!is_klass_initialized(vector_klass)) { @@ -827,8 +898,8 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); bool is_mask = is_vector_mask(vbox_klass); - Node* base = argument(3); - Node* offset = ConvL2X(argument(4)); + Node* base = argument(4); + Node* offset = ConvL2X(argument(5)); // Save state and restore on bailout SavedState old_state(this); @@ -910,7 +981,7 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) { } if (is_store) { - Node* val = unbox_vector(argument(7), vbox_type, elem_bt, num_elem); + Node* val = unbox_vector(argument(8), vbox_type, elem_bt, num_elem); if (val == nullptr) { return false; // operand unboxing failed } @@ -958,50 +1029,55 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) { return true; } +// // public static // , // E, // S extends VectorSpecies, // M extends VectorMask> -// V loadMasked(Class vClass, Class mClass, Class eClass, -// int length, Object base, long offset, // Unsafe addressing -// boolean fromSegment, +// V loadMasked(Class vClass, Class mClass, Class cClass, int operType, +// int length, Object base, long offset, boolean fromSegment, // M m, int offsetInRange, -// C container, long index, S s, // Arguments for default implementation -// LoadVectorMaskedOperation defaultImpl) { +// C container, long index, S s, +// LoadVectorMaskedOperation defaultImpl) +// // public static // , // M extends VectorMask, // E> -// void storeMasked(Class vClass, Class mClass, Class eClass, +// void storeMasked(Class vClass, Class mClass, Class cClass, int operType, // int length, -// Object base, long offset, // Unsafe addressing -// boolean fromSegment, -// V v, M m, C container, long index, // Arguments for default implementation -// StoreVectorMaskedOperation defaultImpl) { +// Object base, long offset, boolean fromSegment, +// V v, M m, C container, long index, +// StoreVectorMaskedOperation defaultImpl) +// bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(3))->isa_int(); - const TypeInt* from_ms = gvn().type(argument(7))->isa_int(); + const TypeInt* operType = gvn().type(argument(3))->isa_int(); + const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* from_ms = gvn().type(argument(8))->isa_int(); if (vector_klass == nullptr || vector_klass->const_oop() == nullptr || mask_klass == nullptr || mask_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() || from_ms == nullptr || !from_ms->is_con()) { - log_if_needed(" ** missing constant: vclass=%s mclass=%s etype=%s vlen=%s from_ms=%s", + log_if_needed(" ** missing constant: vclass=%s mclass=%s etype=%s operType=%s vlen=%s from_ms=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(7)->Opcode()]); + NodeClassNames[argument(4)->Opcode()], + NodeClassNames[argument(8)->Opcode()]); return false; // not enough info for intrinsification } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -1021,8 +1097,8 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { BasicType elem_bt = elem_type->basic_type(); int num_elem = vlen->get_con(); - Node* base = argument(4); - Node* offset = ConvL2X(argument(5)); + Node* base = argument(5); + Node* offset = ConvL2X(argument(6)); // Save state and restore on bailout SavedState old_state(this); @@ -1055,10 +1131,10 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { needs_predicate = true; } else { // Masked vector load with IOOBE always uses the predicated load. - const TypeInt* offset_in_range = gvn().type(argument(9))->isa_int(); + const TypeInt* offset_in_range = gvn().type(argument(10))->isa_int(); if (!offset_in_range->is_con()) { log_if_needed(" ** missing constant: offsetInRange=%s", - NodeClassNames[argument(8)->Opcode()]); + NodeClassNames[argument(10)->Opcode()]); return false; } needs_predicate = (offset_in_range->get_con() == 0); @@ -1113,19 +1189,19 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - Node* mask = unbox_vector(is_store ? argument(9) : argument(8), mbox_type, elem_bt, num_elem); + Node* mask = unbox_vector(is_store ? argument(10) : argument(9), mbox_type, elem_bt, num_elem); if (mask == nullptr) { log_if_needed(" ** unbox failed mask=%s", - is_store ? NodeClassNames[argument(9)->Opcode()] - : NodeClassNames[argument(8)->Opcode()]); + is_store ? NodeClassNames[argument(10)->Opcode()] + : NodeClassNames[argument(9)->Opcode()]); return false; } if (is_store) { - Node* val = unbox_vector(argument(8), vbox_type, elem_bt, num_elem); + Node* val = unbox_vector(argument(9), vbox_type, elem_bt, num_elem); if (val == nullptr) { log_if_needed(" ** unbox failed vector=%s", - NodeClassNames[argument(8)->Opcode()]); + NodeClassNames[argument(9)->Opcode()]); return false; // operand unboxing failed } set_all_memory(reset_memory()); @@ -1183,50 +1259,57 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { } // +// public static // , // W extends Vector, // S extends VectorSpecies, // M extends VectorMask, // E> -// V loadWithMap(Class vClass, Class mClass, Class eClass, int length, -// Class> vectorIndexClass, int indexLength, -// Object base, long offset, -// W indexVector1, W indexVector2, W indexVector3, W indexVector4, -// M m, C container, int index, int[] indexMap, int indexM, S s, -// LoadVectorOperationWithMap defaultImpl) -// +// V loadWithMap(Class vClass, Class mClass, Class cClass, int operType, +// int length, +// Class> vectorIndexClass, +// int indexLength, Object base, long offset, +// W indexVector1, W indexVector2, W indexVector3, W indexVector4, +// M m, C container, int index, int[] indexMap, int indexM, S s, +// LoadVectorOperationWithMap defaultImpl) +// public static // , // W extends Vector, // M extends VectorMask, // E> -// void storeWithMap(Class vClass, Class mClass, Class eClass, int length, -// Class> vectorIndexClass, int indexLength, -// Object base, long offset, // Unsafe addressing -// W indexVector, V v, M m, -// C container, int index, int[] indexMap, int indexM, // Arguments for default implementation -// StoreVectorOperationWithMap defaultImpl) +// void storeWithMap(Class vClass, Class mClass, Class cClass, int operType, +// int length, +// Class> vectorIndexClass, +// int indexLength, Object base, long offset, +// W indexVector, +// V v, M m, C container, int index, int[] indexMap, int indexM, +// StoreVectorOperationWithMap defaultImpl) +// // bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(3))->isa_int(); - const TypeInstPtr* vector_idx_klass = gvn().type(argument(4))->isa_instptr(); - const TypeInt* idx_vlen = gvn().type(argument(5))->isa_int(); + const TypeInt* operType = gvn().type(argument(3))->isa_int(); + const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInstPtr* vector_idx_klass = gvn().type(argument(5))->isa_instptr(); + const TypeInt* idx_vlen = gvn().type(argument(6))->isa_int(); if (vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() || vector_idx_klass == nullptr || vector_idx_klass->const_oop() == nullptr || idx_vlen == nullptr || !idx_vlen->is_con()) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s viclass=%s idx_vlen=%s", + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s viclass=%s idx_vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(2)->Opcode()], NodeClassNames[argument(3)->Opcode()], NodeClassNames[argument(4)->Opcode()], - NodeClassNames[argument(5)->Opcode()]); + NodeClassNames[argument(5)->Opcode()], + NodeClassNames[argument(6)->Opcode()]); return false; // not enough info for intrinsification } @@ -1245,7 +1328,7 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { int num_elem = vlen->get_con(); int idx_num_elem = idx_vlen->get_con(); - Node* m = is_scatter ? argument(11) : argument(13); + Node* m = is_scatter ? argument(12) : argument(14); const Type* vmask_type = gvn().type(m); bool is_masked_op = vmask_type != TypePtr::NULL_PTR; if (is_masked_op) { @@ -1291,8 +1374,8 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { return false; // not supported } - Node* base = argument(6); - Node* offset = ConvL2X(argument(7)); + Node* base = argument(7); + Node* offset = ConvL2X(argument(8)); // Save state and restore on bailout SavedState old_state(this); @@ -1305,7 +1388,7 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { uint header = arrayOopDesc::base_offset_in_bytes(elem_bt); assert(offset->is_Con() && offset->bottom_type()->is_long()->get_con() == header, "offset must be the array base offset"); - Node* index = argument(15); + Node* index = argument(16); addr = array_element_address(base, index, elem_bt); } @@ -1331,12 +1414,12 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { Node* indexes = nullptr; const TypeInstPtr* vbox_idx_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_idx_klass); if (is_subword_type(elem_bt)) { - Node* indexMap = argument(16); - Node* indexM = argument(17); + Node* indexMap = argument(17); + Node* indexM = argument(18); indexes = array_element_address(indexMap, indexM, T_INT); } else { // Get the first index vector. - indexes = unbox_vector(argument(9), vbox_idx_type, T_INT, idx_num_elem); + indexes = unbox_vector(argument(10), vbox_idx_type, T_INT, idx_num_elem); if (indexes == nullptr) { return false; } @@ -1356,7 +1439,7 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { const TypeVect* vector_type = TypeVect::make(elem_bt, num_elem); if (is_scatter) { - Node* val = unbox_vector(argument(10), vbox_type, elem_bt, num_elem); + Node* val = unbox_vector(argument(11), vbox_type, elem_bt, num_elem); if (val == nullptr) { return false; // operand unboxing failed } @@ -1385,29 +1468,35 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { return true; } -// public static -// , -// M extends VectorMask, -// E> -// long reductionCoerced(int oprId, Class vectorClass, Class maskClass, -// Class elementType, int length, V v, M m, -// ReductionOperation defaultImpl) +// +// public static +// , +// M extends VectorMask, +// E> +// long reductionCoerced(int oprId, +// Class vClass, Class mClass, Class cClass, int operType, +// int length, +// V v, M m, +// ReductionOperation defaultImpl) +// bool LibraryCallKit::inline_vector_reduction() { const TypeInt* opr = gvn().type(argument(0))->isa_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* operType = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); - if (opr == nullptr || !opr->is_con() || + if (opr == nullptr || !opr->is_con() || !operType->is_con() || vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || vlen == nullptr || !vlen->is_con()) { - log_if_needed(" ** missing constant: opr=%s vclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: opr=%s vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(4)->Opcode()], + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } if (!is_klass_initialized(vector_klass)) { @@ -1419,8 +1508,12 @@ bool LibraryCallKit::inline_vector_reduction() { log_if_needed(" ** not a primitive bt=%d", elem_type->basic_type()); return false; // should be primitive type } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } - const Type* vmask_type = gvn().type(argument(6)); + const Type* vmask_type = gvn().type(argument(7)); bool is_masked_op = vmask_type != TypePtr::NULL_PTR; if (is_masked_op) { if (mask_klass == nullptr || mask_klass->const_oop() == nullptr) { @@ -1463,7 +1556,7 @@ bool LibraryCallKit::inline_vector_reduction() { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); - Node* opd = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + Node* opd = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); if (opd == nullptr) { return false; // operand unboxing failed } @@ -1473,10 +1566,10 @@ bool LibraryCallKit::inline_vector_reduction() { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); assert(is_vector_mask(mbox_klass), "argument(2) should be a mask class"); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - mask = unbox_vector(argument(6), mbox_type, elem_bt, num_elem); + mask = unbox_vector(argument(7), mbox_type, elem_bt, num_elem); if (mask == nullptr) { log_if_needed(" ** unbox failed mask=%s", - NodeClassNames[argument(6)->Opcode()]); + NodeClassNames[argument(7)->Opcode()]); return false; } } @@ -1529,27 +1622,45 @@ bool LibraryCallKit::inline_vector_reduction() { return true; } -// public static boolean test(int cond, Class vectorClass, Class elementType, int vlen, -// V v1, V v2, -// BiFunction defaultImpl) + + +// +// public static +// , +// E> +// boolean test(int cond, +// Class mClass, Class cClass, int operType, +// int length, +// M m1, M m2, +// BiFunction defaultImpl) +// // bool LibraryCallKit::inline_vector_test() { const TypeInt* cond = gvn().type(argument(0))->isa_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeInt* operType = gvn().type(argument(3))->isa_int(); + const TypeInt* vlen = gvn().type(argument(4))->isa_int(); if (cond == nullptr || !cond->is_con() || vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con()) { - log_if_needed(" ** missing constant: cond=%s vclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: cond=%s vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], - NodeClassNames[argument(3)->Opcode()]); + NodeClassNames[argument(3)->Opcode()], + NodeClassNames[argument(4)->Opcode()]); return false; // not enough info for intrinsification } + + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -1572,11 +1683,11 @@ bool LibraryCallKit::inline_vector_test() { return false; } - Node* opd1 = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); + Node* opd1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); Node* opd2; if (Matcher::vectortest_needs_second_argument(booltest == BoolTest::overflow, opd1->bottom_type()->isa_vectmask())) { - opd2 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + opd2 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); } else { opd2 = opd1; } @@ -1595,31 +1706,37 @@ bool LibraryCallKit::inline_vector_test() { return true; } -// public static -// , -// M extends VectorMask, -// E> -// V blend(Class vectorClass, Class maskClass, Class elementType, int vlen, -// V v1, V v2, M m, -// VectorBlendOp defaultImpl) +// +// public static +// , +// M extends VectorMask, +// E> +// V blend(Class vClass, Class mClass, Class cClass, int operType, +// int length, +// V v1, V v2, M m, +// VectorBlendOp defaultImpl) +// bool LibraryCallKit::inline_vector_blend() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeInt* operType = gvn().type(argument(3))->isa_int(); + const TypeInt* vlen = gvn().type(argument(4))->isa_int(); - if (mask_klass == nullptr || vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr) { + if (mask_klass == nullptr || vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr || operType == nullptr) { return false; // dead code } if (mask_klass->const_oop() == nullptr || vector_klass->const_oop() == nullptr || - elem_klass->const_oop() == nullptr || !vlen->is_con()) { - log_if_needed(" ** missing constant: vclass=%s mclass=%s etype=%s vlen=%s", + elem_klass->const_oop() == nullptr || !vlen->is_con() || !operType->is_con()) { + log_if_needed(" ** missing constant: vclass=%s mclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], - NodeClassNames[argument(3)->Opcode()]); + NodeClassNames[argument(3)->Opcode()], + NodeClassNames[argument(4)->Opcode()]); return false; // not enough info for intrinsification } + if (!is_klass_initialized(vector_klass) || !is_klass_initialized(mask_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -1644,9 +1761,9 @@ bool LibraryCallKit::inline_vector_blend() { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - Node* v1 = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); - Node* v2 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); - Node* mask = unbox_vector(argument(6), mbox_type, mask_bt, num_elem); + Node* v1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + Node* v2 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); + Node* mask = unbox_vector(argument(7), mbox_type, mask_bt, num_elem); if (v1 == nullptr || v2 == nullptr || mask == nullptr) { return false; // operand unboxing failed @@ -1660,33 +1777,46 @@ bool LibraryCallKit::inline_vector_blend() { return true; } + +// // public static // , // M extends VectorMask, // E> -// M compare(int cond, Class vectorClass, Class maskClass, Class elementType, int vlen, +// M compare(int cond, +// Class vectorClass, Class mClass, Class cClass, int operType, +// int length, // V v1, V v2, M m, -// VectorCompareOp defaultImpl) +// VectorCompareOp defaultImpl) +// bool LibraryCallKit::inline_vector_compare() { const TypeInt* cond = gvn().type(argument(0))->isa_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* operType = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); - if (cond == nullptr || vector_klass == nullptr || mask_klass == nullptr || elem_klass == nullptr || vlen == nullptr) { + if (cond == nullptr || vector_klass == nullptr || mask_klass == nullptr || elem_klass == nullptr || operType == nullptr || vlen == nullptr) { return false; // dead code } if (!cond->is_con() || vector_klass->const_oop() == nullptr || mask_klass->const_oop() == nullptr || - elem_klass->const_oop() == nullptr || !vlen->is_con()) { - log_if_needed(" ** missing constant: cond=%s vclass=%s mclass=%s etype=%s vlen=%s", + elem_klass->const_oop() == nullptr || !operType->is_con() || !vlen->is_con()) { + log_if_needed(" ** missing constant: cond=%s vclass=%s mclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(4)->Opcode()], + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } + + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass) || !is_klass_initialized(mask_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -1721,11 +1851,11 @@ bool LibraryCallKit::inline_vector_compare() { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - Node* v1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); - Node* v2 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); + Node* v1 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); + Node* v2 = unbox_vector(argument(7), vbox_type, elem_bt, num_elem); - bool is_masked_op = argument(7)->bottom_type() != TypePtr::NULL_PTR; - Node* mask = is_masked_op ? unbox_vector(argument(7), mbox_type, elem_bt, num_elem) : nullptr; + bool is_masked_op = argument(8)->bottom_type() != TypePtr::NULL_PTR; + Node* mask = is_masked_op ? unbox_vector(argument(8), mbox_type, elem_bt, num_elem) : nullptr; if (is_masked_op && mask == nullptr) { log_if_needed(" ** not supported: mask = null arity=2 op=comp/%d vlen=%d etype=%s ismask=usestore is_masked_op=1", cond->get_con(), num_elem, type2name(elem_bt)); @@ -1766,33 +1896,39 @@ bool LibraryCallKit::inline_vector_compare() { return true; } -// public static -// , -// Sh extends VectorShuffle, -// M extends VectorMask, -// E> -// V rearrangeOp(Class vectorClass, Class shuffleClass, Class maskClass, Class elementType, int vlen, -// V v1, Sh sh, M m, -// VectorRearrangeOp defaultImpl) +// +// public static +// , +// SH extends VectorShuffle, +// M extends VectorMask, +// E> +// V rearrangeOp(Class vClass, Class shClass, Class mClass, Class cClass, int operType, +// int length, +// V v, SH sh, M m, +// VectorRearrangeOp defaultImpl) +// bool LibraryCallKit::inline_vector_rearrange() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* shuffle_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* operType = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); - if (vector_klass == nullptr || shuffle_klass == nullptr || elem_klass == nullptr || vlen == nullptr) { + if (vector_klass == nullptr || shuffle_klass == nullptr || elem_klass == nullptr || operType == nullptr || vlen == nullptr) { return false; // dead code } if (shuffle_klass->const_oop() == nullptr || vector_klass->const_oop() == nullptr || elem_klass->const_oop() == nullptr || + !operType->is_con() || !vlen->is_con()) { - log_if_needed(" ** missing constant: vclass=%s sclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: vclass=%s sclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(4)->Opcode()], + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } if (!is_klass_initialized(vector_klass) || @@ -1825,7 +1961,7 @@ bool LibraryCallKit::inline_vector_rearrange() { return false; // not supported } - bool is_masked_op = argument(7)->bottom_type() != TypePtr::NULL_PTR; + bool is_masked_op = argument(8)->bottom_type() != TypePtr::NULL_PTR; bool use_predicate = is_masked_op; if (is_masked_op && (mask_klass == nullptr || @@ -1856,8 +1992,8 @@ bool LibraryCallKit::inline_vector_rearrange() { ciKlass* shbox_klass = shuffle_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* shbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, shbox_klass); - Node* v1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); - Node* shuffle = unbox_vector(argument(6), shbox_type, shuffle_bt, num_elem); + Node* v1 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); + Node* shuffle = unbox_vector(argument(7), shbox_type, shuffle_bt, num_elem); const TypeVect* st = TypeVect::make(shuffle_bt, num_elem); if (v1 == nullptr || shuffle == nullptr) { @@ -1873,7 +2009,7 @@ bool LibraryCallKit::inline_vector_rearrange() { if (is_masked_op) { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - mask = unbox_vector(argument(7), mbox_type, elem_bt, num_elem); + mask = unbox_vector(argument(8), mbox_type, elem_bt, num_elem); if (mask == nullptr) { log_if_needed(" ** not supported: arity=3 op=shuffle/rearrange vlen=%d etype=%s ismask=useload is_masked_op=1", num_elem, type2name(elem_bt)); @@ -1905,33 +2041,42 @@ bool LibraryCallKit::inline_vector_rearrange() { return true; } -// public static -// , -// M extends VectorMask, -// E> -// V selectFromOp(Class vClass, Class mClass, Class eClass, -// int length, V v1, V v2, M m, -// VectorSelectFromOp defaultImpl) +// +// public static +// , +// M extends VectorMask, +// E> +// V selectFromOp(Class vClass, Class mClass, Class cClass, int operType, +// int length, V v1, V v2, M m, +// VectorSelectFromOp defaultImpl) +// bool LibraryCallKit::inline_vector_select_from() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(2))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeInt* operType = gvn().type(argument(3))->isa_int(); + const TypeInt* vlen = gvn().type(argument(4))->isa_int(); - if (vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr || + if (vector_klass == nullptr || elem_klass == nullptr || operType == nullptr || vlen == nullptr || vector_klass->const_oop() == nullptr || elem_klass->const_oop() == nullptr || + !operType->is_con() || !vlen->is_con()) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(2)->Opcode()], - NodeClassNames[argument(3)->Opcode()]); + NodeClassNames[argument(3)->Opcode()], + NodeClassNames[argument(4)->Opcode()]); return false; // not enough info for intrinsification } if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type(); if (!elem_type->is_primitive_type()) { log_if_needed(" ** not a primitive bt=%d", elem_type->basic_type()); @@ -1962,7 +2107,7 @@ bool LibraryCallKit::inline_vector_select_from() { return false; // not supported } - bool is_masked_op = argument(6)->bottom_type() != TypePtr::NULL_PTR; + bool is_masked_op = argument(7)->bottom_type() != TypePtr::NULL_PTR; bool use_predicate = is_masked_op; if (is_masked_op && (mask_klass == nullptr || @@ -1987,17 +2132,17 @@ bool LibraryCallKit::inline_vector_select_from() { const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); // v1 is the index vector - Node* v1 = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); + Node* v1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); // v2 is the vector being rearranged - Node* v2 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + Node* v2 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); if (v1 == nullptr) { - log_if_needed(" ** unbox failed v1=%s", NodeClassNames[argument(4)->Opcode()]); + log_if_needed(" ** unbox failed v1=%s", NodeClassNames[argument(6)->Opcode()]); return false; // operand unboxing failed } if (v2 == nullptr) { - log_if_needed(" ** unbox failed v2=%s", NodeClassNames[argument(5)->Opcode()]); + log_if_needed(" ** unbox failed v2=%s", NodeClassNames[argument(7)->Opcode()]); return false; // operand unboxing failed } @@ -2005,9 +2150,9 @@ bool LibraryCallKit::inline_vector_select_from() { if (is_masked_op) { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - mask = unbox_vector(argument(6), mbox_type, elem_bt, num_elem); + mask = unbox_vector(argument(7), mbox_type, elem_bt, num_elem); if (mask == nullptr) { - log_if_needed(" ** unbox failed mask=%s", NodeClassNames[argument(6)->Opcode()]); + log_if_needed(" ** unbox failed mask=%s", NodeClassNames[argument(8)->Opcode()]); return false; } } @@ -2061,20 +2206,23 @@ bool LibraryCallKit::inline_vector_select_from() { return true; } -// public static -// , -// M extends VectorMask, -// E> -// V broadcastInt(int opr, Class vectorClass, Class maskClass, -// Class elementType, int length, -// V v, int n, M m, -// VectorBroadcastIntOp defaultImpl) +// +// public static +// , +// M extends VectorMask, +// E> +// V broadcastInt(int opr, +// Class vClass, Class mClass, Class cClass, int operType, +// int length, +// V v, int n, M m, +// VectorBroadcastIntOp defaultImpl) { +// bool LibraryCallKit::inline_vector_broadcast_int() { const TypeInt* opr = gvn().type(argument(0))->isa_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); if (opr == nullptr || vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr) { return false; // dead code @@ -2084,7 +2232,7 @@ bool LibraryCallKit::inline_vector_broadcast_int() { NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } if (!is_klass_initialized(vector_klass)) { @@ -2135,7 +2283,7 @@ bool LibraryCallKit::inline_vector_broadcast_int() { return false; // operation not supported } - Node* cnt = argument(6); + Node* cnt = argument(7); const TypeInt* cnt_type = cnt->bottom_type()->isa_int(); ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); @@ -2161,7 +2309,7 @@ bool LibraryCallKit::inline_vector_broadcast_int() { } } - Node* opd1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + Node* opd1 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); Node* opd2 = nullptr; if (is_shift) { opd2 = vector_shift_count(cnt, opc, elem_bt, num_elem); @@ -2184,9 +2332,9 @@ bool LibraryCallKit::inline_vector_broadcast_int() { if (is_masked_op) { ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - mask = unbox_vector(argument(7), mbox_type, elem_bt, num_elem); + mask = unbox_vector(argument(8), mbox_type, elem_bt, num_elem); if (mask == nullptr) { - log_if_needed(" ** unbox failed mask=%s", NodeClassNames[argument(7)->Opcode()]); + log_if_needed(" ** unbox failed mask=%s", NodeClassNames[argument(8)->Opcode()]); return false; } } @@ -2403,29 +2551,41 @@ bool LibraryCallKit::inline_vector_convert() { return true; } +// // public static // , // E> -// V insert(Class vectorClass, Class elementType, int vlen, -// V vec, int ix, long val, +// V insert(Class vClass, Class cClass, int operType, +// int length, +// V v, int i, long val, // VecInsertOp defaultImpl) +// bool LibraryCallKit::inline_vector_insert() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); - const TypeInt* idx = gvn().type(argument(4))->isa_int(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeInt* idx = gvn().type(argument(5))->isa_int(); - if (vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr || idx == nullptr) { + if (vector_klass == nullptr || elem_klass == nullptr || operType == nullptr || vlen == nullptr || idx == nullptr) { return false; // dead code } - if (vector_klass->const_oop() == nullptr || elem_klass->const_oop() == nullptr || !vlen->is_con() || !idx->is_con()) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s idx=%s", + if (vector_klass->const_oop() == nullptr || elem_klass->const_oop() == nullptr || !operType->is_con() || + !vlen->is_con() || !idx->is_con()) { + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s idx=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(3)->Opcode()], + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } + + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -2446,12 +2606,12 @@ bool LibraryCallKit::inline_vector_insert() { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); - Node* opd = unbox_vector(argument(3), vbox_type, elem_bt, num_elem); + Node* opd = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); if (opd == nullptr) { return false; } - Node* insert_val = argument(5); + Node* insert_val = argument(6); assert(gvn().type(insert_val)->isa_long() != nullptr, "expected to be long"); // Convert insert value back to its appropriate type. @@ -2486,29 +2646,40 @@ bool LibraryCallKit::inline_vector_insert() { return true; } +// // public static // -// long extract(Class vClass, Class eClass, +// long extract(Class vClass, Class cClass, int operType, // int length, // VM vm, int i, // VecExtractOp defaultImpl) +// bool LibraryCallKit::inline_vector_extract() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); - const TypeInt* idx = gvn().type(argument(4))->isa_int(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); + const TypeInt* idx = gvn().type(argument(5))->isa_int(); if (vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() || idx == nullptr) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], - NodeClassNames[argument(2)->Opcode()]); + NodeClassNames[argument(2)->Opcode()], + NodeClassNames[argument(3)->Opcode()]); return false; // not enough info for intrinsification } + + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -2529,10 +2700,10 @@ bool LibraryCallKit::inline_vector_extract() { if (is_vector_mask(vbox_klass)) { // vbox_klass is mask. This is used for VectorMask.laneIsSet(int). - Node* pos = argument(4); // can be variable + Node* pos = argument(5); // can be variable if (arch_supports_vector(Op_ExtractUB, num_elem, elem_bt, VecMaskUseAll)) { // Transform mask to vector with type of boolean and utilize ExtractUB node. - opd = unbox_vector(argument(3), vbox_type, elem_bt, num_elem); + opd = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); if (opd == nullptr) { return false; } @@ -2540,7 +2711,7 @@ bool LibraryCallKit::inline_vector_extract() { opd = gvn().transform(new ExtractUBNode(opd, pos)); opd = gvn().transform(new ConvI2LNode(opd)); } else if (arch_supports_vector(Op_VectorMaskToLong, num_elem, elem_bt, VecMaskUseLoad)) { - opd = unbox_vector(argument(3), vbox_type, elem_bt, num_elem); + opd = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); if (opd == nullptr) { return false; } @@ -2559,7 +2730,7 @@ bool LibraryCallKit::inline_vector_extract() { } else { // vbox_klass is vector. This is used for Vector.lane(int). if (!idx->is_con()) { - log_if_needed(" ** missing constant: idx=%s", NodeClassNames[argument(4)->Opcode()]); + log_if_needed(" ** missing constant: idx=%s", NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } @@ -2570,7 +2741,7 @@ bool LibraryCallKit::inline_vector_extract() { return false; // not supported } - opd = unbox_vector(argument(3), vbox_type, elem_bt, num_elem); + opd = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); if (opd == nullptr) { return false; } @@ -2670,26 +2841,36 @@ static Node* LowerSelectFromTwoVectorOperation(PhaseGVN& phase, Node* index_vec, return new VectorBlendNode(p2, p1, mask); } +// // public static // , // E> -// V selectFromTwoVectorOp(Class vClass, Class eClass, int length, +// V selectFromTwoVectorOp(Class vClass, Class cClass, int operType, int length, // V v1, V v2, V v3, // SelectFromTwoVector defaultImpl) +// bool LibraryCallKit::inline_vector_select_from_two_vectors() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); - if (vector_klass == nullptr || elem_klass == nullptr || vlen == nullptr || vector_klass->const_oop() == nullptr || - elem_klass->const_oop() == nullptr ||!vlen->is_con()) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s", + if (vector_klass == nullptr || elem_klass == nullptr || operType == nullptr || vlen == nullptr || + vector_klass->const_oop() == nullptr || + elem_klass->const_oop() == nullptr || !operType->is_con() || !vlen->is_con()) { + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], - NodeClassNames[argument(2)->Opcode()]); + NodeClassNames[argument(2)->Opcode()], + NodeClassNames[argument(3)->Opcode()]); return false; // not enough info for intrinsification } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -2751,22 +2932,22 @@ bool LibraryCallKit::inline_vector_select_from_two_vectors() { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); - Node* opd1 = unbox_vector(argument(3), vbox_type, elem_bt, num_elem); + Node* opd1 = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); if (opd1 == nullptr) { log_if_needed(" ** unbox failed v1=%s", - NodeClassNames[argument(3)->Opcode()]); + NodeClassNames[argument(4)->Opcode()]); return false; } - Node* opd2 = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); + Node* opd2 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); if (opd2 == nullptr) { log_if_needed(" ** unbox failed v2=%s", - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(5)->Opcode()]); return false; } - Node* opd3 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + Node* opd3 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); if (opd3 == nullptr) { log_if_needed(" ** unbox failed v3=%s", - NodeClassNames[argument(5)->Opcode()]); + NodeClassNames[argument(6)->Opcode()]); return false; } @@ -2793,20 +2974,22 @@ bool LibraryCallKit::inline_vector_select_from_two_vectors() { return true; } -// public static -// , -// M extends VectorMask, -// E> -// V compressExpandOp(int opr, -// Class vClass, Class mClass, Class eClass, -// int length, V v, M m, -// CompressExpandOperation defaultImpl) +// +// public static +// , +// M extends VectorMask, +// E> +// VectorPayload compressExpandOp(int opr, +// Class vClass, Class mClass, Class cClass, int operType, +// int length, V v, M m, +// CompressExpandOperation defaultImpl) +// bool LibraryCallKit::inline_vector_compress_expand() { const TypeInt* opr = gvn().type(argument(0))->isa_int(); const TypeInstPtr* vector_klass = gvn().type(argument(1))->isa_instptr(); const TypeInstPtr* mask_klass = gvn().type(argument(2))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(3))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(4))->isa_int(); + const TypeInt* vlen = gvn().type(argument(5))->isa_int(); if (opr == nullptr || !opr->is_con() || vector_klass == nullptr || vector_klass->const_oop() == nullptr || @@ -2818,7 +3001,7 @@ bool LibraryCallKit::inline_vector_compress_expand() { NodeClassNames[argument(1)->Opcode()], NodeClassNames[argument(2)->Opcode()], NodeClassNames[argument(3)->Opcode()], - NodeClassNames[argument(4)->Opcode()]); + NodeClassNames[argument(5)->Opcode()]); return false; // not enough info for intrinsification } @@ -2848,22 +3031,22 @@ bool LibraryCallKit::inline_vector_compress_expand() { if (opc != Op_CompressM) { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); - opd1 = unbox_vector(argument(5), vbox_type, elem_bt, num_elem); + opd1 = unbox_vector(argument(6), vbox_type, elem_bt, num_elem); if (opd1 == nullptr) { log_if_needed(" ** unbox failed vector=%s", - NodeClassNames[argument(5)->Opcode()]); + NodeClassNames[argument(6)->Opcode()]); return false; } } ciKlass* mbox_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass(); - assert(is_vector_mask(mbox_klass), "argument(6) should be a mask class"); + assert(is_vector_mask(mbox_klass), "argument(7) should be a mask class"); const TypeInstPtr* mbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, mbox_klass); - Node* mask = unbox_vector(argument(6), mbox_type, elem_bt, num_elem); + Node* mask = unbox_vector(argument(7), mbox_type, elem_bt, num_elem); if (mask == nullptr) { log_if_needed(" ** unbox failed mask=%s", - NodeClassNames[argument(6)->Opcode()]); + NodeClassNames[argument(7)->Opcode()]); return false; } @@ -2878,29 +3061,39 @@ bool LibraryCallKit::inline_vector_compress_expand() { return true; } -// public static -// , -// E, -// S extends VectorSpecies> -// V indexVector(Class vClass, Class eClass, +// +// public static +// , +// E, +// S extends VectorSpecies> +// V indexVector(Class vClass, Class cClass, int operType, // int length, // V v, int step, S s, -// IndexOperation defaultImpl) +// IndexOperation defaultImpl) { +// bool LibraryCallKit::inline_index_vector() { const TypeInstPtr* vector_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); if (vector_klass == nullptr || vector_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con() ) { - log_if_needed(" ** missing constant: vclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: vclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], - NodeClassNames[argument(2)->Opcode()]); + NodeClassNames[argument(2)->Opcode()], + NodeClassNames[argument(3)->Opcode()]); return false; // not enough info for intrinsification } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(vector_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -2924,7 +3117,7 @@ bool LibraryCallKit::inline_index_vector() { int mul_op = VectorSupport::vop2ideal(VectorSupport::VECTOR_OP_MUL, elem_bt); int vmul_op = VectorNode::opcode(mul_op, elem_bt); bool needs_mul = true; - Node* scale = argument(4); + Node* scale = argument(5); const TypeInt* scale_type = gvn().type(scale)->isa_int(); // Multiply is not needed if the scale is a constant "1". if (scale_type && scale_type->is_con() && scale_type->get_con() == 1) { @@ -2950,10 +3143,10 @@ bool LibraryCallKit::inline_index_vector() { ciKlass* vbox_klass = vector_klass->const_oop()->as_instance()->java_lang_Class_klass(); const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); - Node* opd = unbox_vector(argument(3), vbox_type, elem_bt, num_elem); + Node* opd = unbox_vector(argument(4), vbox_type, elem_bt, num_elem); if (opd == nullptr) { log_if_needed(" ** unbox failed vector=%s", - NodeClassNames[argument(3)->Opcode()]); + NodeClassNames[argument(4)->Opcode()]); return false; } @@ -3014,27 +3207,37 @@ bool LibraryCallKit::inline_index_vector() { return true; } -// public static -// > -// M indexPartiallyInUpperRange(Class mClass, Class eClass, int length, -// long offset, long limit, -// IndexPartiallyInUpperRangeOperation defaultImpl) +// +// public static +// > +// M indexPartiallyInUpperRange(Class mClass, Class cClass, int operType, +// int length, long offset, long limit, +// IndexPartiallyInUpperRangeOperation defaultImpl) +// bool LibraryCallKit::inline_index_partially_in_upper_range() { const TypeInstPtr* mask_klass = gvn().type(argument(0))->isa_instptr(); const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr(); - const TypeInt* vlen = gvn().type(argument(2))->isa_int(); + const TypeInt* operType = gvn().type(argument(2))->isa_int(); + const TypeInt* vlen = gvn().type(argument(3))->isa_int(); if (mask_klass == nullptr || mask_klass->const_oop() == nullptr || elem_klass == nullptr || elem_klass->const_oop() == nullptr || + operType == nullptr || !operType->is_con() || vlen == nullptr || !vlen->is_con()) { - log_if_needed(" ** missing constant: mclass=%s etype=%s vlen=%s", + log_if_needed(" ** missing constant: mclass=%s etype=%s operType=%s vlen=%s", NodeClassNames[argument(0)->Opcode()], NodeClassNames[argument(1)->Opcode()], - NodeClassNames[argument(2)->Opcode()]); + NodeClassNames[argument(2)->Opcode()], + NodeClassNames[argument(3)->Opcode()]); return false; // not enough info for intrinsification } + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); + return false; + } + if (!is_klass_initialized(mask_klass)) { log_if_needed(" ** klass argument not initialized"); return false; @@ -3071,8 +3274,8 @@ bool LibraryCallKit::inline_index_partially_in_upper_range() { } } - Node* offset = argument(3); - Node* limit = argument(5); + Node* offset = argument(4); + Node* limit = argument(6); if (offset == nullptr || limit == nullptr) { log_if_needed(" ** offset or limit argument is null"); return false; // not supported diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index 6ae8bbe8aa0af..8710659966f66 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -292,6 +292,7 @@ int VectorNode::opcode(int sopc, BasicType bt) { } } + // Limits on vector size (number of elements) for auto-vectorization. bool VectorNode::vector_size_supported_auto_vectorization(const BasicType bt, int size) { return Matcher::max_vector_size_auto_vectorization(bt) >= size && diff --git a/src/hotspot/share/opto/vectornode.hpp b/src/hotspot/share/opto/vectornode.hpp index 427aeff53fcf9..6717cadc5e19e 100644 --- a/src/hotspot/share/opto/vectornode.hpp +++ b/src/hotspot/share/opto/vectornode.hpp @@ -82,6 +82,8 @@ class VectorNode : public TypeNode { static VectorNode* make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt); static VectorNode* make(int vopc, Node* n1, Node* n2, Node* n3, const TypeVect* vt); static VectorNode* make_mask_node(int vopc, Node* n1, Node* n2, uint vlen, BasicType bt); + static VectorNode* make(int vopc, Node* n1, Node* n2, uint vlen); + static VectorNode* make(int vopc, Node* n1, Node* n2, Node* n3, uint vlen); static bool is_shift_opcode(int opc); static bool can_use_RShiftI_instead_of_URShiftI(Node* n, BasicType bt); diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index a98cad072275f..aa5c78c41208f 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -55,7 +55,7 @@ BasicType VectorSupport::klass2bt(InstanceKlass* ik) { assert(ik->is_subclass_of(vmClasses::vector_VectorPayload_klass()), "%s not a VectorPayload", ik->name()->as_C_string()); fieldDescriptor fd; // find_field initializes fd if found // static final Class ETYPE; - Klass* holder = ik->find_field(vmSymbols::ETYPE_name(), vmSymbols::class_signature(), &fd); + Klass* holder = ik->find_field(vmSymbols::CTYPE_name(), vmSymbols::class_signature(), &fd); assert(holder != nullptr, "sanity"); assert(fd.is_static(), ""); @@ -199,13 +199,17 @@ bool VectorSupport::is_unsigned_op(jint id) { } } -int VectorSupport::vop2ideal(jint id, BasicType bt) { +int VectorSupport::vop2ideal(jint id, BasicType bt, int operType) { VectorOperation vop = (VectorOperation)id; switch (vop) { case VECTOR_OP_ADD: { switch (bt) { case T_BYTE: // fall-through - case T_SHORT: // fall-through + case T_SHORT: + if (operType == VECTOR_TYPE_FP16) { + return Op_AddHF; + } + // fall-through case T_INT: return Op_AddI; case T_LONG: return Op_AddL; case T_FLOAT: return Op_AddF; @@ -217,7 +221,11 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { case VECTOR_OP_SUB: { switch (bt) { case T_BYTE: // fall-through - case T_SHORT: // fall-through + case T_SHORT: + if (operType == VECTOR_TYPE_FP16) { + return Op_SubHF; + } + // fall-through case T_INT: return Op_SubI; case T_LONG: return Op_SubL; case T_FLOAT: return Op_SubF; @@ -229,7 +237,11 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { case VECTOR_OP_MUL: { switch (bt) { case T_BYTE: // fall-through - case T_SHORT: // fall-through + case T_SHORT: + if (operType == VECTOR_TYPE_FP16) { + return Op_MulHF; + } + // fall-through case T_INT: return Op_MulI; case T_LONG: return Op_MulL; case T_FLOAT: return Op_MulF; @@ -241,7 +253,11 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { case VECTOR_OP_DIV: { switch (bt) { case T_BYTE: // fall-through - case T_SHORT: // fall-through + case T_SHORT: + if (operType == VECTOR_TYPE_FP16) { + return Op_DivHF; + } + // fall-through case T_INT: return Op_DivI; case T_LONG: return Op_DivL; case T_FLOAT: return Op_DivF; @@ -254,6 +270,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { switch (bt) { case T_BYTE: case T_SHORT: + if (operType == VECTOR_TYPE_FP16) { + return Op_MinHF; + } + // fall-through case T_INT: return Op_MinI; case T_LONG: return Op_MinL; case T_FLOAT: return Op_MinF; @@ -266,6 +286,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { switch (bt) { case T_BYTE: case T_SHORT: + if (operType == VECTOR_TYPE_FP16) { + return Op_MaxHF; + } + // fall-through case T_INT: return Op_MaxI; case T_LONG: return Op_MaxL; case T_FLOAT: return Op_MaxF; @@ -350,6 +374,7 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { } case VECTOR_OP_SQRT: { switch (bt) { + case T_SHORT: return Op_SqrtHF; case T_FLOAT: return Op_SqrtF; case T_DOUBLE: return Op_SqrtD; default: fatal("SQRT: %s", type2name(bt)); @@ -358,6 +383,7 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { } case VECTOR_OP_FMA: { switch (bt) { + case T_SHORT: return Op_FmaHF; case T_FLOAT: return Op_FmaF; case T_DOUBLE: return Op_FmaD; default: fatal("FMA: %s", type2name(bt)); diff --git a/src/hotspot/share/prims/vectorSupport.hpp b/src/hotspot/share/prims/vectorSupport.hpp index 9ec6500543cbe..71d399680874e 100644 --- a/src/hotspot/share/prims/vectorSupport.hpp +++ b/src/hotspot/share/prims/vectorSupport.hpp @@ -137,12 +137,19 @@ class VectorSupport : AllStatic { NUM_VEC_SIZES = 5 }; + enum { + VECTOR_TYPE_PRIM = 1, + VECTOR_TYPE_FP16 = 2, + VECTOR_TYPE_FP8 = 3, + VECTOR_TYPE_INT8 = 4 + }; + enum { MODE_BROADCAST = 0, MODE_BITS_COERCED_LONG_TO_MASK = 1 }; - static int vop2ideal(jint vop, BasicType bt); + static int vop2ideal(jint vop, BasicType bt, int operType = VECTOR_TYPE_PRIM); static bool has_scalar_op(jint id); static bool is_unsigned_op(jint id); diff --git a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template index 158df7c8bb3e3..b7cb8d1fcaf54 100644 --- a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template +++ b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template @@ -326,7 +326,7 @@ public final class ScopedMemoryAccess { @ForceInline public static , E, S extends VectorSupport.VectorSpecies> - V loadFromMemorySegment(Class vmClass, Class e, int length, + V loadFromMemorySegment(Class vmClass, Class c, int operType, int length, AbstractMemorySegmentImpl msp, long offset, S s, VectorSupport.LoadOperation defaultImpl) { @@ -334,7 +334,7 @@ public final class ScopedMemoryAccess { try { return loadFromMemorySegmentScopedInternal( msp.sessionImpl(), - vmClass, e, length, + vmClass, c, operType, length, msp, offset, s, defaultImpl); @@ -348,14 +348,14 @@ public final class ScopedMemoryAccess { private static , E, S extends VectorSupport.VectorSpecies> V loadFromMemorySegmentScopedInternal(MemorySessionImpl session, - Class vmClass, Class e, int length, + Class vmClass, Class c, int operType, int length, AbstractMemorySegmentImpl msp, long offset, S s, VectorSupport.LoadOperation defaultImpl) { try { session.checkValidStateRaw(); - return VectorSupport.load(vmClass, e, length, + return VectorSupport.load(vmClass, c, operType, length, msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true, msp, offset, s, defaultImpl); @@ -368,14 +368,14 @@ public final class ScopedMemoryAccess { public static , E, S extends VectorSupport.VectorSpecies, M extends VectorSupport.VectorMask> - V loadFromMemorySegmentMasked(Class vmClass, Class maskClass, Class e, + V loadFromMemorySegmentMasked(Class vmClass, Class maskClass, Class c, int operType, int length, AbstractMemorySegmentImpl msp, long offset, M m, S s, int offsetInRange, VectorSupport.LoadVectorMaskedOperation defaultImpl) { try { return loadFromMemorySegmentMaskedScopedInternal( msp.sessionImpl(), - vmClass, maskClass, e, length, + vmClass, maskClass, c, operType, length, msp, offset, m, s, offsetInRange, defaultImpl); @@ -390,14 +390,14 @@ public final class ScopedMemoryAccess { , E, S extends VectorSupport.VectorSpecies, M extends VectorSupport.VectorMask> V loadFromMemorySegmentMaskedScopedInternal(MemorySessionImpl session, Class vmClass, - Class maskClass, Class e, int length, + Class maskClass, Class c, int operType, int length, AbstractMemorySegmentImpl msp, long offset, M m, S s, int offsetInRange, VectorSupport.LoadVectorMaskedOperation defaultImpl) { try { session.checkValidStateRaw(); - return VectorSupport.loadMasked(vmClass, maskClass, e, length, + return VectorSupport.loadMasked(vmClass, maskClass, c, operType, length, msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true, m, offsetInRange, msp, offset, s, defaultImpl); @@ -409,7 +409,7 @@ public final class ScopedMemoryAccess { @ForceInline public static , E> - void storeIntoMemorySegment(Class vmClass, Class e, int length, + void storeIntoMemorySegment(Class vmClass, Class c, int operType, int length, V v, AbstractMemorySegmentImpl msp, long offset, VectorSupport.StoreVectorOperation defaultImpl) { @@ -417,7 +417,7 @@ public final class ScopedMemoryAccess { try { storeIntoMemorySegmentScopedInternal( msp.sessionImpl(), - vmClass, e, length, + vmClass, c, operType, length, v, msp, offset, defaultImpl); @@ -431,14 +431,14 @@ public final class ScopedMemoryAccess { private static , E> void storeIntoMemorySegmentScopedInternal(MemorySessionImpl session, - Class vmClass, Class e, int length, + Class vmClass, Class c, int operType, int length, V v, AbstractMemorySegmentImpl msp, long offset, VectorSupport.StoreVectorOperation defaultImpl) { try { session.checkValidStateRaw(); - VectorSupport.store(vmClass, e, length, + VectorSupport.store(vmClass, c, operType, length, msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true, v, msp, offset, @@ -451,15 +451,15 @@ public final class ScopedMemoryAccess { @ForceInline public static , E, M extends VectorSupport.VectorMask> - void storeIntoMemorySegmentMasked(Class vmClass, Class maskClass, Class e, - int length, V v, M m, + void storeIntoMemorySegmentMasked(Class vmClass, Class maskClass, Class c, + int operType, int length, V v, M m, AbstractMemorySegmentImpl msp, long offset, VectorSupport.StoreVectorMaskedOperation defaultImpl) { try { storeIntoMemorySegmentMaskedScopedInternal( msp.sessionImpl(), - vmClass, maskClass, e, length, + vmClass, maskClass, c, operType, length, v, m, msp, offset, defaultImpl); @@ -474,13 +474,13 @@ public final class ScopedMemoryAccess { , E, M extends VectorSupport.VectorMask> void storeIntoMemorySegmentMaskedScopedInternal(MemorySessionImpl session, Class vmClass, Class maskClass, - Class e, int length, V v, M m, + Class c, int operType, int length, V v, M m, AbstractMemorySegmentImpl msp, long offset, VectorSupport.StoreVectorMaskedOperation defaultImpl) { try { session.checkValidStateRaw(); - VectorSupport.storeMasked(vmClass, maskClass, e, length, + VectorSupport.storeMasked(vmClass, maskClass, c, operType, length, msp.unsafeGetBase(), msp.unsafeGetOffset() + offset, true, v, m, msp, offset, diff --git a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java index d3705a279ca28..3efddcbcdf037 100644 --- a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java +++ b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java @@ -149,14 +149,21 @@ public class VectorSupport { public static final int MODE_BROADCAST = 0; public static final int MODE_BITS_COERCED_LONG_TO_MASK = 1; + // Vector operation types. + public static final int VECTOR_TYPE_PRIM = 1; + public static final int VECTOR_TYPE_FP16 = 2; + public static final int VECTOR_TYPE_FP8 = 3; + public static final int VECTOR_TYPE_INT8 = 4; + // BasicType codes, for primitives only: public static final int - T_FLOAT = 6, - T_DOUBLE = 7, - T_BYTE = 8, - T_SHORT = 9, - T_INT = 10, - T_LONG = 11; + T_HALFFLOAT = 5, + T_FLOAT = 6, + T_DOUBLE = 7, + T_BYTE = 8, + T_SHORT = 9, + T_INT = 10, + T_LONG = 11; /* ============================================================================ */ @@ -203,7 +210,7 @@ public interface FromBitsCoercedOperation, E> - VM fromBitsCoerced(Class vmClass, Class eClass, + VM fromBitsCoerced(Class vmClass, Class cClass, int operType, int length, long bits, int mode, S s, FromBitsCoercedOperation defaultImpl) { @@ -221,7 +228,7 @@ public interface IndexPartiallyInUpperRangeOperation> - M indexPartiallyInUpperRange(Class mClass, Class eClass, + M indexPartiallyInUpperRange(Class mClass, Class cClass, int operType, int length, long offset, long limit, IndexPartiallyInUpperRangeOperation defaultImpl) { assert isNonCapturingLambda(defaultImpl) : defaultImpl; @@ -239,7 +246,7 @@ public interface IndexOperation, , E, S extends VectorSpecies> - V indexVector(Class vClass, Class eClass, + V indexVector(Class vClass, Class cClass, int operType, int length, V v, int step, S s, IndexOperation defaultImpl) { @@ -260,7 +267,7 @@ public interface ReductionOperation, M extends VectorMask, E> long reductionCoerced(int oprId, - Class vClass, Class mClass, Class eClass, + Class vClass, Class mClass, Class cClass, int operType, int length, V v, M m, ReductionOperation defaultImpl) { @@ -279,7 +286,7 @@ public interface VecExtractOp { public static - long extract(Class vClass, Class eClass, + long extract(Class vClass, Class cClass, int operType, int length, VM vm, int i, VecExtractOp defaultImpl) { @@ -297,7 +304,7 @@ public interface VecInsertOp> { public static , E> - V insert(Class vClass, Class eClass, + V insert(Class vClass, Class cClass, int operType, int length, V v, int i, long val, VecInsertOp defaultImpl) { @@ -318,7 +325,7 @@ public interface UnaryOperation, M extends VectorMask, E> V unaryOp(int oprId, - Class vClass, Class mClass, Class eClass, + Class vClass, Class mClass, Class cClass, int operType, int length, V v, M m, UnaryOperation defaultImpl) { @@ -356,7 +363,7 @@ public interface BinaryOperation, E> VM binaryOp(int oprId, - Class vmClass, Class mClass, Class eClass, + Class vmClass, Class mClass, Class cClass, int operType, int length, VM v1, VM v2, M m, BinaryOperation defaultImpl) { @@ -391,7 +398,7 @@ public interface SelectFromTwoVector> { public static , E> - V selectFromTwoVectorOp(Class vClass, Class eClass, int length, + V selectFromTwoVectorOp(Class vClass, Class cClass, int operType, int length, V v1, V v2, V v3, SelectFromTwoVector defaultImpl) { assert isNonCapturingLambda(defaultImpl) : defaultImpl; @@ -413,7 +420,7 @@ public interface TernaryOperation, M extends VectorMask, E> V ternaryOp(int oprId, - Class vClass, Class mClass, Class eClass, + Class vClass, Class mClass, Class cClass, int operType, int length, V v1, V v2, V v3, M m, TernaryOperation defaultImpl) { @@ -437,7 +444,7 @@ public interface LoadOperation> - VM load(Class vmClass, Class eClass, + VM load(Class vmClass, Class cClass, int operType, int length, Object base, long offset, boolean fromSegment, C container, long index, S s, @@ -462,7 +469,7 @@ public interface LoadVectorMaskedOperation, M extends VectorMask> - V loadMasked(Class vClass, Class mClass, Class eClass, + V loadMasked(Class vClass, Class mClass, Class cClass, int operType, int length, Object base, long offset, boolean fromSegment, M m, int offsetInRange, C container, long index, S s, @@ -488,7 +495,7 @@ public interface LoadVectorOperationWithMap, M extends VectorMask, E> - V loadWithMap(Class vClass, Class mClass, Class eClass, + V loadWithMap(Class vClass, Class mClass, Class cClass, int operType, int length, Class> vectorIndexClass, int indexLength, Object base, long offset, @@ -510,7 +517,7 @@ public interface StoreVectorOperation - void store(Class vClass, Class eClass, + void store(Class vClass, Class cClass, int operType, int length, Object base, long offset, boolean fromSegment, V v, C container, long index, @@ -531,7 +538,7 @@ public interface StoreVectorMaskedOperation, M extends VectorMask, E> - void storeMasked(Class vClass, Class mClass, Class eClass, + void storeMasked(Class vClass, Class mClass, Class cClass, int operType, int length, Object base, long offset, boolean fromSegment, V v, M m, C container, long index, @@ -555,7 +562,7 @@ public interface StoreVectorOperationWithMap, M extends VectorMask, E> - void storeWithMap(Class vClass, Class mClass, Class eClass, + void storeWithMap(Class vClass, Class mClass, Class cClass, int operType, int length, Class> vectorIndexClass, int indexLength, Object base, long offset, @@ -573,7 +580,7 @@ void storeWithMap(Class vClass, Class mClass, Class eClass, , E> boolean test(int cond, - Class mClass, Class eClass, + Class mClass, Class cClass, int operType, int length, M m1, M m2, BiFunction defaultImpl) { @@ -594,7 +601,7 @@ public interface VectorCompareOp, M extends VectorMask, E> M compare(int cond, - Class vectorClass, Class mClass, Class eClass, + Class vectorClass, Class mClass, Class cClass, int operType, int length, V v1, V v2, M m, VectorCompareOp defaultImpl) { @@ -615,7 +622,7 @@ public interface VectorRearrangeOp, SH extends VectorShuffle, M extends VectorMask, E> - V rearrangeOp(Class vClass, Class shClass, Class mClass, Class eClass, + V rearrangeOp(Class vClass, Class shClass, Class mClass, Class cClass, int operType, int length, V v, SH sh, M m, VectorRearrangeOp defaultImpl) { @@ -633,7 +640,7 @@ public interface VectorSelectFromOp, , M extends VectorMask, E> - V selectFromOp(Class vClass, Class mClass, Class eClass, + V selectFromOp(Class vClass, Class mClass, Class cClass, int operType, int length, V v1, V v2, M m, VectorSelectFromOp defaultImpl) { assert isNonCapturingLambda(defaultImpl) : defaultImpl; @@ -652,7 +659,7 @@ public interface VectorBlendOp, , M extends VectorMask, E> - V blend(Class vClass, Class mClass, Class eClass, + V blend(Class vClass, Class mClass, Class cClass, int operType, int length, V v1, V v2, M m, VectorBlendOp defaultImpl) { @@ -673,7 +680,7 @@ public interface VectorBroadcastIntOp, M extends VectorMask, E> V broadcastInt(int opr, - Class vClass, Class mClass, Class eClass, + Class vClass, Class mClass, Class cClass, int operType, int length, V v, int n, M m, VectorBroadcastIntOp defaultImpl) { @@ -719,7 +726,7 @@ public interface CompressExpandOperation, M extends VectorMask, E> VectorPayload compressExpandOp(int opr, - Class vClass, Class mClass, Class eClass, + Class vClass, Class mClass, Class cClass, int operType, int length, V v, M m, CompressExpandOperation defaultImpl) { assert isNonCapturingLambda(defaultImpl) : defaultImpl; @@ -748,7 +755,7 @@ public interface VectorMaskOp> { , E> long maskReductionCoerced(int oper, - Class mClass, Class eClass, + Class mClass, Class cClass, int operType, int length, M m, VectorMaskOp defaultImpl) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java index 30297b24db06c..96e0712e1875b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java @@ -73,10 +73,10 @@ public void intoArray(boolean[] bits, int i) { int laneCount = vsp.laneCount(); i = VectorIntrinsics.checkFromIndexSize(i, laneCount, bits.length); VectorSupport.store( - vsp.maskType(), vsp.elementType(), laneCount, + vsp.maskType(), vsp.carrierType(), vsp.operType(), laneCount, bits, (long) i + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, false, this, bits, i, - (c, idx, s) -> System.arraycopy(s.getBits(), 0, c, (int) idx, s.length())); + (c, idx, s) -> System.arraycopy(s.getBits(), 0, c, (int)idx, s.length())); } @@ -302,8 +302,14 @@ VectorMask checkIndex0(int offset, int length, // converting, clip the comparison value to [0..vlength] // inclusive. int indexLimit = Math.max(0, Math.min(length - offset, vlength)); - VectorMask badMask = - iota.compare(GE, iota.broadcast(indexLimit)); + VectorMask badMask = null, badMask2 = null; + if (vectorSpecies().elementType() == Float16.class) { + badMask = + iota.compare(GE, Float.floatToFloat16((float)indexLimit)); + } else { + badMask = + iota.compare(GE, iota.broadcast(indexLimit)); + } if (offset < 0) { // An active lane is bad if its number is less than // -offset, because when added to offset it will then @@ -312,8 +318,13 @@ VectorMask checkIndex0(int offset, int length, // vlength. This specific expression works correctly even // when offset is Integer.MIN_VALUE. int firstGoodIndex = -Math.max(offset, -vlength); - VectorMask badMask2 = - iota.compare(LT, iota.broadcast(firstGoodIndex)); + if (vectorSpecies().elementType() == Float16.class) { + badMask2 = + iota.compare(LT, iota.broadcast(Float.floatToFloat16((float)firstGoodIndex))); + } else { + badMask2 = + iota.compare(LT, iota.broadcast(firstGoodIndex)); + } if (indexLimit >= vlength) { badMask = badMask2; // 1st badMask is all true } else { @@ -377,8 +388,14 @@ VectorMask checkIndex0(long offset, long length, // inclusive. // 0 <= indexLimit <= vlength int indexLimit = (int) Math.max(0, Math.min(length - offset, vlength)); - VectorMask badMask = + VectorMask badMask = null, badMask2 = null; + if (vectorSpecies().elementType() == Float16.class) { + badMask = + iota.compare(GE, Float.floatToFloat16((float)indexLimit)); + } else { + badMask = iota.compare(GE, iota.broadcast(indexLimit)); + } if (offset < 0) { // An active lane is bad if its number is less than // -offset, because when added to offset it will then @@ -388,8 +405,13 @@ VectorMask checkIndex0(long offset, long length, // when offset is Integer.MIN_VALUE. // 0 <= firstGoodIndex <= vlength int firstGoodIndex = (int) -Math.max(offset, -vlength); - VectorMask badMask2 = + if (vectorSpecies().elementType() == Float16.class) { + badMask2 = + iota.compare(LT, iota.broadcast(Float.floatToFloat16((float)firstGoodIndex))); + } else { + badMask2 = iota.compare(LT, iota.broadcast(firstGoodIndex)); + } if (indexLimit >= vlength) { badMask = badMask2; // 1st badMask is all true } else { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java index bdc72c64ce513..68f0ff3fcf731 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractSpecies.java @@ -303,6 +303,12 @@ private AbstractShuffle makeSwapBytesShuffle() { /*package-private*/ abstract Vector fromIntValues(int[] values); + /*package-private*/ + abstract Class carrierType(); + + /*package-private*/ + abstract int operType(); + /** * Do not use a dummy except to call methods on it when you don't * care about the lane values. The main benefit of it is to @@ -320,7 +326,7 @@ AbstractVector dummyVector() { return makeDummyVector(); } private AbstractVector makeDummyVector() { - Object za = Array.newInstance(elementType(), laneCount); + Object za = Array.newInstance(carrierType(), laneCount); return dummyVector = vectorFactory.apply(za); // This is the only use of vectorFactory. // All other factory requests are routed @@ -415,18 +421,31 @@ final IllegalArgumentException badArrayBits(Object iv, Object iotaArray() { // Create an iota array. It's OK if this is really slow, // because it happens only once per species. - Object ia = Array.newInstance(laneType.elementType, - laneCount); - assert(ia.getClass() == laneType.arrayType); - checkValue(laneCount-1); // worst case - for (int i = 0; i < laneCount; i++) { - if ((byte)i == i) - Array.setByte(ia, i, (byte)i); - else if ((short)i == i) - Array.setShort(ia, i, (short)i); - else - Array.setInt(ia, i, i); - assert(Array.getDouble(ia, i) == i); + Object ia = null; + if (elementType() == Float16.class) { + ia = Array.newInstance(carrierType(), laneCount); + checkValue(laneCount - 1); // worst case + for (int i = 0; i < laneCount; i++) { + // All the numbers in the range [0 2048] are directly representable in FP16 format without the precision loss. + if (i < 2049) { + Array.setShort(ia, i, Float.floatToFloat16((float)i)); + } else { + assert(Float16.valueOf(i).intValue() == i); + } + } + } else { + ia = Array.newInstance(laneType.elementType, laneCount); + assert(ia.getClass() == laneType.arrayType); + checkValue(laneCount-1); // worst case + for (int i = 0; i < laneCount; i++) { + if ((byte)i == i) + Array.setByte(ia, i, (byte)i); + else if ((short)i == i) + Array.setShort(ia, i, (short)i); + else + Array.setInt(ia, i, i); + assert(Array.getDouble(ia, i) == i); + } } return ia; } @@ -624,6 +643,8 @@ AbstractSpecies computeSpecies(LaneType laneType, s = IntVector.species(shape); break; case LaneType.SK_LONG: s = LongVector.species(shape); break; + case LaneType.SK_HALFFLOAT: + s = HalffloatVector.species(shape); break; } if (s == null) { // NOTE: The result of this method is guaranteed to be @@ -636,7 +657,9 @@ AbstractSpecies computeSpecies(LaneType laneType, // bootstrapping. throw new AssertionError("bootstrap problem"); } - assert(s.laneType == laneType) : s + "!=" + laneType; + // FIXME: Remove the additional check for Halffloat laneTypes from following assertion after proper fix. + // Currently the incoming laneType does not comply with the laneType of Halffloat species. + assert(s.laneType == laneType) || laneType.switchKey == LaneType.SK_HALFFLOAT : s + "!=" + laneType; assert(s.vectorShape == shape) : s + "!=" + shape; CACHES[laneType.switchKey][shape.switchKey] = s; return s; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java index 45773cd29dbb4..7c740dd988723 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java @@ -293,6 +293,15 @@ public DoubleVector reinterpretAsDoubles() { return (DoubleVector) asVectorRaw(LaneType.DOUBLE); } + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public HalffloatVector reinterpretAsHalffloats() { + return (HalffloatVector) asVectorRaw(LaneType.HALFFLOAT); + } + /** * {@inheritDoc} */ @@ -565,6 +574,8 @@ AbstractVector defaultReinterpret(AbstractSpecies rsp) { return FloatVector.fromMemorySegment(rsp.check(float.class), ms, 0, bo, m.check(float.class)).check0(rsp); case LaneType.SK_DOUBLE: return DoubleVector.fromMemorySegment(rsp.check(double.class), ms, 0, bo, m.check(double.class)).check0(rsp); + case LaneType.SK_HALFFLOAT: + return HalffloatVector.fromMemorySegment(rsp.check(Float16.class), ms, 0, bo, m.check(Float16.class)).check0(rsp); default: throw new AssertionError(rsp.toString()); } @@ -627,6 +638,13 @@ AbstractVector defaultCast(AbstractSpecies dsp) { } return DoubleVector.fromArray(dsp.check(double.class), a, 0).check0(dsp); } + case LaneType.SK_HALFFLOAT: { + short[] a = new short[rlength]; + for (int i = 0; i < limit; i++) { + a[i] = Float16.float16ToRawShortBits(Float16.valueOf((float) lanes[i])); + } + return HalffloatVector.fromArray(dsp.check(Float16.class), a, 0).check0(dsp); + } default: break; } } else { @@ -677,6 +695,13 @@ AbstractVector defaultCast(AbstractSpecies dsp) { } return DoubleVector.fromArray(dsp.check(double.class), a, 0).check0(dsp); } + case LaneType.SK_HALFFLOAT: { + short[] a = new short[rlength]; + for (int i = 0; i < limit; i++) { + a[i] = Float16.float16ToRawShortBits(Float16.valueOf((float) lanes[i])); + } + return HalffloatVector.fromArray(dsp.check(Float16.class), a, 0).check0(dsp); + } default: break; } } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java index 3569ed00f1fbb..884b16485fc29 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java @@ -54,7 +54,11 @@ final class Byte128Vector extends ByteVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + + static final Class ETYPE = byte.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Byte128Vector(byte[] v) { super(v); @@ -88,9 +92,12 @@ public ByteSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return byte.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -541,7 +548,7 @@ public byte lane(int i) { @ForceInline public byte laneHelper(int i) { return (byte) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { byte[] vecarr = vec.vec(); @@ -576,7 +583,7 @@ public Byte128Vector withLane(int i, byte e) { @ForceInline public Byte128Vector withLaneHelper(int i, byte e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { byte[] res = v.vec().clone(); @@ -589,7 +596,7 @@ public Byte128Vector withLaneHelper(int i, byte e) { static final class Byte128Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte128Mask(boolean[] bits) { this(bits, 0); @@ -691,7 +698,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Byte128Mask indexPartiallyInUpperRange(long offset, long limit) { return (Byte128Mask) VectorSupport.indexPartiallyInUpperRange( - Byte128Mask.class, byte.class, VLENGTH, offset, limit, + Byte128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Byte128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -707,8 +714,9 @@ public Byte128Mask not() { @ForceInline public Byte128Mask compress() { return (Byte128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte128Vector.class, Byte128Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Byte128Vector.class, Byte128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -719,7 +727,7 @@ public Byte128Mask compress() { public Byte128Mask and(VectorMask mask) { Objects.requireNonNull(mask); Byte128Mask m = (Byte128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte128Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Byte128Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -729,7 +737,7 @@ public Byte128Mask and(VectorMask mask) { public Byte128Mask or(VectorMask mask) { Objects.requireNonNull(mask); Byte128Mask m = (Byte128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte128Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Byte128Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -739,7 +747,7 @@ public Byte128Mask or(VectorMask mask) { public Byte128Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Byte128Mask m = (Byte128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte128Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte128Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -749,22 +757,25 @@ public Byte128Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte128Mask.class, byte.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte128Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte128Mask.class, byte.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte128Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte128Mask.class, byte.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte128Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -773,7 +784,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte128Mask.class, byte.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte128Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -783,7 +795,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte128Mask.class, byte.class, VLENGTH, + return VectorSupport.extract(Byte128Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -792,23 +804,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte128Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte128Mask)m).getBits())); + return VectorSupport.test(BT_ne, Byte128Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Byte128Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte128Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Byte128Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Byte128Mask)m).getBits())); } @ForceInline /*package-private*/ static Byte128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte128Mask.class, byte.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Byte128Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -821,7 +833,7 @@ static Byte128Mask maskAll(boolean bit) { static final class Byte128Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte128Shuffle(byte[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java index 70a3306731ea5..be2e76b2486c2 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java @@ -54,7 +54,11 @@ final class Byte256Vector extends ByteVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + + static final Class ETYPE = byte.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Byte256Vector(byte[] v) { super(v); @@ -88,9 +92,12 @@ public ByteSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return byte.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -557,7 +564,7 @@ public byte lane(int i) { @ForceInline public byte laneHelper(int i) { return (byte) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { byte[] vecarr = vec.vec(); @@ -608,7 +615,7 @@ public Byte256Vector withLane(int i, byte e) { @ForceInline public Byte256Vector withLaneHelper(int i, byte e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { byte[] res = v.vec().clone(); @@ -621,7 +628,7 @@ public Byte256Vector withLaneHelper(int i, byte e) { static final class Byte256Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte256Mask(boolean[] bits) { this(bits, 0); @@ -723,7 +730,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Byte256Mask indexPartiallyInUpperRange(long offset, long limit) { return (Byte256Mask) VectorSupport.indexPartiallyInUpperRange( - Byte256Mask.class, byte.class, VLENGTH, offset, limit, + Byte256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Byte256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -739,8 +746,9 @@ public Byte256Mask not() { @ForceInline public Byte256Mask compress() { return (Byte256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte256Vector.class, Byte256Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Byte256Vector.class, Byte256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -751,7 +759,7 @@ public Byte256Mask compress() { public Byte256Mask and(VectorMask mask) { Objects.requireNonNull(mask); Byte256Mask m = (Byte256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte256Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Byte256Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -761,7 +769,7 @@ public Byte256Mask and(VectorMask mask) { public Byte256Mask or(VectorMask mask) { Objects.requireNonNull(mask); Byte256Mask m = (Byte256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte256Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Byte256Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -771,7 +779,7 @@ public Byte256Mask or(VectorMask mask) { public Byte256Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Byte256Mask m = (Byte256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte256Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte256Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -781,22 +789,25 @@ public Byte256Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte256Mask.class, byte.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte256Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte256Mask.class, byte.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte256Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte256Mask.class, byte.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte256Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -805,7 +816,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte256Mask.class, byte.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte256Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -815,7 +827,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte256Mask.class, byte.class, VLENGTH, + return VectorSupport.extract(Byte256Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -824,23 +836,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte256Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte256Mask)m).getBits())); + return VectorSupport.test(BT_ne, Byte256Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Byte256Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte256Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Byte256Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Byte256Mask)m).getBits())); } @ForceInline /*package-private*/ static Byte256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte256Mask.class, byte.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Byte256Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -853,7 +865,7 @@ static Byte256Mask maskAll(boolean bit) { static final class Byte256Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte256Shuffle(byte[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java index a093fe182892a..dedab8422fc60 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java @@ -54,7 +54,11 @@ final class Byte512Vector extends ByteVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + + static final Class ETYPE = byte.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Byte512Vector(byte[] v) { super(v); @@ -88,9 +92,12 @@ public ByteSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return byte.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -589,7 +596,7 @@ public byte lane(int i) { @ForceInline public byte laneHelper(int i) { return (byte) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { byte[] vecarr = vec.vec(); @@ -672,7 +679,7 @@ public Byte512Vector withLane(int i, byte e) { @ForceInline public Byte512Vector withLaneHelper(int i, byte e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { byte[] res = v.vec().clone(); @@ -685,7 +692,7 @@ public Byte512Vector withLaneHelper(int i, byte e) { static final class Byte512Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte512Mask(boolean[] bits) { this(bits, 0); @@ -787,7 +794,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Byte512Mask indexPartiallyInUpperRange(long offset, long limit) { return (Byte512Mask) VectorSupport.indexPartiallyInUpperRange( - Byte512Mask.class, byte.class, VLENGTH, offset, limit, + Byte512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Byte512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -803,8 +810,9 @@ public Byte512Mask not() { @ForceInline public Byte512Mask compress() { return (Byte512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte512Vector.class, Byte512Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Byte512Vector.class, Byte512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -815,7 +823,7 @@ public Byte512Mask compress() { public Byte512Mask and(VectorMask mask) { Objects.requireNonNull(mask); Byte512Mask m = (Byte512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte512Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Byte512Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -825,7 +833,7 @@ public Byte512Mask and(VectorMask mask) { public Byte512Mask or(VectorMask mask) { Objects.requireNonNull(mask); Byte512Mask m = (Byte512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte512Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Byte512Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -835,7 +843,7 @@ public Byte512Mask or(VectorMask mask) { public Byte512Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Byte512Mask m = (Byte512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte512Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte512Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -845,22 +853,25 @@ public Byte512Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte512Mask.class, byte.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte512Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte512Mask.class, byte.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte512Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte512Mask.class, byte.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte512Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -869,7 +880,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte512Mask.class, byte.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte512Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -879,7 +891,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte512Mask.class, byte.class, VLENGTH, + return VectorSupport.extract(Byte512Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -888,23 +900,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte512Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte512Mask)m).getBits())); + return VectorSupport.test(BT_ne, Byte512Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Byte512Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte512Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Byte512Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Byte512Mask)m).getBits())); } @ForceInline /*package-private*/ static Byte512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte512Mask.class, byte.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Byte512Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -917,7 +929,7 @@ static Byte512Mask maskAll(boolean bit) { static final class Byte512Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte512Shuffle(byte[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java index cd75ee9f61017..3791917cc4563 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java @@ -54,7 +54,11 @@ final class Byte64Vector extends ByteVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + + static final Class ETYPE = byte.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Byte64Vector(byte[] v) { super(v); @@ -88,9 +92,12 @@ public ByteSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return byte.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -533,7 +540,7 @@ public byte lane(int i) { @ForceInline public byte laneHelper(int i) { return (byte) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { byte[] vecarr = vec.vec(); @@ -560,7 +567,7 @@ public Byte64Vector withLane(int i, byte e) { @ForceInline public Byte64Vector withLaneHelper(int i, byte e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { byte[] res = v.vec().clone(); @@ -573,7 +580,7 @@ public Byte64Vector withLaneHelper(int i, byte e) { static final class Byte64Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte64Mask(boolean[] bits) { this(bits, 0); @@ -675,7 +682,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Byte64Mask indexPartiallyInUpperRange(long offset, long limit) { return (Byte64Mask) VectorSupport.indexPartiallyInUpperRange( - Byte64Mask.class, byte.class, VLENGTH, offset, limit, + Byte64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Byte64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -691,8 +698,9 @@ public Byte64Mask not() { @ForceInline public Byte64Mask compress() { return (Byte64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Byte64Vector.class, Byte64Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Byte64Vector.class, Byte64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -703,7 +711,7 @@ public Byte64Mask compress() { public Byte64Mask and(VectorMask mask) { Objects.requireNonNull(mask); Byte64Mask m = (Byte64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Byte64Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Byte64Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -713,7 +721,7 @@ public Byte64Mask and(VectorMask mask) { public Byte64Mask or(VectorMask mask) { Objects.requireNonNull(mask); Byte64Mask m = (Byte64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Byte64Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Byte64Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -723,7 +731,7 @@ public Byte64Mask or(VectorMask mask) { public Byte64Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Byte64Mask m = (Byte64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte64Mask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Byte64Mask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -733,22 +741,25 @@ public Byte64Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte64Mask.class, byte.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Byte64Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte64Mask.class, byte.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Byte64Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte64Mask.class, byte.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Byte64Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -757,7 +768,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte64Mask.class, byte.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Byte64Mask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -767,7 +779,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Byte64Mask.class, byte.class, VLENGTH, + return VectorSupport.extract(Byte64Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -776,23 +788,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Byte64Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Byte64Mask)m).getBits())); + return VectorSupport.test(BT_ne, Byte64Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Byte64Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Byte64Mask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Byte64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Byte64Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Byte64Mask)m).getBits())); } @ForceInline /*package-private*/ static Byte64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Byte64Mask.class, byte.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Byte64Mask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -805,7 +817,7 @@ static Byte64Mask maskAll(boolean bit) { static final class Byte64Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM Byte64Shuffle(byte[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java index 3ac62409a95ca..75fd8d1589b7d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java @@ -54,7 +54,11 @@ final class ByteMaxVector extends ByteVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // carrier type used by the JVM + + static final Class ETYPE = byte.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; ByteMaxVector(byte[] v) { super(v); @@ -88,9 +92,12 @@ public ByteSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return byte.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -526,7 +533,7 @@ public byte lane(int i) { @ForceInline public byte laneHelper(int i) { return (byte) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { byte[] vecarr = vec.vec(); @@ -546,7 +553,7 @@ public ByteMaxVector withLane(int i, byte e) { @ForceInline public ByteMaxVector withLaneHelper(int i, byte e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { byte[] res = v.vec().clone(); @@ -559,7 +566,7 @@ public ByteMaxVector withLaneHelper(int i, byte e) { static final class ByteMaxMask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM ByteMaxMask(boolean[] bits) { this(bits, 0); @@ -661,7 +668,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ ByteMaxMask indexPartiallyInUpperRange(long offset, long limit) { return (ByteMaxMask) VectorSupport.indexPartiallyInUpperRange( - ByteMaxMask.class, byte.class, VLENGTH, offset, limit, + ByteMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (ByteMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -677,8 +684,9 @@ public ByteMaxMask not() { @ForceInline public ByteMaxMask compress() { return (ByteMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - ByteMaxVector.class, ByteMaxMask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + ByteMaxVector.class, ByteMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -689,7 +697,7 @@ public ByteMaxMask compress() { public ByteMaxMask and(VectorMask mask) { Objects.requireNonNull(mask); ByteMaxMask m = (ByteMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMaxMask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, ByteMaxMask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -699,7 +707,7 @@ public ByteMaxMask and(VectorMask mask) { public ByteMaxMask or(VectorMask mask) { Objects.requireNonNull(mask); ByteMaxMask m = (ByteMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMaxMask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, ByteMaxMask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -709,7 +717,7 @@ public ByteMaxMask or(VectorMask mask) { public ByteMaxMask xor(VectorMask mask) { Objects.requireNonNull(mask); ByteMaxMask m = (ByteMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMaxMask.class, null, byte.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, ByteMaxMask.class, null, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -719,22 +727,25 @@ public ByteMaxMask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMaxMask.class, byte.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ByteMaxMask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMaxMask.class, byte.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ByteMaxMask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMaxMask.class, byte.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ByteMaxMask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -743,7 +754,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMaxMask.class, byte.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ByteMaxMask.class, byte.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -753,7 +765,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(ByteMaxMask.class, byte.class, VLENGTH, + return VectorSupport.extract(ByteMaxMask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -762,23 +774,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, ByteMaxMask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((ByteMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, ByteMaxMask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((ByteMaxMask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, ByteMaxMask.class, byte.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((ByteMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, ByteMaxMask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((ByteMaxMask)m).getBits())); } @ForceInline /*package-private*/ static ByteMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(ByteMaxMask.class, byte.class, VLENGTH, + return VectorSupport.fromBitsCoerced(ByteMaxMask.class, byte.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -791,7 +803,7 @@ static ByteMaxMask maskAll(boolean bit) { static final class ByteMaxShuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = byte.class; // used by the JVM + static final Class CTYPE = byte.class; // used by the JVM ByteMaxShuffle(byte[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index 08406fef518df..ab250b46b9b53 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -57,6 +57,8 @@ public abstract class ByteVector extends AbstractVector { static final int FORBID_OPCODE_KIND = VO_ONLYFP; + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; + static final ValueLayout.OfByte ELEMENT_LAYOUT = ValueLayout.JAVA_BYTE.withByteAlignment(1); @ForceInline @@ -573,7 +575,7 @@ static ByteVector selectFromTwoVectorHelper(Vector indexes, Vector s @ForceInline public static ByteVector zero(VectorSpecies species) { ByteSpecies vsp = (ByteSpecies) species; - return VectorSupport.fromBitsCoerced(vsp.vectorType(), byte.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), byte.class, VECTOR_OPER_TYPE, species.length(), 0, MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); } @@ -695,7 +697,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, byte.class, length(), + opc, getClass(), null, byte.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, ByteVector::unaryOperations)); } @@ -723,7 +725,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, byte.class, length(), + opc, getClass(), maskClass, byte.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, ByteVector::unaryOperations)); } @@ -796,7 +798,7 @@ ByteVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, byte.class, length(), + opc, getClass(), null, byte.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, ByteVector::binaryOperations)); } @@ -847,7 +849,7 @@ ByteVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, byte.class, length(), + opc, getClass(), maskClass, byte.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, ByteVector::binaryOperations)); } @@ -1034,7 +1036,7 @@ ByteVector lanewise(VectorOperators.Binary op, e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), null, byte.class, length(), + opc, getClass(), null, byte.class, VECTOR_OPER_TYPE, length(), this, e, null, BIN_INT_IMPL.find(op, opc, ByteVector::broadcastIntOperations)); } @@ -1055,7 +1057,7 @@ opc, getClass(), null, byte.class, length(), e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), maskClass, byte.class, length(), + opc, getClass(), maskClass, byte.class, VECTOR_OPER_TYPE, length(), this, e, m, BIN_INT_IMPL.find(op, opc, ByteVector::broadcastIntOperations)); } @@ -1132,7 +1134,7 @@ ByteVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, byte.class, length(), + opc, getClass(), null, byte.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, ByteVector::ternaryOperations)); } @@ -1172,7 +1174,7 @@ ByteVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, byte.class, length(), + opc, getClass(), maskClass, byte.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, ByteVector::ternaryOperations)); } @@ -2070,7 +2072,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v) { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, byte.class, length(), + opc, getClass(), maskType, byte.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask m @@ -2092,7 +2094,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v, M m) { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, byte.class, length(), + opc, getClass(), maskType, byte.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask cmpM @@ -2223,7 +2225,7 @@ VectorMask compare(Comparison op, long e, VectorMask m) { blendTemplate(Class maskType, ByteVector v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, byte.class, length(), + getClass(), maskType, byte.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2240,7 +2242,7 @@ final ByteVector addIndexTemplate(int scale) { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), byte.class, length(), + getClass(), byte.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2432,7 +2434,7 @@ ByteVector sliceTemplate(int origin) { ByteVector rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, byte.class, length(), + getClass(), shuffletype, null, byte.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2459,7 +2461,7 @@ ByteVector rearrangeTemplate(Class shuffletype, Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, byte.class, length(), + getClass(), shuffletype, masktype, byte.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2485,7 +2487,7 @@ ByteVector rearrangeTemplate(Class shuffletype, VectorMask valid = shuffle.laneIsValid(); ByteVector r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, byte.class, length(), + getClass(), shuffletype, null, byte.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2493,7 +2495,7 @@ ByteVector rearrangeTemplate(Class shuffletype, })); ByteVector r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, byte.class, length(), + getClass(), shuffletype, null, byte.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2543,7 +2545,7 @@ VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { ByteVector compressTemplate(Class masktype, M m) { m.check(masktype, this); return (ByteVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - byte.class, length(), this, m, + byte.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -2562,7 +2564,7 @@ byte.class, length(), this, m, ByteVector expandTemplate(Class masktype, M m) { m.check(masktype, this); return (ByteVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - byte.class, length(), this, m, + byte.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -2577,7 +2579,7 @@ byte.class, length(), this, m, /*package-private*/ @ForceInline final ByteVector selectFromTemplate(ByteVector v) { - return (ByteVector)VectorSupport.selectFromOp(getClass(), null, byte.class, + return (ByteVector)VectorSupport.selectFromOp(getClass(), null, byte.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -2597,7 +2599,7 @@ final ByteVector selectFromTemplate(ByteVector v) { ByteVector selectFromTemplate(ByteVector v, Class masktype, M m) { m.check(masktype, this); - return (ByteVector)VectorSupport.selectFromOp(getClass(), masktype, byte.class, + return (ByteVector)VectorSupport.selectFromOp(getClass(), masktype, byte.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -2615,7 +2617,7 @@ ByteVector selectFromTemplate(ByteVector v, /*package-private*/ @ForceInline final ByteVector selectFromTemplate(ByteVector v1, ByteVector v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), byte.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), byte.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -2835,7 +2837,7 @@ byte reduceLanesTemplate(VectorOperators.Associative op, } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, byte.class, length(), + opc, getClass(), maskClass, byte.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, ByteVector::reductionOperations))); } @@ -2853,7 +2855,7 @@ byte reduceLanesTemplate(VectorOperators.Associative op) { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, byte.class, length(), + opc, getClass(), null, byte.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, ByteVector::reductionOperations))); } @@ -3143,7 +3145,7 @@ ByteVector fromArray(VectorSpecies species, } return VectorSupport.loadWithMap( - vectorType, null, byte.class, vsp.laneCount(), + vectorType, null, byte.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, vix2, vix3, null, a, offset, indexMap, mapOffset, vsp, @@ -3478,7 +3480,7 @@ void intoArray(byte[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); ByteSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -3632,7 +3634,7 @@ void intoBooleanArray(boolean[] a, int offset) { ByteSpecies vsp = vspecies(); ByteVector normalized = this.and((byte) 1); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, normalized, a, offset, @@ -3845,7 +3847,7 @@ void intoMemorySegment(MemorySegment ms, long offset, ByteVector fromArray0Template(byte[] a, int offset) { ByteSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3862,7 +3864,7 @@ ByteVector fromArray0Template(Class maskClass, byte[] a, int offset, M m, int m.check(species()); ByteSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3918,7 +3920,7 @@ ByteVector fromArray0Template(Class maskClass, byte[] a, int offset, } return VectorSupport.loadWithMap( - vectorType, maskClass, byte.class, vsp.laneCount(), + vectorType, maskClass, byte.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, vix2, vix3, m, a, offset, indexMap, mapOffset, vsp, @@ -3935,7 +3937,7 @@ ByteVector fromArray0Template(Class maskClass, byte[] a, int offset, ByteVector fromBooleanArray0Template(boolean[] a, int offset) { ByteSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3952,7 +3954,7 @@ ByteVector fromBooleanArray0Template(Class maskClass, boolean[] a, int offset m.check(species()); ByteSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3966,7 +3968,7 @@ a, booleanArrayAddress(a, offset), false, m, offsetInRange, ByteVector fromMemorySegment0Template(MemorySegment ms, long offset) { ByteSpecies vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, ByteVector::memorySegmentGet); @@ -3982,7 +3984,7 @@ ByteVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long ByteSpecies vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, ByteVector::memorySegmentGet); @@ -4000,7 +4002,7 @@ ByteVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long void intoArray0Template(byte[] a, int offset) { ByteSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -4017,7 +4019,7 @@ void intoArray0Template(Class maskClass, byte[] a, int offset, M m) { m.check(species()); ByteSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -4036,7 +4038,7 @@ void intoBooleanArray0Template(Class maskClass, boolean[] a, int offset, M m) ByteSpecies vsp = vspecies(); ByteVector normalized = this.and((byte) 1); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, normalized, m, a, offset, (arr, off, v, vm) @@ -4049,7 +4051,7 @@ a, booleanArrayAddress(a, offset), false, void intoMemorySegment0(MemorySegment ms, long offset) { ByteSpecies vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -4066,7 +4068,7 @@ void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offse ByteSpecies vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -4247,6 +4249,19 @@ private ByteSpecies(VectorShape shape, // Specializing overrides: + @ForceInline + final Class carrierType() { + return byte.class; + } + + @ForceInline + final int operType() { + if (byte.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class elementType() { @@ -4279,7 +4294,7 @@ public final long checkValue(long e) { final ByteVector broadcastBits(long bits) { return (ByteVector) VectorSupport.fromBitsCoerced( - vectorType, byte.class, laneCount, + vectorType, byte.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java index eaf77d59a236a..4f15c96b6d431 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java @@ -54,7 +54,11 @@ final class Double128Vector extends DoubleVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + + static final Class ETYPE = double.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Double128Vector(double[] v) { super(v); @@ -88,9 +92,12 @@ public DoubleSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return double.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -516,7 +523,7 @@ public double lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { double[] vecarr = vec.vec(); @@ -537,7 +544,7 @@ public Double128Vector withLane(int i, double e) { @ForceInline public Double128Vector withLaneHelper(int i, double e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); @@ -550,7 +557,7 @@ public Double128Vector withLaneHelper(int i, double e) { static final class Double128Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // used by the JVM Double128Mask(boolean[] bits) { this(bits, 0); @@ -652,7 +659,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Double128Mask indexPartiallyInUpperRange(long offset, long limit) { return (Double128Mask) VectorSupport.indexPartiallyInUpperRange( - Double128Mask.class, double.class, VLENGTH, offset, limit, + Double128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Double128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -668,8 +675,9 @@ public Double128Mask not() { @ForceInline public Double128Mask compress() { return (Double128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double128Vector.class, Double128Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Double128Vector.class, Double128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -680,7 +688,7 @@ public Double128Mask compress() { public Double128Mask and(VectorMask mask) { Objects.requireNonNull(mask); Double128Mask m = (Double128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double128Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Double128Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -690,7 +698,7 @@ public Double128Mask and(VectorMask mask) { public Double128Mask or(VectorMask mask) { Objects.requireNonNull(mask); Double128Mask m = (Double128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double128Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Double128Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -700,7 +708,7 @@ public Double128Mask or(VectorMask mask) { public Double128Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Double128Mask m = (Double128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double128Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Double128Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -710,22 +718,25 @@ public Double128Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double128Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double128Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double128Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -734,7 +745,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double128Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -744,7 +756,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double128Mask.class, double.class, VLENGTH, + return VectorSupport.extract(Double128Mask.class, double.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -753,23 +765,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double128Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double128Mask)m).getBits())); + return VectorSupport.test(BT_ne, Double128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Double128Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double128Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Double128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Double128Mask)m).getBits())); } @ForceInline /*package-private*/ static Double128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double128Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Double128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -782,7 +794,7 @@ static Double128Mask maskAll(boolean bit) { static final class Double128Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Double128Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java index cf9c8794ce4bb..e179d0c966531 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java @@ -54,7 +54,11 @@ final class Double256Vector extends DoubleVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + + static final Class ETYPE = double.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Double256Vector(double[] v) { super(v); @@ -88,9 +92,12 @@ public DoubleSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return double.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -518,7 +525,7 @@ public double lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { double[] vecarr = vec.vec(); @@ -541,7 +548,7 @@ public Double256Vector withLane(int i, double e) { @ForceInline public Double256Vector withLaneHelper(int i, double e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); @@ -554,7 +561,7 @@ public Double256Vector withLaneHelper(int i, double e) { static final class Double256Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // used by the JVM Double256Mask(boolean[] bits) { this(bits, 0); @@ -656,7 +663,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Double256Mask indexPartiallyInUpperRange(long offset, long limit) { return (Double256Mask) VectorSupport.indexPartiallyInUpperRange( - Double256Mask.class, double.class, VLENGTH, offset, limit, + Double256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Double256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -672,8 +679,9 @@ public Double256Mask not() { @ForceInline public Double256Mask compress() { return (Double256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double256Vector.class, Double256Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Double256Vector.class, Double256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -684,7 +692,7 @@ public Double256Mask compress() { public Double256Mask and(VectorMask mask) { Objects.requireNonNull(mask); Double256Mask m = (Double256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double256Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Double256Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -694,7 +702,7 @@ public Double256Mask and(VectorMask mask) { public Double256Mask or(VectorMask mask) { Objects.requireNonNull(mask); Double256Mask m = (Double256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double256Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Double256Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -704,7 +712,7 @@ public Double256Mask or(VectorMask mask) { public Double256Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Double256Mask m = (Double256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double256Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Double256Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -714,22 +722,25 @@ public Double256Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double256Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double256Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double256Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -738,7 +749,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double256Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -748,7 +760,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double256Mask.class, double.class, VLENGTH, + return VectorSupport.extract(Double256Mask.class, double.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -757,23 +769,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double256Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double256Mask)m).getBits())); + return VectorSupport.test(BT_ne, Double256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Double256Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double256Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Double256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Double256Mask)m).getBits())); } @ForceInline /*package-private*/ static Double256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double256Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Double256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -786,7 +798,7 @@ static Double256Mask maskAll(boolean bit) { static final class Double256Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Double256Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java index a7a86c2584169..82edc82efc269 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java @@ -54,7 +54,11 @@ final class Double512Vector extends DoubleVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + + static final Class ETYPE = double.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Double512Vector(double[] v) { super(v); @@ -88,9 +92,12 @@ public DoubleSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return double.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -522,7 +529,7 @@ public double lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { double[] vecarr = vec.vec(); @@ -549,7 +556,7 @@ public Double512Vector withLane(int i, double e) { @ForceInline public Double512Vector withLaneHelper(int i, double e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); @@ -562,7 +569,7 @@ public Double512Vector withLaneHelper(int i, double e) { static final class Double512Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // used by the JVM Double512Mask(boolean[] bits) { this(bits, 0); @@ -664,7 +671,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Double512Mask indexPartiallyInUpperRange(long offset, long limit) { return (Double512Mask) VectorSupport.indexPartiallyInUpperRange( - Double512Mask.class, double.class, VLENGTH, offset, limit, + Double512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Double512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -680,8 +687,9 @@ public Double512Mask not() { @ForceInline public Double512Mask compress() { return (Double512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double512Vector.class, Double512Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Double512Vector.class, Double512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -692,7 +700,7 @@ public Double512Mask compress() { public Double512Mask and(VectorMask mask) { Objects.requireNonNull(mask); Double512Mask m = (Double512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double512Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Double512Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -702,7 +710,7 @@ public Double512Mask and(VectorMask mask) { public Double512Mask or(VectorMask mask) { Objects.requireNonNull(mask); Double512Mask m = (Double512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double512Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Double512Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -712,7 +720,7 @@ public Double512Mask or(VectorMask mask) { public Double512Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Double512Mask m = (Double512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double512Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Double512Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -722,22 +730,25 @@ public Double512Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double512Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double512Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double512Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -746,7 +757,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double512Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -756,7 +768,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double512Mask.class, double.class, VLENGTH, + return VectorSupport.extract(Double512Mask.class, double.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -765,23 +777,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double512Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double512Mask)m).getBits())); + return VectorSupport.test(BT_ne, Double512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Double512Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double512Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Double512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Double512Mask)m).getBits())); } @ForceInline /*package-private*/ static Double512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double512Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Double512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -794,7 +806,7 @@ static Double512Mask maskAll(boolean bit) { static final class Double512Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Double512Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java index df6b627cc182c..f7a94c3973912 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java @@ -54,7 +54,11 @@ final class Double64Vector extends DoubleVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + + static final Class ETYPE = double.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Double64Vector(double[] v) { super(v); @@ -88,9 +92,12 @@ public DoubleSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return double.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -515,7 +522,7 @@ public double lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { double[] vecarr = vec.vec(); @@ -535,7 +542,7 @@ public Double64Vector withLane(int i, double e) { @ForceInline public Double64Vector withLaneHelper(int i, double e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); @@ -548,7 +555,7 @@ public Double64Vector withLaneHelper(int i, double e) { static final class Double64Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // used by the JVM Double64Mask(boolean[] bits) { this(bits, 0); @@ -650,7 +657,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Double64Mask indexPartiallyInUpperRange(long offset, long limit) { return (Double64Mask) VectorSupport.indexPartiallyInUpperRange( - Double64Mask.class, double.class, VLENGTH, offset, limit, + Double64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Double64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -666,8 +673,9 @@ public Double64Mask not() { @ForceInline public Double64Mask compress() { return (Double64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Double64Vector.class, Double64Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Double64Vector.class, Double64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -678,7 +686,7 @@ public Double64Mask compress() { public Double64Mask and(VectorMask mask) { Objects.requireNonNull(mask); Double64Mask m = (Double64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Double64Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Double64Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -688,7 +696,7 @@ public Double64Mask and(VectorMask mask) { public Double64Mask or(VectorMask mask) { Objects.requireNonNull(mask); Double64Mask m = (Double64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Double64Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Double64Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -698,7 +706,7 @@ public Double64Mask or(VectorMask mask) { public Double64Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Double64Mask m = (Double64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Double64Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Double64Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -708,22 +716,25 @@ public Double64Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double64Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Double64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double64Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Double64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double64Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Double64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -732,7 +743,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double64Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Double64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -742,7 +754,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Double64Mask.class, double.class, VLENGTH, + return VectorSupport.extract(Double64Mask.class, double.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -751,23 +763,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Double64Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Double64Mask)m).getBits())); + return VectorSupport.test(BT_ne, Double64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Double64Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Double64Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Double64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Double64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Double64Mask)m).getBits())); } @ForceInline /*package-private*/ static Double64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Double64Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Double64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -780,7 +792,7 @@ static Double64Mask maskAll(boolean bit) { static final class Double64Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Double64Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java index 47be1f609d818..93e76e227a8ab 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java @@ -54,7 +54,11 @@ final class DoubleMaxVector extends DoubleVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // carrier type used by the JVM + + static final Class ETYPE = double.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; DoubleMaxVector(double[] v) { super(v); @@ -88,9 +92,12 @@ public DoubleSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return double.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -514,7 +521,7 @@ public double lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { double[] vecarr = vec.vec(); @@ -534,7 +541,7 @@ public DoubleMaxVector withLane(int i, double e) { @ForceInline public DoubleMaxVector withLaneHelper(int i, double e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Double.doubleToRawLongBits(e), (v, ix, bits) -> { double[] res = v.vec().clone(); @@ -547,7 +554,7 @@ public DoubleMaxVector withLaneHelper(int i, double e) { static final class DoubleMaxMask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = double.class; // used by the JVM + static final Class CTYPE = double.class; // used by the JVM DoubleMaxMask(boolean[] bits) { this(bits, 0); @@ -649,7 +656,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ DoubleMaxMask indexPartiallyInUpperRange(long offset, long limit) { return (DoubleMaxMask) VectorSupport.indexPartiallyInUpperRange( - DoubleMaxMask.class, double.class, VLENGTH, offset, limit, + DoubleMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (DoubleMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -665,8 +672,9 @@ public DoubleMaxMask not() { @ForceInline public DoubleMaxMask compress() { return (DoubleMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - DoubleMaxVector.class, DoubleMaxMask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + DoubleMaxVector.class, DoubleMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -677,7 +685,7 @@ public DoubleMaxMask compress() { public DoubleMaxMask and(VectorMask mask) { Objects.requireNonNull(mask); DoubleMaxMask m = (DoubleMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMaxMask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, DoubleMaxMask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -687,7 +695,7 @@ public DoubleMaxMask and(VectorMask mask) { public DoubleMaxMask or(VectorMask mask) { Objects.requireNonNull(mask); DoubleMaxMask m = (DoubleMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMaxMask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, DoubleMaxMask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -697,7 +705,7 @@ public DoubleMaxMask or(VectorMask mask) { public DoubleMaxMask xor(VectorMask mask) { Objects.requireNonNull(mask); DoubleMaxMask m = (DoubleMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMaxMask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, DoubleMaxMask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -707,22 +715,25 @@ public DoubleMaxMask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMaxMask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, DoubleMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMaxMask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, DoubleMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMaxMask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, DoubleMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -731,7 +742,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMaxMask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, DoubleMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -741,7 +753,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(DoubleMaxMask.class, double.class, VLENGTH, + return VectorSupport.extract(DoubleMaxMask.class, double.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -750,23 +762,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, DoubleMaxMask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((DoubleMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, DoubleMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((DoubleMaxMask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, DoubleMaxMask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((DoubleMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, DoubleMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((DoubleMaxMask)m).getBits())); } @ForceInline /*package-private*/ static DoubleMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(DoubleMaxMask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(DoubleMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -779,7 +791,7 @@ static DoubleMaxMask maskAll(boolean bit) { static final class DoubleMaxShuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM DoubleMaxShuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java index 786cd089ebecb..9c20a7c755c43 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java @@ -57,6 +57,8 @@ public abstract class DoubleVector extends AbstractVector { static final int FORBID_OPCODE_KIND = VO_NOFP; + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; + static final ValueLayout.OfDouble ELEMENT_LAYOUT = ValueLayout.JAVA_DOUBLE.withByteAlignment(1); @ForceInline @@ -562,7 +564,7 @@ static DoubleVector selectFromTwoVectorHelper(Vector indexes, Vector species) { DoubleSpecies vsp = (DoubleSpecies) species; - return VectorSupport.fromBitsCoerced(vsp.vectorType(), double.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), double.class, VECTOR_OPER_TYPE, species.length(), toBits(0.0f), MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); } @@ -684,7 +686,7 @@ else if (opKind(op, VO_MATHLIB)) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, double.class, length(), + opc, getClass(), null, double.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, DoubleVector::unaryOperations)); } @@ -712,7 +714,7 @@ else if (opKind(op, VO_MATHLIB)) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, double.class, length(), + opc, getClass(), maskClass, double.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, DoubleVector::unaryOperations)); } @@ -801,7 +803,7 @@ else if (opKind(op, VO_MATHLIB)) { int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, double.class, length(), + opc, getClass(), null, double.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, DoubleVector::binaryOperations)); } @@ -839,7 +841,7 @@ else if (opKind(op, VO_MATHLIB)) { int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, double.class, length(), + opc, getClass(), maskClass, double.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, DoubleVector::binaryOperations)); } @@ -1021,7 +1023,7 @@ DoubleVector lanewiseTemplate(VectorOperators.Ternary op, tother.check(this); int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, double.class, length(), + opc, getClass(), null, double.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, DoubleVector::ternaryOperations)); } @@ -1056,7 +1058,7 @@ DoubleVector lanewiseTemplate(VectorOperators.Ternary op, int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, double.class, length(), + opc, getClass(), maskClass, double.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, DoubleVector::ternaryOperations)); } @@ -1928,7 +1930,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v) { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, double.class, length(), + opc, getClass(), maskType, double.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask m @@ -1950,7 +1952,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v, M m) { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, double.class, length(), + opc, getClass(), maskType, double.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask cmpM @@ -2077,7 +2079,7 @@ VectorMask compare(Comparison op, long e, VectorMask m) { blendTemplate(Class maskType, DoubleVector v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, double.class, length(), + getClass(), maskType, double.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2094,7 +2096,7 @@ final DoubleVector addIndexTemplate(int scale) { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), double.class, length(), + getClass(), double.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2286,7 +2288,7 @@ DoubleVector sliceTemplate(int origin) { DoubleVector rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, double.class, length(), + getClass(), shuffletype, null, double.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2313,7 +2315,7 @@ DoubleVector rearrangeTemplate(Class shuffletype, Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, double.class, length(), + getClass(), shuffletype, masktype, double.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2339,7 +2341,7 @@ DoubleVector rearrangeTemplate(Class shuffletype, VectorMask valid = shuffle.laneIsValid(); DoubleVector r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, double.class, length(), + getClass(), shuffletype, null, double.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2347,7 +2349,7 @@ DoubleVector rearrangeTemplate(Class shuffletype, })); DoubleVector r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, double.class, length(), + getClass(), shuffletype, null, double.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2391,7 +2393,7 @@ VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { DoubleVector compressTemplate(Class masktype, M m) { m.check(masktype, this); return (DoubleVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - double.class, length(), this, m, + double.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -2410,7 +2412,7 @@ DoubleVector compressTemplate(Class masktype, M m) { DoubleVector expandTemplate(Class masktype, M m) { m.check(masktype, this); return (DoubleVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - double.class, length(), this, m, + double.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -2425,7 +2427,7 @@ DoubleVector expandTemplate(Class masktype, M m) { /*package-private*/ @ForceInline final DoubleVector selectFromTemplate(DoubleVector v) { - return (DoubleVector)VectorSupport.selectFromOp(getClass(), null, double.class, + return (DoubleVector)VectorSupport.selectFromOp(getClass(), null, double.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -2445,7 +2447,7 @@ final DoubleVector selectFromTemplate(DoubleVector v) { DoubleVector selectFromTemplate(DoubleVector v, Class masktype, M m) { m.check(masktype, this); - return (DoubleVector)VectorSupport.selectFromOp(getClass(), masktype, double.class, + return (DoubleVector)VectorSupport.selectFromOp(getClass(), masktype, double.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -2463,7 +2465,7 @@ DoubleVector selectFromTemplate(DoubleVector v, /*package-private*/ @ForceInline final DoubleVector selectFromTemplate(DoubleVector v1, DoubleVector v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), double.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), double.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -2661,7 +2663,7 @@ public abstract double reduceLanes(VectorOperators.Associative op, } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, double.class, length(), + opc, getClass(), maskClass, double.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, DoubleVector::reductionOperations))); } @@ -2679,7 +2681,7 @@ opc, getClass(), maskClass, double.class, length(), } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, double.class, length(), + opc, getClass(), null, double.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, DoubleVector::reductionOperations))); } @@ -2936,7 +2938,7 @@ DoubleVector fromArray(VectorSpecies species, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, null, double.class, vsp.laneCount(), + vectorType, null, double.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -3119,7 +3121,7 @@ void intoArray(double[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); DoubleSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -3227,7 +3229,7 @@ void intoArray(double[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), null, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), null, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, null, @@ -3354,7 +3356,7 @@ void intoMemorySegment(MemorySegment ms, long offset, DoubleVector fromArray0Template(double[] a, int offset) { DoubleSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3371,7 +3373,7 @@ DoubleVector fromArray0Template(Class maskClass, double[] a, int offset, M m, m.check(species()); DoubleSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3422,7 +3424,7 @@ DoubleVector fromArray0Template(Class maskClass, double[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, maskClass, double.class, vsp.laneCount(), + vectorType, maskClass, double.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -3439,7 +3441,7 @@ DoubleVector fromArray0Template(Class maskClass, double[] a, int offset, DoubleVector fromMemorySegment0Template(MemorySegment ms, long offset) { DoubleSpecies vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, DoubleVector::memorySegmentGet); @@ -3455,7 +3457,7 @@ DoubleVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, lo DoubleSpecies vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, DoubleVector::memorySegmentGet); @@ -3473,7 +3475,7 @@ DoubleVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, lo void intoArray0Template(double[] a, int offset) { DoubleSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -3490,7 +3492,7 @@ void intoArray0Template(Class maskClass, double[] a, int offset, M m) { m.check(species()); DoubleSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -3538,7 +3540,7 @@ void intoArray0Template(Class maskClass, double[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, m, @@ -3557,7 +3559,7 @@ a, arrayAddress(a, 0), vix, void intoMemorySegment0(MemorySegment ms, long offset) { DoubleSpecies vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -3574,7 +3576,7 @@ void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offse DoubleSpecies vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -3746,6 +3748,19 @@ private DoubleSpecies(VectorShape shape, // Specializing overrides: + @ForceInline + final Class carrierType() { + return double.class; + } + + @ForceInline + final int operType() { + if (double.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class elementType() { @@ -3778,7 +3793,7 @@ public final long checkValue(long e) { final DoubleVector broadcastBits(long bits) { return (DoubleVector) VectorSupport.fromBitsCoerced( - vectorType, double.class, laneCount, + vectorType, double.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java index fdfd234cb4720..90186647529eb 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java @@ -54,7 +54,11 @@ final class Float128Vector extends FloatVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + + static final Class ETYPE = float.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Float128Vector(float[] v) { super(v); @@ -88,9 +92,12 @@ public FloatSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return float.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -518,7 +525,7 @@ public float lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { float[] vecarr = vec.vec(); @@ -541,7 +548,7 @@ public Float128Vector withLane(int i, float e) { @ForceInline public Float128Vector withLaneHelper(int i, float e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); @@ -554,7 +561,7 @@ public Float128Vector withLaneHelper(int i, float e) { static final class Float128Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // used by the JVM Float128Mask(boolean[] bits) { this(bits, 0); @@ -656,7 +663,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Float128Mask indexPartiallyInUpperRange(long offset, long limit) { return (Float128Mask) VectorSupport.indexPartiallyInUpperRange( - Float128Mask.class, float.class, VLENGTH, offset, limit, + Float128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Float128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -672,8 +679,9 @@ public Float128Mask not() { @ForceInline public Float128Mask compress() { return (Float128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float128Vector.class, Float128Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Float128Vector.class, Float128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -684,7 +692,7 @@ public Float128Mask compress() { public Float128Mask and(VectorMask mask) { Objects.requireNonNull(mask); Float128Mask m = (Float128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float128Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Float128Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -694,7 +702,7 @@ public Float128Mask and(VectorMask mask) { public Float128Mask or(VectorMask mask) { Objects.requireNonNull(mask); Float128Mask m = (Float128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float128Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Float128Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -704,7 +712,7 @@ public Float128Mask or(VectorMask mask) { public Float128Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Float128Mask m = (Float128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float128Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Float128Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -714,22 +722,25 @@ public Float128Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float128Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float128Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float128Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -738,7 +749,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float128Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -748,7 +760,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float128Mask.class, float.class, VLENGTH, + return VectorSupport.extract(Float128Mask.class, float.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -757,23 +769,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float128Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float128Mask)m).getBits())); + return VectorSupport.test(BT_ne, Float128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Float128Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float128Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Float128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Float128Mask)m).getBits())); } @ForceInline /*package-private*/ static Float128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float128Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Float128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -786,7 +798,7 @@ static Float128Mask maskAll(boolean bit) { static final class Float128Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Float128Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java index 2543382ca1421..4c17a7e3c3a3d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java @@ -54,7 +54,11 @@ final class Float256Vector extends FloatVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + + static final Class ETYPE = float.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Float256Vector(float[] v) { super(v); @@ -88,9 +92,12 @@ public FloatSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return float.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -522,7 +529,7 @@ public float lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { float[] vecarr = vec.vec(); @@ -549,7 +556,7 @@ public Float256Vector withLane(int i, float e) { @ForceInline public Float256Vector withLaneHelper(int i, float e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); @@ -562,7 +569,7 @@ public Float256Vector withLaneHelper(int i, float e) { static final class Float256Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // used by the JVM Float256Mask(boolean[] bits) { this(bits, 0); @@ -664,7 +671,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Float256Mask indexPartiallyInUpperRange(long offset, long limit) { return (Float256Mask) VectorSupport.indexPartiallyInUpperRange( - Float256Mask.class, float.class, VLENGTH, offset, limit, + Float256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Float256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -680,8 +687,9 @@ public Float256Mask not() { @ForceInline public Float256Mask compress() { return (Float256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float256Vector.class, Float256Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Float256Vector.class, Float256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -692,7 +700,7 @@ public Float256Mask compress() { public Float256Mask and(VectorMask mask) { Objects.requireNonNull(mask); Float256Mask m = (Float256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float256Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Float256Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -702,7 +710,7 @@ public Float256Mask and(VectorMask mask) { public Float256Mask or(VectorMask mask) { Objects.requireNonNull(mask); Float256Mask m = (Float256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float256Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Float256Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -712,7 +720,7 @@ public Float256Mask or(VectorMask mask) { public Float256Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Float256Mask m = (Float256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float256Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Float256Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -722,22 +730,25 @@ public Float256Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float256Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float256Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float256Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -746,7 +757,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float256Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -756,7 +768,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float256Mask.class, float.class, VLENGTH, + return VectorSupport.extract(Float256Mask.class, float.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -765,23 +777,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float256Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float256Mask)m).getBits())); + return VectorSupport.test(BT_ne, Float256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Float256Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float256Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Float256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Float256Mask)m).getBits())); } @ForceInline /*package-private*/ static Float256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float256Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Float256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -794,7 +806,7 @@ static Float256Mask maskAll(boolean bit) { static final class Float256Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Float256Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java index 627b1e0a237d1..40c231362c574 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java @@ -54,7 +54,11 @@ final class Float512Vector extends FloatVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + + static final Class ETYPE = float.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Float512Vector(float[] v) { super(v); @@ -88,9 +92,12 @@ public FloatSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return float.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -530,7 +537,7 @@ public float lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { float[] vecarr = vec.vec(); @@ -565,7 +572,7 @@ public Float512Vector withLane(int i, float e) { @ForceInline public Float512Vector withLaneHelper(int i, float e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); @@ -578,7 +585,7 @@ public Float512Vector withLaneHelper(int i, float e) { static final class Float512Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // used by the JVM Float512Mask(boolean[] bits) { this(bits, 0); @@ -680,7 +687,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Float512Mask indexPartiallyInUpperRange(long offset, long limit) { return (Float512Mask) VectorSupport.indexPartiallyInUpperRange( - Float512Mask.class, float.class, VLENGTH, offset, limit, + Float512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Float512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -696,8 +703,9 @@ public Float512Mask not() { @ForceInline public Float512Mask compress() { return (Float512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float512Vector.class, Float512Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Float512Vector.class, Float512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -708,7 +716,7 @@ public Float512Mask compress() { public Float512Mask and(VectorMask mask) { Objects.requireNonNull(mask); Float512Mask m = (Float512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float512Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Float512Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -718,7 +726,7 @@ public Float512Mask and(VectorMask mask) { public Float512Mask or(VectorMask mask) { Objects.requireNonNull(mask); Float512Mask m = (Float512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float512Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Float512Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -728,7 +736,7 @@ public Float512Mask or(VectorMask mask) { public Float512Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Float512Mask m = (Float512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float512Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Float512Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -738,22 +746,25 @@ public Float512Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float512Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float512Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float512Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -762,7 +773,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float512Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -772,7 +784,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float512Mask.class, float.class, VLENGTH, + return VectorSupport.extract(Float512Mask.class, float.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -781,23 +793,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float512Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float512Mask)m).getBits())); + return VectorSupport.test(BT_ne, Float512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Float512Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float512Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Float512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Float512Mask)m).getBits())); } @ForceInline /*package-private*/ static Float512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float512Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Float512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -810,7 +822,7 @@ static Float512Mask maskAll(boolean bit) { static final class Float512Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Float512Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java index 3360fdb537ae9..96c962b379e40 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java @@ -54,7 +54,11 @@ final class Float64Vector extends FloatVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + + static final Class ETYPE = float.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Float64Vector(float[] v) { super(v); @@ -88,9 +92,12 @@ public FloatSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return float.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -516,7 +523,7 @@ public float lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { float[] vecarr = vec.vec(); @@ -537,7 +544,7 @@ public Float64Vector withLane(int i, float e) { @ForceInline public Float64Vector withLaneHelper(int i, float e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); @@ -550,7 +557,7 @@ public Float64Vector withLaneHelper(int i, float e) { static final class Float64Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // used by the JVM Float64Mask(boolean[] bits) { this(bits, 0); @@ -652,7 +659,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Float64Mask indexPartiallyInUpperRange(long offset, long limit) { return (Float64Mask) VectorSupport.indexPartiallyInUpperRange( - Float64Mask.class, float.class, VLENGTH, offset, limit, + Float64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Float64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -668,8 +675,9 @@ public Float64Mask not() { @ForceInline public Float64Mask compress() { return (Float64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Float64Vector.class, Float64Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Float64Vector.class, Float64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -680,7 +688,7 @@ public Float64Mask compress() { public Float64Mask and(VectorMask mask) { Objects.requireNonNull(mask); Float64Mask m = (Float64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Float64Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Float64Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -690,7 +698,7 @@ public Float64Mask and(VectorMask mask) { public Float64Mask or(VectorMask mask) { Objects.requireNonNull(mask); Float64Mask m = (Float64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Float64Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Float64Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -700,7 +708,7 @@ public Float64Mask or(VectorMask mask) { public Float64Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Float64Mask m = (Float64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Float64Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Float64Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -710,22 +718,25 @@ public Float64Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float64Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Float64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float64Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Float64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float64Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Float64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -734,7 +745,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float64Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Float64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -744,7 +756,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Float64Mask.class, float.class, VLENGTH, + return VectorSupport.extract(Float64Mask.class, float.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -753,23 +765,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Float64Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Float64Mask)m).getBits())); + return VectorSupport.test(BT_ne, Float64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Float64Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Float64Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Float64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Float64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Float64Mask)m).getBits())); } @ForceInline /*package-private*/ static Float64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Float64Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Float64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -782,7 +794,7 @@ static Float64Mask maskAll(boolean bit) { static final class Float64Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Float64Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java index 4a72661ce8b98..fba86f7d740d8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java @@ -54,7 +54,11 @@ final class FloatMaxVector extends FloatVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // carrier type used by the JVM + + static final Class ETYPE = float.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; FloatMaxVector(float[] v) { super(v); @@ -88,9 +92,12 @@ public FloatSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return float.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -514,7 +521,7 @@ public float lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { float[] vecarr = vec.vec(); @@ -534,7 +541,7 @@ public FloatMaxVector withLane(int i, float e) { @ForceInline public FloatMaxVector withLaneHelper(int i, float e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)Float.floatToRawIntBits(e), (v, ix, bits) -> { float[] res = v.vec().clone(); @@ -547,7 +554,7 @@ public FloatMaxVector withLaneHelper(int i, float e) { static final class FloatMaxMask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = float.class; // used by the JVM + static final Class CTYPE = float.class; // used by the JVM FloatMaxMask(boolean[] bits) { this(bits, 0); @@ -649,7 +656,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ FloatMaxMask indexPartiallyInUpperRange(long offset, long limit) { return (FloatMaxMask) VectorSupport.indexPartiallyInUpperRange( - FloatMaxMask.class, float.class, VLENGTH, offset, limit, + FloatMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (FloatMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -665,8 +672,9 @@ public FloatMaxMask not() { @ForceInline public FloatMaxMask compress() { return (FloatMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - FloatMaxVector.class, FloatMaxMask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + FloatMaxVector.class, FloatMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -677,7 +685,7 @@ public FloatMaxMask compress() { public FloatMaxMask and(VectorMask mask) { Objects.requireNonNull(mask); FloatMaxMask m = (FloatMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMaxMask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, FloatMaxMask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -687,7 +695,7 @@ public FloatMaxMask and(VectorMask mask) { public FloatMaxMask or(VectorMask mask) { Objects.requireNonNull(mask); FloatMaxMask m = (FloatMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMaxMask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, FloatMaxMask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -697,7 +705,7 @@ public FloatMaxMask or(VectorMask mask) { public FloatMaxMask xor(VectorMask mask) { Objects.requireNonNull(mask); FloatMaxMask m = (FloatMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMaxMask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, FloatMaxMask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -707,22 +715,25 @@ public FloatMaxMask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMaxMask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, FloatMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMaxMask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, FloatMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMaxMask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, FloatMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -731,7 +742,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMaxMask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, FloatMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -741,7 +753,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(FloatMaxMask.class, float.class, VLENGTH, + return VectorSupport.extract(FloatMaxMask.class, float.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -750,23 +762,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, FloatMaxMask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((FloatMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, FloatMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((FloatMaxMask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, FloatMaxMask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((FloatMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, FloatMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((FloatMaxMask)m).getBits())); } @ForceInline /*package-private*/ static FloatMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(FloatMaxMask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(FloatMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -779,7 +791,7 @@ static FloatMaxMask maskAll(boolean bit) { static final class FloatMaxShuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM FloatMaxShuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java index b481d5a51d740..ad52d6dcf6623 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java @@ -57,6 +57,8 @@ public abstract class FloatVector extends AbstractVector { static final int FORBID_OPCODE_KIND = VO_NOFP; + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; + static final ValueLayout.OfFloat ELEMENT_LAYOUT = ValueLayout.JAVA_FLOAT.withByteAlignment(1); @ForceInline @@ -562,7 +564,7 @@ static FloatVector selectFromTwoVectorHelper(Vector indexes, Vector species) { FloatSpecies vsp = (FloatSpecies) species; - return VectorSupport.fromBitsCoerced(vsp.vectorType(), float.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), float.class, VECTOR_OPER_TYPE, species.length(), toBits(0.0f), MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); } @@ -684,7 +686,7 @@ else if (opKind(op, VO_MATHLIB)) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, float.class, length(), + opc, getClass(), null, float.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, FloatVector::unaryOperations)); } @@ -712,7 +714,7 @@ else if (opKind(op, VO_MATHLIB)) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, float.class, length(), + opc, getClass(), maskClass, float.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, FloatVector::unaryOperations)); } @@ -801,7 +803,7 @@ else if (opKind(op, VO_MATHLIB)) { int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, float.class, length(), + opc, getClass(), null, float.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, FloatVector::binaryOperations)); } @@ -839,7 +841,7 @@ else if (opKind(op, VO_MATHLIB)) { int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, float.class, length(), + opc, getClass(), maskClass, float.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, FloatVector::binaryOperations)); } @@ -1021,7 +1023,7 @@ FloatVector lanewiseTemplate(VectorOperators.Ternary op, tother.check(this); int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, float.class, length(), + opc, getClass(), null, float.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, FloatVector::ternaryOperations)); } @@ -1056,7 +1058,7 @@ FloatVector lanewiseTemplate(VectorOperators.Ternary op, int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, float.class, length(), + opc, getClass(), maskClass, float.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, FloatVector::ternaryOperations)); } @@ -1940,7 +1942,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v) { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, float.class, length(), + opc, getClass(), maskType, float.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask m @@ -1962,7 +1964,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v, M m) { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, float.class, length(), + opc, getClass(), maskType, float.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask cmpM @@ -2089,7 +2091,7 @@ VectorMask compare(Comparison op, long e, VectorMask m) { blendTemplate(Class maskType, FloatVector v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, float.class, length(), + getClass(), maskType, float.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2106,7 +2108,7 @@ final FloatVector addIndexTemplate(int scale) { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), float.class, length(), + getClass(), float.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2298,7 +2300,7 @@ FloatVector sliceTemplate(int origin) { FloatVector rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, float.class, length(), + getClass(), shuffletype, null, float.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2325,7 +2327,7 @@ FloatVector rearrangeTemplate(Class shuffletype, Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, float.class, length(), + getClass(), shuffletype, masktype, float.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2351,7 +2353,7 @@ FloatVector rearrangeTemplate(Class shuffletype, VectorMask valid = shuffle.laneIsValid(); FloatVector r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, float.class, length(), + getClass(), shuffletype, null, float.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2359,7 +2361,7 @@ FloatVector rearrangeTemplate(Class shuffletype, })); FloatVector r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, float.class, length(), + getClass(), shuffletype, null, float.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2403,7 +2405,7 @@ VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { FloatVector compressTemplate(Class masktype, M m) { m.check(masktype, this); return (FloatVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - float.class, length(), this, m, + float.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -2422,7 +2424,7 @@ float.class, length(), this, m, FloatVector expandTemplate(Class masktype, M m) { m.check(masktype, this); return (FloatVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - float.class, length(), this, m, + float.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -2437,7 +2439,7 @@ float.class, length(), this, m, /*package-private*/ @ForceInline final FloatVector selectFromTemplate(FloatVector v) { - return (FloatVector)VectorSupport.selectFromOp(getClass(), null, float.class, + return (FloatVector)VectorSupport.selectFromOp(getClass(), null, float.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -2457,7 +2459,7 @@ final FloatVector selectFromTemplate(FloatVector v) { FloatVector selectFromTemplate(FloatVector v, Class masktype, M m) { m.check(masktype, this); - return (FloatVector)VectorSupport.selectFromOp(getClass(), masktype, float.class, + return (FloatVector)VectorSupport.selectFromOp(getClass(), masktype, float.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -2475,7 +2477,7 @@ FloatVector selectFromTemplate(FloatVector v, /*package-private*/ @ForceInline final FloatVector selectFromTemplate(FloatVector v1, FloatVector v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), float.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), float.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -2681,7 +2683,7 @@ float reduceLanesTemplate(VectorOperators.Associative op, } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, float.class, length(), + opc, getClass(), maskClass, float.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, FloatVector::reductionOperations))); } @@ -2699,7 +2701,7 @@ float reduceLanesTemplate(VectorOperators.Associative op) { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, float.class, length(), + opc, getClass(), null, float.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, FloatVector::reductionOperations))); } @@ -2942,7 +2944,7 @@ FloatVector fromArray(VectorSpecies species, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, null, float.class, vsp.laneCount(), + vectorType, null, float.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -3125,7 +3127,7 @@ void intoArray(float[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); FloatSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -3214,7 +3216,7 @@ void intoArray(float[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), null, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), null, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, null, @@ -3341,7 +3343,7 @@ void intoMemorySegment(MemorySegment ms, long offset, FloatVector fromArray0Template(float[] a, int offset) { FloatSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3358,7 +3360,7 @@ FloatVector fromArray0Template(Class maskClass, float[] a, int offset, M m, i m.check(species()); FloatSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3391,7 +3393,7 @@ FloatVector fromArray0Template(Class maskClass, float[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, maskClass, float.class, vsp.laneCount(), + vectorType, maskClass, float.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -3408,7 +3410,7 @@ FloatVector fromArray0Template(Class maskClass, float[] a, int offset, FloatVector fromMemorySegment0Template(MemorySegment ms, long offset) { FloatSpecies vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, FloatVector::memorySegmentGet); @@ -3424,7 +3426,7 @@ FloatVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, lon FloatSpecies vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, FloatVector::memorySegmentGet); @@ -3442,7 +3444,7 @@ FloatVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, lon void intoArray0Template(float[] a, int offset) { FloatSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -3459,7 +3461,7 @@ void intoArray0Template(Class maskClass, float[] a, int offset, M m) { m.check(species()); FloatSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -3488,7 +3490,7 @@ void intoArray0Template(Class maskClass, float[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, m, @@ -3507,7 +3509,7 @@ a, arrayAddress(a, 0), vix, void intoMemorySegment0(MemorySegment ms, long offset) { FloatSpecies vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -3524,7 +3526,7 @@ void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offse FloatSpecies vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -3696,6 +3698,19 @@ private FloatSpecies(VectorShape shape, // Specializing overrides: + @ForceInline + final Class carrierType() { + return float.class; + } + + @ForceInline + final int operType() { + if (float.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class elementType() { @@ -3728,7 +3743,7 @@ public final long checkValue(long e) { final FloatVector broadcastBits(long bits) { return (FloatVector) VectorSupport.fromBitsCoerced( - vectorType, float.class, laneCount, + vectorType, float.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java new file mode 100644 index 0000000000000..e4a2c7300c5ae --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java @@ -0,0 +1,1042 @@ +/* + * Copyright (c) 2017, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.IntUnaryOperator; + +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.vector.VectorSupport; + +import static jdk.internal.vm.vector.VectorSupport.*; + +import static jdk.incubator.vector.VectorOperators.*; + +// -- This file was mechanically generated: Do not edit! -- // + +@SuppressWarnings("cast") // warning: redundant cast +final class Halffloat128Vector extends HalffloatVector { + static final HalffloatSpecies VSPECIES = + (HalffloatSpecies) HalffloatVector.SPECIES_128; + + static final VectorShape VSHAPE = + VSPECIES.vectorShape(); + + static final Class VCLASS = Halffloat128Vector.class; + + static final int VSIZE = VSPECIES.vectorBitSize(); + + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = Float16.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_FP16; + + Halffloat128Vector(short[] v) { + super(v); + } + + // For compatibility as Halffloat128Vector::new, + // stored into species.vectorFactory. + Halffloat128Vector(Object v) { + this((short[]) v); + } + + static final Halffloat128Vector ZERO = new Halffloat128Vector(new short[VLENGTH]); + static final Halffloat128Vector IOTA = new Halffloat128Vector(VSPECIES.iotaArray()); + + static { + // Warm up a few species caches. + // If we do this too much we will + // get NPEs from bootstrap circularity. + VSPECIES.dummyVector(); + VSPECIES.withLanes(LaneType.BYTE); + } + + // Specialized extractors + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractVector, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + final Class carrierType() { return CTYPE; } + + @ForceInline + @Override + public final Class elementType() { return ETYPE; } + + @ForceInline + @Override + public final int elementSize() { return Float16.SIZE; } + + @ForceInline + @Override + public final VectorShape shape() { return VSHAPE; } + + @ForceInline + @Override + public final int length() { return VLENGTH; } + + @ForceInline + @Override + public final int bitSize() { return VSIZE; } + + @ForceInline + @Override + public final int byteSize() { return VSIZE / Byte.SIZE; } + + /*package-private*/ + @ForceInline + final @Override + short[] vec() { + return (short[])getPayload(); + } + + // Virtualized constructors + + @Override + @ForceInline + public final Halffloat128Vector broadcast(short e) { + return (Halffloat128Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + public final Halffloat128Vector broadcast(long e) { + return (Halffloat128Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + Halffloat128Mask maskFromArray(boolean[] bits) { + return new Halffloat128Mask(bits); + } + + @Override + @ForceInline + Halffloat128Shuffle iotaShuffle() { return Halffloat128Shuffle.IOTA; } + + @Override + @ForceInline + Halffloat128Shuffle iotaShuffle(int start, int step, boolean wrap) { + return (Halffloat128Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + } + + @Override + @ForceInline + Halffloat128Shuffle shuffleFromArray(int[] indices, int i) { return new Halffloat128Shuffle(indices, i); } + + @Override + @ForceInline + Halffloat128Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Halffloat128Shuffle(fn); } + + // Make a vector of the same species but the given elements: + @ForceInline + final @Override + Halffloat128Vector vectorFactory(short[] vec) { + return new Halffloat128Vector(vec); + } + + @ForceInline + final @Override + Byte128Vector asByteVectorRaw() { + return (Byte128Vector) super.asByteVectorRawTemplate(); // specialize + } + + @ForceInline + final @Override + AbstractVector asVectorRaw(LaneType laneType) { + return super.asVectorRawTemplate(laneType); // specialize + } + + // Unary operator + + @ForceInline + final @Override + Halffloat128Vector uOp(FUnOp f) { + return (Halffloat128Vector) super.uOpTemplate(f); // specialize + } + + @ForceInline + final @Override + Halffloat128Vector uOp(VectorMask m, FUnOp f) { + return (Halffloat128Vector) + super.uOpTemplate((Halffloat128Mask)m, f); // specialize + } + + // Binary operator + + @ForceInline + final @Override + Halffloat128Vector bOp(Vector v, FBinOp f) { + return (Halffloat128Vector) super.bOpTemplate((Halffloat128Vector)v, f); // specialize + } + + @ForceInline + final @Override + Halffloat128Vector bOp(Vector v, + VectorMask m, FBinOp f) { + return (Halffloat128Vector) + super.bOpTemplate((Halffloat128Vector)v, (Halffloat128Mask)m, + f); // specialize + } + + // Ternary operator + + @ForceInline + final @Override + Halffloat128Vector tOp(Vector v1, Vector v2, FTriOp f) { + return (Halffloat128Vector) + super.tOpTemplate((Halffloat128Vector)v1, (Halffloat128Vector)v2, + f); // specialize + } + + @ForceInline + final @Override + Halffloat128Vector tOp(Vector v1, Vector v2, + VectorMask m, FTriOp f) { + return (Halffloat128Vector) + super.tOpTemplate((Halffloat128Vector)v1, (Halffloat128Vector)v2, + (Halffloat128Mask)m, f); // specialize + } + + @ForceInline + final @Override + short rOp(short v, VectorMask m, FBinOp f) { + return super.rOpTemplate(v, m, f); // specialize + } + + @Override + @ForceInline + public final + Vector convertShape(VectorOperators.Conversion conv, + VectorSpecies rsp, int part) { + return super.convertShapeTemplate(conv, rsp, part); // specialize + } + + @Override + @ForceInline + public final + Vector reinterpretShape(VectorSpecies toSpecies, int part) { + return super.reinterpretShapeTemplate(toSpecies, part); // specialize + } + + // Specialized algebraic operations: + + // The following definition forces a specialized version of this + // crucial method into the v-table of this class. A call to add() + // will inline to a call to lanewise(ADD,), at which point the JIT + // intrinsic will have the opcode of ADD, plus all the metadata + // for this particular class, enabling it to generate precise + // code. + // + // There is probably no benefit to the JIT to specialize the + // masked or broadcast versions of the lanewise method. + + @Override + @ForceInline + public Halffloat128Vector lanewise(Unary op) { + return (Halffloat128Vector) super.lanewiseTemplate(op); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector lanewise(Unary op, VectorMask m) { + return (Halffloat128Vector) super.lanewiseTemplate(op, Halffloat128Mask.class, (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector lanewise(Binary op, Vector v) { + return (Halffloat128Vector) super.lanewiseTemplate(op, v); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector lanewise(Binary op, Vector v, VectorMask m) { + return (Halffloat128Vector) super.lanewiseTemplate(op, Halffloat128Mask.class, v, (Halffloat128Mask) m); // specialize + } + + + /*package-private*/ + @Override + @ForceInline + public final + Halffloat128Vector + lanewise(Ternary op, Vector v1, Vector v2) { + return (Halffloat128Vector) super.lanewiseTemplate(op, v1, v2); // specialize + } + + @Override + @ForceInline + public final + Halffloat128Vector + lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { + return (Halffloat128Vector) super.lanewiseTemplate(op, Halffloat128Mask.class, v1, v2, (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public final + Halffloat128Vector addIndex(int scale) { + return (Halffloat128Vector) super.addIndexTemplate(scale); // specialize + } + + // Type specific horizontal reductions + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op) { + return super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op, + VectorMask m) { + return super.reduceLanesTemplate(op, Halffloat128Mask.class, (Halffloat128Mask) m); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op) { + return (long) super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op, + VectorMask m) { + return (long) super.reduceLanesTemplate(op, Halffloat128Mask.class, (Halffloat128Mask) m); // specialized + } + + @Override + @ForceInline + final VectorShuffle bitsToShuffle(AbstractSpecies dsp) { + throw new AssertionError(); + } + + @Override + @ForceInline + public final Halffloat128Shuffle toShuffle() { + return (Halffloat128Shuffle) toShuffle(vspecies(), false); + } + + // Specialized unary testing + + @Override + @ForceInline + public final Halffloat128Mask test(Test op) { + return super.testTemplate(Halffloat128Mask.class, op); // specialize + } + + @Override + @ForceInline + public final Halffloat128Mask test(Test op, VectorMask m) { + return super.testTemplate(Halffloat128Mask.class, op, (Halffloat128Mask) m); // specialize + } + + // Specialized comparisons + + @Override + @ForceInline + public final Halffloat128Mask compare(Comparison op, Vector v) { + return super.compareTemplate(Halffloat128Mask.class, op, v); // specialize + } + + @Override + @ForceInline + public final Halffloat128Mask compare(Comparison op, short s) { + return super.compareTemplate(Halffloat128Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat128Mask compare(Comparison op, long s) { + return super.compareTemplate(Halffloat128Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat128Mask compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(Halffloat128Mask.class, op, v, (Halffloat128Mask) m); + } + + + @Override + @ForceInline + public Halffloat128Vector blend(Vector v, VectorMask m) { + return (Halffloat128Vector) + super.blendTemplate(Halffloat128Mask.class, + (Halffloat128Vector) v, + (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector slice(int origin, Vector v) { + return (Halffloat128Vector) super.sliceTemplate(origin, v); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector slice(int origin) { + return (Halffloat128Vector) super.sliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector unslice(int origin, Vector w, int part) { + return (Halffloat128Vector) super.unsliceTemplate(origin, w, part); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector unslice(int origin, Vector w, int part, VectorMask m) { + return (Halffloat128Vector) + super.unsliceTemplate(Halffloat128Mask.class, + origin, w, part, + (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector unslice(int origin) { + return (Halffloat128Vector) super.unsliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector rearrange(VectorShuffle s) { + return (Halffloat128Vector) + super.rearrangeTemplate(Halffloat128Shuffle.class, + (Halffloat128Shuffle) s); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector rearrange(VectorShuffle shuffle, + VectorMask m) { + return (Halffloat128Vector) + super.rearrangeTemplate(Halffloat128Shuffle.class, + Halffloat128Mask.class, + (Halffloat128Shuffle) shuffle, + (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector rearrange(VectorShuffle s, + Vector v) { + return (Halffloat128Vector) + super.rearrangeTemplate(Halffloat128Shuffle.class, + (Halffloat128Shuffle) s, + (Halffloat128Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector compress(VectorMask m) { + return (Halffloat128Vector) + super.compressTemplate(Halffloat128Mask.class, + (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector expand(VectorMask m) { + return (Halffloat128Vector) + super.expandTemplate(Halffloat128Mask.class, + (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector selectFrom(Vector v) { + return (Halffloat128Vector) + super.selectFromTemplate((Halffloat128Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector selectFrom(Vector v, + VectorMask m) { + return (Halffloat128Vector) + super.selectFromTemplate((Halffloat128Vector) v, + Halffloat128Mask.class, (Halffloat128Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat128Vector selectFrom(Vector v1, + Vector v2) { + return (Halffloat128Vector) + super.selectFromTemplate((Halffloat128Vector) v1, (Halffloat128Vector) v2); // specialize + } + + @ForceInline + @Override + public short lane(int i) { + short bits; + switch(i) { + case 0: bits = laneHelper(0); break; + case 1: bits = laneHelper(1); break; + case 2: bits = laneHelper(2); break; + case 3: bits = laneHelper(3); break; + case 4: bits = laneHelper(4); break; + case 5: bits = laneHelper(5); break; + case 6: bits = laneHelper(6); break; + case 7: bits = laneHelper(7); break; + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + return bits; + } + + @ForceInline + public short laneHelper(int i) { + return (short) VectorSupport.extract( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, + (vec, ix) -> { + short[] vecarr = vec.vec(); + return vecarr[ix]; + }); + } + + @ForceInline + @Override + public Halffloat128Vector withLane(int i, short e) { + switch(i) { + case 0: return withLaneHelper(0, e); + case 1: return withLaneHelper(1, e); + case 2: return withLaneHelper(2, e); + case 3: return withLaneHelper(3, e); + case 4: return withLaneHelper(4, e); + case 5: return withLaneHelper(5, e); + case 6: return withLaneHelper(6, e); + case 7: return withLaneHelper(7, e); + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + } + + @ForceInline + public Halffloat128Vector withLaneHelper(int i, short e) { + return VectorSupport.insert( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, (long)e, + (v, ix, bits) -> { + short[] res = v.vec().clone(); + res[ix] = e; + return v.vectorFactory(res); + }); + } + + // Mask + + static final class Halffloat128Mask extends AbstractMask { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat128Mask(boolean[] bits) { + this(bits, 0); + } + + Halffloat128Mask(boolean[] bits, int offset) { + super(prepare(bits, offset)); + } + + Halffloat128Mask(boolean val) { + super(prepare(val)); + } + + private static boolean[] prepare(boolean[] bits, int offset) { + boolean[] newBits = new boolean[VSPECIES.laneCount()]; + for (int i = 0; i < newBits.length; i++) { + newBits[i] = bits[offset + i]; + } + return newBits; + } + + private static boolean[] prepare(boolean val) { + boolean[] bits = new boolean[VSPECIES.laneCount()]; + Arrays.fill(bits, val); + return bits; + } + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractMask, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + boolean[] getBits() { + return (boolean[])getPayload(); + } + + @Override + Halffloat128Mask uOp(MUnOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i]); + } + return new Halffloat128Mask(res); + } + + @Override + Halffloat128Mask bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + boolean[] mbits = ((Halffloat128Mask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i], mbits[i]); + } + return new Halffloat128Mask(res); + } + + @ForceInline + @Override + public final + Halffloat128Vector toVector() { + return (Halffloat128Vector) super.toVectorTemplate(); // specialize + } + + /** + * Helper function for lane-wise mask conversions. + * This function kicks in after intrinsic failure. + */ + @ForceInline + private final + VectorMask defaultMaskCast(AbstractSpecies dsp) { + if (length() != dsp.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + boolean[] maskArray = toArray(); + return dsp.maskFactory(maskArray).check(dsp); + } + + @Override + @ForceInline + public VectorMask cast(VectorSpecies dsp) { + AbstractSpecies species = (AbstractSpecies) dsp; + if (length() != species.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + + return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST, + this.getClass(), ETYPE, VLENGTH, + species.maskType(), species.elementType(), VLENGTH, + this, species, + (m, s) -> s.maskFactory(m.toArray()).check(s)); + } + + @Override + @ForceInline + /*package-private*/ + Halffloat128Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Halffloat128Mask) VectorSupport.indexPartiallyInUpperRange( + Halffloat128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, + (o, l) -> (Halffloat128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + + // Unary operations + + @Override + @ForceInline + public Halffloat128Mask not() { + return xor(maskAll(true)); + } + + @Override + @ForceInline + public Halffloat128Mask compress() { + return (Halffloat128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + Halffloat128Vector.class, Halffloat128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + Float16.float16ToShortBits(Float16.valueOf(m1.trueCount())))); + } + + + // Binary operations + + @Override + @ForceInline + public Halffloat128Mask and(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat128Mask m = (Halffloat128Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, Halffloat128Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); + } + + @Override + @ForceInline + public Halffloat128Mask or(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat128Mask m = (Halffloat128Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, Halffloat128Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); + } + + @Override + @ForceInline + public Halffloat128Mask xor(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat128Mask m = (Halffloat128Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, Halffloat128Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); + } + + // Mask Query operations + + @Override + @ForceInline + public int trueCount() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Halffloat128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); + } + + @Override + @ForceInline + public int firstTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Halffloat128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public int lastTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Halffloat128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public long toLong() { + if (length() > Long.SIZE) { + throw new UnsupportedOperationException("too many lanes for one long"); + } + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Halffloat128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> toLongHelper(m.getBits())); + } + + // laneIsSet + + @Override + @ForceInline + public boolean laneIsSet(int i) { + Objects.checkIndex(i, length()); + return VectorSupport.extract(Halffloat128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; + } + + // Reductions + + @Override + @ForceInline + public boolean anyTrue() { + return VectorSupport.test(BT_ne, Halffloat128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Halffloat128Mask)m).getBits())); + } + + @Override + @ForceInline + public boolean allTrue() { + return VectorSupport.test(BT_overflow, Halffloat128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Halffloat128Mask)m).getBits())); + } + + @ForceInline + /*package-private*/ + static Halffloat128Mask maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(Halffloat128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + (bit ? -1 : 0), MODE_BROADCAST, null, + (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + } + private static final Halffloat128Mask TRUE_MASK = new Halffloat128Mask(true); + private static final Halffloat128Mask FALSE_MASK = new Halffloat128Mask(false); + + } + + // Shuffle + + static final class Halffloat128Shuffle extends AbstractShuffle { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat128Shuffle(short[] indices) { + super(indices); + assert(VLENGTH == indices.length); + assert(indicesInRange(indices)); + } + + Halffloat128Shuffle(int[] indices, int i) { + this(prepare(indices, i)); + } + + Halffloat128Shuffle(IntUnaryOperator fn) { + this(prepare(fn)); + } + + short[] indices() { + return (short[])getPayload(); + } + + @Override + @ForceInline + public HalffloatSpecies vspecies() { + return VSPECIES; + } + + static { + // There must be enough bits in the shuffle lanes to encode + // VLENGTH valid indexes and VLENGTH exceptional ones. + assert(VLENGTH < Short.MAX_VALUE); + assert(Short.MIN_VALUE <= -VLENGTH); + } + static final Halffloat128Shuffle IOTA = new Halffloat128Shuffle(IDENTITY); + + @Override + @ForceInline + public Halffloat128Vector toVector() { + return (Halffloat128Vector) toBitsVector().castShape(vspecies(), 0); + } + + @Override + @ForceInline + Short128Vector toBitsVector() { + return (Short128Vector) super.toBitsVectorTemplate(); + } + + @Override + Short128Vector toBitsVector0() { + return ((Short128Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + } + + @Override + @ForceInline + public int laneSource(int i) { + return (int)toBitsVector().lane(i); + } + + @Override + @ForceInline + public void intoArray(int[] a, int offset) { + VectorSpecies species = IntVector.SPECIES_128; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoArray(a, offset); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoArray(a, offset + species.length()); + } + + @Override + @ForceInline + public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) { + VectorSpecies species = IntVector.SPECIES_128; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoMemorySegment(ms, offset, bo); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoMemorySegment(ms, offset + species.vectorByteSize(), bo); + } + + @Override + @ForceInline + public final Halffloat128Mask laneIsValid() { + return (Halffloat128Mask) toBitsVector().compare(VectorOperators.GE, 0) + .cast(vspecies()); + } + + @ForceInline + @Override + public final Halffloat128Shuffle rearrange(VectorShuffle shuffle) { + Halffloat128Shuffle concreteShuffle = (Halffloat128Shuffle) shuffle; + return (Halffloat128Shuffle) toBitsVector().rearrange(concreteShuffle.cast(ShortVector.SPECIES_128)) + .toShuffle(vspecies(), false); + } + + @ForceInline + @Override + public final Halffloat128Shuffle wrapIndexes() { + Short128Vector v = toBitsVector(); + if ((length() & (length() - 1)) == 0) { + v = (Short128Vector) v.lanewise(VectorOperators.AND, length() - 1); + } else { + v = (Short128Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v.compare(VectorOperators.LT, 0)); + } + return (Halffloat128Shuffle) v.toShuffle(vspecies(), false); + } + + private static short[] prepare(int[] indices, int offset) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = indices[offset + i]; + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static short[] prepare(IntUnaryOperator f) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = f.applyAsInt(i); + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static boolean indicesInRange(short[] indices) { + int length = indices.length; + for (short si : indices) { + if (si >= (short)length || si < (short)(-length)) { + String msg = ("index "+si+"out of range ["+length+"] in "+ + java.util.Arrays.toString(indices)); + throw new AssertionError(msg); + } + } + return true; + } + } + + // ================================================ + + // Specialized low-level memory operations. + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset) { + return super.fromArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromArray0Template(Halffloat128Mask.class, a, offset, (Halffloat128Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { + return super.fromArray0Template(Halffloat128Mask.class, a, offset, indexMap, mapOffset, (Halffloat128Mask) m); + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset) { + return super.fromCharArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromCharArray0Template(Halffloat128Mask.class, a, offset, (Halffloat128Mask) m, offsetInRange); // specialize + } + + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset) { + return super.fromMemorySegment0Template(ms, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { + return super.fromMemorySegment0Template(Halffloat128Mask.class, ms, offset, (Halffloat128Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset) { + super.intoArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset, VectorMask m) { + super.intoArray0Template(Halffloat128Mask.class, a, offset, (Halffloat128Mask) m); + } + + + + @ForceInline + @Override + final + void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { + super.intoMemorySegment0Template(Halffloat128Mask.class, ms, offset, (Halffloat128Mask) m); + } + + @ForceInline + @Override + final + void intoCharArray0(char[] a, int offset, VectorMask m) { + super.intoCharArray0Template(Halffloat128Mask.class, a, offset, (Halffloat128Mask) m); + } + + // End of specialized low-level memory operations. + + // ================================================ + +} + diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java new file mode 100644 index 0000000000000..f92c4ed8f7956 --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java @@ -0,0 +1,1058 @@ +/* + * Copyright (c) 2017, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.IntUnaryOperator; + +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.vector.VectorSupport; + +import static jdk.internal.vm.vector.VectorSupport.*; + +import static jdk.incubator.vector.VectorOperators.*; + +// -- This file was mechanically generated: Do not edit! -- // + +@SuppressWarnings("cast") // warning: redundant cast +final class Halffloat256Vector extends HalffloatVector { + static final HalffloatSpecies VSPECIES = + (HalffloatSpecies) HalffloatVector.SPECIES_256; + + static final VectorShape VSHAPE = + VSPECIES.vectorShape(); + + static final Class VCLASS = Halffloat256Vector.class; + + static final int VSIZE = VSPECIES.vectorBitSize(); + + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = Float16.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_FP16; + + Halffloat256Vector(short[] v) { + super(v); + } + + // For compatibility as Halffloat256Vector::new, + // stored into species.vectorFactory. + Halffloat256Vector(Object v) { + this((short[]) v); + } + + static final Halffloat256Vector ZERO = new Halffloat256Vector(new short[VLENGTH]); + static final Halffloat256Vector IOTA = new Halffloat256Vector(VSPECIES.iotaArray()); + + static { + // Warm up a few species caches. + // If we do this too much we will + // get NPEs from bootstrap circularity. + VSPECIES.dummyVector(); + VSPECIES.withLanes(LaneType.BYTE); + } + + // Specialized extractors + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractVector, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + final Class carrierType() { return CTYPE; } + + @ForceInline + @Override + public final Class elementType() { return ETYPE; } + + @ForceInline + @Override + public final int elementSize() { return Float16.SIZE; } + + @ForceInline + @Override + public final VectorShape shape() { return VSHAPE; } + + @ForceInline + @Override + public final int length() { return VLENGTH; } + + @ForceInline + @Override + public final int bitSize() { return VSIZE; } + + @ForceInline + @Override + public final int byteSize() { return VSIZE / Byte.SIZE; } + + /*package-private*/ + @ForceInline + final @Override + short[] vec() { + return (short[])getPayload(); + } + + // Virtualized constructors + + @Override + @ForceInline + public final Halffloat256Vector broadcast(short e) { + return (Halffloat256Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + public final Halffloat256Vector broadcast(long e) { + return (Halffloat256Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + Halffloat256Mask maskFromArray(boolean[] bits) { + return new Halffloat256Mask(bits); + } + + @Override + @ForceInline + Halffloat256Shuffle iotaShuffle() { return Halffloat256Shuffle.IOTA; } + + @Override + @ForceInline + Halffloat256Shuffle iotaShuffle(int start, int step, boolean wrap) { + return (Halffloat256Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + } + + @Override + @ForceInline + Halffloat256Shuffle shuffleFromArray(int[] indices, int i) { return new Halffloat256Shuffle(indices, i); } + + @Override + @ForceInline + Halffloat256Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Halffloat256Shuffle(fn); } + + // Make a vector of the same species but the given elements: + @ForceInline + final @Override + Halffloat256Vector vectorFactory(short[] vec) { + return new Halffloat256Vector(vec); + } + + @ForceInline + final @Override + Byte256Vector asByteVectorRaw() { + return (Byte256Vector) super.asByteVectorRawTemplate(); // specialize + } + + @ForceInline + final @Override + AbstractVector asVectorRaw(LaneType laneType) { + return super.asVectorRawTemplate(laneType); // specialize + } + + // Unary operator + + @ForceInline + final @Override + Halffloat256Vector uOp(FUnOp f) { + return (Halffloat256Vector) super.uOpTemplate(f); // specialize + } + + @ForceInline + final @Override + Halffloat256Vector uOp(VectorMask m, FUnOp f) { + return (Halffloat256Vector) + super.uOpTemplate((Halffloat256Mask)m, f); // specialize + } + + // Binary operator + + @ForceInline + final @Override + Halffloat256Vector bOp(Vector v, FBinOp f) { + return (Halffloat256Vector) super.bOpTemplate((Halffloat256Vector)v, f); // specialize + } + + @ForceInline + final @Override + Halffloat256Vector bOp(Vector v, + VectorMask m, FBinOp f) { + return (Halffloat256Vector) + super.bOpTemplate((Halffloat256Vector)v, (Halffloat256Mask)m, + f); // specialize + } + + // Ternary operator + + @ForceInline + final @Override + Halffloat256Vector tOp(Vector v1, Vector v2, FTriOp f) { + return (Halffloat256Vector) + super.tOpTemplate((Halffloat256Vector)v1, (Halffloat256Vector)v2, + f); // specialize + } + + @ForceInline + final @Override + Halffloat256Vector tOp(Vector v1, Vector v2, + VectorMask m, FTriOp f) { + return (Halffloat256Vector) + super.tOpTemplate((Halffloat256Vector)v1, (Halffloat256Vector)v2, + (Halffloat256Mask)m, f); // specialize + } + + @ForceInline + final @Override + short rOp(short v, VectorMask m, FBinOp f) { + return super.rOpTemplate(v, m, f); // specialize + } + + @Override + @ForceInline + public final + Vector convertShape(VectorOperators.Conversion conv, + VectorSpecies rsp, int part) { + return super.convertShapeTemplate(conv, rsp, part); // specialize + } + + @Override + @ForceInline + public final + Vector reinterpretShape(VectorSpecies toSpecies, int part) { + return super.reinterpretShapeTemplate(toSpecies, part); // specialize + } + + // Specialized algebraic operations: + + // The following definition forces a specialized version of this + // crucial method into the v-table of this class. A call to add() + // will inline to a call to lanewise(ADD,), at which point the JIT + // intrinsic will have the opcode of ADD, plus all the metadata + // for this particular class, enabling it to generate precise + // code. + // + // There is probably no benefit to the JIT to specialize the + // masked or broadcast versions of the lanewise method. + + @Override + @ForceInline + public Halffloat256Vector lanewise(Unary op) { + return (Halffloat256Vector) super.lanewiseTemplate(op); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector lanewise(Unary op, VectorMask m) { + return (Halffloat256Vector) super.lanewiseTemplate(op, Halffloat256Mask.class, (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector lanewise(Binary op, Vector v) { + return (Halffloat256Vector) super.lanewiseTemplate(op, v); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector lanewise(Binary op, Vector v, VectorMask m) { + return (Halffloat256Vector) super.lanewiseTemplate(op, Halffloat256Mask.class, v, (Halffloat256Mask) m); // specialize + } + + + /*package-private*/ + @Override + @ForceInline + public final + Halffloat256Vector + lanewise(Ternary op, Vector v1, Vector v2) { + return (Halffloat256Vector) super.lanewiseTemplate(op, v1, v2); // specialize + } + + @Override + @ForceInline + public final + Halffloat256Vector + lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { + return (Halffloat256Vector) super.lanewiseTemplate(op, Halffloat256Mask.class, v1, v2, (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public final + Halffloat256Vector addIndex(int scale) { + return (Halffloat256Vector) super.addIndexTemplate(scale); // specialize + } + + // Type specific horizontal reductions + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op) { + return super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op, + VectorMask m) { + return super.reduceLanesTemplate(op, Halffloat256Mask.class, (Halffloat256Mask) m); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op) { + return (long) super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op, + VectorMask m) { + return (long) super.reduceLanesTemplate(op, Halffloat256Mask.class, (Halffloat256Mask) m); // specialized + } + + @Override + @ForceInline + final VectorShuffle bitsToShuffle(AbstractSpecies dsp) { + throw new AssertionError(); + } + + @Override + @ForceInline + public final Halffloat256Shuffle toShuffle() { + return (Halffloat256Shuffle) toShuffle(vspecies(), false); + } + + // Specialized unary testing + + @Override + @ForceInline + public final Halffloat256Mask test(Test op) { + return super.testTemplate(Halffloat256Mask.class, op); // specialize + } + + @Override + @ForceInline + public final Halffloat256Mask test(Test op, VectorMask m) { + return super.testTemplate(Halffloat256Mask.class, op, (Halffloat256Mask) m); // specialize + } + + // Specialized comparisons + + @Override + @ForceInline + public final Halffloat256Mask compare(Comparison op, Vector v) { + return super.compareTemplate(Halffloat256Mask.class, op, v); // specialize + } + + @Override + @ForceInline + public final Halffloat256Mask compare(Comparison op, short s) { + return super.compareTemplate(Halffloat256Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat256Mask compare(Comparison op, long s) { + return super.compareTemplate(Halffloat256Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat256Mask compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(Halffloat256Mask.class, op, v, (Halffloat256Mask) m); + } + + + @Override + @ForceInline + public Halffloat256Vector blend(Vector v, VectorMask m) { + return (Halffloat256Vector) + super.blendTemplate(Halffloat256Mask.class, + (Halffloat256Vector) v, + (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector slice(int origin, Vector v) { + return (Halffloat256Vector) super.sliceTemplate(origin, v); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector slice(int origin) { + return (Halffloat256Vector) super.sliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector unslice(int origin, Vector w, int part) { + return (Halffloat256Vector) super.unsliceTemplate(origin, w, part); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector unslice(int origin, Vector w, int part, VectorMask m) { + return (Halffloat256Vector) + super.unsliceTemplate(Halffloat256Mask.class, + origin, w, part, + (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector unslice(int origin) { + return (Halffloat256Vector) super.unsliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector rearrange(VectorShuffle s) { + return (Halffloat256Vector) + super.rearrangeTemplate(Halffloat256Shuffle.class, + (Halffloat256Shuffle) s); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector rearrange(VectorShuffle shuffle, + VectorMask m) { + return (Halffloat256Vector) + super.rearrangeTemplate(Halffloat256Shuffle.class, + Halffloat256Mask.class, + (Halffloat256Shuffle) shuffle, + (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector rearrange(VectorShuffle s, + Vector v) { + return (Halffloat256Vector) + super.rearrangeTemplate(Halffloat256Shuffle.class, + (Halffloat256Shuffle) s, + (Halffloat256Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector compress(VectorMask m) { + return (Halffloat256Vector) + super.compressTemplate(Halffloat256Mask.class, + (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector expand(VectorMask m) { + return (Halffloat256Vector) + super.expandTemplate(Halffloat256Mask.class, + (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector selectFrom(Vector v) { + return (Halffloat256Vector) + super.selectFromTemplate((Halffloat256Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector selectFrom(Vector v, + VectorMask m) { + return (Halffloat256Vector) + super.selectFromTemplate((Halffloat256Vector) v, + Halffloat256Mask.class, (Halffloat256Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat256Vector selectFrom(Vector v1, + Vector v2) { + return (Halffloat256Vector) + super.selectFromTemplate((Halffloat256Vector) v1, (Halffloat256Vector) v2); // specialize + } + + @ForceInline + @Override + public short lane(int i) { + short bits; + switch(i) { + case 0: bits = laneHelper(0); break; + case 1: bits = laneHelper(1); break; + case 2: bits = laneHelper(2); break; + case 3: bits = laneHelper(3); break; + case 4: bits = laneHelper(4); break; + case 5: bits = laneHelper(5); break; + case 6: bits = laneHelper(6); break; + case 7: bits = laneHelper(7); break; + case 8: bits = laneHelper(8); break; + case 9: bits = laneHelper(9); break; + case 10: bits = laneHelper(10); break; + case 11: bits = laneHelper(11); break; + case 12: bits = laneHelper(12); break; + case 13: bits = laneHelper(13); break; + case 14: bits = laneHelper(14); break; + case 15: bits = laneHelper(15); break; + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + return bits; + } + + @ForceInline + public short laneHelper(int i) { + return (short) VectorSupport.extract( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, + (vec, ix) -> { + short[] vecarr = vec.vec(); + return vecarr[ix]; + }); + } + + @ForceInline + @Override + public Halffloat256Vector withLane(int i, short e) { + switch(i) { + case 0: return withLaneHelper(0, e); + case 1: return withLaneHelper(1, e); + case 2: return withLaneHelper(2, e); + case 3: return withLaneHelper(3, e); + case 4: return withLaneHelper(4, e); + case 5: return withLaneHelper(5, e); + case 6: return withLaneHelper(6, e); + case 7: return withLaneHelper(7, e); + case 8: return withLaneHelper(8, e); + case 9: return withLaneHelper(9, e); + case 10: return withLaneHelper(10, e); + case 11: return withLaneHelper(11, e); + case 12: return withLaneHelper(12, e); + case 13: return withLaneHelper(13, e); + case 14: return withLaneHelper(14, e); + case 15: return withLaneHelper(15, e); + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + } + + @ForceInline + public Halffloat256Vector withLaneHelper(int i, short e) { + return VectorSupport.insert( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, (long)e, + (v, ix, bits) -> { + short[] res = v.vec().clone(); + res[ix] = e; + return v.vectorFactory(res); + }); + } + + // Mask + + static final class Halffloat256Mask extends AbstractMask { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat256Mask(boolean[] bits) { + this(bits, 0); + } + + Halffloat256Mask(boolean[] bits, int offset) { + super(prepare(bits, offset)); + } + + Halffloat256Mask(boolean val) { + super(prepare(val)); + } + + private static boolean[] prepare(boolean[] bits, int offset) { + boolean[] newBits = new boolean[VSPECIES.laneCount()]; + for (int i = 0; i < newBits.length; i++) { + newBits[i] = bits[offset + i]; + } + return newBits; + } + + private static boolean[] prepare(boolean val) { + boolean[] bits = new boolean[VSPECIES.laneCount()]; + Arrays.fill(bits, val); + return bits; + } + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractMask, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + boolean[] getBits() { + return (boolean[])getPayload(); + } + + @Override + Halffloat256Mask uOp(MUnOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i]); + } + return new Halffloat256Mask(res); + } + + @Override + Halffloat256Mask bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + boolean[] mbits = ((Halffloat256Mask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i], mbits[i]); + } + return new Halffloat256Mask(res); + } + + @ForceInline + @Override + public final + Halffloat256Vector toVector() { + return (Halffloat256Vector) super.toVectorTemplate(); // specialize + } + + /** + * Helper function for lane-wise mask conversions. + * This function kicks in after intrinsic failure. + */ + @ForceInline + private final + VectorMask defaultMaskCast(AbstractSpecies dsp) { + if (length() != dsp.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + boolean[] maskArray = toArray(); + return dsp.maskFactory(maskArray).check(dsp); + } + + @Override + @ForceInline + public VectorMask cast(VectorSpecies dsp) { + AbstractSpecies species = (AbstractSpecies) dsp; + if (length() != species.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + + return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST, + this.getClass(), ETYPE, VLENGTH, + species.maskType(), species.elementType(), VLENGTH, + this, species, + (m, s) -> s.maskFactory(m.toArray()).check(s)); + } + + @Override + @ForceInline + /*package-private*/ + Halffloat256Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Halffloat256Mask) VectorSupport.indexPartiallyInUpperRange( + Halffloat256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, + (o, l) -> (Halffloat256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + + // Unary operations + + @Override + @ForceInline + public Halffloat256Mask not() { + return xor(maskAll(true)); + } + + @Override + @ForceInline + public Halffloat256Mask compress() { + return (Halffloat256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + Halffloat256Vector.class, Halffloat256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + Float16.float16ToShortBits(Float16.valueOf(m1.trueCount())))); + } + + + // Binary operations + + @Override + @ForceInline + public Halffloat256Mask and(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat256Mask m = (Halffloat256Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, Halffloat256Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); + } + + @Override + @ForceInline + public Halffloat256Mask or(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat256Mask m = (Halffloat256Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, Halffloat256Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); + } + + @Override + @ForceInline + public Halffloat256Mask xor(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat256Mask m = (Halffloat256Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, Halffloat256Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); + } + + // Mask Query operations + + @Override + @ForceInline + public int trueCount() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Halffloat256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); + } + + @Override + @ForceInline + public int firstTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Halffloat256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public int lastTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Halffloat256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public long toLong() { + if (length() > Long.SIZE) { + throw new UnsupportedOperationException("too many lanes for one long"); + } + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Halffloat256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> toLongHelper(m.getBits())); + } + + // laneIsSet + + @Override + @ForceInline + public boolean laneIsSet(int i) { + Objects.checkIndex(i, length()); + return VectorSupport.extract(Halffloat256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; + } + + // Reductions + + @Override + @ForceInline + public boolean anyTrue() { + return VectorSupport.test(BT_ne, Halffloat256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Halffloat256Mask)m).getBits())); + } + + @Override + @ForceInline + public boolean allTrue() { + return VectorSupport.test(BT_overflow, Halffloat256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Halffloat256Mask)m).getBits())); + } + + @ForceInline + /*package-private*/ + static Halffloat256Mask maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(Halffloat256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + (bit ? -1 : 0), MODE_BROADCAST, null, + (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + } + private static final Halffloat256Mask TRUE_MASK = new Halffloat256Mask(true); + private static final Halffloat256Mask FALSE_MASK = new Halffloat256Mask(false); + + } + + // Shuffle + + static final class Halffloat256Shuffle extends AbstractShuffle { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat256Shuffle(short[] indices) { + super(indices); + assert(VLENGTH == indices.length); + assert(indicesInRange(indices)); + } + + Halffloat256Shuffle(int[] indices, int i) { + this(prepare(indices, i)); + } + + Halffloat256Shuffle(IntUnaryOperator fn) { + this(prepare(fn)); + } + + short[] indices() { + return (short[])getPayload(); + } + + @Override + @ForceInline + public HalffloatSpecies vspecies() { + return VSPECIES; + } + + static { + // There must be enough bits in the shuffle lanes to encode + // VLENGTH valid indexes and VLENGTH exceptional ones. + assert(VLENGTH < Short.MAX_VALUE); + assert(Short.MIN_VALUE <= -VLENGTH); + } + static final Halffloat256Shuffle IOTA = new Halffloat256Shuffle(IDENTITY); + + @Override + @ForceInline + public Halffloat256Vector toVector() { + return (Halffloat256Vector) toBitsVector().castShape(vspecies(), 0); + } + + @Override + @ForceInline + Short256Vector toBitsVector() { + return (Short256Vector) super.toBitsVectorTemplate(); + } + + @Override + Short256Vector toBitsVector0() { + return ((Short256Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + } + + @Override + @ForceInline + public int laneSource(int i) { + return (int)toBitsVector().lane(i); + } + + @Override + @ForceInline + public void intoArray(int[] a, int offset) { + VectorSpecies species = IntVector.SPECIES_256; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoArray(a, offset); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoArray(a, offset + species.length()); + } + + @Override + @ForceInline + public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) { + VectorSpecies species = IntVector.SPECIES_256; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoMemorySegment(ms, offset, bo); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoMemorySegment(ms, offset + species.vectorByteSize(), bo); + } + + @Override + @ForceInline + public final Halffloat256Mask laneIsValid() { + return (Halffloat256Mask) toBitsVector().compare(VectorOperators.GE, 0) + .cast(vspecies()); + } + + @ForceInline + @Override + public final Halffloat256Shuffle rearrange(VectorShuffle shuffle) { + Halffloat256Shuffle concreteShuffle = (Halffloat256Shuffle) shuffle; + return (Halffloat256Shuffle) toBitsVector().rearrange(concreteShuffle.cast(ShortVector.SPECIES_256)) + .toShuffle(vspecies(), false); + } + + @ForceInline + @Override + public final Halffloat256Shuffle wrapIndexes() { + Short256Vector v = toBitsVector(); + if ((length() & (length() - 1)) == 0) { + v = (Short256Vector) v.lanewise(VectorOperators.AND, length() - 1); + } else { + v = (Short256Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v.compare(VectorOperators.LT, 0)); + } + return (Halffloat256Shuffle) v.toShuffle(vspecies(), false); + } + + private static short[] prepare(int[] indices, int offset) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = indices[offset + i]; + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static short[] prepare(IntUnaryOperator f) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = f.applyAsInt(i); + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static boolean indicesInRange(short[] indices) { + int length = indices.length; + for (short si : indices) { + if (si >= (short)length || si < (short)(-length)) { + String msg = ("index "+si+"out of range ["+length+"] in "+ + java.util.Arrays.toString(indices)); + throw new AssertionError(msg); + } + } + return true; + } + } + + // ================================================ + + // Specialized low-level memory operations. + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset) { + return super.fromArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromArray0Template(Halffloat256Mask.class, a, offset, (Halffloat256Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { + return super.fromArray0Template(Halffloat256Mask.class, a, offset, indexMap, mapOffset, (Halffloat256Mask) m); + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset) { + return super.fromCharArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromCharArray0Template(Halffloat256Mask.class, a, offset, (Halffloat256Mask) m, offsetInRange); // specialize + } + + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset) { + return super.fromMemorySegment0Template(ms, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { + return super.fromMemorySegment0Template(Halffloat256Mask.class, ms, offset, (Halffloat256Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset) { + super.intoArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset, VectorMask m) { + super.intoArray0Template(Halffloat256Mask.class, a, offset, (Halffloat256Mask) m); + } + + + + @ForceInline + @Override + final + void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { + super.intoMemorySegment0Template(Halffloat256Mask.class, ms, offset, (Halffloat256Mask) m); + } + + @ForceInline + @Override + final + void intoCharArray0(char[] a, int offset, VectorMask m) { + super.intoCharArray0Template(Halffloat256Mask.class, a, offset, (Halffloat256Mask) m); + } + + // End of specialized low-level memory operations. + + // ================================================ + +} + diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java new file mode 100644 index 0000000000000..15e86b35b42a0 --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java @@ -0,0 +1,1090 @@ +/* + * Copyright (c) 2017, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.IntUnaryOperator; + +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.vector.VectorSupport; + +import static jdk.internal.vm.vector.VectorSupport.*; + +import static jdk.incubator.vector.VectorOperators.*; + +// -- This file was mechanically generated: Do not edit! -- // + +@SuppressWarnings("cast") // warning: redundant cast +final class Halffloat512Vector extends HalffloatVector { + static final HalffloatSpecies VSPECIES = + (HalffloatSpecies) HalffloatVector.SPECIES_512; + + static final VectorShape VSHAPE = + VSPECIES.vectorShape(); + + static final Class VCLASS = Halffloat512Vector.class; + + static final int VSIZE = VSPECIES.vectorBitSize(); + + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = Float16.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_FP16; + + Halffloat512Vector(short[] v) { + super(v); + } + + // For compatibility as Halffloat512Vector::new, + // stored into species.vectorFactory. + Halffloat512Vector(Object v) { + this((short[]) v); + } + + static final Halffloat512Vector ZERO = new Halffloat512Vector(new short[VLENGTH]); + static final Halffloat512Vector IOTA = new Halffloat512Vector(VSPECIES.iotaArray()); + + static { + // Warm up a few species caches. + // If we do this too much we will + // get NPEs from bootstrap circularity. + VSPECIES.dummyVector(); + VSPECIES.withLanes(LaneType.BYTE); + } + + // Specialized extractors + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractVector, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + final Class carrierType() { return CTYPE; } + + @ForceInline + @Override + public final Class elementType() { return ETYPE; } + + @ForceInline + @Override + public final int elementSize() { return Float16.SIZE; } + + @ForceInline + @Override + public final VectorShape shape() { return VSHAPE; } + + @ForceInline + @Override + public final int length() { return VLENGTH; } + + @ForceInline + @Override + public final int bitSize() { return VSIZE; } + + @ForceInline + @Override + public final int byteSize() { return VSIZE / Byte.SIZE; } + + /*package-private*/ + @ForceInline + final @Override + short[] vec() { + return (short[])getPayload(); + } + + // Virtualized constructors + + @Override + @ForceInline + public final Halffloat512Vector broadcast(short e) { + return (Halffloat512Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + public final Halffloat512Vector broadcast(long e) { + return (Halffloat512Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + Halffloat512Mask maskFromArray(boolean[] bits) { + return new Halffloat512Mask(bits); + } + + @Override + @ForceInline + Halffloat512Shuffle iotaShuffle() { return Halffloat512Shuffle.IOTA; } + + @Override + @ForceInline + Halffloat512Shuffle iotaShuffle(int start, int step, boolean wrap) { + return (Halffloat512Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + } + + @Override + @ForceInline + Halffloat512Shuffle shuffleFromArray(int[] indices, int i) { return new Halffloat512Shuffle(indices, i); } + + @Override + @ForceInline + Halffloat512Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Halffloat512Shuffle(fn); } + + // Make a vector of the same species but the given elements: + @ForceInline + final @Override + Halffloat512Vector vectorFactory(short[] vec) { + return new Halffloat512Vector(vec); + } + + @ForceInline + final @Override + Byte512Vector asByteVectorRaw() { + return (Byte512Vector) super.asByteVectorRawTemplate(); // specialize + } + + @ForceInline + final @Override + AbstractVector asVectorRaw(LaneType laneType) { + return super.asVectorRawTemplate(laneType); // specialize + } + + // Unary operator + + @ForceInline + final @Override + Halffloat512Vector uOp(FUnOp f) { + return (Halffloat512Vector) super.uOpTemplate(f); // specialize + } + + @ForceInline + final @Override + Halffloat512Vector uOp(VectorMask m, FUnOp f) { + return (Halffloat512Vector) + super.uOpTemplate((Halffloat512Mask)m, f); // specialize + } + + // Binary operator + + @ForceInline + final @Override + Halffloat512Vector bOp(Vector v, FBinOp f) { + return (Halffloat512Vector) super.bOpTemplate((Halffloat512Vector)v, f); // specialize + } + + @ForceInline + final @Override + Halffloat512Vector bOp(Vector v, + VectorMask m, FBinOp f) { + return (Halffloat512Vector) + super.bOpTemplate((Halffloat512Vector)v, (Halffloat512Mask)m, + f); // specialize + } + + // Ternary operator + + @ForceInline + final @Override + Halffloat512Vector tOp(Vector v1, Vector v2, FTriOp f) { + return (Halffloat512Vector) + super.tOpTemplate((Halffloat512Vector)v1, (Halffloat512Vector)v2, + f); // specialize + } + + @ForceInline + final @Override + Halffloat512Vector tOp(Vector v1, Vector v2, + VectorMask m, FTriOp f) { + return (Halffloat512Vector) + super.tOpTemplate((Halffloat512Vector)v1, (Halffloat512Vector)v2, + (Halffloat512Mask)m, f); // specialize + } + + @ForceInline + final @Override + short rOp(short v, VectorMask m, FBinOp f) { + return super.rOpTemplate(v, m, f); // specialize + } + + @Override + @ForceInline + public final + Vector convertShape(VectorOperators.Conversion conv, + VectorSpecies rsp, int part) { + return super.convertShapeTemplate(conv, rsp, part); // specialize + } + + @Override + @ForceInline + public final + Vector reinterpretShape(VectorSpecies toSpecies, int part) { + return super.reinterpretShapeTemplate(toSpecies, part); // specialize + } + + // Specialized algebraic operations: + + // The following definition forces a specialized version of this + // crucial method into the v-table of this class. A call to add() + // will inline to a call to lanewise(ADD,), at which point the JIT + // intrinsic will have the opcode of ADD, plus all the metadata + // for this particular class, enabling it to generate precise + // code. + // + // There is probably no benefit to the JIT to specialize the + // masked or broadcast versions of the lanewise method. + + @Override + @ForceInline + public Halffloat512Vector lanewise(Unary op) { + return (Halffloat512Vector) super.lanewiseTemplate(op); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector lanewise(Unary op, VectorMask m) { + return (Halffloat512Vector) super.lanewiseTemplate(op, Halffloat512Mask.class, (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector lanewise(Binary op, Vector v) { + return (Halffloat512Vector) super.lanewiseTemplate(op, v); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector lanewise(Binary op, Vector v, VectorMask m) { + return (Halffloat512Vector) super.lanewiseTemplate(op, Halffloat512Mask.class, v, (Halffloat512Mask) m); // specialize + } + + + /*package-private*/ + @Override + @ForceInline + public final + Halffloat512Vector + lanewise(Ternary op, Vector v1, Vector v2) { + return (Halffloat512Vector) super.lanewiseTemplate(op, v1, v2); // specialize + } + + @Override + @ForceInline + public final + Halffloat512Vector + lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { + return (Halffloat512Vector) super.lanewiseTemplate(op, Halffloat512Mask.class, v1, v2, (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public final + Halffloat512Vector addIndex(int scale) { + return (Halffloat512Vector) super.addIndexTemplate(scale); // specialize + } + + // Type specific horizontal reductions + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op) { + return super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op, + VectorMask m) { + return super.reduceLanesTemplate(op, Halffloat512Mask.class, (Halffloat512Mask) m); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op) { + return (long) super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op, + VectorMask m) { + return (long) super.reduceLanesTemplate(op, Halffloat512Mask.class, (Halffloat512Mask) m); // specialized + } + + @Override + @ForceInline + final VectorShuffle bitsToShuffle(AbstractSpecies dsp) { + throw new AssertionError(); + } + + @Override + @ForceInline + public final Halffloat512Shuffle toShuffle() { + return (Halffloat512Shuffle) toShuffle(vspecies(), false); + } + + // Specialized unary testing + + @Override + @ForceInline + public final Halffloat512Mask test(Test op) { + return super.testTemplate(Halffloat512Mask.class, op); // specialize + } + + @Override + @ForceInline + public final Halffloat512Mask test(Test op, VectorMask m) { + return super.testTemplate(Halffloat512Mask.class, op, (Halffloat512Mask) m); // specialize + } + + // Specialized comparisons + + @Override + @ForceInline + public final Halffloat512Mask compare(Comparison op, Vector v) { + return super.compareTemplate(Halffloat512Mask.class, op, v); // specialize + } + + @Override + @ForceInline + public final Halffloat512Mask compare(Comparison op, short s) { + return super.compareTemplate(Halffloat512Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat512Mask compare(Comparison op, long s) { + return super.compareTemplate(Halffloat512Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat512Mask compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(Halffloat512Mask.class, op, v, (Halffloat512Mask) m); + } + + + @Override + @ForceInline + public Halffloat512Vector blend(Vector v, VectorMask m) { + return (Halffloat512Vector) + super.blendTemplate(Halffloat512Mask.class, + (Halffloat512Vector) v, + (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector slice(int origin, Vector v) { + return (Halffloat512Vector) super.sliceTemplate(origin, v); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector slice(int origin) { + return (Halffloat512Vector) super.sliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector unslice(int origin, Vector w, int part) { + return (Halffloat512Vector) super.unsliceTemplate(origin, w, part); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector unslice(int origin, Vector w, int part, VectorMask m) { + return (Halffloat512Vector) + super.unsliceTemplate(Halffloat512Mask.class, + origin, w, part, + (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector unslice(int origin) { + return (Halffloat512Vector) super.unsliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector rearrange(VectorShuffle s) { + return (Halffloat512Vector) + super.rearrangeTemplate(Halffloat512Shuffle.class, + (Halffloat512Shuffle) s); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector rearrange(VectorShuffle shuffle, + VectorMask m) { + return (Halffloat512Vector) + super.rearrangeTemplate(Halffloat512Shuffle.class, + Halffloat512Mask.class, + (Halffloat512Shuffle) shuffle, + (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector rearrange(VectorShuffle s, + Vector v) { + return (Halffloat512Vector) + super.rearrangeTemplate(Halffloat512Shuffle.class, + (Halffloat512Shuffle) s, + (Halffloat512Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector compress(VectorMask m) { + return (Halffloat512Vector) + super.compressTemplate(Halffloat512Mask.class, + (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector expand(VectorMask m) { + return (Halffloat512Vector) + super.expandTemplate(Halffloat512Mask.class, + (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector selectFrom(Vector v) { + return (Halffloat512Vector) + super.selectFromTemplate((Halffloat512Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector selectFrom(Vector v, + VectorMask m) { + return (Halffloat512Vector) + super.selectFromTemplate((Halffloat512Vector) v, + Halffloat512Mask.class, (Halffloat512Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat512Vector selectFrom(Vector v1, + Vector v2) { + return (Halffloat512Vector) + super.selectFromTemplate((Halffloat512Vector) v1, (Halffloat512Vector) v2); // specialize + } + + @ForceInline + @Override + public short lane(int i) { + short bits; + switch(i) { + case 0: bits = laneHelper(0); break; + case 1: bits = laneHelper(1); break; + case 2: bits = laneHelper(2); break; + case 3: bits = laneHelper(3); break; + case 4: bits = laneHelper(4); break; + case 5: bits = laneHelper(5); break; + case 6: bits = laneHelper(6); break; + case 7: bits = laneHelper(7); break; + case 8: bits = laneHelper(8); break; + case 9: bits = laneHelper(9); break; + case 10: bits = laneHelper(10); break; + case 11: bits = laneHelper(11); break; + case 12: bits = laneHelper(12); break; + case 13: bits = laneHelper(13); break; + case 14: bits = laneHelper(14); break; + case 15: bits = laneHelper(15); break; + case 16: bits = laneHelper(16); break; + case 17: bits = laneHelper(17); break; + case 18: bits = laneHelper(18); break; + case 19: bits = laneHelper(19); break; + case 20: bits = laneHelper(20); break; + case 21: bits = laneHelper(21); break; + case 22: bits = laneHelper(22); break; + case 23: bits = laneHelper(23); break; + case 24: bits = laneHelper(24); break; + case 25: bits = laneHelper(25); break; + case 26: bits = laneHelper(26); break; + case 27: bits = laneHelper(27); break; + case 28: bits = laneHelper(28); break; + case 29: bits = laneHelper(29); break; + case 30: bits = laneHelper(30); break; + case 31: bits = laneHelper(31); break; + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + return bits; + } + + @ForceInline + public short laneHelper(int i) { + return (short) VectorSupport.extract( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, + (vec, ix) -> { + short[] vecarr = vec.vec(); + return vecarr[ix]; + }); + } + + @ForceInline + @Override + public Halffloat512Vector withLane(int i, short e) { + switch(i) { + case 0: return withLaneHelper(0, e); + case 1: return withLaneHelper(1, e); + case 2: return withLaneHelper(2, e); + case 3: return withLaneHelper(3, e); + case 4: return withLaneHelper(4, e); + case 5: return withLaneHelper(5, e); + case 6: return withLaneHelper(6, e); + case 7: return withLaneHelper(7, e); + case 8: return withLaneHelper(8, e); + case 9: return withLaneHelper(9, e); + case 10: return withLaneHelper(10, e); + case 11: return withLaneHelper(11, e); + case 12: return withLaneHelper(12, e); + case 13: return withLaneHelper(13, e); + case 14: return withLaneHelper(14, e); + case 15: return withLaneHelper(15, e); + case 16: return withLaneHelper(16, e); + case 17: return withLaneHelper(17, e); + case 18: return withLaneHelper(18, e); + case 19: return withLaneHelper(19, e); + case 20: return withLaneHelper(20, e); + case 21: return withLaneHelper(21, e); + case 22: return withLaneHelper(22, e); + case 23: return withLaneHelper(23, e); + case 24: return withLaneHelper(24, e); + case 25: return withLaneHelper(25, e); + case 26: return withLaneHelper(26, e); + case 27: return withLaneHelper(27, e); + case 28: return withLaneHelper(28, e); + case 29: return withLaneHelper(29, e); + case 30: return withLaneHelper(30, e); + case 31: return withLaneHelper(31, e); + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + } + + @ForceInline + public Halffloat512Vector withLaneHelper(int i, short e) { + return VectorSupport.insert( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, (long)e, + (v, ix, bits) -> { + short[] res = v.vec().clone(); + res[ix] = e; + return v.vectorFactory(res); + }); + } + + // Mask + + static final class Halffloat512Mask extends AbstractMask { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat512Mask(boolean[] bits) { + this(bits, 0); + } + + Halffloat512Mask(boolean[] bits, int offset) { + super(prepare(bits, offset)); + } + + Halffloat512Mask(boolean val) { + super(prepare(val)); + } + + private static boolean[] prepare(boolean[] bits, int offset) { + boolean[] newBits = new boolean[VSPECIES.laneCount()]; + for (int i = 0; i < newBits.length; i++) { + newBits[i] = bits[offset + i]; + } + return newBits; + } + + private static boolean[] prepare(boolean val) { + boolean[] bits = new boolean[VSPECIES.laneCount()]; + Arrays.fill(bits, val); + return bits; + } + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractMask, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + boolean[] getBits() { + return (boolean[])getPayload(); + } + + @Override + Halffloat512Mask uOp(MUnOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i]); + } + return new Halffloat512Mask(res); + } + + @Override + Halffloat512Mask bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + boolean[] mbits = ((Halffloat512Mask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i], mbits[i]); + } + return new Halffloat512Mask(res); + } + + @ForceInline + @Override + public final + Halffloat512Vector toVector() { + return (Halffloat512Vector) super.toVectorTemplate(); // specialize + } + + /** + * Helper function for lane-wise mask conversions. + * This function kicks in after intrinsic failure. + */ + @ForceInline + private final + VectorMask defaultMaskCast(AbstractSpecies dsp) { + if (length() != dsp.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + boolean[] maskArray = toArray(); + return dsp.maskFactory(maskArray).check(dsp); + } + + @Override + @ForceInline + public VectorMask cast(VectorSpecies dsp) { + AbstractSpecies species = (AbstractSpecies) dsp; + if (length() != species.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + + return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST, + this.getClass(), ETYPE, VLENGTH, + species.maskType(), species.elementType(), VLENGTH, + this, species, + (m, s) -> s.maskFactory(m.toArray()).check(s)); + } + + @Override + @ForceInline + /*package-private*/ + Halffloat512Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Halffloat512Mask) VectorSupport.indexPartiallyInUpperRange( + Halffloat512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, + (o, l) -> (Halffloat512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + + // Unary operations + + @Override + @ForceInline + public Halffloat512Mask not() { + return xor(maskAll(true)); + } + + @Override + @ForceInline + public Halffloat512Mask compress() { + return (Halffloat512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + Halffloat512Vector.class, Halffloat512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + Float16.float16ToShortBits(Float16.valueOf(m1.trueCount())))); + } + + + // Binary operations + + @Override + @ForceInline + public Halffloat512Mask and(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat512Mask m = (Halffloat512Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, Halffloat512Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); + } + + @Override + @ForceInline + public Halffloat512Mask or(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat512Mask m = (Halffloat512Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, Halffloat512Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); + } + + @Override + @ForceInline + public Halffloat512Mask xor(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat512Mask m = (Halffloat512Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, Halffloat512Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); + } + + // Mask Query operations + + @Override + @ForceInline + public int trueCount() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Halffloat512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); + } + + @Override + @ForceInline + public int firstTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Halffloat512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public int lastTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Halffloat512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public long toLong() { + if (length() > Long.SIZE) { + throw new UnsupportedOperationException("too many lanes for one long"); + } + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Halffloat512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> toLongHelper(m.getBits())); + } + + // laneIsSet + + @Override + @ForceInline + public boolean laneIsSet(int i) { + Objects.checkIndex(i, length()); + return VectorSupport.extract(Halffloat512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; + } + + // Reductions + + @Override + @ForceInline + public boolean anyTrue() { + return VectorSupport.test(BT_ne, Halffloat512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Halffloat512Mask)m).getBits())); + } + + @Override + @ForceInline + public boolean allTrue() { + return VectorSupport.test(BT_overflow, Halffloat512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Halffloat512Mask)m).getBits())); + } + + @ForceInline + /*package-private*/ + static Halffloat512Mask maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(Halffloat512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + (bit ? -1 : 0), MODE_BROADCAST, null, + (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + } + private static final Halffloat512Mask TRUE_MASK = new Halffloat512Mask(true); + private static final Halffloat512Mask FALSE_MASK = new Halffloat512Mask(false); + + } + + // Shuffle + + static final class Halffloat512Shuffle extends AbstractShuffle { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat512Shuffle(short[] indices) { + super(indices); + assert(VLENGTH == indices.length); + assert(indicesInRange(indices)); + } + + Halffloat512Shuffle(int[] indices, int i) { + this(prepare(indices, i)); + } + + Halffloat512Shuffle(IntUnaryOperator fn) { + this(prepare(fn)); + } + + short[] indices() { + return (short[])getPayload(); + } + + @Override + @ForceInline + public HalffloatSpecies vspecies() { + return VSPECIES; + } + + static { + // There must be enough bits in the shuffle lanes to encode + // VLENGTH valid indexes and VLENGTH exceptional ones. + assert(VLENGTH < Short.MAX_VALUE); + assert(Short.MIN_VALUE <= -VLENGTH); + } + static final Halffloat512Shuffle IOTA = new Halffloat512Shuffle(IDENTITY); + + @Override + @ForceInline + public Halffloat512Vector toVector() { + return (Halffloat512Vector) toBitsVector().castShape(vspecies(), 0); + } + + @Override + @ForceInline + Short512Vector toBitsVector() { + return (Short512Vector) super.toBitsVectorTemplate(); + } + + @Override + Short512Vector toBitsVector0() { + return ((Short512Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + } + + @Override + @ForceInline + public int laneSource(int i) { + return (int)toBitsVector().lane(i); + } + + @Override + @ForceInline + public void intoArray(int[] a, int offset) { + VectorSpecies species = IntVector.SPECIES_512; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoArray(a, offset); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoArray(a, offset + species.length()); + } + + @Override + @ForceInline + public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) { + VectorSpecies species = IntVector.SPECIES_512; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoMemorySegment(ms, offset, bo); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoMemorySegment(ms, offset + species.vectorByteSize(), bo); + } + + @Override + @ForceInline + public final Halffloat512Mask laneIsValid() { + return (Halffloat512Mask) toBitsVector().compare(VectorOperators.GE, 0) + .cast(vspecies()); + } + + @ForceInline + @Override + public final Halffloat512Shuffle rearrange(VectorShuffle shuffle) { + Halffloat512Shuffle concreteShuffle = (Halffloat512Shuffle) shuffle; + return (Halffloat512Shuffle) toBitsVector().rearrange(concreteShuffle.cast(ShortVector.SPECIES_512)) + .toShuffle(vspecies(), false); + } + + @ForceInline + @Override + public final Halffloat512Shuffle wrapIndexes() { + Short512Vector v = toBitsVector(); + if ((length() & (length() - 1)) == 0) { + v = (Short512Vector) v.lanewise(VectorOperators.AND, length() - 1); + } else { + v = (Short512Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v.compare(VectorOperators.LT, 0)); + } + return (Halffloat512Shuffle) v.toShuffle(vspecies(), false); + } + + private static short[] prepare(int[] indices, int offset) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = indices[offset + i]; + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static short[] prepare(IntUnaryOperator f) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = f.applyAsInt(i); + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static boolean indicesInRange(short[] indices) { + int length = indices.length; + for (short si : indices) { + if (si >= (short)length || si < (short)(-length)) { + String msg = ("index "+si+"out of range ["+length+"] in "+ + java.util.Arrays.toString(indices)); + throw new AssertionError(msg); + } + } + return true; + } + } + + // ================================================ + + // Specialized low-level memory operations. + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset) { + return super.fromArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromArray0Template(Halffloat512Mask.class, a, offset, (Halffloat512Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { + return super.fromArray0Template(Halffloat512Mask.class, a, offset, indexMap, mapOffset, (Halffloat512Mask) m); + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset) { + return super.fromCharArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromCharArray0Template(Halffloat512Mask.class, a, offset, (Halffloat512Mask) m, offsetInRange); // specialize + } + + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset) { + return super.fromMemorySegment0Template(ms, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { + return super.fromMemorySegment0Template(Halffloat512Mask.class, ms, offset, (Halffloat512Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset) { + super.intoArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset, VectorMask m) { + super.intoArray0Template(Halffloat512Mask.class, a, offset, (Halffloat512Mask) m); + } + + + + @ForceInline + @Override + final + void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { + super.intoMemorySegment0Template(Halffloat512Mask.class, ms, offset, (Halffloat512Mask) m); + } + + @ForceInline + @Override + final + void intoCharArray0(char[] a, int offset, VectorMask m) { + super.intoCharArray0Template(Halffloat512Mask.class, a, offset, (Halffloat512Mask) m); + } + + // End of specialized low-level memory operations. + + // ================================================ + +} + diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java new file mode 100644 index 0000000000000..2fced0182d35e --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java @@ -0,0 +1,1034 @@ +/* + * Copyright (c) 2017, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.IntUnaryOperator; + +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.vector.VectorSupport; + +import static jdk.internal.vm.vector.VectorSupport.*; + +import static jdk.incubator.vector.VectorOperators.*; + +// -- This file was mechanically generated: Do not edit! -- // + +@SuppressWarnings("cast") // warning: redundant cast +final class Halffloat64Vector extends HalffloatVector { + static final HalffloatSpecies VSPECIES = + (HalffloatSpecies) HalffloatVector.SPECIES_64; + + static final VectorShape VSHAPE = + VSPECIES.vectorShape(); + + static final Class VCLASS = Halffloat64Vector.class; + + static final int VSIZE = VSPECIES.vectorBitSize(); + + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = Float16.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_FP16; + + Halffloat64Vector(short[] v) { + super(v); + } + + // For compatibility as Halffloat64Vector::new, + // stored into species.vectorFactory. + Halffloat64Vector(Object v) { + this((short[]) v); + } + + static final Halffloat64Vector ZERO = new Halffloat64Vector(new short[VLENGTH]); + static final Halffloat64Vector IOTA = new Halffloat64Vector(VSPECIES.iotaArray()); + + static { + // Warm up a few species caches. + // If we do this too much we will + // get NPEs from bootstrap circularity. + VSPECIES.dummyVector(); + VSPECIES.withLanes(LaneType.BYTE); + } + + // Specialized extractors + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractVector, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + final Class carrierType() { return CTYPE; } + + @ForceInline + @Override + public final Class elementType() { return ETYPE; } + + @ForceInline + @Override + public final int elementSize() { return Float16.SIZE; } + + @ForceInline + @Override + public final VectorShape shape() { return VSHAPE; } + + @ForceInline + @Override + public final int length() { return VLENGTH; } + + @ForceInline + @Override + public final int bitSize() { return VSIZE; } + + @ForceInline + @Override + public final int byteSize() { return VSIZE / Byte.SIZE; } + + /*package-private*/ + @ForceInline + final @Override + short[] vec() { + return (short[])getPayload(); + } + + // Virtualized constructors + + @Override + @ForceInline + public final Halffloat64Vector broadcast(short e) { + return (Halffloat64Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + public final Halffloat64Vector broadcast(long e) { + return (Halffloat64Vector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + Halffloat64Mask maskFromArray(boolean[] bits) { + return new Halffloat64Mask(bits); + } + + @Override + @ForceInline + Halffloat64Shuffle iotaShuffle() { return Halffloat64Shuffle.IOTA; } + + @Override + @ForceInline + Halffloat64Shuffle iotaShuffle(int start, int step, boolean wrap) { + return (Halffloat64Shuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + } + + @Override + @ForceInline + Halffloat64Shuffle shuffleFromArray(int[] indices, int i) { return new Halffloat64Shuffle(indices, i); } + + @Override + @ForceInline + Halffloat64Shuffle shuffleFromOp(IntUnaryOperator fn) { return new Halffloat64Shuffle(fn); } + + // Make a vector of the same species but the given elements: + @ForceInline + final @Override + Halffloat64Vector vectorFactory(short[] vec) { + return new Halffloat64Vector(vec); + } + + @ForceInline + final @Override + Byte64Vector asByteVectorRaw() { + return (Byte64Vector) super.asByteVectorRawTemplate(); // specialize + } + + @ForceInline + final @Override + AbstractVector asVectorRaw(LaneType laneType) { + return super.asVectorRawTemplate(laneType); // specialize + } + + // Unary operator + + @ForceInline + final @Override + Halffloat64Vector uOp(FUnOp f) { + return (Halffloat64Vector) super.uOpTemplate(f); // specialize + } + + @ForceInline + final @Override + Halffloat64Vector uOp(VectorMask m, FUnOp f) { + return (Halffloat64Vector) + super.uOpTemplate((Halffloat64Mask)m, f); // specialize + } + + // Binary operator + + @ForceInline + final @Override + Halffloat64Vector bOp(Vector v, FBinOp f) { + return (Halffloat64Vector) super.bOpTemplate((Halffloat64Vector)v, f); // specialize + } + + @ForceInline + final @Override + Halffloat64Vector bOp(Vector v, + VectorMask m, FBinOp f) { + return (Halffloat64Vector) + super.bOpTemplate((Halffloat64Vector)v, (Halffloat64Mask)m, + f); // specialize + } + + // Ternary operator + + @ForceInline + final @Override + Halffloat64Vector tOp(Vector v1, Vector v2, FTriOp f) { + return (Halffloat64Vector) + super.tOpTemplate((Halffloat64Vector)v1, (Halffloat64Vector)v2, + f); // specialize + } + + @ForceInline + final @Override + Halffloat64Vector tOp(Vector v1, Vector v2, + VectorMask m, FTriOp f) { + return (Halffloat64Vector) + super.tOpTemplate((Halffloat64Vector)v1, (Halffloat64Vector)v2, + (Halffloat64Mask)m, f); // specialize + } + + @ForceInline + final @Override + short rOp(short v, VectorMask m, FBinOp f) { + return super.rOpTemplate(v, m, f); // specialize + } + + @Override + @ForceInline + public final + Vector convertShape(VectorOperators.Conversion conv, + VectorSpecies rsp, int part) { + return super.convertShapeTemplate(conv, rsp, part); // specialize + } + + @Override + @ForceInline + public final + Vector reinterpretShape(VectorSpecies toSpecies, int part) { + return super.reinterpretShapeTemplate(toSpecies, part); // specialize + } + + // Specialized algebraic operations: + + // The following definition forces a specialized version of this + // crucial method into the v-table of this class. A call to add() + // will inline to a call to lanewise(ADD,), at which point the JIT + // intrinsic will have the opcode of ADD, plus all the metadata + // for this particular class, enabling it to generate precise + // code. + // + // There is probably no benefit to the JIT to specialize the + // masked or broadcast versions of the lanewise method. + + @Override + @ForceInline + public Halffloat64Vector lanewise(Unary op) { + return (Halffloat64Vector) super.lanewiseTemplate(op); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector lanewise(Unary op, VectorMask m) { + return (Halffloat64Vector) super.lanewiseTemplate(op, Halffloat64Mask.class, (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector lanewise(Binary op, Vector v) { + return (Halffloat64Vector) super.lanewiseTemplate(op, v); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector lanewise(Binary op, Vector v, VectorMask m) { + return (Halffloat64Vector) super.lanewiseTemplate(op, Halffloat64Mask.class, v, (Halffloat64Mask) m); // specialize + } + + + /*package-private*/ + @Override + @ForceInline + public final + Halffloat64Vector + lanewise(Ternary op, Vector v1, Vector v2) { + return (Halffloat64Vector) super.lanewiseTemplate(op, v1, v2); // specialize + } + + @Override + @ForceInline + public final + Halffloat64Vector + lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { + return (Halffloat64Vector) super.lanewiseTemplate(op, Halffloat64Mask.class, v1, v2, (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public final + Halffloat64Vector addIndex(int scale) { + return (Halffloat64Vector) super.addIndexTemplate(scale); // specialize + } + + // Type specific horizontal reductions + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op) { + return super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op, + VectorMask m) { + return super.reduceLanesTemplate(op, Halffloat64Mask.class, (Halffloat64Mask) m); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op) { + return (long) super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op, + VectorMask m) { + return (long) super.reduceLanesTemplate(op, Halffloat64Mask.class, (Halffloat64Mask) m); // specialized + } + + @Override + @ForceInline + final VectorShuffle bitsToShuffle(AbstractSpecies dsp) { + throw new AssertionError(); + } + + @Override + @ForceInline + public final Halffloat64Shuffle toShuffle() { + return (Halffloat64Shuffle) toShuffle(vspecies(), false); + } + + // Specialized unary testing + + @Override + @ForceInline + public final Halffloat64Mask test(Test op) { + return super.testTemplate(Halffloat64Mask.class, op); // specialize + } + + @Override + @ForceInline + public final Halffloat64Mask test(Test op, VectorMask m) { + return super.testTemplate(Halffloat64Mask.class, op, (Halffloat64Mask) m); // specialize + } + + // Specialized comparisons + + @Override + @ForceInline + public final Halffloat64Mask compare(Comparison op, Vector v) { + return super.compareTemplate(Halffloat64Mask.class, op, v); // specialize + } + + @Override + @ForceInline + public final Halffloat64Mask compare(Comparison op, short s) { + return super.compareTemplate(Halffloat64Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat64Mask compare(Comparison op, long s) { + return super.compareTemplate(Halffloat64Mask.class, op, s); // specialize + } + + @Override + @ForceInline + public final Halffloat64Mask compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(Halffloat64Mask.class, op, v, (Halffloat64Mask) m); + } + + + @Override + @ForceInline + public Halffloat64Vector blend(Vector v, VectorMask m) { + return (Halffloat64Vector) + super.blendTemplate(Halffloat64Mask.class, + (Halffloat64Vector) v, + (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector slice(int origin, Vector v) { + return (Halffloat64Vector) super.sliceTemplate(origin, v); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector slice(int origin) { + return (Halffloat64Vector) super.sliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector unslice(int origin, Vector w, int part) { + return (Halffloat64Vector) super.unsliceTemplate(origin, w, part); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector unslice(int origin, Vector w, int part, VectorMask m) { + return (Halffloat64Vector) + super.unsliceTemplate(Halffloat64Mask.class, + origin, w, part, + (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector unslice(int origin) { + return (Halffloat64Vector) super.unsliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector rearrange(VectorShuffle s) { + return (Halffloat64Vector) + super.rearrangeTemplate(Halffloat64Shuffle.class, + (Halffloat64Shuffle) s); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector rearrange(VectorShuffle shuffle, + VectorMask m) { + return (Halffloat64Vector) + super.rearrangeTemplate(Halffloat64Shuffle.class, + Halffloat64Mask.class, + (Halffloat64Shuffle) shuffle, + (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector rearrange(VectorShuffle s, + Vector v) { + return (Halffloat64Vector) + super.rearrangeTemplate(Halffloat64Shuffle.class, + (Halffloat64Shuffle) s, + (Halffloat64Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector compress(VectorMask m) { + return (Halffloat64Vector) + super.compressTemplate(Halffloat64Mask.class, + (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector expand(VectorMask m) { + return (Halffloat64Vector) + super.expandTemplate(Halffloat64Mask.class, + (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector selectFrom(Vector v) { + return (Halffloat64Vector) + super.selectFromTemplate((Halffloat64Vector) v); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector selectFrom(Vector v, + VectorMask m) { + return (Halffloat64Vector) + super.selectFromTemplate((Halffloat64Vector) v, + Halffloat64Mask.class, (Halffloat64Mask) m); // specialize + } + + @Override + @ForceInline + public Halffloat64Vector selectFrom(Vector v1, + Vector v2) { + return (Halffloat64Vector) + super.selectFromTemplate((Halffloat64Vector) v1, (Halffloat64Vector) v2); // specialize + } + + @ForceInline + @Override + public short lane(int i) { + short bits; + switch(i) { + case 0: bits = laneHelper(0); break; + case 1: bits = laneHelper(1); break; + case 2: bits = laneHelper(2); break; + case 3: bits = laneHelper(3); break; + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + return bits; + } + + @ForceInline + public short laneHelper(int i) { + return (short) VectorSupport.extract( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, + (vec, ix) -> { + short[] vecarr = vec.vec(); + return vecarr[ix]; + }); + } + + @ForceInline + @Override + public Halffloat64Vector withLane(int i, short e) { + switch(i) { + case 0: return withLaneHelper(0, e); + case 1: return withLaneHelper(1, e); + case 2: return withLaneHelper(2, e); + case 3: return withLaneHelper(3, e); + default: throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + } + + @ForceInline + public Halffloat64Vector withLaneHelper(int i, short e) { + return VectorSupport.insert( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, (long)e, + (v, ix, bits) -> { + short[] res = v.vec().clone(); + res[ix] = e; + return v.vectorFactory(res); + }); + } + + // Mask + + static final class Halffloat64Mask extends AbstractMask { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat64Mask(boolean[] bits) { + this(bits, 0); + } + + Halffloat64Mask(boolean[] bits, int offset) { + super(prepare(bits, offset)); + } + + Halffloat64Mask(boolean val) { + super(prepare(val)); + } + + private static boolean[] prepare(boolean[] bits, int offset) { + boolean[] newBits = new boolean[VSPECIES.laneCount()]; + for (int i = 0; i < newBits.length; i++) { + newBits[i] = bits[offset + i]; + } + return newBits; + } + + private static boolean[] prepare(boolean val) { + boolean[] bits = new boolean[VSPECIES.laneCount()]; + Arrays.fill(bits, val); + return bits; + } + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractMask, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + boolean[] getBits() { + return (boolean[])getPayload(); + } + + @Override + Halffloat64Mask uOp(MUnOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i]); + } + return new Halffloat64Mask(res); + } + + @Override + Halffloat64Mask bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + boolean[] mbits = ((Halffloat64Mask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i], mbits[i]); + } + return new Halffloat64Mask(res); + } + + @ForceInline + @Override + public final + Halffloat64Vector toVector() { + return (Halffloat64Vector) super.toVectorTemplate(); // specialize + } + + /** + * Helper function for lane-wise mask conversions. + * This function kicks in after intrinsic failure. + */ + @ForceInline + private final + VectorMask defaultMaskCast(AbstractSpecies dsp) { + if (length() != dsp.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + boolean[] maskArray = toArray(); + return dsp.maskFactory(maskArray).check(dsp); + } + + @Override + @ForceInline + public VectorMask cast(VectorSpecies dsp) { + AbstractSpecies species = (AbstractSpecies) dsp; + if (length() != species.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + + return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST, + this.getClass(), ETYPE, VLENGTH, + species.maskType(), species.elementType(), VLENGTH, + this, species, + (m, s) -> s.maskFactory(m.toArray()).check(s)); + } + + @Override + @ForceInline + /*package-private*/ + Halffloat64Mask indexPartiallyInUpperRange(long offset, long limit) { + return (Halffloat64Mask) VectorSupport.indexPartiallyInUpperRange( + Halffloat64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, + (o, l) -> (Halffloat64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + + // Unary operations + + @Override + @ForceInline + public Halffloat64Mask not() { + return xor(maskAll(true)); + } + + @Override + @ForceInline + public Halffloat64Mask compress() { + return (Halffloat64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + Halffloat64Vector.class, Halffloat64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + Float16.float16ToShortBits(Float16.valueOf(m1.trueCount())))); + } + + + // Binary operations + + @Override + @ForceInline + public Halffloat64Mask and(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat64Mask m = (Halffloat64Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, Halffloat64Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); + } + + @Override + @ForceInline + public Halffloat64Mask or(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat64Mask m = (Halffloat64Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, Halffloat64Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); + } + + @Override + @ForceInline + public Halffloat64Mask xor(VectorMask mask) { + Objects.requireNonNull(mask); + Halffloat64Mask m = (Halffloat64Mask)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, Halffloat64Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); + } + + // Mask Query operations + + @Override + @ForceInline + public int trueCount() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Halffloat64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); + } + + @Override + @ForceInline + public int firstTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Halffloat64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public int lastTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Halffloat64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public long toLong() { + if (length() > Long.SIZE) { + throw new UnsupportedOperationException("too many lanes for one long"); + } + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Halffloat64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> toLongHelper(m.getBits())); + } + + // laneIsSet + + @Override + @ForceInline + public boolean laneIsSet(int i) { + Objects.checkIndex(i, length()); + return VectorSupport.extract(Halffloat64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; + } + + // Reductions + + @Override + @ForceInline + public boolean anyTrue() { + return VectorSupport.test(BT_ne, Halffloat64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Halffloat64Mask)m).getBits())); + } + + @Override + @ForceInline + public boolean allTrue() { + return VectorSupport.test(BT_overflow, Halffloat64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Halffloat64Mask)m).getBits())); + } + + @ForceInline + /*package-private*/ + static Halffloat64Mask maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(Halffloat64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + (bit ? -1 : 0), MODE_BROADCAST, null, + (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + } + private static final Halffloat64Mask TRUE_MASK = new Halffloat64Mask(true); + private static final Halffloat64Mask FALSE_MASK = new Halffloat64Mask(false); + + } + + // Shuffle + + static final class Halffloat64Shuffle extends AbstractShuffle { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + Halffloat64Shuffle(short[] indices) { + super(indices); + assert(VLENGTH == indices.length); + assert(indicesInRange(indices)); + } + + Halffloat64Shuffle(int[] indices, int i) { + this(prepare(indices, i)); + } + + Halffloat64Shuffle(IntUnaryOperator fn) { + this(prepare(fn)); + } + + short[] indices() { + return (short[])getPayload(); + } + + @Override + @ForceInline + public HalffloatSpecies vspecies() { + return VSPECIES; + } + + static { + // There must be enough bits in the shuffle lanes to encode + // VLENGTH valid indexes and VLENGTH exceptional ones. + assert(VLENGTH < Short.MAX_VALUE); + assert(Short.MIN_VALUE <= -VLENGTH); + } + static final Halffloat64Shuffle IOTA = new Halffloat64Shuffle(IDENTITY); + + @Override + @ForceInline + public Halffloat64Vector toVector() { + return (Halffloat64Vector) toBitsVector().castShape(vspecies(), 0); + } + + @Override + @ForceInline + Short64Vector toBitsVector() { + return (Short64Vector) super.toBitsVectorTemplate(); + } + + @Override + Short64Vector toBitsVector0() { + return ((Short64Vector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + } + + @Override + @ForceInline + public int laneSource(int i) { + return (int)toBitsVector().lane(i); + } + + @Override + @ForceInline + public void intoArray(int[] a, int offset) { + VectorSpecies species = IntVector.SPECIES_64; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoArray(a, offset); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoArray(a, offset + species.length()); + } + + @Override + @ForceInline + public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) { + VectorSpecies species = IntVector.SPECIES_64; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoMemorySegment(ms, offset, bo); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoMemorySegment(ms, offset + species.vectorByteSize(), bo); + } + + @Override + @ForceInline + public final Halffloat64Mask laneIsValid() { + return (Halffloat64Mask) toBitsVector().compare(VectorOperators.GE, 0) + .cast(vspecies()); + } + + @ForceInline + @Override + public final Halffloat64Shuffle rearrange(VectorShuffle shuffle) { + Halffloat64Shuffle concreteShuffle = (Halffloat64Shuffle) shuffle; + return (Halffloat64Shuffle) toBitsVector().rearrange(concreteShuffle.cast(ShortVector.SPECIES_64)) + .toShuffle(vspecies(), false); + } + + @ForceInline + @Override + public final Halffloat64Shuffle wrapIndexes() { + Short64Vector v = toBitsVector(); + if ((length() & (length() - 1)) == 0) { + v = (Short64Vector) v.lanewise(VectorOperators.AND, length() - 1); + } else { + v = (Short64Vector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v.compare(VectorOperators.LT, 0)); + } + return (Halffloat64Shuffle) v.toShuffle(vspecies(), false); + } + + private static short[] prepare(int[] indices, int offset) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = indices[offset + i]; + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static short[] prepare(IntUnaryOperator f) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = f.applyAsInt(i); + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static boolean indicesInRange(short[] indices) { + int length = indices.length; + for (short si : indices) { + if (si >= (short)length || si < (short)(-length)) { + String msg = ("index "+si+"out of range ["+length+"] in "+ + java.util.Arrays.toString(indices)); + throw new AssertionError(msg); + } + } + return true; + } + } + + // ================================================ + + // Specialized low-level memory operations. + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset) { + return super.fromArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromArray0Template(Halffloat64Mask.class, a, offset, (Halffloat64Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { + return super.fromArray0Template(Halffloat64Mask.class, a, offset, indexMap, mapOffset, (Halffloat64Mask) m); + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset) { + return super.fromCharArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromCharArray0Template(Halffloat64Mask.class, a, offset, (Halffloat64Mask) m, offsetInRange); // specialize + } + + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset) { + return super.fromMemorySegment0Template(ms, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { + return super.fromMemorySegment0Template(Halffloat64Mask.class, ms, offset, (Halffloat64Mask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset) { + super.intoArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset, VectorMask m) { + super.intoArray0Template(Halffloat64Mask.class, a, offset, (Halffloat64Mask) m); + } + + + + @ForceInline + @Override + final + void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { + super.intoMemorySegment0Template(Halffloat64Mask.class, ms, offset, (Halffloat64Mask) m); + } + + @ForceInline + @Override + final + void intoCharArray0(char[] a, int offset, VectorMask m) { + super.intoCharArray0Template(Halffloat64Mask.class, a, offset, (Halffloat64Mask) m); + } + + // End of specialized low-level memory operations. + + // ================================================ + +} + diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java new file mode 100644 index 0000000000000..dae70528a5a02 --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java @@ -0,0 +1,1027 @@ +/* + * Copyright (c) 2017, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.IntUnaryOperator; + +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.vector.VectorSupport; + +import static jdk.internal.vm.vector.VectorSupport.*; + +import static jdk.incubator.vector.VectorOperators.*; + +// -- This file was mechanically generated: Do not edit! -- // + +@SuppressWarnings("cast") // warning: redundant cast +final class HalffloatMaxVector extends HalffloatVector { + static final HalffloatSpecies VSPECIES = + (HalffloatSpecies) HalffloatVector.SPECIES_MAX; + + static final VectorShape VSHAPE = + VSPECIES.vectorShape(); + + static final Class VCLASS = HalffloatMaxVector.class; + + static final int VSIZE = VSPECIES.vectorBitSize(); + + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = Float16.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_FP16; + + HalffloatMaxVector(short[] v) { + super(v); + } + + // For compatibility as HalffloatMaxVector::new, + // stored into species.vectorFactory. + HalffloatMaxVector(Object v) { + this((short[]) v); + } + + static final HalffloatMaxVector ZERO = new HalffloatMaxVector(new short[VLENGTH]); + static final HalffloatMaxVector IOTA = new HalffloatMaxVector(VSPECIES.iotaArray()); + + static { + // Warm up a few species caches. + // If we do this too much we will + // get NPEs from bootstrap circularity. + VSPECIES.dummyVector(); + VSPECIES.withLanes(LaneType.BYTE); + } + + // Specialized extractors + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractVector, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + final Class carrierType() { return CTYPE; } + + @ForceInline + @Override + public final Class elementType() { return ETYPE; } + + @ForceInline + @Override + public final int elementSize() { return Float16.SIZE; } + + @ForceInline + @Override + public final VectorShape shape() { return VSHAPE; } + + @ForceInline + @Override + public final int length() { return VLENGTH; } + + @ForceInline + @Override + public final int bitSize() { return VSIZE; } + + @ForceInline + @Override + public final int byteSize() { return VSIZE / Byte.SIZE; } + + /*package-private*/ + @ForceInline + final @Override + short[] vec() { + return (short[])getPayload(); + } + + // Virtualized constructors + + @Override + @ForceInline + public final HalffloatMaxVector broadcast(short e) { + return (HalffloatMaxVector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + public final HalffloatMaxVector broadcast(long e) { + return (HalffloatMaxVector) super.broadcastTemplate(e); // specialize + } + + @Override + @ForceInline + HalffloatMaxMask maskFromArray(boolean[] bits) { + return new HalffloatMaxMask(bits); + } + + @Override + @ForceInline + HalffloatMaxShuffle iotaShuffle() { return HalffloatMaxShuffle.IOTA; } + + @Override + @ForceInline + HalffloatMaxShuffle iotaShuffle(int start, int step, boolean wrap) { + return (HalffloatMaxShuffle) iotaShuffleTemplate((short) start, (short) step, wrap); + } + + @Override + @ForceInline + HalffloatMaxShuffle shuffleFromArray(int[] indices, int i) { return new HalffloatMaxShuffle(indices, i); } + + @Override + @ForceInline + HalffloatMaxShuffle shuffleFromOp(IntUnaryOperator fn) { return new HalffloatMaxShuffle(fn); } + + // Make a vector of the same species but the given elements: + @ForceInline + final @Override + HalffloatMaxVector vectorFactory(short[] vec) { + return new HalffloatMaxVector(vec); + } + + @ForceInline + final @Override + ByteMaxVector asByteVectorRaw() { + return (ByteMaxVector) super.asByteVectorRawTemplate(); // specialize + } + + @ForceInline + final @Override + AbstractVector asVectorRaw(LaneType laneType) { + return super.asVectorRawTemplate(laneType); // specialize + } + + // Unary operator + + @ForceInline + final @Override + HalffloatMaxVector uOp(FUnOp f) { + return (HalffloatMaxVector) super.uOpTemplate(f); // specialize + } + + @ForceInline + final @Override + HalffloatMaxVector uOp(VectorMask m, FUnOp f) { + return (HalffloatMaxVector) + super.uOpTemplate((HalffloatMaxMask)m, f); // specialize + } + + // Binary operator + + @ForceInline + final @Override + HalffloatMaxVector bOp(Vector v, FBinOp f) { + return (HalffloatMaxVector) super.bOpTemplate((HalffloatMaxVector)v, f); // specialize + } + + @ForceInline + final @Override + HalffloatMaxVector bOp(Vector v, + VectorMask m, FBinOp f) { + return (HalffloatMaxVector) + super.bOpTemplate((HalffloatMaxVector)v, (HalffloatMaxMask)m, + f); // specialize + } + + // Ternary operator + + @ForceInline + final @Override + HalffloatMaxVector tOp(Vector v1, Vector v2, FTriOp f) { + return (HalffloatMaxVector) + super.tOpTemplate((HalffloatMaxVector)v1, (HalffloatMaxVector)v2, + f); // specialize + } + + @ForceInline + final @Override + HalffloatMaxVector tOp(Vector v1, Vector v2, + VectorMask m, FTriOp f) { + return (HalffloatMaxVector) + super.tOpTemplate((HalffloatMaxVector)v1, (HalffloatMaxVector)v2, + (HalffloatMaxMask)m, f); // specialize + } + + @ForceInline + final @Override + short rOp(short v, VectorMask m, FBinOp f) { + return super.rOpTemplate(v, m, f); // specialize + } + + @Override + @ForceInline + public final + Vector convertShape(VectorOperators.Conversion conv, + VectorSpecies rsp, int part) { + return super.convertShapeTemplate(conv, rsp, part); // specialize + } + + @Override + @ForceInline + public final + Vector reinterpretShape(VectorSpecies toSpecies, int part) { + return super.reinterpretShapeTemplate(toSpecies, part); // specialize + } + + // Specialized algebraic operations: + + // The following definition forces a specialized version of this + // crucial method into the v-table of this class. A call to add() + // will inline to a call to lanewise(ADD,), at which point the JIT + // intrinsic will have the opcode of ADD, plus all the metadata + // for this particular class, enabling it to generate precise + // code. + // + // There is probably no benefit to the JIT to specialize the + // masked or broadcast versions of the lanewise method. + + @Override + @ForceInline + public HalffloatMaxVector lanewise(Unary op) { + return (HalffloatMaxVector) super.lanewiseTemplate(op); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector lanewise(Unary op, VectorMask m) { + return (HalffloatMaxVector) super.lanewiseTemplate(op, HalffloatMaxMask.class, (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector lanewise(Binary op, Vector v) { + return (HalffloatMaxVector) super.lanewiseTemplate(op, v); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector lanewise(Binary op, Vector v, VectorMask m) { + return (HalffloatMaxVector) super.lanewiseTemplate(op, HalffloatMaxMask.class, v, (HalffloatMaxMask) m); // specialize + } + + + /*package-private*/ + @Override + @ForceInline + public final + HalffloatMaxVector + lanewise(Ternary op, Vector v1, Vector v2) { + return (HalffloatMaxVector) super.lanewiseTemplate(op, v1, v2); // specialize + } + + @Override + @ForceInline + public final + HalffloatMaxVector + lanewise(Ternary op, Vector v1, Vector v2, VectorMask m) { + return (HalffloatMaxVector) super.lanewiseTemplate(op, HalffloatMaxMask.class, v1, v2, (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public final + HalffloatMaxVector addIndex(int scale) { + return (HalffloatMaxVector) super.addIndexTemplate(scale); // specialize + } + + // Type specific horizontal reductions + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op) { + return super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final short reduceLanes(VectorOperators.Associative op, + VectorMask m) { + return super.reduceLanesTemplate(op, HalffloatMaxMask.class, (HalffloatMaxMask) m); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op) { + return (long) super.reduceLanesTemplate(op); // specialized + } + + @Override + @ForceInline + public final long reduceLanesToLong(VectorOperators.Associative op, + VectorMask m) { + return (long) super.reduceLanesTemplate(op, HalffloatMaxMask.class, (HalffloatMaxMask) m); // specialized + } + + @Override + @ForceInline + final VectorShuffle bitsToShuffle(AbstractSpecies dsp) { + throw new AssertionError(); + } + + @Override + @ForceInline + public final HalffloatMaxShuffle toShuffle() { + return (HalffloatMaxShuffle) toShuffle(vspecies(), false); + } + + // Specialized unary testing + + @Override + @ForceInline + public final HalffloatMaxMask test(Test op) { + return super.testTemplate(HalffloatMaxMask.class, op); // specialize + } + + @Override + @ForceInline + public final HalffloatMaxMask test(Test op, VectorMask m) { + return super.testTemplate(HalffloatMaxMask.class, op, (HalffloatMaxMask) m); // specialize + } + + // Specialized comparisons + + @Override + @ForceInline + public final HalffloatMaxMask compare(Comparison op, Vector v) { + return super.compareTemplate(HalffloatMaxMask.class, op, v); // specialize + } + + @Override + @ForceInline + public final HalffloatMaxMask compare(Comparison op, short s) { + return super.compareTemplate(HalffloatMaxMask.class, op, s); // specialize + } + + @Override + @ForceInline + public final HalffloatMaxMask compare(Comparison op, long s) { + return super.compareTemplate(HalffloatMaxMask.class, op, s); // specialize + } + + @Override + @ForceInline + public final HalffloatMaxMask compare(Comparison op, Vector v, VectorMask m) { + return super.compareTemplate(HalffloatMaxMask.class, op, v, (HalffloatMaxMask) m); + } + + + @Override + @ForceInline + public HalffloatMaxVector blend(Vector v, VectorMask m) { + return (HalffloatMaxVector) + super.blendTemplate(HalffloatMaxMask.class, + (HalffloatMaxVector) v, + (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector slice(int origin, Vector v) { + return (HalffloatMaxVector) super.sliceTemplate(origin, v); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector slice(int origin) { + return (HalffloatMaxVector) super.sliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector unslice(int origin, Vector w, int part) { + return (HalffloatMaxVector) super.unsliceTemplate(origin, w, part); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector unslice(int origin, Vector w, int part, VectorMask m) { + return (HalffloatMaxVector) + super.unsliceTemplate(HalffloatMaxMask.class, + origin, w, part, + (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector unslice(int origin) { + return (HalffloatMaxVector) super.unsliceTemplate(origin); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector rearrange(VectorShuffle s) { + return (HalffloatMaxVector) + super.rearrangeTemplate(HalffloatMaxShuffle.class, + (HalffloatMaxShuffle) s); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector rearrange(VectorShuffle shuffle, + VectorMask m) { + return (HalffloatMaxVector) + super.rearrangeTemplate(HalffloatMaxShuffle.class, + HalffloatMaxMask.class, + (HalffloatMaxShuffle) shuffle, + (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector rearrange(VectorShuffle s, + Vector v) { + return (HalffloatMaxVector) + super.rearrangeTemplate(HalffloatMaxShuffle.class, + (HalffloatMaxShuffle) s, + (HalffloatMaxVector) v); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector compress(VectorMask m) { + return (HalffloatMaxVector) + super.compressTemplate(HalffloatMaxMask.class, + (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector expand(VectorMask m) { + return (HalffloatMaxVector) + super.expandTemplate(HalffloatMaxMask.class, + (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector selectFrom(Vector v) { + return (HalffloatMaxVector) + super.selectFromTemplate((HalffloatMaxVector) v); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector selectFrom(Vector v, + VectorMask m) { + return (HalffloatMaxVector) + super.selectFromTemplate((HalffloatMaxVector) v, + HalffloatMaxMask.class, (HalffloatMaxMask) m); // specialize + } + + @Override + @ForceInline + public HalffloatMaxVector selectFrom(Vector v1, + Vector v2) { + return (HalffloatMaxVector) + super.selectFromTemplate((HalffloatMaxVector) v1, (HalffloatMaxVector) v2); // specialize + } + + @ForceInline + @Override + public short lane(int i) { + if (i < 0 || i >= VLENGTH) { + throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + short bits = laneHelper(i); + return bits; + } + + @ForceInline + public short laneHelper(int i) { + return (short) VectorSupport.extract( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, + (vec, ix) -> { + short[] vecarr = vec.vec(); + return vecarr[ix]; + }); + } + + @ForceInline + @Override + public HalffloatMaxVector withLane(int i, short e) { + if (i < 0 || i >= VLENGTH) { + throw new IllegalArgumentException("Index " + i + " must be zero or positive, and less than " + VLENGTH); + } + return withLaneHelper(i, e); + } + + @ForceInline + public HalffloatMaxVector withLaneHelper(int i, short e) { + return VectorSupport.insert( + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, (long)e, + (v, ix, bits) -> { + short[] res = v.vec().clone(); + res[ix] = e; + return v.vectorFactory(res); + }); + } + + // Mask + + static final class HalffloatMaxMask extends AbstractMask { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + HalffloatMaxMask(boolean[] bits) { + this(bits, 0); + } + + HalffloatMaxMask(boolean[] bits, int offset) { + super(prepare(bits, offset)); + } + + HalffloatMaxMask(boolean val) { + super(prepare(val)); + } + + private static boolean[] prepare(boolean[] bits, int offset) { + boolean[] newBits = new boolean[VSPECIES.laneCount()]; + for (int i = 0; i < newBits.length; i++) { + newBits[i] = bits[offset + i]; + } + return newBits; + } + + private static boolean[] prepare(boolean val) { + boolean[] bits = new boolean[VSPECIES.laneCount()]; + Arrays.fill(bits, val); + return bits; + } + + @ForceInline + final @Override + public HalffloatSpecies vspecies() { + // ISSUE: This should probably be a @Stable + // field inside AbstractMask, rather than + // a megamorphic method. + return VSPECIES; + } + + @ForceInline + boolean[] getBits() { + return (boolean[])getPayload(); + } + + @Override + HalffloatMaxMask uOp(MUnOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i]); + } + return new HalffloatMaxMask(res); + } + + @Override + HalffloatMaxMask bOp(VectorMask m, MBinOp f) { + boolean[] res = new boolean[vspecies().laneCount()]; + boolean[] bits = getBits(); + boolean[] mbits = ((HalffloatMaxMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, bits[i], mbits[i]); + } + return new HalffloatMaxMask(res); + } + + @ForceInline + @Override + public final + HalffloatMaxVector toVector() { + return (HalffloatMaxVector) super.toVectorTemplate(); // specialize + } + + /** + * Helper function for lane-wise mask conversions. + * This function kicks in after intrinsic failure. + */ + @ForceInline + private final + VectorMask defaultMaskCast(AbstractSpecies dsp) { + if (length() != dsp.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + boolean[] maskArray = toArray(); + return dsp.maskFactory(maskArray).check(dsp); + } + + @Override + @ForceInline + public VectorMask cast(VectorSpecies dsp) { + AbstractSpecies species = (AbstractSpecies) dsp; + if (length() != species.laneCount()) + throw new IllegalArgumentException("VectorMask length and species length differ"); + + return VectorSupport.convert(VectorSupport.VECTOR_OP_CAST, + this.getClass(), ETYPE, VLENGTH, + species.maskType(), species.elementType(), VLENGTH, + this, species, + (m, s) -> s.maskFactory(m.toArray()).check(s)); + } + + @Override + @ForceInline + /*package-private*/ + HalffloatMaxMask indexPartiallyInUpperRange(long offset, long limit) { + return (HalffloatMaxMask) VectorSupport.indexPartiallyInUpperRange( + HalffloatMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, + (o, l) -> (HalffloatMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); + } + + // Unary operations + + @Override + @ForceInline + public HalffloatMaxMask not() { + return xor(maskAll(true)); + } + + @Override + @ForceInline + public HalffloatMaxMask compress() { + return (HalffloatMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, + HalffloatMaxVector.class, HalffloatMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + Float16.float16ToShortBits(Float16.valueOf(m1.trueCount())))); + } + + + // Binary operations + + @Override + @ForceInline + public HalffloatMaxMask and(VectorMask mask) { + Objects.requireNonNull(mask); + HalffloatMaxMask m = (HalffloatMaxMask)mask; + return VectorSupport.binaryOp(VECTOR_OP_AND, HalffloatMaxMask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); + } + + @Override + @ForceInline + public HalffloatMaxMask or(VectorMask mask) { + Objects.requireNonNull(mask); + HalffloatMaxMask m = (HalffloatMaxMask)mask; + return VectorSupport.binaryOp(VECTOR_OP_OR, HalffloatMaxMask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); + } + + @Override + @ForceInline + public HalffloatMaxMask xor(VectorMask mask) { + Objects.requireNonNull(mask); + HalffloatMaxMask m = (HalffloatMaxMask)mask; + return VectorSupport.binaryOp(VECTOR_OP_XOR, HalffloatMaxMask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, m, null, + (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); + } + + // Mask Query operations + + @Override + @ForceInline + public int trueCount() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, HalffloatMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); + } + + @Override + @ForceInline + public int firstTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, HalffloatMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public int lastTrue() { + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, HalffloatMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); + } + + @Override + @ForceInline + public long toLong() { + if (length() > Long.SIZE) { + throw new UnsupportedOperationException("too many lanes for one long"); + } + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, HalffloatMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> toLongHelper(m.getBits())); + } + + // laneIsSet + + @Override + @ForceInline + public boolean laneIsSet(int i) { + Objects.checkIndex(i, length()); + return VectorSupport.extract(HalffloatMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; + } + + // Reductions + + @Override + @ForceInline + public boolean anyTrue() { + return VectorSupport.test(BT_ne, HalffloatMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((HalffloatMaxMask)m).getBits())); + } + + @Override + @ForceInline + public boolean allTrue() { + return VectorSupport.test(BT_overflow, HalffloatMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((HalffloatMaxMask)m).getBits())); + } + + @ForceInline + /*package-private*/ + static HalffloatMaxMask maskAll(boolean bit) { + return VectorSupport.fromBitsCoerced(HalffloatMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + (bit ? -1 : 0), MODE_BROADCAST, null, + (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); + } + private static final HalffloatMaxMask TRUE_MASK = new HalffloatMaxMask(true); + private static final HalffloatMaxMask FALSE_MASK = new HalffloatMaxMask(false); + + } + + // Shuffle + + static final class HalffloatMaxShuffle extends AbstractShuffle { + static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM + static final Class CTYPE = short.class; // used by the JVM + + HalffloatMaxShuffle(short[] indices) { + super(indices); + assert(VLENGTH == indices.length); + assert(indicesInRange(indices)); + } + + HalffloatMaxShuffle(int[] indices, int i) { + this(prepare(indices, i)); + } + + HalffloatMaxShuffle(IntUnaryOperator fn) { + this(prepare(fn)); + } + + short[] indices() { + return (short[])getPayload(); + } + + @Override + @ForceInline + public HalffloatSpecies vspecies() { + return VSPECIES; + } + + static { + // There must be enough bits in the shuffle lanes to encode + // VLENGTH valid indexes and VLENGTH exceptional ones. + assert(VLENGTH < Short.MAX_VALUE); + assert(Short.MIN_VALUE <= -VLENGTH); + } + static final HalffloatMaxShuffle IOTA = new HalffloatMaxShuffle(IDENTITY); + + @Override + @ForceInline + public HalffloatMaxVector toVector() { + return (HalffloatMaxVector) toBitsVector().castShape(vspecies(), 0); + } + + @Override + @ForceInline + ShortMaxVector toBitsVector() { + return (ShortMaxVector) super.toBitsVectorTemplate(); + } + + @Override + ShortMaxVector toBitsVector0() { + return ((ShortMaxVector) vspecies().asIntegral().dummyVector()).vectorFactory(indices()); + } + + @Override + @ForceInline + public int laneSource(int i) { + return (int)toBitsVector().lane(i); + } + + @Override + @ForceInline + public void intoArray(int[] a, int offset) { + VectorSpecies species = IntVector.SPECIES_MAX; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoArray(a, offset); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoArray(a, offset + species.length()); + } + + @Override + @ForceInline + public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) { + VectorSpecies species = IntVector.SPECIES_MAX; + Vector v = toBitsVector(); + v.convertShape(VectorOperators.S2I, species, 0) + .reinterpretAsInts() + .intoMemorySegment(ms, offset, bo); + v.convertShape(VectorOperators.S2I, species, 1) + .reinterpretAsInts() + .intoMemorySegment(ms, offset + species.vectorByteSize(), bo); + } + + @Override + @ForceInline + public final HalffloatMaxMask laneIsValid() { + return (HalffloatMaxMask) toBitsVector().compare(VectorOperators.GE, 0) + .cast(vspecies()); + } + + @ForceInline + @Override + public final HalffloatMaxShuffle rearrange(VectorShuffle shuffle) { + HalffloatMaxShuffle concreteShuffle = (HalffloatMaxShuffle) shuffle; + return (HalffloatMaxShuffle) toBitsVector().rearrange(concreteShuffle.cast(ShortVector.SPECIES_MAX)) + .toShuffle(vspecies(), false); + } + + @ForceInline + @Override + public final HalffloatMaxShuffle wrapIndexes() { + ShortMaxVector v = toBitsVector(); + if ((length() & (length() - 1)) == 0) { + v = (ShortMaxVector) v.lanewise(VectorOperators.AND, length() - 1); + } else { + v = (ShortMaxVector) v.blend(v.lanewise(VectorOperators.ADD, length()), + v.compare(VectorOperators.LT, 0)); + } + return (HalffloatMaxShuffle) v.toShuffle(vspecies(), false); + } + + private static short[] prepare(int[] indices, int offset) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = indices[offset + i]; + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static short[] prepare(IntUnaryOperator f) { + short[] a = new short[VLENGTH]; + for (int i = 0; i < VLENGTH; i++) { + int si = f.applyAsInt(i); + si = partiallyWrapIndex(si, VLENGTH); + a[i] = (short)si; + } + return a; + } + + private static boolean indicesInRange(short[] indices) { + int length = indices.length; + for (short si : indices) { + if (si >= (short)length || si < (short)(-length)) { + String msg = ("index "+si+"out of range ["+length+"] in "+ + java.util.Arrays.toString(indices)); + throw new AssertionError(msg); + } + } + return true; + } + } + + // ================================================ + + // Specialized low-level memory operations. + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset) { + return super.fromArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromArray0Template(HalffloatMaxMask.class, a, offset, (HalffloatMaxMask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromArray0(short[] a, int offset, int[] indexMap, int mapOffset, VectorMask m) { + return super.fromArray0Template(HalffloatMaxMask.class, a, offset, indexMap, mapOffset, (HalffloatMaxMask) m); + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset) { + return super.fromCharArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange) { + return super.fromCharArray0Template(HalffloatMaxMask.class, a, offset, (HalffloatMaxMask) m, offsetInRange); // specialize + } + + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset) { + return super.fromMemorySegment0Template(ms, offset); // specialize + } + + @ForceInline + @Override + final + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange) { + return super.fromMemorySegment0Template(HalffloatMaxMask.class, ms, offset, (HalffloatMaxMask) m, offsetInRange); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset) { + super.intoArray0Template(a, offset); // specialize + } + + @ForceInline + @Override + final + void intoArray0(short[] a, int offset, VectorMask m) { + super.intoArray0Template(HalffloatMaxMask.class, a, offset, (HalffloatMaxMask) m); + } + + + + @ForceInline + @Override + final + void intoMemorySegment0(MemorySegment ms, long offset, VectorMask m) { + super.intoMemorySegment0Template(HalffloatMaxMask.class, ms, offset, (HalffloatMaxMask) m); + } + + @ForceInline + @Override + final + void intoCharArray0(char[] a, int offset, VectorMask m) { + super.intoCharArray0Template(HalffloatMaxMask.class, a, offset, (HalffloatMaxMask) m); + } + + // End of specialized low-level memory operations. + + // ================================================ + +} + diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java new file mode 100644 index 0000000000000..ef117e79a8a88 --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java @@ -0,0 +1,4362 @@ +/* + * Copyright (c) 2017, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Objects; +import java.util.function.Function; + +import jdk.internal.foreign.AbstractMemorySegmentImpl; +import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.misc.Unsafe; +import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.vm.vector.VectorSupport; + +import static jdk.internal.vm.vector.VectorSupport.*; +import static jdk.incubator.vector.VectorIntrinsics.*; + +import static jdk.incubator.vector.VectorOperators.*; +import jdk.incubator.vector.Float16; + +// -- This file was mechanically generated: Do not edit! -- // + +/** + * A specialized {@link Vector} representing an ordered immutable sequence of + * {@code short} values. + */ +@SuppressWarnings("cast") // warning: redundant cast +public abstract class HalffloatVector extends AbstractVector { + + HalffloatVector(short[] vec) { + super(vec); + } + + static final int FORBID_OPCODE_KIND = VO_NOFP; + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_FP16; + + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); + + @ForceInline + static int opCode(Operator op) { + return VectorOperators.opCode(op, VO_OPCODE_VALID, FORBID_OPCODE_KIND); + } + @ForceInline + static int opCode(Operator op, int requireKind) { + requireKind |= VO_OPCODE_VALID; + return VectorOperators.opCode(op, requireKind, FORBID_OPCODE_KIND); + } + @ForceInline + static boolean opKind(Operator op, int bit) { + return VectorOperators.opKind(op, bit); + } + + // Virtualized factories and operators, + // coded with portable definitions. + // These are all @ForceInline in case + // they need to be used performantly. + // The various shape-specific subclasses + // also specialize them by wrapping + // them in a call like this: + // return (Byte128Vector) + // super.bOp((Byte128Vector) o); + // The purpose of that is to forcibly inline + // the generic definition from this file + // into a sharply-typed and size-specific + // wrapper in the subclass file, so that + // the JIT can specialize the code. + // The code is only inlined and expanded + // if it gets hot. Think of it as a cheap + // and lazy version of C++ templates. + + // Virtualized getter + + /*package-private*/ + abstract short[] vec(); + + // Virtualized constructors + + /** + * Build a vector directly using my own constructor. + * It is an error if the array is aliased elsewhere. + */ + /*package-private*/ + abstract HalffloatVector vectorFactory(short[] vec); + + /** + * Build a mask directly using my species. + * It is an error if the array is aliased elsewhere. + */ + /*package-private*/ + @ForceInline + final + AbstractMask maskFactory(boolean[] bits) { + return vspecies().maskFactory(bits); + } + + // Constant loader (takes dummy as vector arg) + interface FVOp { + short apply(int i); + } + + /*package-private*/ + @ForceInline + final + HalffloatVector vOp(FVOp f) { + short[] res = new short[length()]; + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i); + } + return vectorFactory(res); + } + + @ForceInline + final + HalffloatVector vOp(VectorMask m, FVOp f) { + short[] res = new short[length()]; + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + if (mbits[i]) { + res[i] = f.apply(i); + } + } + return vectorFactory(res); + } + + // Unary operator + + /*package-private*/ + interface FUnOp { + short apply(int i, short a); + } + + /*package-private*/ + abstract + HalffloatVector uOp(FUnOp f); + @ForceInline + final + HalffloatVector uOpTemplate(FUnOp f) { + short[] vec = vec(); + short[] res = new short[length()]; + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, vec[i]); + } + return vectorFactory(res); + } + + /*package-private*/ + abstract + HalffloatVector uOp(VectorMask m, + FUnOp f); + @ForceInline + final + HalffloatVector uOpTemplate(VectorMask m, + FUnOp f) { + if (m == null) { + return uOpTemplate(f); + } + short[] vec = vec(); + short[] res = new short[length()]; + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = mbits[i] ? f.apply(i, vec[i]) : vec[i]; + } + return vectorFactory(res); + } + + // Binary operator + + /*package-private*/ + interface FBinOp { + short apply(int i, short a, short b); + } + + /*package-private*/ + abstract + HalffloatVector bOp(Vector o, + FBinOp f); + @ForceInline + final + HalffloatVector bOpTemplate(Vector o, + FBinOp f) { + short[] res = new short[length()]; + short[] vec1 = this.vec(); + short[] vec2 = ((HalffloatVector)o).vec(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, vec1[i], vec2[i]); + } + return vectorFactory(res); + } + + /*package-private*/ + abstract + HalffloatVector bOp(Vector o, + VectorMask m, + FBinOp f); + @ForceInline + final + HalffloatVector bOpTemplate(Vector o, + VectorMask m, + FBinOp f) { + if (m == null) { + return bOpTemplate(o, f); + } + short[] res = new short[length()]; + short[] vec1 = this.vec(); + short[] vec2 = ((HalffloatVector)o).vec(); + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i]) : vec1[i]; + } + return vectorFactory(res); + } + + // Ternary operator + + /*package-private*/ + interface FTriOp { + short apply(int i, short a, short b, short c); + } + + /*package-private*/ + abstract + HalffloatVector tOp(Vector o1, + Vector o2, + FTriOp f); + @ForceInline + final + HalffloatVector tOpTemplate(Vector o1, + Vector o2, + FTriOp f) { + short[] res = new short[length()]; + short[] vec1 = this.vec(); + short[] vec2 = ((HalffloatVector)o1).vec(); + short[] vec3 = ((HalffloatVector)o2).vec(); + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i, vec1[i], vec2[i], vec3[i]); + } + return vectorFactory(res); + } + + /*package-private*/ + abstract + HalffloatVector tOp(Vector o1, + Vector o2, + VectorMask m, + FTriOp f); + @ForceInline + final + HalffloatVector tOpTemplate(Vector o1, + Vector o2, + VectorMask m, + FTriOp f) { + if (m == null) { + return tOpTemplate(o1, o2, f); + } + short[] res = new short[length()]; + short[] vec1 = this.vec(); + short[] vec2 = ((HalffloatVector)o1).vec(); + short[] vec3 = ((HalffloatVector)o2).vec(); + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + res[i] = mbits[i] ? f.apply(i, vec1[i], vec2[i], vec3[i]) : vec1[i]; + } + return vectorFactory(res); + } + + // Reduction operator + + /*package-private*/ + abstract + short rOp(short v, VectorMask m, FBinOp f); + + @ForceInline + final + short rOpTemplate(short v, VectorMask m, FBinOp f) { + if (m == null) { + return rOpTemplate(v, f); + } + short[] vec = vec(); + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < vec.length; i++) { + v = mbits[i] ? f.apply(i, v, vec[i]) : v; + } + return v; + } + + @ForceInline + final + short rOpTemplate(short v, FBinOp f) { + short[] vec = vec(); + for (int i = 0; i < vec.length; i++) { + v = f.apply(i, v, vec[i]); + } + return v; + } + + // Memory reference + + /*package-private*/ + interface FLdOp { + short apply(M memory, int offset, int i); + } + + /*package-private*/ + @ForceInline + final + HalffloatVector ldOp(M memory, int offset, + FLdOp f) { + //dummy; no vec = vec(); + short[] res = new short[length()]; + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(memory, offset, i); + } + return vectorFactory(res); + } + + /*package-private*/ + @ForceInline + final + HalffloatVector ldOp(M memory, int offset, + VectorMask m, + FLdOp f) { + //short[] vec = vec(); + short[] res = new short[length()]; + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + if (mbits[i]) { + res[i] = f.apply(memory, offset, i); + } + } + return vectorFactory(res); + } + + /*package-private*/ + interface FLdLongOp { + short apply(MemorySegment memory, long offset, int i); + } + + /*package-private*/ + @ForceInline + final + HalffloatVector ldLongOp(MemorySegment memory, long offset, + FLdLongOp f) { + //dummy; no vec = vec(); + short[] res = new short[length()]; + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(memory, offset, i); + } + return vectorFactory(res); + } + + /*package-private*/ + @ForceInline + final + HalffloatVector ldLongOp(MemorySegment memory, long offset, + VectorMask m, + FLdLongOp f) { + //short[] vec = vec(); + short[] res = new short[length()]; + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + if (mbits[i]) { + res[i] = f.apply(memory, offset, i); + } + } + return vectorFactory(res); + } + + static short memorySegmentGet(MemorySegment ms, long o, int i) { + return ms.get(ELEMENT_LAYOUT, o + i * 2L); + } + + interface FStOp { + void apply(M memory, int offset, int i, short a); + } + + /*package-private*/ + @ForceInline + final + void stOp(M memory, int offset, + FStOp f) { + short[] vec = vec(); + for (int i = 0; i < vec.length; i++) { + f.apply(memory, offset, i, vec[i]); + } + } + + /*package-private*/ + @ForceInline + final + void stOp(M memory, int offset, + VectorMask m, + FStOp f) { + short[] vec = vec(); + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < vec.length; i++) { + if (mbits[i]) { + f.apply(memory, offset, i, vec[i]); + } + } + } + + interface FStLongOp { + void apply(MemorySegment memory, long offset, int i, short a); + } + + /*package-private*/ + @ForceInline + final + void stLongOp(MemorySegment memory, long offset, + FStLongOp f) { + short[] vec = vec(); + for (int i = 0; i < vec.length; i++) { + f.apply(memory, offset, i, vec[i]); + } + } + + /*package-private*/ + @ForceInline + final + void stLongOp(MemorySegment memory, long offset, + VectorMask m, + FStLongOp f) { + short[] vec = vec(); + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < vec.length; i++) { + if (mbits[i]) { + f.apply(memory, offset, i, vec[i]); + } + } + } + + static void memorySegmentSet(MemorySegment ms, long o, int i, short e) { + ms.set(ELEMENT_LAYOUT, o + i * 2L, e); + } + + // Binary test + + /*package-private*/ + interface FBinTest { + boolean apply(int cond, int i, short a, short b); + } + + /*package-private*/ + @ForceInline + final + AbstractMask bTest(int cond, + Vector o, + FBinTest f) { + short[] vec1 = vec(); + short[] vec2 = ((HalffloatVector)o).vec(); + boolean[] bits = new boolean[length()]; + for (int i = 0; i < length(); i++){ + bits[i] = f.apply(cond, i, vec1[i], vec2[i]); + } + return maskFactory(bits); + } + + + /*package-private*/ + @Override + abstract HalffloatSpecies vspecies(); + + /*package-private*/ + @ForceInline + static long toBits(short e) { + return e; + } + + /*package-private*/ + @ForceInline + static short fromBits(long bits) { + return Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)bits)); + } + + static HalffloatVector expandHelper(Vector v, VectorMask m) { + VectorSpecies vsp = m.vectorSpecies(); + HalffloatVector r = (HalffloatVector) vsp.zero(); + HalffloatVector vi = (HalffloatVector) v; + if (m.allTrue()) { + return vi; + } + for (int i = 0, j = 0; i < vsp.length(); i++) { + if (m.laneIsSet(i)) { + r = r.withLane(i, vi.lane(j++)); + } + } + return r; + } + + static HalffloatVector compressHelper(Vector v, VectorMask m) { + VectorSpecies vsp = m.vectorSpecies(); + HalffloatVector r = (HalffloatVector) vsp.zero(); + HalffloatVector vi = (HalffloatVector) v; + if (m.allTrue()) { + return vi; + } + for (int i = 0, j = 0; i < vsp.length(); i++) { + if (m.laneIsSet(i)) { + r = r.withLane(j++, vi.lane(i)); + } + } + return r; + } + + static HalffloatVector selectFromTwoVectorHelper(Vector indexes, Vector src1, Vector src2) { + int vlen = indexes.length(); + short[] res = new short[vlen]; + short[] vecPayload1 = ((HalffloatVector)indexes).vec(); + short[] vecPayload2 = ((HalffloatVector)src1).vec(); + short[] vecPayload3 = ((HalffloatVector)src2).vec(); + for (int i = 0; i < vlen; i++) { + int index = Float16.shortBitsToFloat16(vecPayload1[i]).intValue(); + int wrapped_index = VectorIntrinsics.wrapToRange(index, 2 * vlen); + res[i] = wrapped_index >= vlen ? vecPayload3[wrapped_index - vlen] : vecPayload2[wrapped_index]; + } + return ((HalffloatVector)src1).vectorFactory(res); + } + + // Static factories (other than memory operations) + + // Note: A surprising behavior in javadoc + // sometimes makes a lone /** {@inheritDoc} */ + // comment drop the method altogether, + // apparently if the method mentions a + // parameter or return type of Vector + // instead of Vector as originally specified. + // Adding an empty HTML fragment appears to + // nudge javadoc into providing the desired + // inherited documentation. We use the HTML + // comment for this. + + /** + * Returns a vector of the given species + * where all lane elements are set to + * zero, the default primitive value. + * + * @param species species of the desired zero vector + * @return a zero vector + */ + @ForceInline + public static HalffloatVector zero(VectorSpecies species) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + return VectorSupport.fromBitsCoerced(vsp.vectorType(), short.class, VECTOR_OPER_TYPE, species.length(), + toBits((short) 0), MODE_BROADCAST, vsp, + ((bits_, s_) -> s_.rvOp(i -> bits_))); + } + + /** + * Returns a vector of the same species as this one + * where all lane elements are set to + * the primitive value {@code e}. + * + * The contents of the current vector are discarded; + * only the species is relevant to this operation. + * + *

This method returns the value of this expression: + * {@code HalffloatVector.broadcast(this.species(), e)}. + * + * @apiNote + * Unlike the similar method named {@code broadcast()} + * in the supertype {@code Vector}, this method does not + * need to validate its argument, and cannot throw + * {@code IllegalArgumentException}. This method is + * therefore preferable to the supertype method. + * + * @param e the value to broadcast + * @return a vector where all lane elements are set to + * the primitive value {@code e} + * @see #broadcast(VectorSpecies,long) + * @see Vector#broadcast(long) + * @see VectorSpecies#broadcast(long) + */ + public abstract HalffloatVector broadcast(short e); + + /** + * Returns a vector of the given species + * where all lane elements are set to + * the primitive value {@code e}. + * + * @param species species of the desired vector + * @param e the value to broadcast + * @return a vector where all lane elements are set to + * the primitive value {@code e} + * @see #broadcast(long) + * @see Vector#broadcast(long) + * @see VectorSpecies#broadcast(long) + */ + @ForceInline + public static HalffloatVector broadcast(VectorSpecies species, short e) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.broadcast(e); + } + + /*package-private*/ + @ForceInline + final HalffloatVector broadcastTemplate(short e) { + HalffloatSpecies vsp = vspecies(); + return vsp.broadcast(e); + } + + /** + * {@inheritDoc} + * @apiNote + * When working with vector subtypes like {@code HalffloatVector}, + * {@linkplain #broadcast(short) the more strongly typed method} + * is typically selected. It can be explicitly selected + * using a cast: {@code v.broadcast((short)e)}. + * The two expressions will produce numerically identical results. + */ + @Override + public abstract HalffloatVector broadcast(long e); + + /** + * Returns a vector of the given species + * where all lane elements are set to + * the primitive value {@code e}. + * + * The {@code long} value must be accurately representable + * by the {@code ETYPE} of the vector species, so that + * {@code e==(long)(ETYPE)e}. + * + * @param species species of the desired vector + * @param e the value to broadcast + * @return a vector where all lane elements are set to + * the primitive value {@code e} + * @throws IllegalArgumentException + * if the given {@code long} value cannot + * be represented by the vector's {@code ETYPE} + * @see #broadcast(VectorSpecies,short) + * @see VectorSpecies#checkValue(long) + */ + @ForceInline + public static HalffloatVector broadcast(VectorSpecies species, long e) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.broadcast(e); + } + + /*package-private*/ + @ForceInline + final HalffloatVector broadcastTemplate(long e) { + return vspecies().broadcast(e); + } + + // Unary lanewise support + + /** + * {@inheritDoc} + */ + public abstract + HalffloatVector lanewise(VectorOperators.Unary op); + + @ForceInline + final + HalffloatVector lanewiseTemplate(VectorOperators.Unary op) { + if (opKind(op, VO_SPECIAL)) { + if (op == ZOMO) { + return blend(broadcast(-1), compare(NE, 0)); + } + else if (opKind(op, VO_MATHLIB)) { + return unaryMathOp(op); + } + } + int opc = opCode(op); + return VectorSupport.unaryOp( + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), + this, null, + UN_IMPL.find(op, opc, HalffloatVector::unaryOperations)); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector lanewise(VectorOperators.Unary op, + VectorMask m); + @ForceInline + final + HalffloatVector lanewiseTemplate(VectorOperators.Unary op, + Class> maskClass, + VectorMask m) { + m.check(maskClass, this); + if (opKind(op, VO_SPECIAL)) { + if (op == ZOMO) { + return blend(broadcast(-1), compare(NE, 0, m)); + } + else if (opKind(op, VO_MATHLIB)) { + return blend(unaryMathOp(op), m); + } + } + int opc = opCode(op); + return VectorSupport.unaryOp( + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), + this, m, + UN_IMPL.find(op, opc, HalffloatVector::unaryOperations)); + } + + @ForceInline + final + HalffloatVector unaryMathOp(VectorOperators.Unary op) { + return VectorMathLibrary.unaryMathOp(op, opCode(op), species(), HalffloatVector::unaryOperations, + this); + } + + private static final + ImplCache>> + UN_IMPL = new ImplCache<>(Unary.class, HalffloatVector.class); + + private static UnaryOperation> unaryOperations(int opc_) { + switch (opc_) { + case VECTOR_OP_NEG: return (v0, m) -> + v0.uOp(m, (i, a) -> (short) -a); + case VECTOR_OP_ABS: return (v0, m) -> + v0.uOp(m, (i, a) -> (short) Math.abs(a)); + case VECTOR_OP_SIN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sin(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_COS: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cos(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_TAN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tan(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_ASIN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.asin(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_ACOS: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.acos(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_ATAN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_EXP: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.exp(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_LOG: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_LOG10: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log10(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_SQRT: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sqrt(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_CBRT: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cbrt(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_SINH: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sinh(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_COSH: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cosh(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_TANH: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tanh(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_EXPM1: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.expm1(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_LOG1P: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log1p(Float16.shortBitsToFloat16(a).doubleValue())))); + default: return null; + } + } + + // Binary lanewise support + + /** + * {@inheritDoc} + * @see #lanewise(VectorOperators.Binary,short) + * @see #lanewise(VectorOperators.Binary,short,VectorMask) + */ + @Override + public abstract + HalffloatVector lanewise(VectorOperators.Binary op, + Vector v); + @ForceInline + final + HalffloatVector lanewiseTemplate(VectorOperators.Binary op, + Vector v) { + HalffloatVector that = (HalffloatVector) v; + that.check(this); + + if (opKind(op, VO_SPECIAL )) { + if (op == FIRST_NONZERO) { + VectorMask mask + = this.viewAsIntegralLanes().compare(EQ, (short) 0); + return this.blend(that, mask.cast(vspecies())); + } + else if (opKind(op, VO_MATHLIB)) { + return binaryMathOp(op, that); + } + } + + int opc = opCode(op); + return VectorSupport.binaryOp( + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), + this, that, null, + BIN_IMPL.find(op, opc, HalffloatVector::binaryOperations)); + } + + /** + * {@inheritDoc} + * @see #lanewise(VectorOperators.Binary,short,VectorMask) + */ + @Override + public abstract + HalffloatVector lanewise(VectorOperators.Binary op, + Vector v, + VectorMask m); + @ForceInline + final + HalffloatVector lanewiseTemplate(VectorOperators.Binary op, + Class> maskClass, + Vector v, VectorMask m) { + HalffloatVector that = (HalffloatVector) v; + that.check(this); + m.check(maskClass, this); + + if (opKind(op, VO_SPECIAL )) { + if (op == FIRST_NONZERO) { + ShortVector bits = this.viewAsIntegralLanes(); + VectorMask mask + = bits.compare(EQ, (short) 0, m.cast(bits.vspecies())); + return this.blend(that, mask.cast(vspecies())); + } + else if (opKind(op, VO_MATHLIB)) { + return this.blend(binaryMathOp(op, that), m); + } + + } + + int opc = opCode(op); + return VectorSupport.binaryOp( + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), + this, that, m, + BIN_IMPL.find(op, opc, HalffloatVector::binaryOperations)); + } + + @ForceInline + final + HalffloatVector binaryMathOp(VectorOperators.Binary op, HalffloatVector that) { + return VectorMathLibrary.binaryMathOp(op, opCode(op), species(), HalffloatVector::binaryOperations, + this, that); + } + + private static final + ImplCache>> + BIN_IMPL = new ImplCache<>(Binary.class, HalffloatVector.class); + + private static BinaryOperation> binaryOperations(int opc_) { + switch (opc_) { + case VECTOR_OP_ADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_SUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.subtract(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_MUL: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_DIV: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.divide(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_MAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_MIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_ATAN2: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan2(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + case VECTOR_OP_POW: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.pow(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + case VECTOR_OP_HYPOT: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.hypot(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + default: return null; + } + } + + // FIXME: Maybe all of the public final methods in this file (the + // simple ones that just call lanewise) should be pushed down to + // the X-VectorBits template. They can't optimize properly at + // this level, and must rely on inlining. Does it work? + // (If it works, of course keep the code here.) + + /** + * Combines the lane values of this vector + * with the value of a broadcast scalar. + * + * This is a lane-wise binary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, this.broadcast(e))}. + * + * @param op the operation used to process lane values + * @param e the input scalar + * @return the result of applying the operation lane-wise + * to the two input vectors + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short,VectorMask) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Binary op, + short e) { + return lanewise(op, broadcast(e)); + } + + /** + * Combines the lane values of this vector + * with the value of a broadcast scalar, + * with selection of lane elements controlled by a mask. + * + * This is a masked lane-wise binary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, this.broadcast(e), m)}. + * + * @param op the operation used to process lane values + * @param e the input scalar + * @param m the mask controlling lane selection + * @return the result of applying the operation lane-wise + * to the input vector and the scalar + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Binary,Vector,VectorMask) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Binary op, + short e, + VectorMask m) { + return lanewise(op, broadcast(e), m); + } + + /** + * {@inheritDoc} + * @apiNote + * When working with vector subtypes like {@code HalffloatVector}, + * {@linkplain #lanewise(VectorOperators.Binary,short) + * the more strongly typed method} + * is typically selected. It can be explicitly selected + * using a cast: {@code v.lanewise(op,(short)e)}. + * The two expressions will produce numerically identical results. + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Binary op, + long e) { + short e1 = (short) e; + if ((long)e1 != e) { + vspecies().checkValue(e); // for exception + } + return lanewise(op, e1); + } + + /** + * {@inheritDoc} + * @apiNote + * When working with vector subtypes like {@code HalffloatVector}, + * {@linkplain #lanewise(VectorOperators.Binary,short,VectorMask) + * the more strongly typed method} + * is typically selected. It can be explicitly selected + * using a cast: {@code v.lanewise(op,(short)e,m)}. + * The two expressions will produce numerically identical results. + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Binary op, + long e, VectorMask m) { + short e1 = (short) e; + if ((long)e1 != e) { + vspecies().checkValue(e); // for exception + } + return lanewise(op, e1, m); + } + + + // Ternary lanewise support + + // Ternary operators come in eight variations: + // lanewise(op, [broadcast(e1)|v1], [broadcast(e2)|v2]) + // lanewise(op, [broadcast(e1)|v1], [broadcast(e2)|v2], mask) + + // It is annoying to support all of these variations of masking + // and broadcast, but it would be more surprising not to continue + // the obvious pattern started by unary and binary. + + /** + * {@inheritDoc} + * @see #lanewise(VectorOperators.Ternary,short,short,VectorMask) + * @see #lanewise(VectorOperators.Ternary,Vector,short,VectorMask) + * @see #lanewise(VectorOperators.Ternary,short,Vector,VectorMask) + * @see #lanewise(VectorOperators.Ternary,short,short) + * @see #lanewise(VectorOperators.Ternary,Vector,short) + * @see #lanewise(VectorOperators.Ternary,short,Vector) + */ + @Override + public abstract + HalffloatVector lanewise(VectorOperators.Ternary op, + Vector v1, + Vector v2); + @ForceInline + final + HalffloatVector lanewiseTemplate(VectorOperators.Ternary op, + Vector v1, + Vector v2) { + HalffloatVector that = (HalffloatVector) v1; + HalffloatVector tother = (HalffloatVector) v2; + // It's a word: https://www.dictionary.com/browse/tother + // See also Chapter 11 of Dickens, Our Mutual Friend: + // "Totherest Governor," replied Mr Riderhood... + that.check(this); + tother.check(this); + int opc = opCode(op); + return VectorSupport.ternaryOp( + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), + this, that, tother, null, + TERN_IMPL.find(op, opc, HalffloatVector::ternaryOperations)); + } + + /** + * {@inheritDoc} + * @see #lanewise(VectorOperators.Ternary,short,short,VectorMask) + * @see #lanewise(VectorOperators.Ternary,Vector,short,VectorMask) + * @see #lanewise(VectorOperators.Ternary,short,Vector,VectorMask) + */ + @Override + public abstract + HalffloatVector lanewise(VectorOperators.Ternary op, + Vector v1, + Vector v2, + VectorMask m); + @ForceInline + final + HalffloatVector lanewiseTemplate(VectorOperators.Ternary op, + Class> maskClass, + Vector v1, + Vector v2, + VectorMask m) { + HalffloatVector that = (HalffloatVector) v1; + HalffloatVector tother = (HalffloatVector) v2; + // It's a word: https://www.dictionary.com/browse/tother + // See also Chapter 11 of Dickens, Our Mutual Friend: + // "Totherest Governor," replied Mr Riderhood... + that.check(this); + tother.check(this); + m.check(maskClass, this); + + int opc = opCode(op); + return VectorSupport.ternaryOp( + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), + this, that, tother, m, + TERN_IMPL.find(op, opc, HalffloatVector::ternaryOperations)); + } + + private static final + ImplCache>> + TERN_IMPL = new ImplCache<>(Ternary.class, HalffloatVector.class); + + private static TernaryOperation> ternaryOperations(int opc_) { + switch (opc_) { + case VECTOR_OP_FMA: return (v0, v1_, v2_, m) -> v0.tOp(v1_, v2_, m, (i, a, b, c) -> + Float16.float16ToRawShortBits(Float16.fma(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b), Float16.shortBitsToFloat16(c)))); + default: return null; + } + } + + /** + * Combines the lane values of this vector + * with the values of two broadcast scalars. + * + * This is a lane-wise ternary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, this.broadcast(e1), this.broadcast(e2))}. + * + * @param op the operation used to combine lane values + * @param e1 the first input scalar + * @param e2 the second input scalar + * @return the result of applying the operation lane-wise + * to the input vector and the scalars + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Ternary,Vector,Vector) + * @see #lanewise(VectorOperators.Ternary,short,short,VectorMask) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Ternary op, //(op,e1,e2) + short e1, + short e2) { + return lanewise(op, broadcast(e1), broadcast(e2)); + } + + /** + * Combines the lane values of this vector + * with the values of two broadcast scalars, + * with selection of lane elements controlled by a mask. + * + * This is a masked lane-wise ternary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, this.broadcast(e1), this.broadcast(e2), m)}. + * + * @param op the operation used to combine lane values + * @param e1 the first input scalar + * @param e2 the second input scalar + * @param m the mask controlling lane selection + * @return the result of applying the operation lane-wise + * to the input vector and the scalars + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Ternary,Vector,Vector,VectorMask) + * @see #lanewise(VectorOperators.Ternary,short,short) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Ternary op, //(op,e1,e2,m) + short e1, + short e2, + VectorMask m) { + return lanewise(op, broadcast(e1), broadcast(e2), m); + } + + /** + * Combines the lane values of this vector + * with the values of another vector and a broadcast scalar. + * + * This is a lane-wise ternary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, v1, this.broadcast(e2))}. + * + * @param op the operation used to combine lane values + * @param v1 the other input vector + * @param e2 the input scalar + * @return the result of applying the operation lane-wise + * to the input vectors and the scalar + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Ternary,short,short) + * @see #lanewise(VectorOperators.Ternary,Vector,short,VectorMask) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Ternary op, //(op,v1,e2) + Vector v1, + short e2) { + return lanewise(op, v1, broadcast(e2)); + } + + /** + * Combines the lane values of this vector + * with the values of another vector and a broadcast scalar, + * with selection of lane elements controlled by a mask. + * + * This is a masked lane-wise ternary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, v1, this.broadcast(e2), m)}. + * + * @param op the operation used to combine lane values + * @param v1 the other input vector + * @param e2 the input scalar + * @param m the mask controlling lane selection + * @return the result of applying the operation lane-wise + * to the input vectors and the scalar + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Ternary,Vector,Vector) + * @see #lanewise(VectorOperators.Ternary,short,short,VectorMask) + * @see #lanewise(VectorOperators.Ternary,Vector,short) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Ternary op, //(op,v1,e2,m) + Vector v1, + short e2, + VectorMask m) { + return lanewise(op, v1, broadcast(e2), m); + } + + /** + * Combines the lane values of this vector + * with the values of another vector and a broadcast scalar. + * + * This is a lane-wise ternary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, this.broadcast(e1), v2)}. + * + * @param op the operation used to combine lane values + * @param e1 the input scalar + * @param v2 the other input vector + * @return the result of applying the operation lane-wise + * to the input vectors and the scalar + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Ternary,Vector,Vector) + * @see #lanewise(VectorOperators.Ternary,short,Vector,VectorMask) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Ternary op, //(op,e1,v2) + short e1, + Vector v2) { + return lanewise(op, broadcast(e1), v2); + } + + /** + * Combines the lane values of this vector + * with the values of another vector and a broadcast scalar, + * with selection of lane elements controlled by a mask. + * + * This is a masked lane-wise ternary operation which applies + * the selected operation to each lane. + * The return value will be equal to this expression: + * {@code this.lanewise(op, this.broadcast(e1), v2, m)}. + * + * @param op the operation used to combine lane values + * @param e1 the input scalar + * @param v2 the other input vector + * @param m the mask controlling lane selection + * @return the result of applying the operation lane-wise + * to the input vectors and the scalar + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #lanewise(VectorOperators.Ternary,Vector,Vector,VectorMask) + * @see #lanewise(VectorOperators.Ternary,short,Vector) + */ + @ForceInline + public final + HalffloatVector lanewise(VectorOperators.Ternary op, //(op,e1,v2,m) + short e1, + Vector v2, + VectorMask m) { + return lanewise(op, broadcast(e1), v2, m); + } + + // (Thus endeth the Great and Mighty Ternary Ogdoad.) + // https://en.wikipedia.org/wiki/Ogdoad + + /// FULL-SERVICE BINARY METHODS: ADD, SUB, MUL, DIV + // + // These include masked and non-masked versions. + // This subclass adds broadcast (masked or not). + + /** + * {@inheritDoc} + * @see #add(short) + */ + @Override + @ForceInline + public final HalffloatVector add(Vector v) { + return lanewise(ADD, v); + } + + /** + * Adds this vector to the broadcast of an input scalar. + * + * This is a lane-wise binary operation which applies + * the primitive addition operation ({@code +}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short) + * lanewise}{@code (}{@link VectorOperators#ADD + * ADD}{@code , e)}. + * + * @param e the input scalar + * @return the result of adding each lane of this vector to the scalar + * @see #add(Vector) + * @see #broadcast(short) + * @see #add(short,VectorMask) + * @see VectorOperators#ADD + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final + HalffloatVector add(short e) { + return lanewise(ADD, e); + } + + /** + * {@inheritDoc} + * @see #add(short,VectorMask) + */ + @Override + @ForceInline + public final HalffloatVector add(Vector v, + VectorMask m) { + return lanewise(ADD, v, m); + } + + /** + * Adds this vector to the broadcast of an input scalar, + * selecting lane elements controlled by a mask. + * + * This is a masked lane-wise binary operation which applies + * the primitive addition operation ({@code +}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short,VectorMask) + * lanewise}{@code (}{@link VectorOperators#ADD + * ADD}{@code , s, m)}. + * + * @param e the input scalar + * @param m the mask controlling lane selection + * @return the result of adding each lane of this vector to the scalar + * @see #add(Vector,VectorMask) + * @see #broadcast(short) + * @see #add(short) + * @see VectorOperators#ADD + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector add(short e, + VectorMask m) { + return lanewise(ADD, e, m); + } + + /** + * {@inheritDoc} + * @see #sub(short) + */ + @Override + @ForceInline + public final HalffloatVector sub(Vector v) { + return lanewise(SUB, v); + } + + /** + * Subtracts an input scalar from this vector. + * + * This is a masked lane-wise binary operation which applies + * the primitive subtraction operation ({@code -}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short) + * lanewise}{@code (}{@link VectorOperators#SUB + * SUB}{@code , e)}. + * + * @param e the input scalar + * @return the result of subtracting the scalar from each lane of this vector + * @see #sub(Vector) + * @see #broadcast(short) + * @see #sub(short,VectorMask) + * @see VectorOperators#SUB + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector sub(short e) { + return lanewise(SUB, e); + } + + /** + * {@inheritDoc} + * @see #sub(short,VectorMask) + */ + @Override + @ForceInline + public final HalffloatVector sub(Vector v, + VectorMask m) { + return lanewise(SUB, v, m); + } + + /** + * Subtracts an input scalar from this vector + * under the control of a mask. + * + * This is a masked lane-wise binary operation which applies + * the primitive subtraction operation ({@code -}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short,VectorMask) + * lanewise}{@code (}{@link VectorOperators#SUB + * SUB}{@code , s, m)}. + * + * @param e the input scalar + * @param m the mask controlling lane selection + * @return the result of subtracting the scalar from each lane of this vector + * @see #sub(Vector,VectorMask) + * @see #broadcast(short) + * @see #sub(short) + * @see VectorOperators#SUB + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector sub(short e, + VectorMask m) { + return lanewise(SUB, e, m); + } + + /** + * {@inheritDoc} + * @see #mul(short) + */ + @Override + @ForceInline + public final HalffloatVector mul(Vector v) { + return lanewise(MUL, v); + } + + /** + * Multiplies this vector by the broadcast of an input scalar. + * + * This is a lane-wise binary operation which applies + * the primitive multiplication operation ({@code *}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short) + * lanewise}{@code (}{@link VectorOperators#MUL + * MUL}{@code , e)}. + * + * @param e the input scalar + * @return the result of multiplying this vector by the given scalar + * @see #mul(Vector) + * @see #broadcast(short) + * @see #mul(short,VectorMask) + * @see VectorOperators#MUL + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector mul(short e) { + return lanewise(MUL, e); + } + + /** + * {@inheritDoc} + * @see #mul(short,VectorMask) + */ + @Override + @ForceInline + public final HalffloatVector mul(Vector v, + VectorMask m) { + return lanewise(MUL, v, m); + } + + /** + * Multiplies this vector by the broadcast of an input scalar, + * selecting lane elements controlled by a mask. + * + * This is a masked lane-wise binary operation which applies + * the primitive multiplication operation ({@code *}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short,VectorMask) + * lanewise}{@code (}{@link VectorOperators#MUL + * MUL}{@code , s, m)}. + * + * @param e the input scalar + * @param m the mask controlling lane selection + * @return the result of muling each lane of this vector to the scalar + * @see #mul(Vector,VectorMask) + * @see #broadcast(short) + * @see #mul(short) + * @see VectorOperators#MUL + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector mul(short e, + VectorMask m) { + return lanewise(MUL, e, m); + } + + /** + * {@inheritDoc} + * @apiNote Because the underlying scalar operator is an IEEE + * floating point number, division by zero in fact will + * not throw an exception, but will yield a signed + * infinity or NaN. + */ + @Override + @ForceInline + public final HalffloatVector div(Vector v) { + return lanewise(DIV, v); + } + + /** + * Divides this vector by the broadcast of an input scalar. + * + * This is a lane-wise binary operation which applies + * the primitive division operation ({@code /}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short) + * lanewise}{@code (}{@link VectorOperators#DIV + * DIV}{@code , e)}. + * + * @apiNote Because the underlying scalar operator is an IEEE + * floating point number, division by zero in fact will + * not throw an exception, but will yield a signed + * infinity or NaN. + * + * @param e the input scalar + * @return the result of dividing each lane of this vector by the scalar + * @see #div(Vector) + * @see #broadcast(short) + * @see #div(short,VectorMask) + * @see VectorOperators#DIV + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector div(short e) { + return lanewise(DIV, e); + } + + /** + * {@inheritDoc} + * @see #div(short,VectorMask) + * @apiNote Because the underlying scalar operator is an IEEE + * floating point number, division by zero in fact will + * not throw an exception, but will yield a signed + * infinity or NaN. + */ + @Override + @ForceInline + public final HalffloatVector div(Vector v, + VectorMask m) { + return lanewise(DIV, v, m); + } + + /** + * Divides this vector by the broadcast of an input scalar, + * selecting lane elements controlled by a mask. + * + * This is a masked lane-wise binary operation which applies + * the primitive division operation ({@code /}) to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short,VectorMask) + * lanewise}{@code (}{@link VectorOperators#DIV + * DIV}{@code , s, m)}. + * + * @apiNote Because the underlying scalar operator is an IEEE + * floating point number, division by zero in fact will + * not throw an exception, but will yield a signed + * infinity or NaN. + * + * @param e the input scalar + * @param m the mask controlling lane selection + * @return the result of dividing each lane of this vector by the scalar + * @see #div(Vector,VectorMask) + * @see #broadcast(short) + * @see #div(short) + * @see VectorOperators#DIV + * @see #lanewise(VectorOperators.Binary,Vector) + * @see #lanewise(VectorOperators.Binary,short) + */ + @ForceInline + public final HalffloatVector div(short e, + VectorMask m) { + return lanewise(DIV, e, m); + } + + /// END OF FULL-SERVICE BINARY METHODS + + /// SECOND-TIER BINARY METHODS + // + // There are no masked versions. + + /** + * {@inheritDoc} + * @apiNote + * For this method, floating point negative + * zero {@code -0.0} is treated as a value distinct from, and less + * than the default value (positive zero). + */ + @Override + @ForceInline + public final HalffloatVector min(Vector v) { + return lanewise(MIN, v); + } + + // FIXME: "broadcast of an input scalar" is really wordy. Reduce? + /** + * Computes the smaller of this vector and the broadcast of an input scalar. + * + * This is a lane-wise binary operation which applies the + * operation {@code Math.min()} to each pair of + * corresponding lane values. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short) + * lanewise}{@code (}{@link VectorOperators#MIN + * MIN}{@code , e)}. + * + * @param e the input scalar + * @return the result of multiplying this vector by the given scalar + * @see #min(Vector) + * @see #broadcast(short) + * @see VectorOperators#MIN + * @see #lanewise(VectorOperators.Binary,short,VectorMask) + * @apiNote + * For this method, floating point negative + * zero {@code -0.0} is treated as a value distinct from, and less + * than the default value (positive zero). + */ + @ForceInline + public final HalffloatVector min(short e) { + return lanewise(MIN, e); + } + + /** + * {@inheritDoc} + * @apiNote + * For this method, floating point negative + * zero {@code -0.0} is treated as a value distinct from, and less + * than the default value (positive zero). + */ + @Override + @ForceInline + public final HalffloatVector max(Vector v) { + return lanewise(MAX, v); + } + + /** + * Computes the larger of this vector and the broadcast of an input scalar. + * + * This is a lane-wise binary operation which applies the + * operation {@code Math.max()} to each pair of + * corresponding lane values. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,short) + * lanewise}{@code (}{@link VectorOperators#MAX + * MAX}{@code , e)}. + * + * @param e the input scalar + * @return the result of multiplying this vector by the given scalar + * @see #max(Vector) + * @see #broadcast(short) + * @see VectorOperators#MAX + * @see #lanewise(VectorOperators.Binary,short,VectorMask) + * @apiNote + * For this method, floating point negative + * zero {@code -0.0} is treated as a value distinct from, and less + * than the default value (positive zero). + */ + @ForceInline + public final HalffloatVector max(short e) { + return lanewise(MAX, e); + } + + + // common FP operator: pow + /** + * Raises this vector to the power of a second input vector. + * + * This is a lane-wise binary operation which applies an operation + * conforming to the specification of + * {@link Math#pow Math.pow(a,b)} + * to each pair of corresponding lane values. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,Vector) + * lanewise}{@code (}{@link VectorOperators#POW + * POW}{@code , b)}. + * + *

+ * This is not a full-service named operation like + * {@link #add(Vector) add}. A masked version of + * this operation is not directly available + * but may be obtained via the masked version of + * {@code lanewise}. + * + * @param b a vector exponent by which to raise this vector + * @return the {@code b}-th power of this vector + * @see #pow(short) + * @see VectorOperators#POW + * @see #lanewise(VectorOperators.Binary,Vector,VectorMask) + */ + @ForceInline + public final HalffloatVector pow(Vector b) { + return lanewise(POW, b); + } + + /** + * Raises this vector to a scalar power. + * + * This is a lane-wise binary operation which applies an operation + * conforming to the specification of + * {@link Math#pow Math.pow(a,b)} + * to each pair of corresponding lane values. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Binary,Vector) + * lanewise}{@code (}{@link VectorOperators#POW + * POW}{@code , b)}. + * + * @param b a scalar exponent by which to raise this vector + * @return the {@code b}-th power of this vector + * @see #pow(Vector) + * @see VectorOperators#POW + * @see #lanewise(VectorOperators.Binary,short,VectorMask) + */ + @ForceInline + public final HalffloatVector pow(short b) { + return lanewise(POW, b); + } + + /// UNARY METHODS + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + HalffloatVector neg() { + return lanewise(NEG); + } + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + HalffloatVector abs() { + return lanewise(ABS); + } + + + + // sqrt + /** + * Computes the square root of this vector. + * + * This is a lane-wise unary operation which applies an operation + * conforming to the specification of + * {@link Math#sqrt Math.sqrt(a)} + * to each lane value. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Unary) + * lanewise}{@code (}{@link VectorOperators#SQRT + * SQRT}{@code )}. + * + * @return the square root of this vector + * @see VectorOperators#SQRT + * @see #lanewise(VectorOperators.Unary,VectorMask) + */ + @ForceInline + public final HalffloatVector sqrt() { + return lanewise(SQRT); + } + + /// COMPARISONS + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + VectorMask eq(Vector v) { + return compare(EQ, v); + } + + /** + * Tests if this vector is equal to an input scalar. + * + * This is a lane-wise binary test operation which applies + * the primitive equals operation ({@code ==}) to each lane. + * The result is the same as {@code compare(VectorOperators.Comparison.EQ, e)}. + * + * @param e the input scalar + * @return the result mask of testing if this vector + * is equal to {@code e} + * @see #compare(VectorOperators.Comparison,short) + */ + @ForceInline + public final + VectorMask eq(short e) { + return compare(EQ, e); + } + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + VectorMask lt(Vector v) { + return compare(LT, v); + } + + /** + * Tests if this vector is less than an input scalar. + * + * This is a lane-wise binary test operation which applies + * the primitive less than operation ({@code <}) to each lane. + * The result is the same as {@code compare(VectorOperators.LT, e)}. + * + * @param e the input scalar + * @return the mask result of testing if this vector + * is less than the input scalar + * @see #compare(VectorOperators.Comparison,short) + */ + @ForceInline + public final + VectorMask lt(short e) { + return compare(LT, e); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + VectorMask test(VectorOperators.Test op); + + /*package-private*/ + @ForceInline + final + > + M testTemplate(Class maskType, Test op) { + HalffloatSpecies vsp = vspecies(); + if (opKind(op, VO_SPECIAL)) { + ShortVector bits = this.viewAsIntegralLanes(); + VectorMask m; + if (op == IS_DEFAULT) { + m = bits.compare(EQ, (short) 0); + } else if (op == IS_NEGATIVE) { + m = bits.compare(LT, (short) 0); + } + else if (op == IS_FINITE || + op == IS_NAN || + op == IS_INFINITE) { + // first kill the sign: + bits = bits.and(Short.MAX_VALUE); + // next find the bit pattern for infinity: + short infbits = (short) toBits(Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY)); + // now compare: + if (op == IS_FINITE) { + m = bits.compare(LT, infbits); + } else if (op == IS_NAN) { + m = bits.compare(GT, infbits); + } else { + m = bits.compare(EQ, infbits); + } + } + else { + throw new AssertionError(op); + } + return maskType.cast(m.cast(vsp)); + } + int opc = opCode(op); + throw new AssertionError(op); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + VectorMask test(VectorOperators.Test op, + VectorMask m); + + /*package-private*/ + @ForceInline + final + > + M testTemplate(Class maskType, Test op, M mask) { + HalffloatSpecies vsp = vspecies(); + mask.check(maskType, this); + if (opKind(op, VO_SPECIAL)) { + ShortVector bits = this.viewAsIntegralLanes(); + VectorMask m = mask.cast(ShortVector.species(shape())); + if (op == IS_DEFAULT) { + m = bits.compare(EQ, (short) 0, m); + } else if (op == IS_NEGATIVE) { + m = bits.compare(LT, (short) 0, m); + } + else if (op == IS_FINITE || + op == IS_NAN || + op == IS_INFINITE) { + // first kill the sign: + bits = bits.and(Short.MAX_VALUE); + // next find the bit pattern for infinity: + short infbits = (short) toBits(Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY)); + // now compare: + if (op == IS_FINITE) { + m = bits.compare(LT, infbits, m); + } else if (op == IS_NAN) { + m = bits.compare(GT, infbits, m); + } else { + m = bits.compare(EQ, infbits, m); + } + } + else { + throw new AssertionError(op); + } + return maskType.cast(m.cast(vsp)); + } + int opc = opCode(op); + throw new AssertionError(op); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + VectorMask compare(VectorOperators.Comparison op, Vector v); + + /*package-private*/ + @ForceInline + final + > + M compareTemplate(Class maskType, Comparison op, Vector v) { + HalffloatVector that = (HalffloatVector) v; + that.check(this); + int opc = opCode(op); + return VectorSupport.compare( + opc, getClass(), maskType, short.class, VECTOR_OPER_TYPE, length(), + this, that, null, + (cond, v0, v1, m1) -> { + AbstractMask m + = v0.bTest(cond, v1, (cond_, i, a, b) + -> compareWithOp(cond, a, b)); + @SuppressWarnings("unchecked") + M m2 = (M) m; + return m2; + }); + } + + /*package-private*/ + @ForceInline + final + > + M compareTemplate(Class maskType, Comparison op, Vector v, M m) { + HalffloatVector that = (HalffloatVector) v; + that.check(this); + m.check(maskType, this); + int opc = opCode(op); + return VectorSupport.compare( + opc, getClass(), maskType, short.class, VECTOR_OPER_TYPE, length(), + this, that, m, + (cond, v0, v1, m1) -> { + AbstractMask cmpM + = v0.bTest(cond, v1, (cond_, i, a, b) + -> compareWithOp(cond, a, b)); + @SuppressWarnings("unchecked") + M m2 = (M) cmpM.and(m1); + return m2; + }); + } + + @ForceInline + private static boolean compareWithOp(int cond, short a, short b) { + return switch (cond) { + case BT_eq -> Float.float16ToFloat(a) == Float.float16ToFloat(b); + case BT_ne -> Float.float16ToFloat(a) != Float.float16ToFloat(b); + case BT_lt -> Float.float16ToFloat(a) < Float.float16ToFloat(b); + case BT_le -> Float.float16ToFloat(a) <= Float.float16ToFloat(b); + case BT_gt -> Float.float16ToFloat(a) > Float.float16ToFloat(b); + case BT_ge -> Float.float16ToFloat(a) >= Float.float16ToFloat(b); + default -> throw new AssertionError(); + }; + } + + /** + * Tests this vector by comparing it with an input scalar, + * according to the given comparison operation. + * + * This is a lane-wise binary test operation which applies + * the comparison operation to each lane. + *

+ * The result is the same as + * {@code compare(op, broadcast(species(), e))}. + * That is, the scalar may be regarded as broadcast to + * a vector of the same species, and then compared + * against the original vector, using the selected + * comparison operation. + * + * @param op the operation used to compare lane values + * @param e the input scalar + * @return the mask result of testing lane-wise if this vector + * compares to the input, according to the selected + * comparison operator + * @see HalffloatVector#compare(VectorOperators.Comparison,Vector) + * @see #eq(short) + * @see #lt(short) + */ + public abstract + VectorMask compare(Comparison op, short e); + + /*package-private*/ + @ForceInline + final + > + M compareTemplate(Class maskType, Comparison op, short e) { + return compareTemplate(maskType, op, broadcast(e)); + } + + /** + * Tests this vector by comparing it with an input scalar, + * according to the given comparison operation, + * in lanes selected by a mask. + * + * This is a masked lane-wise binary test operation which applies + * to each pair of corresponding lane values. + * + * The returned result is equal to the expression + * {@code compare(op,s).and(m)}. + * + * @param op the operation used to compare lane values + * @param e the input scalar + * @param m the mask controlling lane selection + * @return the mask result of testing lane-wise if this vector + * compares to the input, according to the selected + * comparison operator, + * and only in the lanes selected by the mask + * @see HalffloatVector#compare(VectorOperators.Comparison,Vector,VectorMask) + */ + @ForceInline + public final VectorMask compare(VectorOperators.Comparison op, + short e, + VectorMask m) { + return compare(op, broadcast(e), m); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + VectorMask compare(Comparison op, long e); + + /*package-private*/ + @ForceInline + final + > + M compareTemplate(Class maskType, Comparison op, long e) { + return compareTemplate(maskType, op, broadcast(e)); + } + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + VectorMask compare(Comparison op, long e, VectorMask m) { + return compare(op, broadcast(e), m); + } + + + + /** + * {@inheritDoc} + */ + @Override public abstract + HalffloatVector blend(Vector v, VectorMask m); + + /*package-private*/ + @ForceInline + final + > + HalffloatVector + blendTemplate(Class maskType, HalffloatVector v, M m) { + v.check(this); + return VectorSupport.blend( + getClass(), maskType, short.class, VECTOR_OPER_TYPE, length(), + this, v, m, + (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); + } + + /** + * {@inheritDoc} + */ + @Override public abstract HalffloatVector addIndex(int scale); + + /*package-private*/ + @ForceInline + final HalffloatVector addIndexTemplate(int scale) { + HalffloatSpecies vsp = vspecies(); + // make sure VLENGTH*scale doesn't overflow: + vsp.checkScale(scale); + return VectorSupport.indexVector( + getClass(), short.class, VECTOR_OPER_TYPE, length(), + this, scale, vsp, + (v, scale_, s) + -> { + // If the platform doesn't support an INDEX + // instruction directly, load IOTA from memory + // and multiply. + HalffloatVector iota = s.iota(); + short sc = (short) scale_; + return v.add(sc == 1 ? iota : iota.mul(Float16.float16ToRawShortBits(Float16.valueOf(sc)))); + }); + } + + /** + * Replaces selected lanes of this vector with + * a scalar value + * under the control of a mask. + * + * This is a masked lane-wise binary operation which + * selects each lane value from one or the other input. + * + * The returned result is equal to the expression + * {@code blend(broadcast(e),m)}. + * + * @param e the input scalar, containing the replacement lane value + * @param m the mask controlling lane selection of the scalar + * @return the result of blending the lane elements of this vector with + * the scalar value + */ + @ForceInline + public final HalffloatVector blend(short e, + VectorMask m) { + return blend(broadcast(e), m); + } + + /** + * Replaces selected lanes of this vector with + * a scalar value + * under the control of a mask. + * + * This is a masked lane-wise binary operation which + * selects each lane value from one or the other input. + * + * The returned result is equal to the expression + * {@code blend(broadcast(e),m)}. + * + * @param e the input scalar, containing the replacement lane value + * @param m the mask controlling lane selection of the scalar + * @return the result of blending the lane elements of this vector with + * the scalar value + */ + @ForceInline + public final HalffloatVector blend(long e, + VectorMask m) { + return blend(broadcast(e), m); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector slice(int origin, Vector v1); + + /*package-private*/ + final + @ForceInline + HalffloatVector sliceTemplate(int origin, Vector v1) { + HalffloatVector that = (HalffloatVector) v1; + that.check(this); + Objects.checkIndex(origin, length() + 1); + ShortVector iotaVector = (ShortVector) iotaShuffle().toBitsVector(); + ShortVector filter = ShortVector.broadcast((ShortVector.ShortSpecies) vspecies().asIntegral(), (short)(length() - origin)); + VectorMask blendMask = iotaVector.compare(VectorOperators.LT, filter).cast(vspecies()); + AbstractShuffle iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); + } + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + HalffloatVector slice(int origin, + Vector w, + VectorMask m) { + return broadcast(0).blend(slice(origin, w), m); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector slice(int origin); + + /*package-private*/ + final + @ForceInline + HalffloatVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + ShortVector iotaVector = (ShortVector) iotaShuffle().toBitsVector(); + ShortVector filter = ShortVector.broadcast((ShortVector.ShortSpecies) vspecies().asIntegral(), (short)(length() - origin)); + VectorMask blendMask = iotaVector.compare(VectorOperators.LT, filter).cast(vspecies()); + AbstractShuffle iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector unslice(int origin, Vector w, int part); + + /*package-private*/ + final + @ForceInline + HalffloatVector + unsliceTemplate(int origin, Vector w, int part) { + HalffloatVector that = (HalffloatVector) w; + that.check(this); + Objects.checkIndex(origin, length() + 1); + ShortVector iotaVector = (ShortVector) iotaShuffle().toBitsVector(); + ShortVector filter = ShortVector.broadcast((ShortVector.ShortSpecies) vspecies().asIntegral(), (short)origin); + VectorMask blendMask = iotaVector.compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, filter).cast(vspecies()); + AbstractShuffle iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); + } + + /*package-private*/ + final + @ForceInline + > + HalffloatVector + unsliceTemplate(Class maskType, int origin, Vector w, int part, M m) { + HalffloatVector that = (HalffloatVector) w; + that.check(this); + HalffloatVector slice = that.sliceTemplate(origin, that); + slice = slice.blendTemplate(maskType, this, m); + return slice.unsliceTemplate(origin, w, part); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector unslice(int origin, Vector w, int part, VectorMask m); + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector unslice(int origin); + + /*package-private*/ + final + @ForceInline + HalffloatVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + ShortVector iotaVector = (ShortVector) iotaShuffle().toBitsVector(); + ShortVector filter = ShortVector.broadcast((ShortVector.ShortSpecies) vspecies().asIntegral(), (short)origin); + VectorMask blendMask = iotaVector.compare(VectorOperators.GE, filter).cast(vspecies()); + AbstractShuffle iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + + private ArrayIndexOutOfBoundsException + wrongPartForSlice(int part) { + String msg = String.format("bad part number %d for slice operation", + part); + return new ArrayIndexOutOfBoundsException(msg); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector rearrange(VectorShuffle shuffle); + + /*package-private*/ + @ForceInline + final + > + HalffloatVector rearrangeTemplate(Class shuffletype, S shuffle) { + Objects.requireNonNull(shuffle); + return VectorSupport.rearrangeOp( + getClass(), shuffletype, null, short.class, VECTOR_OPER_TYPE, length(), + this, shuffle, null, + (v1, s_, m_) -> v1.uOp((i, a) -> { + int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); + return v1.lane(ei); + })); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector rearrange(VectorShuffle s, + VectorMask m); + + /*package-private*/ + @ForceInline + final + , M extends VectorMask> + HalffloatVector rearrangeTemplate(Class shuffletype, + Class masktype, + S shuffle, + M m) { + Objects.requireNonNull(shuffle); + m.check(masktype, this); + return VectorSupport.rearrangeOp( + getClass(), shuffletype, masktype, short.class, VECTOR_OPER_TYPE, length(), + this, shuffle, m, + (v1, s_, m_) -> v1.uOp((i, a) -> { + int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); + return !m_.laneIsSet(i) ? 0 : v1.lane(ei); + })); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector rearrange(VectorShuffle s, + Vector v); + + /*package-private*/ + @ForceInline + final + > + HalffloatVector rearrangeTemplate(Class shuffletype, + S shuffle, + HalffloatVector v) { + VectorMask valid = shuffle.laneIsValid(); + HalffloatVector r0 = + VectorSupport.rearrangeOp( + getClass(), shuffletype, null, short.class, VECTOR_OPER_TYPE, length(), + this, shuffle, null, + (v0, s_, m_) -> v0.uOp((i, a) -> { + int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); + return v0.lane(ei); + })); + HalffloatVector r1 = + VectorSupport.rearrangeOp( + getClass(), shuffletype, null, short.class, VECTOR_OPER_TYPE, length(), + v, shuffle, null, + (v1, s_, m_) -> v1.uOp((i, a) -> { + int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); + return v1.lane(ei); + })); + return r1.blend(r0, valid); + } + + @Override + @ForceInline + final VectorShuffle bitsToShuffle0(AbstractSpecies dsp) { + throw new AssertionError(); + } + + @ForceInline + final + VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { + assert(dsp.elementSize() == vspecies().elementSize()); + ShortVector idx = convert(VectorOperators.H2S, 0).reinterpretAsShorts(); + ShortVector wrapped = idx.lanewise(VectorOperators.AND, length() - 1); + if (!wrap) { + ShortVector wrappedEx = wrapped.lanewise(VectorOperators.SUB, length()); + VectorMask inBound = wrapped.compare(VectorOperators.EQ, idx); + wrapped = wrappedEx.blend(wrapped, inBound); + } + return wrapped.bitsToShuffle(dsp); + } + + /** + * {@inheritDoc} + * @since 19 + */ + @Override + public abstract + HalffloatVector compress(VectorMask m); + + /*package-private*/ + @ForceInline + final + > + HalffloatVector compressTemplate(Class masktype, M m) { + m.check(masktype, this); + return (HalffloatVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, + short.class, VECTOR_OPER_TYPE, length(), this, m, + (v1, m1) -> compressHelper(v1, m1)); + } + + /** + * {@inheritDoc} + * @since 19 + */ + @Override + public abstract + HalffloatVector expand(VectorMask m); + + /*package-private*/ + @ForceInline + final + > + HalffloatVector expandTemplate(Class masktype, M m) { + m.check(masktype, this); + return (HalffloatVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, + short.class, VECTOR_OPER_TYPE, length(), this, m, + (v1, m1) -> expandHelper(v1, m1)); + } + + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector selectFrom(Vector v); + + /*package-private*/ + @ForceInline + final HalffloatVector selectFromTemplate(HalffloatVector v) { + return (HalffloatVector)VectorSupport.selectFromOp(getClass(), null, short.class, VECTOR_OPER_TYPE, + length(), this, v, null, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle())); + } + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector selectFrom(Vector s, VectorMask m); + + /*package-private*/ + @ForceInline + final + > + HalffloatVector selectFromTemplate(HalffloatVector v, + Class masktype, M m) { + m.check(masktype, this); + return (HalffloatVector)VectorSupport.selectFromOp(getClass(), masktype, short.class, VECTOR_OPER_TYPE, + length(), this, v, m, + (v1, v2, _m) -> + v2.rearrange(v1.toShuffle(), _m)); + } + + + /** + * {@inheritDoc} + */ + @Override + public abstract + HalffloatVector selectFrom(Vector v1, Vector v2); + + + /*package-private*/ + @ForceInline + final HalffloatVector selectFromTemplate(HalffloatVector v1, HalffloatVector v2) { + return VectorSupport.selectFromTwoVectorOp(getClass(), short.class, VECTOR_OPER_TYPE, length(), this, v1, v2, + (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); + } + + /// Ternary operations + + + /** + * Multiplies this vector by a second input vector, and sums + * the result with a third. + * + * Extended precision is used for the intermediate result, + * avoiding possible loss of precision from rounding once + * for each of the two operations. + * The result is numerically close to {@code this.mul(b).add(c)}, + * and is typically closer to the true mathematical result. + * + * This is a lane-wise ternary operation which applies an operation + * conforming to the specification of + * {@link Math#fma(short,short,short) Math.fma(a,b,c)} + * to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Ternary,Vector,Vector) + * lanewise}{@code (}{@link VectorOperators#FMA + * FMA}{@code , b, c)}. + * + * @param b the second input vector, supplying multiplier values + * @param c the third input vector, supplying addend values + * @return the product of this vector and the second input vector + * summed with the third input vector, using extended precision + * for the intermediate result + * @see #fma(short,short) + * @see VectorOperators#FMA + * @see #lanewise(VectorOperators.Ternary,Vector,Vector,VectorMask) + */ + @ForceInline + public final + HalffloatVector fma(Vector b, Vector c) { + return lanewise(FMA, b, c); + } + + /** + * Multiplies this vector by a scalar multiplier, and sums + * the result with a scalar addend. + * + * Extended precision is used for the intermediate result, + * avoiding possible loss of precision from rounding once + * for each of the two operations. + * The result is numerically close to {@code this.mul(b).add(c)}, + * and is typically closer to the true mathematical result. + * + * This is a lane-wise ternary operation which applies an operation + * conforming to the specification of + * {@link Math#fma(short,short,short) Math.fma(a,b,c)} + * to each lane. + * + * This method is also equivalent to the expression + * {@link #lanewise(VectorOperators.Ternary,Vector,Vector) + * lanewise}{@code (}{@link VectorOperators#FMA + * FMA}{@code , b, c)}. + * + * @param b the scalar multiplier + * @param c the scalar addend + * @return the product of this vector and the scalar multiplier + * summed with scalar addend, using extended precision + * for the intermediate result + * @see #fma(Vector,Vector) + * @see VectorOperators#FMA + * @see #lanewise(VectorOperators.Ternary,short,short,VectorMask) + */ + @ForceInline + public final + HalffloatVector fma(short b, short c) { + return lanewise(FMA, b, c); + } + + // Don't bother with (Vector,short) and (short,Vector) overloadings. + + // Type specific horizontal reductions + + /** + * Returns a value accumulated from all the lanes of this vector. + * + * This is an associative cross-lane reduction operation which + * applies the specified operation to all the lane elements. + *

+ * A few reduction operations do not support arbitrary reordering + * of their operands, yet are included here because of their + * usefulness. + *

    + *
  • + * In the case of {@code FIRST_NONZERO}, the reduction returns + * the value from the lowest-numbered non-zero lane. + * (As with {@code MAX} and {@code MIN}, floating point negative + * zero {@code -0.0} is treated as a value distinct from + * the default value, positive zero. So a first-nonzero lane reduction + * might return {@code -0.0} even in the presence of non-zero + * lane values.) + *
  • + * In the case of {@code ADD} and {@code MUL}, the + * precise result will reflect the choice of an arbitrary order + * of operations, which may even vary over time. + * For further details see the section + * Operations on floating point vectors. + *
  • + * All other reduction operations are fully commutative and + * associative. The implementation can choose any order of + * processing, yet it will always produce the same result. + *
+ * + * @param op the operation used to combine lane values + * @return the accumulated result + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #reduceLanes(VectorOperators.Associative,VectorMask) + * @see #add(Vector) + * @see #mul(Vector) + * @see #min(Vector) + * @see #max(Vector) + * @see VectorOperators#FIRST_NONZERO + */ + public abstract short reduceLanes(VectorOperators.Associative op); + + /** + * Returns a value accumulated from selected lanes of this vector, + * controlled by a mask. + * + * This is an associative cross-lane reduction operation which + * applies the specified operation to the selected lane elements. + *

+ * If no elements are selected, an operation-specific identity + * value is returned. + *

    + *
  • + * If the operation is + * {@code ADD} + * or {@code FIRST_NONZERO}, + * then the identity value is positive zero, the default {@code short} value. + *
  • + * If the operation is {@code MUL}, + * then the identity value is one. + *
  • + * If the operation is {@code MAX}, + * then the identity value is {@code Float16.NEGATIVE_INFINITY}. + *
  • + * If the operation is {@code MIN}, + * then the identity value is {@code Float16.POSITIVE_INFINITY}. + *
+ *

+ * A few reduction operations do not support arbitrary reordering + * of their operands, yet are included here because of their + * usefulness. + *

    + *
  • + * In the case of {@code FIRST_NONZERO}, the reduction returns + * the value from the lowest-numbered non-zero lane. + * (As with {@code MAX} and {@code MIN}, floating point negative + * zero {@code -0.0} is treated as a value distinct from + * the default value, positive zero. So a first-nonzero lane reduction + * might return {@code -0.0} even in the presence of non-zero + * lane values.) + *
  • + * In the case of {@code ADD} and {@code MUL}, the + * precise result will reflect the choice of an arbitrary order + * of operations, which may even vary over time. + * For further details see the section + * Operations on floating point vectors. + *
  • + * All other reduction operations are fully commutative and + * associative. The implementation can choose any order of + * processing, yet it will always produce the same result. + *
+ * + * @param op the operation used to combine lane values + * @param m the mask controlling lane selection + * @return the reduced result accumulated from the selected lane values + * @throws UnsupportedOperationException if this vector does + * not support the requested operation + * @see #reduceLanes(VectorOperators.Associative) + */ + public abstract short reduceLanes(VectorOperators.Associative op, + VectorMask m); + + /*package-private*/ + @ForceInline + final + short reduceLanesTemplate(VectorOperators.Associative op, + Class> maskClass, + VectorMask m) { + m.check(maskClass, this); + if (op == FIRST_NONZERO) { + // FIXME: The JIT should handle this. + HalffloatVector v = broadcast((short) 0).blend(this, m); + return v.reduceLanesTemplate(op); + } + int opc = opCode(op); + return fromBits(VectorSupport.reductionCoerced( + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), + this, m, + REDUCE_IMPL.find(op, opc, HalffloatVector::reductionOperations))); + } + + /*package-private*/ + @ForceInline + final + short reduceLanesTemplate(VectorOperators.Associative op) { + if (op == FIRST_NONZERO) { + // FIXME: The JIT should handle this. + VectorMask thisNZ + = this.viewAsIntegralLanes().compare(NE, (short) 0); + int ft = thisNZ.firstTrue(); + return ft < length() ? this.lane(ft) : (short) 0; + } + int opc = opCode(op); + return fromBits(VectorSupport.reductionCoerced( + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), + this, null, + REDUCE_IMPL.find(op, opc, HalffloatVector::reductionOperations))); + } + + private static final + ImplCache>> + REDUCE_IMPL = new ImplCache<>(Associative.class, HalffloatVector.class); + + private static ReductionOperation> reductionOperations(int opc_) { + switch (opc_) { + case VECTOR_OP_ADD: return (v, m) -> + toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + case VECTOR_OP_MUL: return (v, m) -> + toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + case VECTOR_OP_MIN: return (v, m) -> + toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + case VECTOR_OP_MAX: return (v, m) -> + toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + default: return null; + } + } + + private static final short MIN_OR_INF = Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + private static final short MAX_OR_INF = Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + + public @Override abstract long reduceLanesToLong(VectorOperators.Associative op); + public @Override abstract long reduceLanesToLong(VectorOperators.Associative op, + VectorMask m); + + // Type specific accessors + + /** + * Gets the lane element at lane index {@code i} + * + * @param i the lane index + * @return the lane element at lane index {@code i} + * @throws IllegalArgumentException if the index is out of range + * ({@code < 0 || >= length()}) + */ + public abstract short lane(int i); + + /** + * Replaces the lane element of this vector at lane index {@code i} with + * value {@code e}. + * + * This is a cross-lane operation and behaves as if it returns the result + * of blending this vector with an input vector that is the result of + * broadcasting {@code e} and a mask that has only one lane set at lane + * index {@code i}. + * + * @param i the lane index of the lane element to be replaced + * @param e the value to be placed + * @return the result of replacing the lane element of this vector at lane + * index {@code i} with value {@code e}. + * @throws IllegalArgumentException if the index is out of range + * ({@code < 0 || >= length()}) + */ + public abstract HalffloatVector withLane(int i, short e); + + // Memory load operations + + /** + * Returns an array of type {@code short[]} + * containing all the lane values. + * The array length is the same as the vector length. + * The array elements are stored in lane order. + *

+ * This method behaves as if it stores + * this vector into an allocated array + * (using {@link #intoArray(short[], int) intoArray}) + * and returns the array as follows: + *

{@code
+     *   short[] a = new short[this.length()];
+     *   this.intoArray(a, 0);
+     *   return a;
+     * }
+ * + * @return an array containing the lane values of this vector + */ + @ForceInline + @Override + public final short[] toArray() { + short[] a = new short[vspecies().laneCount()]; + intoArray(a, 0); + return a; + } + + /** {@inheritDoc} + */ + @ForceInline + @Override + public final int[] toIntArray() { + short[] a = toArray(); + int[] res = new int[a.length]; + for (int i = 0; i < a.length; i++) { + short e = a[i]; + res[i] = (int) HalffloatSpecies.toIntegralChecked(e, true); + } + return res; + } + + /** {@inheritDoc} + */ + @ForceInline + @Override + public final long[] toLongArray() { + short[] a = toArray(); + long[] res = new long[a.length]; + for (int i = 0; i < a.length; i++) { + short e = Float16.shortBitsToFloat16(a[i]).shortValue(); + res[i] = HalffloatSpecies.toIntegralChecked(e, false); + } + return res; + } + + /** {@inheritDoc} + * @implNote + * When this method is used on vectors + * of type {@code HalffloatVector}, + * there will be no loss of precision. + */ + @ForceInline + @Override + public final double[] toDoubleArray() { + short[] a = toArray(); + double[] res = new double[a.length]; + for (int i = 0; i < a.length; i++) { + res[i] = (double) Float16.shortBitsToFloat16(a[i]).doubleValue(); + } + return res; + } + + /** + * Loads a vector from an array of type {@code short[]} + * starting at an offset. + * For each vector lane, where {@code N} is the vector lane index, the + * array element at index {@code offset + N} is placed into the + * resulting vector at lane index {@code N}. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array + * @return the vector loaded from an array + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + */ + @ForceInline + public static + HalffloatVector fromArray(VectorSpecies species, + short[] a, int offset) { + offset = checkFromIndexSize(offset, species.length(), a.length); + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.dummyVector().fromArray0(a, offset); + } + + /** + * Loads a vector from an array of type {@code short[]} + * starting at an offset and using a mask. + * Lanes where the mask is unset are filled with the default + * value of {@code short} (positive zero). + * For each vector lane, where {@code N} is the vector lane index, + * if the mask lane at index {@code N} is set then the array element at + * index {@code offset + N} is placed into the resulting vector at lane index + * {@code N}, otherwise the default element value is placed into the + * resulting vector at lane index {@code N}. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array + * @param m the mask controlling lane selection + * @return the vector loaded from an array + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + * where the mask is set + */ + @ForceInline + public static + HalffloatVector fromArray(VectorSpecies species, + short[] a, int offset, + VectorMask m) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + if (VectorIntrinsics.indexInRange(offset, vsp.length(), a.length)) { + return vsp.dummyVector().fromArray0(a, offset, m, OFFSET_IN_RANGE); + } + + ((AbstractMask)m) + .checkIndexByLane(offset, a.length, vsp.iota(), 1); + return vsp.dummyVector().fromArray0(a, offset, m, OFFSET_OUT_OF_RANGE); + } + + /** + * Gathers a new vector composed of elements from an array of type + * {@code short[]}, + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane is loaded from the array + * element {@code a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array, may be negative if relative + * indexes in the index map compensate to produce a value within the + * array bounds + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @return the vector loaded from the indexed elements of the array + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public static + HalffloatVector fromArray(VectorSpecies species, + short[] a, int offset, + int[] indexMap, int mapOffset) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + IntVector.IntSpecies isp = IntVector.species(vsp.indexShape()); + Objects.requireNonNull(a); + Objects.requireNonNull(indexMap); + Class vectorType = vsp.vectorType(); + + + // Constant folding should sweep out following conditonal logic. + VectorSpecies lsp; + if (isp.length() > IntVector.SPECIES_PREFERRED.length()) { + lsp = IntVector.SPECIES_PREFERRED; + } else { + lsp = isp; + } + + // Check indices are within array bounds. + IntVector vix0 = IntVector.fromArray(lsp, indexMap, mapOffset).add(offset); + VectorIntrinsics.checkIndex(vix0, a.length); + + int vlen = vsp.length(); + int idx_vlen = lsp.length(); + IntVector vix1 = null; + if (vlen >= idx_vlen * 2) { + vix1 = IntVector.fromArray(lsp, indexMap, mapOffset + idx_vlen).add(offset); + VectorIntrinsics.checkIndex(vix1, a.length); + } + + return VectorSupport.loadWithMap( + vectorType, null, short.class, VECTOR_OPER_TYPE, vsp.laneCount(), + lsp.vectorType(), lsp.length(), + a, ARRAY_BASE, vix0, vix1, null, null, null, + a, offset, indexMap, mapOffset, vsp, + (c, idx, iMap, idy, s, vm) -> + s.vOp(n -> c[idx + iMap[idy+n]])); + } + + /** + * Gathers a new vector composed of elements from an array of type + * {@code short[]}, + * under the control of a mask, and + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * if the lane is set in the mask, + * the lane is loaded from the array + * element {@code a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * Unset lanes in the resulting vector are set to zero. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array, may be negative if relative + * indexes in the index map compensate to produce a value within the + * array bounds + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @param m the mask controlling lane selection + * @return the vector loaded from the indexed elements of the array + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * where the mask is set + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public static + HalffloatVector fromArray(VectorSpecies species, + short[] a, int offset, + int[] indexMap, int mapOffset, + VectorMask m) { + if (m.allTrue()) { + return fromArray(species, a, offset, indexMap, mapOffset); + } + else { + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.dummyVector().fromArray0(a, offset, indexMap, mapOffset, m); + } + } + + /** + * Loads a vector from an array of type {@code char[]} + * starting at an offset. + * For each vector lane, where {@code N} is the vector lane index, the + * array element at index {@code offset + N} + * is first cast to a {@code short} value and then + * placed into the resulting vector at lane index {@code N}. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array + * @return the vector loaded from an array + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + */ + @ForceInline + public static + HalffloatVector fromCharArray(VectorSpecies species, + char[] a, int offset) { + offset = checkFromIndexSize(offset, species.length(), a.length); + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.dummyVector().fromCharArray0(a, offset); + } + + /** + * Loads a vector from an array of type {@code char[]} + * starting at an offset and using a mask. + * Lanes where the mask is unset are filled with the default + * value of {@code short} (positive zero). + * For each vector lane, where {@code N} is the vector lane index, + * if the mask lane at index {@code N} is set then the array element at + * index {@code offset + N} + * is first cast to a {@code short} value and then + * placed into the resulting vector at lane index + * {@code N}, otherwise the default element value is placed into the + * resulting vector at lane index {@code N}. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array + * @param m the mask controlling lane selection + * @return the vector loaded from an array + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + * where the mask is set + */ + @ForceInline + public static + HalffloatVector fromCharArray(VectorSpecies species, + char[] a, int offset, + VectorMask m) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + if (VectorIntrinsics.indexInRange(offset, vsp.length(), a.length)) { + return vsp.dummyVector().fromCharArray0(a, offset, m, OFFSET_IN_RANGE); + } + + ((AbstractMask)m) + .checkIndexByLane(offset, a.length, vsp.iota(), 1); + return vsp.dummyVector().fromCharArray0(a, offset, m, OFFSET_OUT_OF_RANGE); + } + + /** + * Gathers a new vector composed of elements from an array of type + * {@code char[]}, + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane is loaded from the expression + * {@code (short) a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array, may be negative if relative + * indexes in the index map compensate to produce a value within the + * array bounds + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @return the vector loaded from the indexed elements of the array + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public static + HalffloatVector fromCharArray(VectorSpecies species, + char[] a, int offset, + int[] indexMap, int mapOffset) { + // FIXME: optimize + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.vOp(n -> (short) a[offset + indexMap[mapOffset + n]]); + } + + /** + * Gathers a new vector composed of elements from an array of type + * {@code char[]}, + * under the control of a mask, and + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * if the lane is set in the mask, + * the lane is loaded from the expression + * {@code (short) a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * Unset lanes in the resulting vector are set to zero. + * + * @param species species of desired vector + * @param a the array + * @param offset the offset into the array, may be negative if relative + * indexes in the index map compensate to produce a value within the + * array bounds + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @param m the mask controlling lane selection + * @return the vector loaded from the indexed elements of the array + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * where the mask is set + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public static + HalffloatVector fromCharArray(VectorSpecies species, + char[] a, int offset, + int[] indexMap, int mapOffset, + VectorMask m) { + // FIXME: optimize + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.vOp(m, n -> (short) a[offset + indexMap[mapOffset + n]]); + } + + + /** + * Loads a vector from a {@linkplain MemorySegment memory segment} + * starting at an offset into the memory segment. + * Bytes are composed into primitive lane elements according + * to the specified byte order. + * The vector is arranged into lanes according to + * memory ordering. + *

+ * This method behaves as if it returns the result of calling + * {@link #fromMemorySegment(VectorSpecies,MemorySegment,long,ByteOrder,VectorMask) + * fromMemorySegment()} as follows: + *

{@code
+     * var m = species.maskAll(true);
+     * return fromMemorySegment(species, ms, offset, bo, m);
+     * }
+ * + * @param species species of desired vector + * @param ms the memory segment + * @param offset the offset into the memory segment + * @param bo the intended byte order + * @return a vector loaded from the memory segment + * @throws IndexOutOfBoundsException + * if {@code offset+N*2 < 0} + * or {@code offset+N*2 >= ms.byteSize()} + * for any lane {@code N} in the vector + * @throws IllegalStateException if the memory segment's session is not alive, + * or if access occurs from a thread other than the thread owning the session. + * @since 19 + */ + @ForceInline + public static + HalffloatVector fromMemorySegment(VectorSpecies species, + MemorySegment ms, long offset, + ByteOrder bo) { + offset = checkFromIndexSize(offset, species.vectorByteSize(), ms.byteSize()); + HalffloatSpecies vsp = (HalffloatSpecies) species; + return vsp.dummyVector().fromMemorySegment0(ms, offset).maybeSwap(bo); + } + + /** + * Loads a vector from a {@linkplain MemorySegment memory segment} + * starting at an offset into the memory segment + * and using a mask. + * Lanes where the mask is unset are filled with the default + * value of {@code short} (positive zero). + * Bytes are composed into primitive lane elements according + * to the specified byte order. + * The vector is arranged into lanes according to + * memory ordering. + *

+ * The following pseudocode illustrates the behavior: + *

{@code
+     * var slice = ms.asSlice(offset);
+     * short[] ar = new short[species.length()];
+     * for (int n = 0; n < ar.length; n++) {
+     *     if (m.laneIsSet(n)) {
+     *         ar[n] = slice.getAtIndex(ValuaLayout.JAVA_SHORT.withByteAlignment(1), n);
+     *     }
+     * }
+     * HalffloatVector r = HalffloatVector.fromArray(species, ar, 0);
+     * }
+ * @implNote + * This operation is likely to be more efficient if + * the specified byte order is the same as + * {@linkplain ByteOrder#nativeOrder() + * the platform native order}, + * since this method will not need to reorder + * the bytes of lane values. + * + * @param species species of desired vector + * @param ms the memory segment + * @param offset the offset into the memory segment + * @param bo the intended byte order + * @param m the mask controlling lane selection + * @return a vector loaded from the memory segment + * @throws IndexOutOfBoundsException + * if {@code offset+N*2 < 0} + * or {@code offset+N*2 >= ms.byteSize()} + * for any lane {@code N} in the vector + * where the mask is set + * @throws IllegalStateException if the memory segment's session is not alive, + * or if access occurs from a thread other than the thread owning the session. + * @since 19 + */ + @ForceInline + public static + HalffloatVector fromMemorySegment(VectorSpecies species, + MemorySegment ms, long offset, + ByteOrder bo, + VectorMask m) { + HalffloatSpecies vsp = (HalffloatSpecies) species; + if (VectorIntrinsics.indexInRange(offset, vsp.vectorByteSize(), ms.byteSize())) { + return vsp.dummyVector().fromMemorySegment0(ms, offset, m, OFFSET_IN_RANGE).maybeSwap(bo); + } + + ((AbstractMask)m) + .checkIndexByLane(offset, ms.byteSize(), vsp.iota(), 2); + return vsp.dummyVector().fromMemorySegment0(ms, offset, m, OFFSET_OUT_OF_RANGE).maybeSwap(bo); + } + + // Memory store operations + + /** + * Stores this vector into an array of type {@code short[]} + * starting at an offset. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane element at index {@code N} is stored into the array + * element {@code a[offset+N]}. + * + * @param a the array, of type {@code short[]} + * @param offset the offset into the array + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + */ + @ForceInline + public final + void intoArray(short[] a, int offset) { + offset = checkFromIndexSize(offset, length(), a.length); + HalffloatSpecies vsp = vspecies(); + VectorSupport.store( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, arrayAddress(a, offset), false, + this, + a, offset, + (arr, off, v) + -> v.stOp(arr, (int) off, + (arr_, off_, i, e) -> arr_[off_ + i] = e)); + } + + /** + * Stores this vector into an array of type {@code short[]} + * starting at offset and using a mask. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane element at index {@code N} is stored into the array + * element {@code a[offset+N]}. + * If the mask lane at {@code N} is unset then the corresponding + * array element {@code a[offset+N]} is left unchanged. + *

+ * Array range checking is done for lanes where the mask is set. + * Lanes where the mask is unset are not stored and do not need + * to correspond to legitimate elements of {@code a}. + * That is, unset lanes may correspond to array indexes less than + * zero or beyond the end of the array. + * + * @param a the array, of type {@code short[]} + * @param offset the offset into the array + * @param m the mask controlling lane storage + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + * where the mask is set + */ + @ForceInline + public final + void intoArray(short[] a, int offset, + VectorMask m) { + if (m.allTrue()) { + intoArray(a, offset); + } else { + HalffloatSpecies vsp = vspecies(); + if (!VectorIntrinsics.indexInRange(offset, vsp.length(), a.length)) { + ((AbstractMask)m) + .checkIndexByLane(offset, a.length, vsp.iota(), 1); + } + intoArray0(a, offset, m); + } + } + + /** + * Scatters this vector into an array of type {@code short[]} + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane element at index {@code N} is stored into the array + * element {@code a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * + * @param a the array + * @param offset an offset to combine with the index map offsets + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public final + void intoArray(short[] a, int offset, + int[] indexMap, int mapOffset) { + stOp(a, offset, + (arr, off, i, e) -> { + int j = indexMap[mapOffset + i]; + arr[off + j] = e; + }); + } + + /** + * Scatters this vector into an array of type {@code short[]}, + * under the control of a mask, and + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * if the mask lane at index {@code N} is set then + * the lane element at index {@code N} is stored into the array + * element {@code a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * + * @param a the array + * @param offset an offset to combine with the index map offsets + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @param m the mask + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * where the mask is set + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public final + void intoArray(short[] a, int offset, + int[] indexMap, int mapOffset, + VectorMask m) { + stOp(a, offset, m, + (arr, off, i, e) -> { + int j = indexMap[mapOffset + i]; + arr[off + j] = e; + }); + } + + /** + * Stores this vector into an array of type {@code char[]} + * starting at an offset. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane element at index {@code N} + * is first cast to a {@code char} value and then + * stored into the array element {@code a[offset+N]}. + * + * @param a the array, of type {@code char[]} + * @param offset the offset into the array + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + */ + @ForceInline + public final + void intoCharArray(char[] a, int offset) { + offset = checkFromIndexSize(offset, length(), a.length); + HalffloatSpecies vsp = vspecies(); + VectorSupport.store( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, charArrayAddress(a, offset), false, + this, + a, offset, + (arr, off, v) + -> v.stOp(arr, (int) off, + (arr_, off_, i, e) -> arr_[off_ + i] = (char) e)); + } + + /** + * Stores this vector into an array of type {@code char[]} + * starting at offset and using a mask. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane element at index {@code N} + * is first cast to a {@code char} value and then + * stored into the array element {@code a[offset+N]}. + * If the mask lane at {@code N} is unset then the corresponding + * array element {@code a[offset+N]} is left unchanged. + *

+ * Array range checking is done for lanes where the mask is set. + * Lanes where the mask is unset are not stored and do not need + * to correspond to legitimate elements of {@code a}. + * That is, unset lanes may correspond to array indexes less than + * zero or beyond the end of the array. + * + * @param a the array, of type {@code char[]} + * @param offset the offset into the array + * @param m the mask controlling lane storage + * @throws IndexOutOfBoundsException + * if {@code offset+N < 0} or {@code offset+N >= a.length} + * for any lane {@code N} in the vector + * where the mask is set + */ + @ForceInline + public final + void intoCharArray(char[] a, int offset, + VectorMask m) { + if (m.allTrue()) { + intoCharArray(a, offset); + } else { + HalffloatSpecies vsp = vspecies(); + if (!VectorIntrinsics.indexInRange(offset, vsp.length(), a.length)) { + ((AbstractMask)m) + .checkIndexByLane(offset, a.length, vsp.iota(), 1); + } + intoCharArray0(a, offset, m); + } + } + + /** + * Scatters this vector into an array of type {@code char[]} + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * the lane element at index {@code N} + * is first cast to a {@code char} value and then + * stored into the array + * element {@code a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * + * @param a the array + * @param offset an offset to combine with the index map offsets + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public final + void intoCharArray(char[] a, int offset, + int[] indexMap, int mapOffset) { + // FIXME: optimize + stOp(a, offset, + (arr, off, i, e) -> { + int j = indexMap[mapOffset + i]; + arr[off + j] = (char) e; + }); + } + + /** + * Scatters this vector into an array of type {@code char[]}, + * under the control of a mask, and + * using indexes obtained by adding a fixed {@code offset} to a + * series of secondary offsets from an index map. + * The index map is a contiguous sequence of {@code VLENGTH} + * elements in a second array of {@code int}s, starting at a given + * {@code mapOffset}. + *

+ * For each vector lane, where {@code N} is the vector lane index, + * if the mask lane at index {@code N} is set then + * the lane element at index {@code N} + * is first cast to a {@code char} value and then + * stored into the array + * element {@code a[f(N)]}, where {@code f(N)} is the + * index mapping expression + * {@code offset + indexMap[mapOffset + N]]}. + * + * @param a the array + * @param offset an offset to combine with the index map offsets + * @param indexMap the index map + * @param mapOffset the offset into the index map + * @param m the mask + * @throws IndexOutOfBoundsException + * if {@code mapOffset+N < 0} + * or if {@code mapOffset+N >= indexMap.length}, + * or if {@code f(N)=offset+indexMap[mapOffset+N]} + * is an invalid index into {@code a}, + * for any lane {@code N} in the vector + * where the mask is set + * @see HalffloatVector#toIntArray() + */ + @ForceInline + public final + void intoCharArray(char[] a, int offset, + int[] indexMap, int mapOffset, + VectorMask m) { + // FIXME: optimize + stOp(a, offset, m, + (arr, off, i, e) -> { + int j = indexMap[mapOffset + i]; + arr[off + j] = (char) e; + }); + } + + + /** + * {@inheritDoc} + * @since 19 + */ + @Override + @ForceInline + public final + void intoMemorySegment(MemorySegment ms, long offset, + ByteOrder bo) { + if (ms.isReadOnly()) { + throw new UnsupportedOperationException("Attempt to write a read-only segment"); + } + + offset = checkFromIndexSize(offset, byteSize(), ms.byteSize()); + maybeSwap(bo).intoMemorySegment0(ms, offset); + } + + /** + * {@inheritDoc} + * @since 19 + */ + @Override + @ForceInline + public final + void intoMemorySegment(MemorySegment ms, long offset, + ByteOrder bo, + VectorMask m) { + if (m.allTrue()) { + intoMemorySegment(ms, offset, bo); + } else { + if (ms.isReadOnly()) { + throw new UnsupportedOperationException("Attempt to write a read-only segment"); + } + HalffloatSpecies vsp = vspecies(); + if (!VectorIntrinsics.indexInRange(offset, vsp.vectorByteSize(), ms.byteSize())) { + ((AbstractMask)m) + .checkIndexByLane(offset, ms.byteSize(), vsp.iota(), 2); + } + maybeSwap(bo).intoMemorySegment0(ms, offset, m); + } + } + + // ================================================ + + // Low-level memory operations. + // + // Note that all of these operations *must* inline into a context + // where the exact species of the involved vector is a + // compile-time constant. Otherwise, the intrinsic generation + // will fail and performance will suffer. + // + // In many cases this is achieved by re-deriving a version of the + // method in each concrete subclass (per species). The re-derived + // method simply calls one of these generic methods, with exact + // parameters for the controlling metadata, which is either a + // typed vector or constant species instance. + + // Unchecked loading operations in native byte order. + // Caller is responsible for applying index checks, masking, and + // byte swapping. + + /*package-private*/ + abstract + HalffloatVector fromArray0(short[] a, int offset); + @ForceInline + final + HalffloatVector fromArray0Template(short[] a, int offset) { + HalffloatSpecies vsp = vspecies(); + return VectorSupport.load( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, arrayAddress(a, offset), false, + a, offset, vsp, + (arr, off, s) -> s.ldOp(arr, (int) off, + (arr_, off_, i) -> arr_[off_ + i])); + } + + /*package-private*/ + abstract + HalffloatVector fromArray0(short[] a, int offset, VectorMask m, int offsetInRange); + @ForceInline + final + > + HalffloatVector fromArray0Template(Class maskClass, short[] a, int offset, M m, int offsetInRange) { + m.check(species()); + HalffloatSpecies vsp = vspecies(); + return VectorSupport.loadMasked( + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, arrayAddress(a, offset), false, m, offsetInRange, + a, offset, vsp, + (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, + (arr_, off_, i) -> arr_[off_ + i])); + } + + /*package-private*/ + abstract + HalffloatVector fromArray0(short[] a, int offset, + int[] indexMap, int mapOffset, + VectorMask m); + @ForceInline + final + > + HalffloatVector fromArray0Template(Class maskClass, short[] a, int offset, + int[] indexMap, int mapOffset, M m) { + HalffloatSpecies vsp = vspecies(); + IntVector.IntSpecies isp = IntVector.species(vsp.indexShape()); + Objects.requireNonNull(a); + Objects.requireNonNull(indexMap); + m.check(vsp); + Class vectorType = vsp.vectorType(); + + + // Constant folding should sweep out following conditonal logic. + VectorSpecies lsp; + if (isp.length() > IntVector.SPECIES_PREFERRED.length()) { + lsp = IntVector.SPECIES_PREFERRED; + } else { + lsp = isp; + } + + // Check indices are within array bounds. + // FIXME: Check index under mask controlling. + IntVector vix0 = IntVector.fromArray(lsp, indexMap, mapOffset).add(offset); + VectorIntrinsics.checkIndex(vix0, a.length); + + int vlen = vsp.length(); + int idx_vlen = lsp.length(); + IntVector vix1 = null; + if (vlen >= idx_vlen * 2) { + vix1 = IntVector.fromArray(lsp, indexMap, mapOffset + idx_vlen).add(offset); + VectorIntrinsics.checkIndex(vix1, a.length); + } + + return VectorSupport.loadWithMap( + vectorType, maskClass, short.class, VECTOR_OPER_TYPE, vsp.laneCount(), + lsp.vectorType(), lsp.length(), + a, ARRAY_BASE, vix0, vix1, null, null, m, + a, offset, indexMap, mapOffset, vsp, + (c, idx, iMap, idy, s, vm) -> + s.vOp(vm, n -> c[idx + iMap[idy+n]])); + } + + /*package-private*/ + abstract + HalffloatVector fromCharArray0(char[] a, int offset); + @ForceInline + final + HalffloatVector fromCharArray0Template(char[] a, int offset) { + HalffloatSpecies vsp = vspecies(); + return VectorSupport.load( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, charArrayAddress(a, offset), false, + a, offset, vsp, + (arr, off, s) -> s.ldOp(arr, (int) off, + (arr_, off_, i) -> (short) arr_[off_ + i])); + } + + /*package-private*/ + abstract + HalffloatVector fromCharArray0(char[] a, int offset, VectorMask m, int offsetInRange); + @ForceInline + final + > + HalffloatVector fromCharArray0Template(Class maskClass, char[] a, int offset, M m, int offsetInRange) { + m.check(species()); + HalffloatSpecies vsp = vspecies(); + return VectorSupport.loadMasked( + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, charArrayAddress(a, offset), false, m, offsetInRange, + a, offset, vsp, + (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, + (arr_, off_, i) -> (short) arr_[off_ + i])); + } + + + abstract + HalffloatVector fromMemorySegment0(MemorySegment bb, long offset); + @ForceInline + final + HalffloatVector fromMemorySegment0Template(MemorySegment ms, long offset) { + HalffloatSpecies vsp = vspecies(); + return ScopedMemoryAccess.loadFromMemorySegment( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + (AbstractMemorySegmentImpl) ms, offset, vsp, + (msp, off, s) -> { + return s.ldLongOp((MemorySegment) msp, off, HalffloatVector::memorySegmentGet); + }); + } + + abstract + HalffloatVector fromMemorySegment0(MemorySegment ms, long offset, VectorMask m, int offsetInRange); + @ForceInline + final + > + HalffloatVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long offset, M m, int offsetInRange) { + HalffloatSpecies vsp = vspecies(); + m.check(vsp); + return ScopedMemoryAccess.loadFromMemorySegmentMasked( + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, + (msp, off, s, vm) -> { + return s.ldLongOp((MemorySegment) msp, off, vm, HalffloatVector::memorySegmentGet); + }); + } + + // Unchecked storing operations in native byte order. + // Caller is responsible for applying index checks, masking, and + // byte swapping. + + abstract + void intoArray0(short[] a, int offset); + @ForceInline + final + void intoArray0Template(short[] a, int offset) { + HalffloatSpecies vsp = vspecies(); + VectorSupport.store( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, arrayAddress(a, offset), false, + this, a, offset, + (arr, off, v) + -> v.stOp(arr, (int) off, + (arr_, off_, i, e) -> arr_[off_+i] = e)); + } + + abstract + void intoArray0(short[] a, int offset, VectorMask m); + @ForceInline + final + > + void intoArray0Template(Class maskClass, short[] a, int offset, M m) { + m.check(species()); + HalffloatSpecies vsp = vspecies(); + VectorSupport.storeMasked( + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, arrayAddress(a, offset), false, + this, m, a, offset, + (arr, off, v, vm) + -> v.stOp(arr, (int) off, vm, + (arr_, off_, i, e) -> arr_[off_ + i] = e)); + } + + + + @ForceInline + final + void intoMemorySegment0(MemorySegment ms, long offset) { + HalffloatSpecies vsp = vspecies(); + ScopedMemoryAccess.storeIntoMemorySegment( + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + this, + (AbstractMemorySegmentImpl) ms, offset, + (msp, off, v) -> { + v.stLongOp((MemorySegment) msp, off, HalffloatVector::memorySegmentSet); + }); + } + + abstract + void intoMemorySegment0(MemorySegment bb, long offset, VectorMask m); + @ForceInline + final + > + void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offset, M m) { + HalffloatSpecies vsp = vspecies(); + m.check(vsp); + ScopedMemoryAccess.storeIntoMemorySegmentMasked( + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + this, m, + (AbstractMemorySegmentImpl) ms, offset, + (msp, off, v, vm) -> { + v.stLongOp((MemorySegment) msp, off, vm, HalffloatVector::memorySegmentSet); + }); + } + + /*package-private*/ + abstract + void intoCharArray0(char[] a, int offset, VectorMask m); + @ForceInline + final + > + void intoCharArray0Template(Class maskClass, char[] a, int offset, M m) { + m.check(species()); + HalffloatSpecies vsp = vspecies(); + VectorSupport.storeMasked( + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), + a, charArrayAddress(a, offset), false, + this, m, a, offset, + (arr, off, v, vm) + -> v.stOp(arr, (int) off, vm, + (arr_, off_, i, e) -> arr_[off_ + i] = (char) e)); + } + + // End of low-level memory operations. + + @ForceInline + private void conditionalStoreNYI(int offset, + HalffloatSpecies vsp, + VectorMask m, + int scale, + int limit) { + if (offset < 0 || offset + vsp.laneCount() * scale > limit) { + String msg = + String.format("unimplemented: store @%d in [0..%d), %s in %s", + offset, limit, m, vsp); + throw new AssertionError(msg); + } + } + + /*package-private*/ + @Override + @ForceInline + final + HalffloatVector maybeSwap(ByteOrder bo) { + if (bo != NATIVE_ENDIAN) { + return this.reinterpretAsBytes() + .rearrange(swapBytesShuffle()) + .reinterpretAsHalffloats(); + } + return this; + } + + static final int ARRAY_SHIFT = + 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_SHORT_INDEX_SCALE); + static final long ARRAY_BASE = + Unsafe.ARRAY_SHORT_BASE_OFFSET; + + @ForceInline + static long arrayAddress(short[] a, int index) { + return ARRAY_BASE + (((long)index) << ARRAY_SHIFT); + } + + static final int ARRAY_CHAR_SHIFT = + 31 - Integer.numberOfLeadingZeros(Unsafe.ARRAY_CHAR_INDEX_SCALE); + static final long ARRAY_CHAR_BASE = + Unsafe.ARRAY_CHAR_BASE_OFFSET; + + @ForceInline + static long charArrayAddress(char[] a, int index) { + return ARRAY_CHAR_BASE + (((long)index) << ARRAY_CHAR_SHIFT); + } + + + @ForceInline + static long byteArrayAddress(byte[] a, int index) { + return Unsafe.ARRAY_BYTE_BASE_OFFSET + index; + } + + // ================================================ + + /// Reinterpreting view methods: + // lanewise reinterpret: viewAsXVector() + // keep shape, redraw lanes: reinterpretAsEs() + + /** + * {@inheritDoc} + */ + @ForceInline + @Override + public final ByteVector reinterpretAsBytes() { + // Going to ByteVector, pay close attention to byte order. + assert(REGISTER_ENDIAN == ByteOrder.LITTLE_ENDIAN); + return asByteVectorRaw(); + //return asByteVectorRaw().rearrange(swapBytesShuffle()); + } + + /** + * {@inheritDoc} + */ + @ForceInline + @Override + public final ShortVector viewAsIntegralLanes() { + LaneType ilt = LaneType.SHORT.asIntegral(); + return (ShortVector) asVectorRaw(ilt); + } + + /** + * {@inheritDoc} + * + * @implNote This method always throws + * {@code UnsupportedOperationException}, because there is no floating + * point type of the same size as {@code short}. The return type + * of this method is arbitrarily designated as + * {@code Vector}. Future versions of this API may change the return + * type if additional floating point types become available. + */ + @ForceInline + @Override + public final + HalffloatVector + viewAsFloatingLanes() { + return this; + } + + // ================================================ + + /// Object methods: toString, equals, hashCode + // + // Object methods are defined as if via Arrays.toString, etc., + // is applied to the array of elements. Two equal vectors + // are required to have equal species and equal lane values. + + /** + * Returns a string representation of this vector, of the form + * {@code "[0,1,2...]"}, reporting the lane values of this vector, + * in lane order. + * + * The string is produced as if by a call to {@link + * java.util.Arrays#toString(short[]) Arrays.toString()}, + * as appropriate to the {@code short} array returned by + * {@link #toArray this.toArray()}. + * + * @return a string of the form {@code "[0,1,2...]"} + * reporting the lane values of this vector + */ + @Override + @ForceInline + public final + String toString() { + // now that toArray is strongly typed, we can define this + return Arrays.toString(toArray()); + } + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + boolean equals(Object obj) { + if (obj instanceof Vector) { + Vector that = (Vector) obj; + if (this.species().equals(that.species())) { + return this.eq(that.check(this.species())).allTrue(); + } + } + return false; + } + + /** + * {@inheritDoc} + */ + @Override + @ForceInline + public final + int hashCode() { + // now that toArray is strongly typed, we can define this + return Objects.hash(species(), Arrays.hashCode(toArray())); + } + + // ================================================ + + // Species + + /** + * Class representing {@link HalffloatVector}'s of the same {@link VectorShape VectorShape}. + */ + /*package-private*/ + static final class HalffloatSpecies extends AbstractSpecies { + private HalffloatSpecies(VectorShape shape, + Class vectorType, + Class> maskType, + Class> shuffleType, + Function vectorFactory) { + super(shape, LaneType.of(Float16.class), + vectorType, maskType, shuffleType, + vectorFactory); + assert(this.elementSize() == Float16.SIZE); + } + + // Specializing overrides: + + @ForceInline + final Class carrierType() { + return short.class; + } + + @ForceInline + final int operType() { + if (Float16.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + + @Override + @ForceInline + public final Class elementType() { + return Float16.class; + } + + @Override + @ForceInline + final Class genericElementType() { + return Float16.class; + } + + @SuppressWarnings("unchecked") + @Override + @ForceInline + public final Class vectorType() { + return (Class) vectorType; + } + + @Override + @ForceInline + public final long checkValue(long e) { + longToElementBits(e); // only for exception + return e; + } + + /*package-private*/ + @Override + @ForceInline + final HalffloatVector broadcastBits(long bits) { + return (HalffloatVector) + VectorSupport.fromBitsCoerced( + vectorType, short.class, VECTOR_OPER_TYPE, laneCount, + bits, MODE_BROADCAST, this, + (bits_, s_) -> s_.rvOp(i -> bits_)); + } + + /*package-private*/ + @ForceInline + final HalffloatVector broadcast(short e) { + return broadcastBits(toBits(e)); + } + + @Override + @ForceInline + public final HalffloatVector broadcast(long e) { + return broadcastBits(longToElementBits(e)); + } + + /*package-private*/ + final @Override + @ForceInline + long longToElementBits(long value) { + // Do the conversion, and then test it for failure. + short e = (short) value; + if ((long) e != value) { + throw badElementBits(value, e); + } + return toBits(e); + } + + /*package-private*/ + @ForceInline + static long toIntegralChecked(short e, boolean convertToInt) { + long value = convertToInt ? (int) e : (long) e; + if ((short) value != e) { + throw badArrayBits(e, convertToInt, value); + } + return value; + } + + /* this non-public one is for internal conversions */ + @Override + @ForceInline + final HalffloatVector fromIntValues(int[] values) { + VectorIntrinsics.requireLength(values.length, laneCount); + short[] va = new short[laneCount()]; + for (int i = 0; i < va.length; i++) { + int lv = values[i]; + short v = Float16.float16ToRawShortBits(Float16.valueOf(lv)); + va[i] = v; + if (Float16.valueOf(lv).intValue() != lv) { + throw badElementBits(lv, v); + } + } + return dummyVector().fromArray0(va, 0); + } + + // Virtual constructors + + @ForceInline + @Override final + public HalffloatVector fromArray(Object a, int offset) { + // User entry point + // Defer only to the equivalent method on the vector class, using the same inputs + return HalffloatVector + .fromArray(this, (short[]) a, offset); + } + + @ForceInline + @Override final + public HalffloatVector fromMemorySegment(MemorySegment ms, long offset, ByteOrder bo) { + // User entry point + // Defer only to the equivalent method on the vector class, using the same inputs + return HalffloatVector + .fromMemorySegment(this, ms, offset, bo); + } + + @ForceInline + @Override final + HalffloatVector dummyVector() { + return (HalffloatVector) super.dummyVector(); + } + + /*package-private*/ + final @Override + @ForceInline + HalffloatVector rvOp(RVOp f) { + short[] res = new short[laneCount()]; + for (int i = 0; i < res.length; i++) { + short bits = (short) f.apply(i); + res[i] = fromBits(bits); + } + return dummyVector().vectorFactory(res); + } + + HalffloatVector vOp(FVOp f) { + short[] res = new short[laneCount()]; + for (int i = 0; i < res.length; i++) { + res[i] = f.apply(i); + } + return dummyVector().vectorFactory(res); + } + + HalffloatVector vOp(VectorMask m, FVOp f) { + short[] res = new short[laneCount()]; + boolean[] mbits = ((AbstractMask)m).getBits(); + for (int i = 0; i < res.length; i++) { + if (mbits[i]) { + res[i] = f.apply(i); + } + } + return dummyVector().vectorFactory(res); + } + + /*package-private*/ + @ForceInline + HalffloatVector ldOp(M memory, int offset, + FLdOp f) { + return dummyVector().ldOp(memory, offset, f); + } + + /*package-private*/ + @ForceInline + HalffloatVector ldOp(M memory, int offset, + VectorMask m, + FLdOp f) { + return dummyVector().ldOp(memory, offset, m, f); + } + + /*package-private*/ + @ForceInline + HalffloatVector ldLongOp(MemorySegment memory, long offset, + FLdLongOp f) { + return dummyVector().ldLongOp(memory, offset, f); + } + + /*package-private*/ + @ForceInline + HalffloatVector ldLongOp(MemorySegment memory, long offset, + VectorMask m, + FLdLongOp f) { + return dummyVector().ldLongOp(memory, offset, m, f); + } + + /*package-private*/ + @ForceInline + void stOp(M memory, int offset, FStOp f) { + dummyVector().stOp(memory, offset, f); + } + + /*package-private*/ + @ForceInline + void stOp(M memory, int offset, + AbstractMask m, + FStOp f) { + dummyVector().stOp(memory, offset, m, f); + } + + /*package-private*/ + @ForceInline + void stLongOp(MemorySegment memory, long offset, FStLongOp f) { + dummyVector().stLongOp(memory, offset, f); + } + + /*package-private*/ + @ForceInline + void stLongOp(MemorySegment memory, long offset, + AbstractMask m, + FStLongOp f) { + dummyVector().stLongOp(memory, offset, m, f); + } + + // N.B. Make sure these constant vectors and + // masks load up correctly into registers. + // + // Also, see if we can avoid all that switching. + // Could we cache both vectors and both masks in + // this species object? + + // Zero and iota vector access + @Override + @ForceInline + public final HalffloatVector zero() { + if ((Class) vectorType() == HalffloatMaxVector.class) + return HalffloatMaxVector.ZERO; + switch (vectorBitSize()) { + case 64: return Halffloat64Vector.ZERO; + case 128: return Halffloat128Vector.ZERO; + case 256: return Halffloat256Vector.ZERO; + case 512: return Halffloat512Vector.ZERO; + } + throw new AssertionError(); + } + + @Override + @ForceInline + public final HalffloatVector iota() { + if ((Class) vectorType() == HalffloatMaxVector.class) + return HalffloatMaxVector.IOTA; + switch (vectorBitSize()) { + case 64: return Halffloat64Vector.IOTA; + case 128: return Halffloat128Vector.IOTA; + case 256: return Halffloat256Vector.IOTA; + case 512: return Halffloat512Vector.IOTA; + } + throw new AssertionError(); + } + + // Mask access + @Override + @ForceInline + public final VectorMask maskAll(boolean bit) { + if ((Class) vectorType() == HalffloatMaxVector.class) + return HalffloatMaxVector.HalffloatMaxMask.maskAll(bit); + switch (vectorBitSize()) { + case 64: return Halffloat64Vector.Halffloat64Mask.maskAll(bit); + case 128: return Halffloat128Vector.Halffloat128Mask.maskAll(bit); + case 256: return Halffloat256Vector.Halffloat256Mask.maskAll(bit); + case 512: return Halffloat512Vector.Halffloat512Mask.maskAll(bit); + } + throw new AssertionError(); + } + } + + /** + * Finds a species for an element type of {@code short} and shape. + * + * @param s the shape + * @return a species for an element type of {@code short} and shape + * @throws IllegalArgumentException if no such species exists for the shape + */ + static HalffloatSpecies species(VectorShape s) { + Objects.requireNonNull(s); + switch (s.switchKey) { + case VectorShape.SK_64_BIT: return (HalffloatSpecies) SPECIES_64; + case VectorShape.SK_128_BIT: return (HalffloatSpecies) SPECIES_128; + case VectorShape.SK_256_BIT: return (HalffloatSpecies) SPECIES_256; + case VectorShape.SK_512_BIT: return (HalffloatSpecies) SPECIES_512; + case VectorShape.SK_Max_BIT: return (HalffloatSpecies) SPECIES_MAX; + default: throw new IllegalArgumentException("Bad shape: " + s); + } + } + + /** Species representing {@link HalffloatVector}s of {@link VectorShape#S_64_BIT VectorShape.S_64_BIT}. */ + public static final VectorSpecies SPECIES_64 + = new HalffloatSpecies(VectorShape.S_64_BIT, + Halffloat64Vector.class, + Halffloat64Vector.Halffloat64Mask.class, + Halffloat64Vector.Halffloat64Shuffle.class, + Halffloat64Vector::new); + + /** Species representing {@link HalffloatVector}s of {@link VectorShape#S_128_BIT VectorShape.S_128_BIT}. */ + public static final VectorSpecies SPECIES_128 + = new HalffloatSpecies(VectorShape.S_128_BIT, + Halffloat128Vector.class, + Halffloat128Vector.Halffloat128Mask.class, + Halffloat128Vector.Halffloat128Shuffle.class, + Halffloat128Vector::new); + + /** Species representing {@link HalffloatVector}s of {@link VectorShape#S_256_BIT VectorShape.S_256_BIT}. */ + public static final VectorSpecies SPECIES_256 + = new HalffloatSpecies(VectorShape.S_256_BIT, + Halffloat256Vector.class, + Halffloat256Vector.Halffloat256Mask.class, + Halffloat256Vector.Halffloat256Shuffle.class, + Halffloat256Vector::new); + + /** Species representing {@link HalffloatVector}s of {@link VectorShape#S_512_BIT VectorShape.S_512_BIT}. */ + public static final VectorSpecies SPECIES_512 + = new HalffloatSpecies(VectorShape.S_512_BIT, + Halffloat512Vector.class, + Halffloat512Vector.Halffloat512Mask.class, + Halffloat512Vector.Halffloat512Shuffle.class, + Halffloat512Vector::new); + + /** Species representing {@link HalffloatVector}s of {@link VectorShape#S_Max_BIT VectorShape.S_Max_BIT}. */ + public static final VectorSpecies SPECIES_MAX + = new HalffloatSpecies(VectorShape.S_Max_BIT, + HalffloatMaxVector.class, + HalffloatMaxVector.HalffloatMaxMask.class, + HalffloatMaxVector.HalffloatMaxShuffle.class, + HalffloatMaxVector::new); + + /** + * Preferred species for {@link HalffloatVector}s. + * A preferred species is a species of maximal bit-size for the platform. + */ + public static final VectorSpecies SPECIES_PREFERRED + = (HalffloatSpecies) VectorSpecies.ofPreferred(Float16.class); +} + diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java index edf45b8772a8a..9949158018c43 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java @@ -54,7 +54,11 @@ final class Int128Vector extends IntVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + + static final Class ETYPE = int.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Int128Vector(int[] v) { super(v); @@ -88,9 +92,12 @@ public IntSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return int.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -529,7 +536,7 @@ public int lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { int[] vecarr = vec.vec(); @@ -552,7 +559,7 @@ public Int128Vector withLane(int i, int e) { @ForceInline public Int128Vector withLaneHelper(int i, int e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { int[] res = v.vec().clone(); @@ -565,7 +572,7 @@ public Int128Vector withLaneHelper(int i, int e) { static final class Int128Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int128Mask(boolean[] bits) { this(bits, 0); @@ -667,7 +674,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Int128Mask indexPartiallyInUpperRange(long offset, long limit) { return (Int128Mask) VectorSupport.indexPartiallyInUpperRange( - Int128Mask.class, int.class, VLENGTH, offset, limit, + Int128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Int128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -683,8 +690,9 @@ public Int128Mask not() { @ForceInline public Int128Mask compress() { return (Int128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int128Vector.class, Int128Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Int128Vector.class, Int128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -695,7 +703,7 @@ public Int128Mask compress() { public Int128Mask and(VectorMask mask) { Objects.requireNonNull(mask); Int128Mask m = (Int128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int128Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Int128Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -705,7 +713,7 @@ public Int128Mask and(VectorMask mask) { public Int128Mask or(VectorMask mask) { Objects.requireNonNull(mask); Int128Mask m = (Int128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int128Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Int128Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -715,7 +723,7 @@ public Int128Mask or(VectorMask mask) { public Int128Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Int128Mask m = (Int128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int128Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Int128Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -725,22 +733,25 @@ public Int128Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int128Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int128Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int128Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -749,7 +760,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int128Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int128Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -759,7 +771,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int128Mask.class, int.class, VLENGTH, + return VectorSupport.extract(Int128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -768,23 +780,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int128Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int128Mask)m).getBits())); + return VectorSupport.test(BT_ne, Int128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Int128Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int128Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Int128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Int128Mask)m).getBits())); } @ForceInline /*package-private*/ static Int128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int128Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Int128Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -797,7 +809,7 @@ static Int128Mask maskAll(boolean bit) { static final class Int128Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int128Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java index bb86ede05e1e2..0eddd456ea22c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java @@ -54,7 +54,11 @@ final class Int256Vector extends IntVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + + static final Class ETYPE = int.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Int256Vector(int[] v) { super(v); @@ -88,9 +92,12 @@ public IntSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return int.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -533,7 +540,7 @@ public int lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { int[] vecarr = vec.vec(); @@ -560,7 +567,7 @@ public Int256Vector withLane(int i, int e) { @ForceInline public Int256Vector withLaneHelper(int i, int e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { int[] res = v.vec().clone(); @@ -573,7 +580,7 @@ public Int256Vector withLaneHelper(int i, int e) { static final class Int256Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int256Mask(boolean[] bits) { this(bits, 0); @@ -675,7 +682,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Int256Mask indexPartiallyInUpperRange(long offset, long limit) { return (Int256Mask) VectorSupport.indexPartiallyInUpperRange( - Int256Mask.class, int.class, VLENGTH, offset, limit, + Int256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Int256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -691,8 +698,9 @@ public Int256Mask not() { @ForceInline public Int256Mask compress() { return (Int256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int256Vector.class, Int256Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Int256Vector.class, Int256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -703,7 +711,7 @@ public Int256Mask compress() { public Int256Mask and(VectorMask mask) { Objects.requireNonNull(mask); Int256Mask m = (Int256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int256Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Int256Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -713,7 +721,7 @@ public Int256Mask and(VectorMask mask) { public Int256Mask or(VectorMask mask) { Objects.requireNonNull(mask); Int256Mask m = (Int256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int256Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Int256Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -723,7 +731,7 @@ public Int256Mask or(VectorMask mask) { public Int256Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Int256Mask m = (Int256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int256Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Int256Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -733,22 +741,25 @@ public Int256Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int256Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int256Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int256Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -757,7 +768,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int256Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int256Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -767,7 +779,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int256Mask.class, int.class, VLENGTH, + return VectorSupport.extract(Int256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -776,23 +788,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int256Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int256Mask)m).getBits())); + return VectorSupport.test(BT_ne, Int256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Int256Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int256Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Int256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Int256Mask)m).getBits())); } @ForceInline /*package-private*/ static Int256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int256Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Int256Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -805,7 +817,7 @@ static Int256Mask maskAll(boolean bit) { static final class Int256Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int256Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java index 16d3b673da0fb..f323f282f1917 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java @@ -54,7 +54,11 @@ final class Int512Vector extends IntVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + + static final Class ETYPE = int.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Int512Vector(int[] v) { super(v); @@ -88,9 +92,12 @@ public IntSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return int.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -541,7 +548,7 @@ public int lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { int[] vecarr = vec.vec(); @@ -576,7 +583,7 @@ public Int512Vector withLane(int i, int e) { @ForceInline public Int512Vector withLaneHelper(int i, int e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { int[] res = v.vec().clone(); @@ -589,7 +596,7 @@ public Int512Vector withLaneHelper(int i, int e) { static final class Int512Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int512Mask(boolean[] bits) { this(bits, 0); @@ -691,7 +698,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Int512Mask indexPartiallyInUpperRange(long offset, long limit) { return (Int512Mask) VectorSupport.indexPartiallyInUpperRange( - Int512Mask.class, int.class, VLENGTH, offset, limit, + Int512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Int512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -707,8 +714,9 @@ public Int512Mask not() { @ForceInline public Int512Mask compress() { return (Int512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int512Vector.class, Int512Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Int512Vector.class, Int512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -719,7 +727,7 @@ public Int512Mask compress() { public Int512Mask and(VectorMask mask) { Objects.requireNonNull(mask); Int512Mask m = (Int512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int512Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Int512Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -729,7 +737,7 @@ public Int512Mask and(VectorMask mask) { public Int512Mask or(VectorMask mask) { Objects.requireNonNull(mask); Int512Mask m = (Int512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int512Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Int512Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -739,7 +747,7 @@ public Int512Mask or(VectorMask mask) { public Int512Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Int512Mask m = (Int512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int512Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Int512Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -749,22 +757,25 @@ public Int512Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int512Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int512Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int512Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -773,7 +784,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int512Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int512Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -783,7 +795,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int512Mask.class, int.class, VLENGTH, + return VectorSupport.extract(Int512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -792,23 +804,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int512Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int512Mask)m).getBits())); + return VectorSupport.test(BT_ne, Int512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Int512Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int512Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Int512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Int512Mask)m).getBits())); } @ForceInline /*package-private*/ static Int512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int512Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Int512Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -821,7 +833,7 @@ static Int512Mask maskAll(boolean bit) { static final class Int512Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int512Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java index d55364a8d670c..4836e58118ca3 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java @@ -54,7 +54,11 @@ final class Int64Vector extends IntVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + + static final Class ETYPE = int.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Int64Vector(int[] v) { super(v); @@ -88,9 +92,12 @@ public IntSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return int.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -527,7 +534,7 @@ public int lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { int[] vecarr = vec.vec(); @@ -548,7 +555,7 @@ public Int64Vector withLane(int i, int e) { @ForceInline public Int64Vector withLaneHelper(int i, int e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { int[] res = v.vec().clone(); @@ -561,7 +568,7 @@ public Int64Vector withLaneHelper(int i, int e) { static final class Int64Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int64Mask(boolean[] bits) { this(bits, 0); @@ -663,7 +670,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Int64Mask indexPartiallyInUpperRange(long offset, long limit) { return (Int64Mask) VectorSupport.indexPartiallyInUpperRange( - Int64Mask.class, int.class, VLENGTH, offset, limit, + Int64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Int64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -679,8 +686,9 @@ public Int64Mask not() { @ForceInline public Int64Mask compress() { return (Int64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Int64Vector.class, Int64Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Int64Vector.class, Int64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -691,7 +699,7 @@ public Int64Mask compress() { public Int64Mask and(VectorMask mask) { Objects.requireNonNull(mask); Int64Mask m = (Int64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Int64Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Int64Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -701,7 +709,7 @@ public Int64Mask and(VectorMask mask) { public Int64Mask or(VectorMask mask) { Objects.requireNonNull(mask); Int64Mask m = (Int64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Int64Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Int64Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -711,7 +719,7 @@ public Int64Mask or(VectorMask mask) { public Int64Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Int64Mask m = (Int64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Int64Mask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Int64Mask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -721,22 +729,25 @@ public Int64Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int64Mask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Int64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int64Mask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Int64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int64Mask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Int64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -745,7 +756,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int64Mask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Int64Mask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -755,7 +767,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Int64Mask.class, int.class, VLENGTH, + return VectorSupport.extract(Int64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -764,23 +776,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Int64Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Int64Mask)m).getBits())); + return VectorSupport.test(BT_ne, Int64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Int64Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Int64Mask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Int64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Int64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Int64Mask)m).getBits())); } @ForceInline /*package-private*/ static Int64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Int64Mask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Int64Mask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -793,7 +805,7 @@ static Int64Mask maskAll(boolean bit) { static final class Int64Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM Int64Shuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java index 0a1cd45eb93b0..eef9dfa624d81 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java @@ -54,7 +54,11 @@ final class IntMaxVector extends IntVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // carrier type used by the JVM + + static final Class ETYPE = int.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; IntMaxVector(int[] v) { super(v); @@ -88,9 +92,12 @@ public IntSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return int.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -526,7 +533,7 @@ public int lane(int i) { @ForceInline public int laneHelper(int i) { return (int) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { int[] vecarr = vec.vec(); @@ -546,7 +553,7 @@ public IntMaxVector withLane(int i, int e) { @ForceInline public IntMaxVector withLaneHelper(int i, int e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { int[] res = v.vec().clone(); @@ -559,7 +566,7 @@ public IntMaxVector withLaneHelper(int i, int e) { static final class IntMaxMask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM IntMaxMask(boolean[] bits) { this(bits, 0); @@ -661,7 +668,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ IntMaxMask indexPartiallyInUpperRange(long offset, long limit) { return (IntMaxMask) VectorSupport.indexPartiallyInUpperRange( - IntMaxMask.class, int.class, VLENGTH, offset, limit, + IntMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (IntMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -677,8 +684,9 @@ public IntMaxMask not() { @ForceInline public IntMaxMask compress() { return (IntMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - IntMaxVector.class, IntMaxMask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + IntMaxVector.class, IntMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -689,7 +697,7 @@ public IntMaxMask compress() { public IntMaxMask and(VectorMask mask) { Objects.requireNonNull(mask); IntMaxMask m = (IntMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, IntMaxMask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, IntMaxMask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -699,7 +707,7 @@ public IntMaxMask and(VectorMask mask) { public IntMaxMask or(VectorMask mask) { Objects.requireNonNull(mask); IntMaxMask m = (IntMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, IntMaxMask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, IntMaxMask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -709,7 +717,7 @@ public IntMaxMask or(VectorMask mask) { public IntMaxMask xor(VectorMask mask) { Objects.requireNonNull(mask); IntMaxMask m = (IntMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMaxMask.class, null, int.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, IntMaxMask.class, null, int.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -719,22 +727,25 @@ public IntMaxMask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMaxMask.class, int.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, IntMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMaxMask.class, int.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, IntMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMaxMask.class, int.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, IntMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -743,7 +754,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMaxMask.class, int.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, IntMaxMask.class, int.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -753,7 +765,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(IntMaxMask.class, int.class, VLENGTH, + return VectorSupport.extract(IntMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -762,23 +774,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, IntMaxMask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((IntMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, IntMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((IntMaxMask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, IntMaxMask.class, int.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((IntMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, IntMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((IntMaxMask)m).getBits())); } @ForceInline /*package-private*/ static IntMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(IntMaxMask.class, int.class, VLENGTH, + return VectorSupport.fromBitsCoerced(IntMaxMask.class, int.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -802,7 +814,7 @@ static boolean[] maskLowerHalf() { static final class IntMaxShuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = int.class; // used by the JVM + static final Class CTYPE = int.class; // used by the JVM IntMaxShuffle(int[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index 43356b9ea6c9e..89976a052183b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -57,6 +57,8 @@ public abstract class IntVector extends AbstractVector { static final int FORBID_OPCODE_KIND = VO_ONLYFP; + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; + static final ValueLayout.OfInt ELEMENT_LAYOUT = ValueLayout.JAVA_INT.withByteAlignment(1); @ForceInline @@ -573,7 +575,7 @@ static IntVector selectFromTwoVectorHelper(Vector indexes, Vector species) { IntSpecies vsp = (IntSpecies) species; - return VectorSupport.fromBitsCoerced(vsp.vectorType(), int.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), int.class, VECTOR_OPER_TYPE, species.length(), 0, MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); } @@ -695,7 +697,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, int.class, length(), + opc, getClass(), null, int.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, IntVector::unaryOperations)); } @@ -723,7 +725,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, int.class, length(), + opc, getClass(), maskClass, int.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, IntVector::unaryOperations)); } @@ -796,7 +798,7 @@ IntVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, int.class, length(), + opc, getClass(), null, int.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, IntVector::binaryOperations)); } @@ -847,7 +849,7 @@ IntVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, int.class, length(), + opc, getClass(), maskClass, int.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, IntVector::binaryOperations)); } @@ -1038,7 +1040,7 @@ IntVector lanewise(VectorOperators.Binary op, e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), null, int.class, length(), + opc, getClass(), null, int.class, VECTOR_OPER_TYPE, length(), this, e, null, BIN_INT_IMPL.find(op, opc, IntVector::broadcastIntOperations)); } @@ -1059,7 +1061,7 @@ opc, getClass(), null, int.class, length(), e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), maskClass, int.class, length(), + opc, getClass(), maskClass, int.class, VECTOR_OPER_TYPE, length(), this, e, m, BIN_INT_IMPL.find(op, opc, IntVector::broadcastIntOperations)); } @@ -1135,7 +1137,7 @@ IntVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, int.class, length(), + opc, getClass(), null, int.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, IntVector::ternaryOperations)); } @@ -1175,7 +1177,7 @@ IntVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, int.class, length(), + opc, getClass(), maskClass, int.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, IntVector::ternaryOperations)); } @@ -2055,7 +2057,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v) { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, int.class, length(), + opc, getClass(), maskType, int.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask m @@ -2077,7 +2079,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v, M m) { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, int.class, length(), + opc, getClass(), maskType, int.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask cmpM @@ -2208,7 +2210,7 @@ VectorMask compare(Comparison op, long e, VectorMask m) { blendTemplate(Class maskType, IntVector v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, int.class, length(), + getClass(), maskType, int.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2225,7 +2227,7 @@ final IntVector addIndexTemplate(int scale) { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), int.class, length(), + getClass(), int.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2417,7 +2419,7 @@ IntVector sliceTemplate(int origin) { IntVector rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, int.class, length(), + getClass(), shuffletype, null, int.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2444,7 +2446,7 @@ IntVector rearrangeTemplate(Class shuffletype, Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, int.class, length(), + getClass(), shuffletype, masktype, int.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2470,7 +2472,7 @@ IntVector rearrangeTemplate(Class shuffletype, VectorMask valid = shuffle.laneIsValid(); IntVector r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, int.class, length(), + getClass(), shuffletype, null, int.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2478,7 +2480,7 @@ IntVector rearrangeTemplate(Class shuffletype, })); IntVector r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, int.class, length(), + getClass(), shuffletype, null, int.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2528,7 +2530,7 @@ VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { IntVector compressTemplate(Class masktype, M m) { m.check(masktype, this); return (IntVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - int.class, length(), this, m, + int.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -2547,7 +2549,7 @@ int.class, length(), this, m, IntVector expandTemplate(Class masktype, M m) { m.check(masktype, this); return (IntVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - int.class, length(), this, m, + int.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -2562,7 +2564,7 @@ int.class, length(), this, m, /*package-private*/ @ForceInline final IntVector selectFromTemplate(IntVector v) { - return (IntVector)VectorSupport.selectFromOp(getClass(), null, int.class, + return (IntVector)VectorSupport.selectFromOp(getClass(), null, int.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -2582,7 +2584,7 @@ final IntVector selectFromTemplate(IntVector v) { IntVector selectFromTemplate(IntVector v, Class masktype, M m) { m.check(masktype, this); - return (IntVector)VectorSupport.selectFromOp(getClass(), masktype, int.class, + return (IntVector)VectorSupport.selectFromOp(getClass(), masktype, int.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -2600,7 +2602,7 @@ IntVector selectFromTemplate(IntVector v, /*package-private*/ @ForceInline final IntVector selectFromTemplate(IntVector v1, IntVector v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), int.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), int.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -2820,7 +2822,7 @@ int reduceLanesTemplate(VectorOperators.Associative op, } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, int.class, length(), + opc, getClass(), maskClass, int.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, IntVector::reductionOperations))); } @@ -2838,7 +2840,7 @@ int reduceLanesTemplate(VectorOperators.Associative op) { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, int.class, length(), + opc, getClass(), null, int.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, IntVector::reductionOperations))); } @@ -3098,7 +3100,7 @@ IntVector fromArray(VectorSpecies species, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, null, int.class, vsp.laneCount(), + vectorType, null, int.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -3281,7 +3283,7 @@ void intoArray(int[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); IntSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -3370,7 +3372,7 @@ void intoArray(int[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), null, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), null, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, null, @@ -3497,7 +3499,7 @@ void intoMemorySegment(MemorySegment ms, long offset, IntVector fromArray0Template(int[] a, int offset) { IntSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3514,7 +3516,7 @@ IntVector fromArray0Template(Class maskClass, int[] a, int offset, M m, int o m.check(species()); IntSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3547,7 +3549,7 @@ IntVector fromArray0Template(Class maskClass, int[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, maskClass, int.class, vsp.laneCount(), + vectorType, maskClass, int.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -3564,7 +3566,7 @@ IntVector fromArray0Template(Class maskClass, int[] a, int offset, IntVector fromMemorySegment0Template(MemorySegment ms, long offset) { IntSpecies vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, IntVector::memorySegmentGet); @@ -3580,7 +3582,7 @@ IntVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long IntSpecies vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, IntVector::memorySegmentGet); @@ -3598,7 +3600,7 @@ IntVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long void intoArray0Template(int[] a, int offset) { IntSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -3615,7 +3617,7 @@ void intoArray0Template(Class maskClass, int[] a, int offset, M m) { m.check(species()); IntSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -3644,7 +3646,7 @@ void intoArray0Template(Class maskClass, int[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, m, @@ -3663,7 +3665,7 @@ a, arrayAddress(a, 0), vix, void intoMemorySegment0(MemorySegment ms, long offset) { IntSpecies vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -3680,7 +3682,7 @@ void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offse IntSpecies vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -3852,6 +3854,19 @@ private IntSpecies(VectorShape shape, // Specializing overrides: + @ForceInline + final Class carrierType() { + return int.class; + } + + @ForceInline + final int operType() { + if (int.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class elementType() { @@ -3884,7 +3899,7 @@ public final long checkValue(long e) { final IntVector broadcastBits(long bits) { return (IntVector) VectorSupport.fromBitsCoerced( - vectorType, int.class, laneCount, + vectorType, int.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java index 53fa773555f90..40c920fa59990 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LaneType.java @@ -40,7 +40,8 @@ enum LaneType { BYTE(byte.class, Byte.class, byte[].class, 'I', -1, Byte.SIZE, T_BYTE), SHORT(short.class, Short.class, short[].class, 'I', -1, Short.SIZE, T_SHORT), INT(int.class, Integer.class, int[].class, 'I', -1, Integer.SIZE, T_INT), - LONG(long.class, Long.class, long[].class, 'I', -1, Long.SIZE, T_LONG); + LONG(long.class, Long.class, long[].class, 'I', -1, Long.SIZE, T_LONG), + HALFFLOAT(Float16.class, Short.class, short[].class, 'F', 11, Float16.SIZE, T_HALFFLOAT); LaneType(Class elementType, Class genericElementType, @@ -66,13 +67,18 @@ enum LaneType { // printName. If we do unsigned or vector or bit lane types, // report that condition also. this.typeChar = genericElementType.getSimpleName().charAt(0); - assert("FDBSIL".indexOf(typeChar) == ordinal()) : this; + if (basicType == T_HALFFLOAT) { + assert("FDBSILS".indexOf(typeChar, "FDBSILS".indexOf(typeChar) + 1) == ordinal()) : this; + } + else { + assert("FDBSILS".indexOf(typeChar) == ordinal()) : this; + } // Same as in JVMS, org.objectweb.asm.Opcodes, etc.: this.basicType = basicType; assert(basicType == ( (elementSizeLog2 - /*lg(Byte.SIZE)*/ 3) | (elementKind == 'F' ? 4 : 8))) : this; - assert("....zcFDBSILoav..".charAt(basicType) == typeChar); + assert("....zSFDBSILSoav..".charAt(basicType) == typeChar); } final Class elementType; @@ -178,13 +184,14 @@ RuntimeException badElementType(Class elementType, Object expected) { // don't optimize properly; see JDK-8161245 static final int - SK_FLOAT = 1, - SK_DOUBLE = 2, - SK_BYTE = 3, - SK_SHORT = 4, - SK_INT = 5, - SK_LONG = 6, - SK_LIMIT = 7; + SK_FLOAT = 1, + SK_DOUBLE = 2, + SK_BYTE = 3, + SK_SHORT = 4, + SK_INT = 5, + SK_LONG = 6, + SK_HALFFLOAT = 7, + SK_LIMIT = 8; /*package-private*/ @ForceInline diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java index 5a47153837a88..d60d26702b705 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java @@ -54,7 +54,11 @@ final class Long128Vector extends LongVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + + static final Class ETYPE = long.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Long128Vector(long[] v) { super(v); @@ -88,9 +92,12 @@ public LongSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return long.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -517,7 +524,7 @@ public long lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { long[] vecarr = vec.vec(); @@ -538,7 +545,7 @@ public Long128Vector withLane(int i, long e) { @ForceInline public Long128Vector withLaneHelper(int i, long e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { long[] res = v.vec().clone(); @@ -551,7 +558,7 @@ public Long128Vector withLaneHelper(int i, long e) { static final class Long128Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long128Mask(boolean[] bits) { this(bits, 0); @@ -653,7 +660,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Long128Mask indexPartiallyInUpperRange(long offset, long limit) { return (Long128Mask) VectorSupport.indexPartiallyInUpperRange( - Long128Mask.class, long.class, VLENGTH, offset, limit, + Long128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Long128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -669,8 +676,9 @@ public Long128Mask not() { @ForceInline public Long128Mask compress() { return (Long128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long128Vector.class, Long128Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Long128Vector.class, Long128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -681,7 +689,7 @@ public Long128Mask compress() { public Long128Mask and(VectorMask mask) { Objects.requireNonNull(mask); Long128Mask m = (Long128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long128Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Long128Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -691,7 +699,7 @@ public Long128Mask and(VectorMask mask) { public Long128Mask or(VectorMask mask) { Objects.requireNonNull(mask); Long128Mask m = (Long128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long128Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Long128Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -701,7 +709,7 @@ public Long128Mask or(VectorMask mask) { public Long128Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Long128Mask m = (Long128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long128Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Long128Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -711,22 +719,25 @@ public Long128Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long128Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long128Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long128Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -735,7 +746,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long128Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long128Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -745,7 +757,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long128Mask.class, long.class, VLENGTH, + return VectorSupport.extract(Long128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -754,23 +766,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long128Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long128Mask)m).getBits())); + return VectorSupport.test(BT_ne, Long128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Long128Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long128Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Long128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Long128Mask)m).getBits())); } @ForceInline /*package-private*/ static Long128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long128Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Long128Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -783,7 +795,7 @@ static Long128Mask maskAll(boolean bit) { static final class Long128Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long128Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java index 9c3ff7627ccbd..4f7f2e629fd92 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java @@ -54,7 +54,11 @@ final class Long256Vector extends LongVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + + static final Class ETYPE = long.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Long256Vector(long[] v) { super(v); @@ -88,9 +92,12 @@ public LongSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return long.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -519,7 +526,7 @@ public long lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { long[] vecarr = vec.vec(); @@ -542,7 +549,7 @@ public Long256Vector withLane(int i, long e) { @ForceInline public Long256Vector withLaneHelper(int i, long e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { long[] res = v.vec().clone(); @@ -555,7 +562,7 @@ public Long256Vector withLaneHelper(int i, long e) { static final class Long256Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long256Mask(boolean[] bits) { this(bits, 0); @@ -657,7 +664,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Long256Mask indexPartiallyInUpperRange(long offset, long limit) { return (Long256Mask) VectorSupport.indexPartiallyInUpperRange( - Long256Mask.class, long.class, VLENGTH, offset, limit, + Long256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Long256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -673,8 +680,9 @@ public Long256Mask not() { @ForceInline public Long256Mask compress() { return (Long256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long256Vector.class, Long256Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Long256Vector.class, Long256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -685,7 +693,7 @@ public Long256Mask compress() { public Long256Mask and(VectorMask mask) { Objects.requireNonNull(mask); Long256Mask m = (Long256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long256Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Long256Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -695,7 +703,7 @@ public Long256Mask and(VectorMask mask) { public Long256Mask or(VectorMask mask) { Objects.requireNonNull(mask); Long256Mask m = (Long256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long256Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Long256Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -705,7 +713,7 @@ public Long256Mask or(VectorMask mask) { public Long256Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Long256Mask m = (Long256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long256Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Long256Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -715,22 +723,25 @@ public Long256Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long256Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long256Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long256Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -739,7 +750,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long256Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long256Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -749,7 +761,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long256Mask.class, long.class, VLENGTH, + return VectorSupport.extract(Long256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -758,23 +770,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long256Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long256Mask)m).getBits())); + return VectorSupport.test(BT_ne, Long256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Long256Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long256Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Long256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Long256Mask)m).getBits())); } @ForceInline /*package-private*/ static Long256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long256Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Long256Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -787,7 +799,7 @@ static Long256Mask maskAll(boolean bit) { static final class Long256Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long256Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java index 30d29c3cd035f..8f763f974d757 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java @@ -54,7 +54,11 @@ final class Long512Vector extends LongVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + + static final Class ETYPE = long.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Long512Vector(long[] v) { super(v); @@ -88,9 +92,12 @@ public LongSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return long.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -523,7 +530,7 @@ public long lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { long[] vecarr = vec.vec(); @@ -550,7 +557,7 @@ public Long512Vector withLane(int i, long e) { @ForceInline public Long512Vector withLaneHelper(int i, long e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { long[] res = v.vec().clone(); @@ -563,7 +570,7 @@ public Long512Vector withLaneHelper(int i, long e) { static final class Long512Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long512Mask(boolean[] bits) { this(bits, 0); @@ -665,7 +672,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Long512Mask indexPartiallyInUpperRange(long offset, long limit) { return (Long512Mask) VectorSupport.indexPartiallyInUpperRange( - Long512Mask.class, long.class, VLENGTH, offset, limit, + Long512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Long512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -681,8 +688,9 @@ public Long512Mask not() { @ForceInline public Long512Mask compress() { return (Long512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long512Vector.class, Long512Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Long512Vector.class, Long512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -693,7 +701,7 @@ public Long512Mask compress() { public Long512Mask and(VectorMask mask) { Objects.requireNonNull(mask); Long512Mask m = (Long512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long512Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Long512Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -703,7 +711,7 @@ public Long512Mask and(VectorMask mask) { public Long512Mask or(VectorMask mask) { Objects.requireNonNull(mask); Long512Mask m = (Long512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long512Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Long512Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -713,7 +721,7 @@ public Long512Mask or(VectorMask mask) { public Long512Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Long512Mask m = (Long512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long512Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Long512Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -723,22 +731,25 @@ public Long512Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long512Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long512Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long512Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -747,7 +758,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long512Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long512Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -757,7 +769,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long512Mask.class, long.class, VLENGTH, + return VectorSupport.extract(Long512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -766,23 +778,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long512Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long512Mask)m).getBits())); + return VectorSupport.test(BT_ne, Long512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Long512Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long512Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Long512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Long512Mask)m).getBits())); } @ForceInline /*package-private*/ static Long512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long512Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Long512Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -795,7 +807,7 @@ static Long512Mask maskAll(boolean bit) { static final class Long512Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long512Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java index 518baa168ec8e..666f5c3dc746a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java @@ -54,7 +54,11 @@ final class Long64Vector extends LongVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + + static final Class ETYPE = long.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Long64Vector(long[] v) { super(v); @@ -88,9 +92,12 @@ public LongSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return long.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -516,7 +523,7 @@ public long lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { long[] vecarr = vec.vec(); @@ -536,7 +543,7 @@ public Long64Vector withLane(int i, long e) { @ForceInline public Long64Vector withLaneHelper(int i, long e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { long[] res = v.vec().clone(); @@ -549,7 +556,7 @@ public Long64Vector withLaneHelper(int i, long e) { static final class Long64Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long64Mask(boolean[] bits) { this(bits, 0); @@ -651,7 +658,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Long64Mask indexPartiallyInUpperRange(long offset, long limit) { return (Long64Mask) VectorSupport.indexPartiallyInUpperRange( - Long64Mask.class, long.class, VLENGTH, offset, limit, + Long64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Long64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -667,8 +674,9 @@ public Long64Mask not() { @ForceInline public Long64Mask compress() { return (Long64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Long64Vector.class, Long64Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Long64Vector.class, Long64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -679,7 +687,7 @@ public Long64Mask compress() { public Long64Mask and(VectorMask mask) { Objects.requireNonNull(mask); Long64Mask m = (Long64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Long64Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Long64Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -689,7 +697,7 @@ public Long64Mask and(VectorMask mask) { public Long64Mask or(VectorMask mask) { Objects.requireNonNull(mask); Long64Mask m = (Long64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Long64Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Long64Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -699,7 +707,7 @@ public Long64Mask or(VectorMask mask) { public Long64Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Long64Mask m = (Long64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Long64Mask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Long64Mask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -709,22 +717,25 @@ public Long64Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long64Mask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Long64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long64Mask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Long64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long64Mask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Long64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -733,7 +744,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long64Mask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Long64Mask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -743,7 +755,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Long64Mask.class, long.class, VLENGTH, + return VectorSupport.extract(Long64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -752,23 +764,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Long64Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Long64Mask)m).getBits())); + return VectorSupport.test(BT_ne, Long64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Long64Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Long64Mask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Long64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Long64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Long64Mask)m).getBits())); } @ForceInline /*package-private*/ static Long64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Long64Mask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Long64Mask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -781,7 +793,7 @@ static Long64Mask maskAll(boolean bit) { static final class Long64Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM Long64Shuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java index 3d981c37ae256..349459b44a45e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java @@ -54,7 +54,11 @@ final class LongMaxVector extends LongVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // carrier type used by the JVM + + static final Class ETYPE = long.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; LongMaxVector(long[] v) { super(v); @@ -88,9 +92,12 @@ public LongSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return long.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -516,7 +523,7 @@ public long lane(int i) { @ForceInline public long laneHelper(int i) { return (long) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { long[] vecarr = vec.vec(); @@ -536,7 +543,7 @@ public LongMaxVector withLane(int i, long e) { @ForceInline public LongMaxVector withLaneHelper(int i, long e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { long[] res = v.vec().clone(); @@ -549,7 +556,7 @@ public LongMaxVector withLaneHelper(int i, long e) { static final class LongMaxMask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM LongMaxMask(boolean[] bits) { this(bits, 0); @@ -651,7 +658,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ LongMaxMask indexPartiallyInUpperRange(long offset, long limit) { return (LongMaxMask) VectorSupport.indexPartiallyInUpperRange( - LongMaxMask.class, long.class, VLENGTH, offset, limit, + LongMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (LongMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -667,8 +674,9 @@ public LongMaxMask not() { @ForceInline public LongMaxMask compress() { return (LongMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - LongMaxVector.class, LongMaxMask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + LongMaxVector.class, LongMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -679,7 +687,7 @@ public LongMaxMask compress() { public LongMaxMask and(VectorMask mask) { Objects.requireNonNull(mask); LongMaxMask m = (LongMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, LongMaxMask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, LongMaxMask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -689,7 +697,7 @@ public LongMaxMask and(VectorMask mask) { public LongMaxMask or(VectorMask mask) { Objects.requireNonNull(mask); LongMaxMask m = (LongMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, LongMaxMask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, LongMaxMask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -699,7 +707,7 @@ public LongMaxMask or(VectorMask mask) { public LongMaxMask xor(VectorMask mask) { Objects.requireNonNull(mask); LongMaxMask m = (LongMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMaxMask.class, null, long.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, LongMaxMask.class, null, long.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -709,22 +717,25 @@ public LongMaxMask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMaxMask.class, long.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, LongMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMaxMask.class, long.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, LongMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMaxMask.class, long.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, LongMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -733,7 +744,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMaxMask.class, long.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, LongMaxMask.class, long.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -743,7 +755,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(LongMaxMask.class, long.class, VLENGTH, + return VectorSupport.extract(LongMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -752,23 +764,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, LongMaxMask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((LongMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, LongMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((LongMaxMask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, LongMaxMask.class, long.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((LongMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, LongMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((LongMaxMask)m).getBits())); } @ForceInline /*package-private*/ static LongMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(LongMaxMask.class, long.class, VLENGTH, + return VectorSupport.fromBitsCoerced(LongMaxMask.class, long.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -781,7 +793,7 @@ static LongMaxMask maskAll(boolean bit) { static final class LongMaxShuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = long.class; // used by the JVM + static final Class CTYPE = long.class; // used by the JVM LongMaxShuffle(long[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 8947343ff306b..8bbb5e09db80c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -57,6 +57,8 @@ public abstract class LongVector extends AbstractVector { static final int FORBID_OPCODE_KIND = VO_ONLYFP; + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; + static final ValueLayout.OfLong ELEMENT_LAYOUT = ValueLayout.JAVA_LONG.withByteAlignment(1); @ForceInline @@ -573,7 +575,7 @@ static LongVector selectFromTwoVectorHelper(Vector indexes, Vector s @ForceInline public static LongVector zero(VectorSpecies species) { LongSpecies vsp = (LongSpecies) species; - return VectorSupport.fromBitsCoerced(vsp.vectorType(), long.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), long.class, VECTOR_OPER_TYPE, species.length(), 0, MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); } @@ -653,7 +655,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, long.class, length(), + opc, getClass(), null, long.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, LongVector::unaryOperations)); } @@ -681,7 +683,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, long.class, length(), + opc, getClass(), maskClass, long.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, LongVector::unaryOperations)); } @@ -754,7 +756,7 @@ LongVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, long.class, length(), + opc, getClass(), null, long.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, LongVector::binaryOperations)); } @@ -805,7 +807,7 @@ LongVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, long.class, length(), + opc, getClass(), maskClass, long.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, LongVector::binaryOperations)); } @@ -951,7 +953,7 @@ LongVector lanewise(VectorOperators.Binary op, e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), null, long.class, length(), + opc, getClass(), null, long.class, VECTOR_OPER_TYPE, length(), this, e, null, BIN_INT_IMPL.find(op, opc, LongVector::broadcastIntOperations)); } @@ -972,7 +974,7 @@ opc, getClass(), null, long.class, length(), e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), maskClass, long.class, length(), + opc, getClass(), maskClass, long.class, VECTOR_OPER_TYPE, length(), this, e, m, BIN_INT_IMPL.find(op, opc, LongVector::broadcastIntOperations)); } @@ -1048,7 +1050,7 @@ LongVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, long.class, length(), + opc, getClass(), null, long.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, LongVector::ternaryOperations)); } @@ -1088,7 +1090,7 @@ LongVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, long.class, length(), + opc, getClass(), maskClass, long.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, LongVector::ternaryOperations)); } @@ -1968,7 +1970,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v) { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, long.class, length(), + opc, getClass(), maskType, long.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask m @@ -1990,7 +1992,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v, M m) { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, long.class, length(), + opc, getClass(), maskType, long.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask cmpM @@ -2095,7 +2097,7 @@ public final VectorMask compare(VectorOperators.Comparison op, blendTemplate(Class maskType, LongVector v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, long.class, length(), + getClass(), maskType, long.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2112,7 +2114,7 @@ final LongVector addIndexTemplate(int scale) { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), long.class, length(), + getClass(), long.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2283,7 +2285,7 @@ LongVector sliceTemplate(int origin) { LongVector rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, long.class, length(), + getClass(), shuffletype, null, long.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2310,7 +2312,7 @@ LongVector rearrangeTemplate(Class shuffletype, Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, long.class, length(), + getClass(), shuffletype, masktype, long.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2336,7 +2338,7 @@ LongVector rearrangeTemplate(Class shuffletype, VectorMask valid = shuffle.laneIsValid(); LongVector r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, long.class, length(), + getClass(), shuffletype, null, long.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2344,7 +2346,7 @@ LongVector rearrangeTemplate(Class shuffletype, })); LongVector r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, long.class, length(), + getClass(), shuffletype, null, long.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2394,7 +2396,7 @@ VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { LongVector compressTemplate(Class masktype, M m) { m.check(masktype, this); return (LongVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - long.class, length(), this, m, + long.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -2413,7 +2415,7 @@ long.class, length(), this, m, LongVector expandTemplate(Class masktype, M m) { m.check(masktype, this); return (LongVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - long.class, length(), this, m, + long.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -2428,7 +2430,7 @@ long.class, length(), this, m, /*package-private*/ @ForceInline final LongVector selectFromTemplate(LongVector v) { - return (LongVector)VectorSupport.selectFromOp(getClass(), null, long.class, + return (LongVector)VectorSupport.selectFromOp(getClass(), null, long.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -2448,7 +2450,7 @@ final LongVector selectFromTemplate(LongVector v) { LongVector selectFromTemplate(LongVector v, Class masktype, M m) { m.check(masktype, this); - return (LongVector)VectorSupport.selectFromOp(getClass(), masktype, long.class, + return (LongVector)VectorSupport.selectFromOp(getClass(), masktype, long.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -2466,7 +2468,7 @@ LongVector selectFromTemplate(LongVector v, /*package-private*/ @ForceInline final LongVector selectFromTemplate(LongVector v1, LongVector v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), long.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), long.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -2686,7 +2688,7 @@ long reduceLanesTemplate(VectorOperators.Associative op, } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, long.class, length(), + opc, getClass(), maskClass, long.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, LongVector::reductionOperations))); } @@ -2704,7 +2706,7 @@ long reduceLanesTemplate(VectorOperators.Associative op) { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, long.class, length(), + opc, getClass(), null, long.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, LongVector::reductionOperations))); } @@ -2977,7 +2979,7 @@ LongVector fromArray(VectorSpecies species, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, null, long.class, vsp.laneCount(), + vectorType, null, long.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -3160,7 +3162,7 @@ void intoArray(long[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); LongSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -3268,7 +3270,7 @@ void intoArray(long[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), null, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), null, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, null, @@ -3395,7 +3397,7 @@ void intoMemorySegment(MemorySegment ms, long offset, LongVector fromArray0Template(long[] a, int offset) { LongSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3412,7 +3414,7 @@ LongVector fromArray0Template(Class maskClass, long[] a, int offset, M m, int m.check(species()); LongSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3463,7 +3465,7 @@ LongVector fromArray0Template(Class maskClass, long[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, maskClass, long.class, vsp.laneCount(), + vectorType, maskClass, long.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -3480,7 +3482,7 @@ LongVector fromArray0Template(Class maskClass, long[] a, int offset, LongVector fromMemorySegment0Template(MemorySegment ms, long offset) { LongSpecies vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, LongVector::memorySegmentGet); @@ -3496,7 +3498,7 @@ LongVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long LongSpecies vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, LongVector::memorySegmentGet); @@ -3514,7 +3516,7 @@ LongVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, long void intoArray0Template(long[] a, int offset) { LongSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -3531,7 +3533,7 @@ void intoArray0Template(Class maskClass, long[] a, int offset, M m) { m.check(species()); LongSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -3579,7 +3581,7 @@ void intoArray0Template(Class maskClass, long[] a, int offset, vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, m, @@ -3598,7 +3600,7 @@ a, arrayAddress(a, 0), vix, void intoMemorySegment0(MemorySegment ms, long offset) { LongSpecies vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -3615,7 +3617,7 @@ void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offse LongSpecies vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -3787,6 +3789,19 @@ private LongSpecies(VectorShape shape, // Specializing overrides: + @ForceInline + final Class carrierType() { + return long.class; + } + + @ForceInline + final int operType() { + if (long.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class elementType() { @@ -3819,7 +3834,7 @@ public final long checkValue(long e) { final LongVector broadcastBits(long bits) { return (LongVector) VectorSupport.fromBitsCoerced( - vectorType, long.class, laneCount, + vectorType, long.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java index 60f22eb5fb923..66b3073636f6a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java @@ -54,7 +54,11 @@ final class Short128Vector extends ShortVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = short.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Short128Vector(short[] v) { super(v); @@ -88,9 +92,12 @@ public ShortSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return short.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -533,7 +540,7 @@ public short lane(int i) { @ForceInline public short laneHelper(int i) { return (short) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { short[] vecarr = vec.vec(); @@ -560,7 +567,7 @@ public Short128Vector withLane(int i, short e) { @ForceInline public Short128Vector withLaneHelper(int i, short e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); @@ -573,7 +580,7 @@ public Short128Vector withLaneHelper(int i, short e) { static final class Short128Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short128Mask(boolean[] bits) { this(bits, 0); @@ -675,7 +682,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Short128Mask indexPartiallyInUpperRange(long offset, long limit) { return (Short128Mask) VectorSupport.indexPartiallyInUpperRange( - Short128Mask.class, short.class, VLENGTH, offset, limit, + Short128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Short128Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -691,8 +698,9 @@ public Short128Mask not() { @ForceInline public Short128Mask compress() { return (Short128Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short128Vector.class, Short128Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Short128Vector.class, Short128Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -703,7 +711,7 @@ public Short128Mask compress() { public Short128Mask and(VectorMask mask) { Objects.requireNonNull(mask); Short128Mask m = (Short128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short128Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Short128Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -713,7 +721,7 @@ public Short128Mask and(VectorMask mask) { public Short128Mask or(VectorMask mask) { Objects.requireNonNull(mask); Short128Mask m = (Short128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short128Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Short128Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -723,7 +731,7 @@ public Short128Mask or(VectorMask mask) { public Short128Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Short128Mask m = (Short128Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short128Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Short128Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -733,22 +741,25 @@ public Short128Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short128Mask.class, short.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short128Mask.class, short.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short128Mask.class, short.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -757,7 +768,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short128Mask.class, short.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short128Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -767,7 +779,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short128Mask.class, short.class, VLENGTH, + return VectorSupport.extract(Short128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -776,23 +788,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short128Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short128Mask)m).getBits())); + return VectorSupport.test(BT_ne, Short128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Short128Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short128Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short128Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Short128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Short128Mask)m).getBits())); } @ForceInline /*package-private*/ static Short128Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short128Mask.class, short.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Short128Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -805,7 +817,7 @@ static Short128Mask maskAll(boolean bit) { static final class Short128Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short128Shuffle(short[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java index 14c415afac2da..51bb65ab8069f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java @@ -54,7 +54,11 @@ final class Short256Vector extends ShortVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = short.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Short256Vector(short[] v) { super(v); @@ -88,9 +92,12 @@ public ShortSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return short.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -541,7 +548,7 @@ public short lane(int i) { @ForceInline public short laneHelper(int i) { return (short) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { short[] vecarr = vec.vec(); @@ -576,7 +583,7 @@ public Short256Vector withLane(int i, short e) { @ForceInline public Short256Vector withLaneHelper(int i, short e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); @@ -589,7 +596,7 @@ public Short256Vector withLaneHelper(int i, short e) { static final class Short256Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short256Mask(boolean[] bits) { this(bits, 0); @@ -691,7 +698,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Short256Mask indexPartiallyInUpperRange(long offset, long limit) { return (Short256Mask) VectorSupport.indexPartiallyInUpperRange( - Short256Mask.class, short.class, VLENGTH, offset, limit, + Short256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Short256Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -707,8 +714,9 @@ public Short256Mask not() { @ForceInline public Short256Mask compress() { return (Short256Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short256Vector.class, Short256Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Short256Vector.class, Short256Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -719,7 +727,7 @@ public Short256Mask compress() { public Short256Mask and(VectorMask mask) { Objects.requireNonNull(mask); Short256Mask m = (Short256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short256Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Short256Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -729,7 +737,7 @@ public Short256Mask and(VectorMask mask) { public Short256Mask or(VectorMask mask) { Objects.requireNonNull(mask); Short256Mask m = (Short256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short256Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Short256Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -739,7 +747,7 @@ public Short256Mask or(VectorMask mask) { public Short256Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Short256Mask m = (Short256Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short256Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Short256Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -749,22 +757,25 @@ public Short256Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short256Mask.class, short.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short256Mask.class, short.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short256Mask.class, short.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -773,7 +784,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short256Mask.class, short.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short256Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -783,7 +795,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short256Mask.class, short.class, VLENGTH, + return VectorSupport.extract(Short256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -792,23 +804,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short256Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short256Mask)m).getBits())); + return VectorSupport.test(BT_ne, Short256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Short256Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short256Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short256Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Short256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Short256Mask)m).getBits())); } @ForceInline /*package-private*/ static Short256Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short256Mask.class, short.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Short256Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -821,7 +833,7 @@ static Short256Mask maskAll(boolean bit) { static final class Short256Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short256Shuffle(short[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java index c92979302a6da..2bd0872594a89 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java @@ -54,7 +54,11 @@ final class Short512Vector extends ShortVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = short.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Short512Vector(short[] v) { super(v); @@ -88,9 +92,12 @@ public ShortSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return short.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -557,7 +564,7 @@ public short lane(int i) { @ForceInline public short laneHelper(int i) { return (short) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { short[] vecarr = vec.vec(); @@ -608,7 +615,7 @@ public Short512Vector withLane(int i, short e) { @ForceInline public Short512Vector withLaneHelper(int i, short e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); @@ -621,7 +628,7 @@ public Short512Vector withLaneHelper(int i, short e) { static final class Short512Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short512Mask(boolean[] bits) { this(bits, 0); @@ -723,7 +730,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Short512Mask indexPartiallyInUpperRange(long offset, long limit) { return (Short512Mask) VectorSupport.indexPartiallyInUpperRange( - Short512Mask.class, short.class, VLENGTH, offset, limit, + Short512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Short512Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -739,8 +746,9 @@ public Short512Mask not() { @ForceInline public Short512Mask compress() { return (Short512Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short512Vector.class, Short512Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Short512Vector.class, Short512Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -751,7 +759,7 @@ public Short512Mask compress() { public Short512Mask and(VectorMask mask) { Objects.requireNonNull(mask); Short512Mask m = (Short512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short512Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Short512Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -761,7 +769,7 @@ public Short512Mask and(VectorMask mask) { public Short512Mask or(VectorMask mask) { Objects.requireNonNull(mask); Short512Mask m = (Short512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short512Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Short512Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -771,7 +779,7 @@ public Short512Mask or(VectorMask mask) { public Short512Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Short512Mask m = (Short512Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short512Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Short512Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -781,22 +789,25 @@ public Short512Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short512Mask.class, short.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short512Mask.class, short.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short512Mask.class, short.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -805,7 +816,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short512Mask.class, short.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short512Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -815,7 +827,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short512Mask.class, short.class, VLENGTH, + return VectorSupport.extract(Short512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -824,23 +836,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short512Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short512Mask)m).getBits())); + return VectorSupport.test(BT_ne, Short512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Short512Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short512Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short512Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Short512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Short512Mask)m).getBits())); } @ForceInline /*package-private*/ static Short512Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short512Mask.class, short.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Short512Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -853,7 +865,7 @@ static Short512Mask maskAll(boolean bit) { static final class Short512Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short512Shuffle(short[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java index b454989b45f95..124c97149a11e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java @@ -54,7 +54,11 @@ final class Short64Vector extends ShortVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = short.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; Short64Vector(short[] v) { super(v); @@ -88,9 +92,12 @@ public ShortSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return short.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -529,7 +536,7 @@ public short lane(int i) { @ForceInline public short laneHelper(int i) { return (short) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { short[] vecarr = vec.vec(); @@ -552,7 +559,7 @@ public Short64Vector withLane(int i, short e) { @ForceInline public Short64Vector withLaneHelper(int i, short e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); @@ -565,7 +572,7 @@ public Short64Vector withLaneHelper(int i, short e) { static final class Short64Mask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short64Mask(boolean[] bits) { this(bits, 0); @@ -667,7 +674,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ Short64Mask indexPartiallyInUpperRange(long offset, long limit) { return (Short64Mask) VectorSupport.indexPartiallyInUpperRange( - Short64Mask.class, short.class, VLENGTH, offset, limit, + Short64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (Short64Mask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -683,8 +690,9 @@ public Short64Mask not() { @ForceInline public Short64Mask compress() { return (Short64Mask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - Short64Vector.class, Short64Mask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + Short64Vector.class, Short64Mask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -695,7 +703,7 @@ public Short64Mask compress() { public Short64Mask and(VectorMask mask) { Objects.requireNonNull(mask); Short64Mask m = (Short64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, Short64Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, Short64Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -705,7 +713,7 @@ public Short64Mask and(VectorMask mask) { public Short64Mask or(VectorMask mask) { Objects.requireNonNull(mask); Short64Mask m = (Short64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, Short64Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, Short64Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -715,7 +723,7 @@ public Short64Mask or(VectorMask mask) { public Short64Mask xor(VectorMask mask) { Objects.requireNonNull(mask); Short64Mask m = (Short64Mask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, Short64Mask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, Short64Mask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -725,22 +733,25 @@ public Short64Mask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short64Mask.class, short.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, Short64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short64Mask.class, short.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, Short64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short64Mask.class, short.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, Short64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -749,7 +760,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short64Mask.class, short.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, Short64Mask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -759,7 +771,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(Short64Mask.class, short.class, VLENGTH, + return VectorSupport.extract(Short64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -768,23 +780,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, Short64Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((Short64Mask)m).getBits())); + return VectorSupport.test(BT_ne, Short64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((Short64Mask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, Short64Mask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((Short64Mask)m).getBits())); + return VectorSupport.test(BT_overflow, Short64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((Short64Mask)m).getBits())); } @ForceInline /*package-private*/ static Short64Mask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(Short64Mask.class, short.class, VLENGTH, + return VectorSupport.fromBitsCoerced(Short64Mask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -797,7 +809,7 @@ static Short64Mask maskAll(boolean bit) { static final class Short64Shuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM Short64Shuffle(short[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java index bea14b7d5fdb6..519ba6cda74cc 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java @@ -54,7 +54,11 @@ final class ShortMaxVector extends ShortVector { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // carrier type used by the JVM + + static final Class ETYPE = short.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; ShortMaxVector(short[] v) { super(v); @@ -88,9 +92,12 @@ public ShortSpecies vspecies() { return VSPECIES; } + @ForceInline + final Class carrierType() { return CTYPE; } + @ForceInline @Override - public final Class elementType() { return short.class; } + public final Class elementType() { return ETYPE; } @ForceInline @Override @@ -526,7 +533,7 @@ public short lane(int i) { @ForceInline public short laneHelper(int i) { return (short) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { short[] vecarr = vec.vec(); @@ -546,7 +553,7 @@ public ShortMaxVector withLane(int i, short e) { @ForceInline public ShortMaxVector withLaneHelper(int i, short e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); @@ -559,7 +566,7 @@ public ShortMaxVector withLaneHelper(int i, short e) { static final class ShortMaxMask extends AbstractMask { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM ShortMaxMask(boolean[] bits) { this(bits, 0); @@ -661,7 +668,7 @@ public VectorMask cast(VectorSpecies dsp) { /*package-private*/ ShortMaxMask indexPartiallyInUpperRange(long offset, long limit) { return (ShortMaxMask) VectorSupport.indexPartiallyInUpperRange( - ShortMaxMask.class, short.class, VLENGTH, offset, limit, + ShortMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> (ShortMaxMask) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -677,8 +684,9 @@ public ShortMaxMask not() { @ForceInline public ShortMaxMask compress() { return (ShortMaxMask)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - ShortMaxVector.class, ShortMaxMask.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + ShortMaxVector.class, ShortMaxMask.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + m1.trueCount())); } @@ -689,7 +697,7 @@ public ShortMaxMask compress() { public ShortMaxMask and(VectorMask mask) { Objects.requireNonNull(mask); ShortMaxMask m = (ShortMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMaxMask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, ShortMaxMask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -699,7 +707,7 @@ public ShortMaxMask and(VectorMask mask) { public ShortMaxMask or(VectorMask mask) { Objects.requireNonNull(mask); ShortMaxMask m = (ShortMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMaxMask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, ShortMaxMask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -709,7 +717,7 @@ public ShortMaxMask or(VectorMask mask) { public ShortMaxMask xor(VectorMask mask) { Objects.requireNonNull(mask); ShortMaxMask m = (ShortMaxMask)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMaxMask.class, null, short.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, ShortMaxMask.class, null, short.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -719,22 +727,25 @@ public ShortMaxMask xor(VectorMask mask) { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMaxMask.class, short.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, ShortMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMaxMask.class, short.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, ShortMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMaxMask.class, short.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, ShortMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -743,7 +754,8 @@ public long toLong() { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMaxMask.class, short.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, ShortMaxMask.class, short.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -753,7 +765,7 @@ public long toLong() { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract(ShortMaxMask.class, short.class, VLENGTH, + return VectorSupport.extract(ShortMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -762,23 +774,23 @@ public boolean laneIsSet(int i) { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, ShortMaxMask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper(((ShortMaxMask)m).getBits())); + return VectorSupport.test(BT_ne, ShortMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper(((ShortMaxMask)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, ShortMaxMask.class, short.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper(((ShortMaxMask)m).getBits())); + return VectorSupport.test(BT_overflow, ShortMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper(((ShortMaxMask)m).getBits())); } @ForceInline /*package-private*/ static ShortMaxMask maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced(ShortMaxMask.class, short.class, VLENGTH, + return VectorSupport.fromBitsCoerced(ShortMaxMask.class, short.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -791,7 +803,7 @@ static ShortMaxMask maskAll(boolean bit) { static final class ShortMaxShuffle extends AbstractShuffle { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class ETYPE = short.class; // used by the JVM + static final Class CTYPE = short.class; // used by the JVM ShortMaxShuffle(short[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index e222c6d25f390..b203b39997229 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -57,6 +57,8 @@ public abstract class ShortVector extends AbstractVector { static final int FORBID_OPCODE_KIND = VO_ONLYFP; + static final int VECTOR_OPER_TYPE = VECTOR_TYPE_PRIM; + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); @ForceInline @@ -573,7 +575,7 @@ static ShortVector selectFromTwoVectorHelper(Vector indexes, Vector species) { ShortSpecies vsp = (ShortSpecies) species; - return VectorSupport.fromBitsCoerced(vsp.vectorType(), short.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), short.class, VECTOR_OPER_TYPE, species.length(), 0, MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); } @@ -695,7 +697,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, short.class, length(), + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, ShortVector::unaryOperations)); } @@ -723,7 +725,7 @@ else if (op == NOT) { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, short.class, length(), + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, ShortVector::unaryOperations)); } @@ -796,7 +798,7 @@ ShortVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, short.class, length(), + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, ShortVector::binaryOperations)); } @@ -847,7 +849,7 @@ ShortVector lanewiseTemplate(VectorOperators.Binary op, int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, short.class, length(), + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, ShortVector::binaryOperations)); } @@ -1034,7 +1036,7 @@ ShortVector lanewise(VectorOperators.Binary op, e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), null, short.class, length(), + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), this, e, null, BIN_INT_IMPL.find(op, opc, ShortVector::broadcastIntOperations)); } @@ -1055,7 +1057,7 @@ opc, getClass(), null, short.class, length(), e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), maskClass, short.class, length(), + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), this, e, m, BIN_INT_IMPL.find(op, opc, ShortVector::broadcastIntOperations)); } @@ -1132,7 +1134,7 @@ ShortVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, short.class, length(), + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, ShortVector::ternaryOperations)); } @@ -1172,7 +1174,7 @@ ShortVector lanewiseTemplate(VectorOperators.Ternary op, } int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, short.class, length(), + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, ShortVector::ternaryOperations)); } @@ -2071,7 +2073,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v) { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, short.class, length(), + opc, getClass(), maskType, short.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask m @@ -2093,7 +2095,7 @@ M compareTemplate(Class maskType, Comparison op, Vector v, M m) { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, short.class, length(), + opc, getClass(), maskType, short.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask cmpM @@ -2224,7 +2226,7 @@ VectorMask compare(Comparison op, long e, VectorMask m) { blendTemplate(Class maskType, ShortVector v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, short.class, length(), + getClass(), maskType, short.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2241,7 +2243,7 @@ final ShortVector addIndexTemplate(int scale) { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), short.class, length(), + getClass(), short.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2433,7 +2435,7 @@ ShortVector sliceTemplate(int origin) { ShortVector rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, short.class, length(), + getClass(), shuffletype, null, short.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2460,7 +2462,7 @@ ShortVector rearrangeTemplate(Class shuffletype, Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, short.class, length(), + getClass(), shuffletype, masktype, short.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2486,7 +2488,7 @@ ShortVector rearrangeTemplate(Class shuffletype, VectorMask valid = shuffle.laneIsValid(); ShortVector r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, short.class, length(), + getClass(), shuffletype, null, short.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2494,7 +2496,7 @@ ShortVector rearrangeTemplate(Class shuffletype, })); ShortVector r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, short.class, length(), + getClass(), shuffletype, null, short.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2544,7 +2546,7 @@ VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { ShortVector compressTemplate(Class masktype, M m) { m.check(masktype, this); return (ShortVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - short.class, length(), this, m, + short.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -2563,7 +2565,7 @@ short.class, length(), this, m, ShortVector expandTemplate(Class masktype, M m) { m.check(masktype, this); return (ShortVector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - short.class, length(), this, m, + short.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -2578,7 +2580,7 @@ short.class, length(), this, m, /*package-private*/ @ForceInline final ShortVector selectFromTemplate(ShortVector v) { - return (ShortVector)VectorSupport.selectFromOp(getClass(), null, short.class, + return (ShortVector)VectorSupport.selectFromOp(getClass(), null, short.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -2598,7 +2600,7 @@ final ShortVector selectFromTemplate(ShortVector v) { ShortVector selectFromTemplate(ShortVector v, Class masktype, M m) { m.check(masktype, this); - return (ShortVector)VectorSupport.selectFromOp(getClass(), masktype, short.class, + return (ShortVector)VectorSupport.selectFromOp(getClass(), masktype, short.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -2616,7 +2618,7 @@ ShortVector selectFromTemplate(ShortVector v, /*package-private*/ @ForceInline final ShortVector selectFromTemplate(ShortVector v1, ShortVector v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), short.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), short.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -2836,7 +2838,7 @@ short reduceLanesTemplate(VectorOperators.Associative op, } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, short.class, length(), + opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, ShortVector::reductionOperations))); } @@ -2854,7 +2856,7 @@ short reduceLanesTemplate(VectorOperators.Associative op) { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, short.class, length(), + opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, ShortVector::reductionOperations))); } @@ -3135,7 +3137,7 @@ ShortVector fromArray(VectorSpecies species, } return VectorSupport.loadWithMap( - vectorType, null, short.class, vsp.laneCount(), + vectorType, null, short.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -3468,7 +3470,7 @@ void intoArray(short[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); ShortSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -3617,7 +3619,7 @@ void intoCharArray(char[] a, int offset) { offset = checkFromIndexSize(offset, length(), a.length); ShortSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, this, a, offset, @@ -3822,7 +3824,7 @@ void intoMemorySegment(MemorySegment ms, long offset, ShortVector fromArray0Template(short[] a, int offset) { ShortSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3839,7 +3841,7 @@ ShortVector fromArray0Template(Class maskClass, short[] a, int offset, M m, i m.check(species()); ShortSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3886,7 +3888,7 @@ ShortVector fromArray0Template(Class maskClass, short[] a, int offset, } return VectorSupport.loadWithMap( - vectorType, maskClass, short.class, vsp.laneCount(), + vectorType, maskClass, short.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -3902,7 +3904,7 @@ ShortVector fromArray0Template(Class maskClass, short[] a, int offset, ShortVector fromCharArray0Template(char[] a, int offset) { ShortSpecies vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -3919,7 +3921,7 @@ ShortVector fromCharArray0Template(Class maskClass, char[] a, int offset, M m m.check(species()); ShortSpecies vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -3934,7 +3936,7 @@ a, charArrayAddress(a, offset), false, m, offsetInRange, ShortVector fromMemorySegment0Template(MemorySegment ms, long offset) { ShortSpecies vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, ShortVector::memorySegmentGet); @@ -3950,7 +3952,7 @@ ShortVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, lon ShortSpecies vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, ShortVector::memorySegmentGet); @@ -3968,7 +3970,7 @@ ShortVector fromMemorySegment0Template(Class maskClass, MemorySegment ms, lon void intoArray0Template(short[] a, int offset) { ShortSpecies vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -3985,7 +3987,7 @@ void intoArray0Template(Class maskClass, short[] a, int offset, M m) { m.check(species()); ShortSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -4000,7 +4002,7 @@ a, arrayAddress(a, offset), false, void intoMemorySegment0(MemorySegment ms, long offset) { ShortSpecies vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -4017,7 +4019,7 @@ void intoMemorySegment0Template(Class maskClass, MemorySegment ms, long offse ShortSpecies vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -4035,7 +4037,7 @@ void intoCharArray0Template(Class maskClass, char[] a, int offset, M m) { m.check(species()); ShortSpecies vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -4138,11 +4140,10 @@ public final ShortVector viewAsIntegralLanes() { @ForceInline @Override public final - Vector + HalffloatVector viewAsFloatingLanes() { LaneType flt = LaneType.SHORT.asFloating(); - // asFloating() will throw UnsupportedOperationException for the unsupported type short - throw new AssertionError("Cannot reach here"); + return (HalffloatVector) asVectorRaw(flt); } // ================================================ @@ -4223,6 +4224,19 @@ private ShortSpecies(VectorShape shape, // Specializing overrides: + @ForceInline + final Class carrierType() { + return short.class; + } + + @ForceInline + final int operType() { + if (short.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class elementType() { @@ -4255,7 +4269,7 @@ public final long checkValue(long e) { final ShortVector broadcastBits(long bits) { return (ShortVector) VectorSupport.fromBitsCoerced( - vectorType, short.class, laneCount, + vectorType, short.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java index 0e4516efa86ed..6318a7476e397 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, 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 @@ -3069,6 +3069,19 @@ public abstract VectorMask compare(VectorOperators.Comparison op, */ public abstract DoubleVector reinterpretAsDoubles(); + /** + * Reinterprets this vector as a vector of the same shape + * and contents but a lane type of {@code halffloat}, + * where the lanes are assembled from successive bytes + * according to little-endian order. + * It is a convenience method for the expression + * {@code reinterpretShape(species().withLanes(halffloat.class))}. + * It may be considered an inverse to {@link Vector#reinterpretAsBytes()}. + * + * @return a {@code HalffloatVector} with the same shape and information content + */ + public abstract HalffloatVector reinterpretAsHalffloats(); + /** * Views this vector as a vector of the same shape, length, and * contents, but a lane type that is not a floating-point type. diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java index 266a843083a08..e92ce3bc56872 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java @@ -25,6 +25,7 @@ package jdk.incubator.vector; import jdk.internal.vm.annotation.ForceInline; +import jdk.internal.misc.Unsafe; import java.util.Objects; @@ -32,6 +33,8 @@ static final int VECTOR_ACCESS_OOB_CHECK = Integer.getInteger("jdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK", 2); + static final Unsafe U = Unsafe.getUnsafe(); + @ForceInline static void requireLength(int haveLength, int length) { if (haveLength != length) { @@ -148,4 +151,8 @@ private static int wrapToRangeNPOT(int index, int size) { return Math.floorMod(index, Math.abs(size)); } } + static V maybeRebox(V v) { + U.loadFence(); + return v; + } } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java index 5695dff62fbce..fcefd22957b8d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMask.java @@ -28,6 +28,8 @@ import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.vector.VectorSupport; +import static jdk.internal.vm.vector.VectorSupport.*; + import java.util.Arrays; import java.util.Objects; @@ -207,11 +209,11 @@ public static VectorMask fromArray(VectorSpecies species, boolean[] bi int laneCount = vsp.laneCount(); offset = VectorIntrinsics.checkFromIndexSize(offset, laneCount, bits.length); return VectorSupport.load( - vsp.maskType(), vsp.elementType(), laneCount, - bits, (long) offset + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, false, + vsp.maskType(), vsp.carrierType(), vsp.operType(), laneCount, bits, + (long) offset + Unsafe.ARRAY_BOOLEAN_BASE_OFFSET, false, bits, offset, vsp, (c, idx, s) - -> s.opm(n -> c[((int )idx) + n])); + -> s.opm(n -> c[((int)idx) + n])); } /** @@ -240,7 +242,8 @@ public static VectorMask fromArray(VectorSpecies species, boolean[] bi public static VectorMask fromLong(VectorSpecies species, long bits) { AbstractSpecies vsp = (AbstractSpecies) species; bits = bits & (0xFFFFFFFFFFFFFFFFL >>> (64 - vsp.laneCount())); - return VectorSupport.fromBitsCoerced(vsp.maskType(), vsp.elementType(), vsp.laneCount(), bits, + return VectorSupport.fromBitsCoerced(vsp.maskType(), vsp.carrierType(), + vsp.operType(), vsp.laneCount(), bits, VectorSupport.MODE_BITS_COERCED_LONG_TO_MASK, vsp, (m, s) -> { if (m == (m >> 1)) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java index f4da4f429346e..976626d49b924 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, 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 @@ -694,6 +694,8 @@ static boolean opKind(Operator op, int bit) { public static final Conversion B2L = convert("B2L", 'C', byte.class, long.class, VO_KIND_CAST, VO_ALL); /** Convert {@code byteVal} to {@code (short)byteVal}. */ public static final Conversion B2S = convert("B2S", 'C', byte.class, short.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code byteVal} to {@code (halffloat)byteVal}. */ + public static final Conversion B2H = convert("B2H", 'C', byte.class, Float16.class, VO_KIND_CAST, VO_ALL); /** Convert {@code doubleVal} to {@code (byte)doubleVal}. */ public static final Conversion D2B = convert("D2B", 'C', double.class, byte.class, VO_KIND_CAST, VO_ALL); /** Convert {@code doubleVal} to {@code (float)doubleVal}. */ @@ -704,6 +706,8 @@ static boolean opKind(Operator op, int bit) { public static final Conversion D2L = convert("D2L", 'C', double.class, long.class, VO_KIND_CAST, VO_ALL); /** Convert {@code doubleVal} to {@code (short)doubleVal}. */ public static final Conversion D2S = convert("D2S", 'C', double.class, short.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code doubleVal} to {@code (halffloat)doubleVal}. */ + public static final Conversion D2H = convert("D2H", 'C', double.class, Float16.class, VO_KIND_CAST, VO_ALL); /** Convert {@code floatVal} to {@code (byte)floatVal}. */ public static final Conversion F2B = convert("F2B", 'C', float.class, byte.class, VO_KIND_CAST, VO_ALL); /** Convert {@code floatVal} to {@code (double)floatVal}. */ @@ -714,6 +718,8 @@ static boolean opKind(Operator op, int bit) { public static final Conversion F2L = convert("F2L", 'C', float.class, long.class, VO_KIND_CAST, VO_ALL); /** Convert {@code floatVal} to {@code (short)floatVal}. */ public static final Conversion F2S = convert("F2S", 'C', float.class, short.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code floatVal} to {@code (halffloat)floatVal}. */ + public static final Conversion F2H = convert("F2H", 'C', float.class, Float16.class, VO_KIND_CAST, VO_ALL); /** Convert {@code intVal} to {@code (byte)intVal}. */ public static final Conversion I2B = convert("I2B", 'C', int.class, byte.class, VO_KIND_CAST, VO_ALL); /** Convert {@code intVal} to {@code (double)intVal}. */ @@ -724,6 +730,8 @@ static boolean opKind(Operator op, int bit) { public static final Conversion I2L = convert("I2L", 'C', int.class, long.class, VO_KIND_CAST, VO_ALL); /** Convert {@code intVal} to {@code (short)intVal}. */ public static final Conversion I2S = convert("I2S", 'C', int.class, short.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code intVal} to {@code (halffloat)intVal}. */ + public static final Conversion I2H = convert("I2H", 'C', int.class, Float16.class, VO_KIND_CAST, VO_ALL); /** Convert {@code longVal} to {@code (byte)longVal}. */ public static final Conversion L2B = convert("L2B", 'C', long.class, byte.class, VO_KIND_CAST, VO_ALL); /** Convert {@code longVal} to {@code (double)longVal}. */ @@ -734,6 +742,8 @@ static boolean opKind(Operator op, int bit) { public static final Conversion L2I = convert("L2I", 'C', long.class, int.class, VO_KIND_CAST, VO_ALL); /** Convert {@code longVal} to {@code (short)longVal}. */ public static final Conversion L2S = convert("L2S", 'C', long.class, short.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code longVal} to {@code (halffloat)longVal}. */ + public static final Conversion L2H = convert("L2H", 'C', long.class, Float16.class, VO_KIND_CAST, VO_ALL); /** Convert {@code shortVal} to {@code (byte)shortVal}. */ public static final Conversion S2B = convert("S2B", 'C', short.class, byte.class, VO_KIND_CAST, VO_ALL); /** Convert {@code shortVal} to {@code (double)shortVal}. */ @@ -744,6 +754,21 @@ static boolean opKind(Operator op, int bit) { public static final Conversion S2I = convert("S2I", 'C', short.class, int.class, VO_KIND_CAST, VO_ALL); /** Convert {@code shortVal} to {@code (long)shortVal}. */ public static final Conversion S2L = convert("S2L", 'C', short.class, long.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code shortVal} to {@code (halffloat)shortVal}. */ + public static final Conversion S2H = convert("S2H", 'C', short.class, Float16.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code halffloatVal} to {@code (byte)halffloatVal}. */ + public static final Conversion H2B = convert("H2B", 'C', Float16.class, byte.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code halffloatVal} to {@code (short)halffloatVal}. */ + public static final Conversion H2S = convert("H2S", 'C', Float16.class, short.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code halffloatVal} to {@code (double)halffloatVal}. */ + public static final Conversion H2D = convert("H2D", 'C', Float16.class, double.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code halffloatVal} to {@code (float)halffloatVal}. */ + public static final Conversion H2F = convert("H2F", 'C', Float16.class, float.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code halffloatVal} to {@code (int)halffloatVal}. */ + public static final Conversion H2I = convert("H2I", 'C', Float16.class, int.class, VO_KIND_CAST, VO_ALL); + /** Convert {@code halffloatVal} to {@code (long)halffloatVal}. */ + public static final Conversion H2L = convert("H2L", 'C', Float16.class, long.class, VO_KIND_CAST, VO_ALL); + /** Reinterpret bits of {@code doubleVal} as {@code long}. As if by {@link Double#doubleToRawLongBits(double)} */ public static final Conversion REINTERPRET_D2L = convert("REINTERPRET_D2L", 'R', double.class, long.class, VO_KIND_BITWISE, VO_ALL); /** Reinterpret bits of {@code floatVal} as {@code int}. As if by {@link Float#floatToRawIntBits(float)} */ diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java index f6e36450ce088..08c91ff6390eb 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorShape.java @@ -272,6 +272,9 @@ static int getMaxVectorBitSize(Class etype) { // VectorSupport.getMaxLaneCount may return -1 if C2 is not enabled, // or a value smaller than the S_64_BIT.vectorBitSize / elementSizeInBits if MaxVectorSize < 16 // If so default to S_64_BIT + if (etype == Float16.class) { + etype = short.class; + } int maxLaneCount = VectorSupport.getMaxLaneCount(etype); int elementSizeInBits = LaneType.of(etype).elementSize; return Math.max(maxLaneCount * elementSizeInBits, S_64_BIT.vectorBitSize); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index f7d987fd280a0..9380e3f23896d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -41,6 +41,9 @@ import static jdk.internal.vm.vector.VectorSupport.*; import static jdk.incubator.vector.VectorIntrinsics.*; import static jdk.incubator.vector.VectorOperators.*; +#if[FP16] +import jdk.incubator.vector.Float16; +#end[FP16] #warn This file is preprocessed before being compiled @@ -61,7 +64,9 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { static final int FORBID_OPCODE_KIND = VO_ONLYFP; #end[FP] - static final ValueLayout.Of$Type$ ELEMENT_LAYOUT = ValueLayout.JAVA_$TYPE$.withByteAlignment(1); + static final int VECTOR_OPER_TYPE = {#if[FP16]?VECTOR_TYPE_FP16:VECTOR_TYPE_PRIM}; + + static final ValueLayout.Of$ElemLayout$ ELEMENT_LAYOUT = ValueLayout.JAVA_$TYPE$.withByteAlignment(1); @ForceInline static int opCode(Operator op) { @@ -511,13 +516,21 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { /*package-private*/ @ForceInline static long toBits($type$ e) { +#if[FP16] + return e; +#else[FP16] return {#if[FP]? $Type$.$type$ToRaw$Bitstype$Bits(e): e}; +#end[FP16] } /*package-private*/ @ForceInline static $type$ fromBits(long bits) { +#if[FP16] + return Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)bits)); +#else[FP16] return {#if[FP]?$Type$.$bitstype$BitsTo$Type$}(($bitstype$)bits); +#end[FP16] } static $abstractvectortype$ expandHelper(Vector<$Boxtype$> v, VectorMask<$Boxtype$> m) { @@ -557,7 +570,12 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] vecPayload2 = (($abstractvectortype$)src1).vec(); $type$[] vecPayload3 = (($abstractvectortype$)src2).vec(); for (int i = 0; i < vlen; i++) { +#if[FP16] + int index = Float16.shortBitsToFloat16(vecPayload1[i]).intValue(); + int wrapped_index = VectorIntrinsics.wrapToRange(index, 2 * vlen); +#else[FP16] int wrapped_index = VectorIntrinsics.wrapToRange((int)vecPayload1[i], 2 * vlen); +#end[FP16] res[i] = wrapped_index >= vlen ? vecPayload3[wrapped_index - vlen] : vecPayload2[wrapped_index]; } return (($abstractvectortype$)src1).vectorFactory(res); @@ -588,11 +606,11 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { public static $abstractvectortype$ zero(VectorSpecies<$Boxtype$> species) { $Type$Species vsp = ($Type$Species) species; #if[FP] - return VectorSupport.fromBitsCoerced(vsp.vectorType(), $type$.class, species.length(), - toBits(0.0f), MODE_BROADCAST, vsp, + return VectorSupport.fromBitsCoerced(vsp.vectorType(), $carriertype$.class, VECTOR_OPER_TYPE, species.length(), + toBits({#if[FP16]?(short) 0:0.0f}), MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); #else[FP] - return VectorSupport.fromBitsCoerced(vsp.vectorType(), $type$.class, species.length(), + return VectorSupport.fromBitsCoerced(vsp.vectorType(), $carriertype$.class, VECTOR_OPER_TYPE, species.length(), 0, MODE_BROADCAST, vsp, ((bits_, s_) -> s_.rvOp(i -> bits_))); #end[FP] @@ -724,7 +742,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), null, $type$.class, length(), + opc, getClass(), null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, null, UN_IMPL.find(op, opc, $abstractvectortype$::unaryOperations)); } @@ -759,7 +777,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } int opc = opCode(op); return VectorSupport.unaryOp( - opc, getClass(), maskClass, $type$.class, length(), + opc, getClass(), maskClass, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, m, UN_IMPL.find(op, opc, $abstractvectortype$::unaryOperations)); } @@ -814,6 +832,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { #end[BITWISE] #end[!FP] #if[FP] +#if[!FP16] case VECTOR_OP_SIN: return (v0, m) -> v0.uOp(m, (i, a) -> ($type$) Math.sin(a)); case VECTOR_OP_COS: return (v0, m) -> @@ -846,6 +865,40 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { v0.uOp(m, (i, a) -> ($type$) Math.expm1(a)); case VECTOR_OP_LOG1P: return (v0, m) -> v0.uOp(m, (i, a) -> ($type$) Math.log1p(a)); +#else[!FP16] + case VECTOR_OP_SIN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sin(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_COS: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cos(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_TAN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tan(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_ASIN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.asin(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_ACOS: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.acos(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_ATAN: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_EXP: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.exp(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_LOG: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_LOG10: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log10(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_SQRT: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sqrt(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_CBRT: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cbrt(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_SINH: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sinh(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_COSH: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cosh(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_TANH: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tanh(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_EXPM1: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.expm1(Float16.shortBitsToFloat16(a).doubleValue())))); + case VECTOR_OP_LOG1P: return (v0, m) -> + v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log1p(Float16.shortBitsToFloat16(a).doubleValue())))); +#end[!FP16] #end[FP] default: return null; } @@ -903,7 +956,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), null, $type$.class, length(), + opc, getClass(), null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, that, null, BIN_IMPL.find(op, opc, $abstractvectortype$::binaryOperations)); } @@ -970,7 +1023,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { int opc = opCode(op); return VectorSupport.binaryOp( - opc, getClass(), maskClass, $type$.class, length(), + opc, getClass(), maskClass, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, that, m, BIN_IMPL.find(op, opc, $abstractvectortype$::binaryOperations)); } @@ -990,6 +1043,20 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { private static BinaryOperation<$abstractvectortype$, VectorMask<$Boxtype$>> binaryOperations(int opc_) { switch (opc_) { +#if[FP16] + case VECTOR_OP_ADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_SUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.subtract(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_MUL: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_DIV: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.divide(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_MAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + case VECTOR_OP_MIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); +#else[FP16] case VECTOR_OP_ADD: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, b) -> ($type$)(a + b)); case VECTOR_OP_SUB: return (v0, v1, vm) -> @@ -1002,6 +1069,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { v0.bOp(v1, vm, (i, a, b) -> ($type$)Math.max(a, b)); case VECTOR_OP_MIN: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, b) -> ($type$)Math.min(a, b)); +#end[FP16] #if[BITWISE] case VECTOR_OP_AND: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, b) -> ($type$)(a & b)); @@ -1039,6 +1107,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { #end[intOrLong] #end[BITWISE] #if[FP] +#if[!FP16] case VECTOR_OP_OR: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, b) -> fromBits(toBits(a) | toBits(b))); case VECTOR_OP_ATAN2: return (v0, v1, vm) -> @@ -1047,6 +1116,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { v0.bOp(v1, vm, (i, a, b) -> ($type$) Math.pow(a, b)); case VECTOR_OP_HYPOT: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, b) -> ($type$) Math.hypot(a, b)); +#else[!FP16] + case VECTOR_OP_ATAN2: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan2(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + case VECTOR_OP_POW: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.pow(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + case VECTOR_OP_HYPOT: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.hypot(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); +#end[!FP16] #end[FP] default: return null; } @@ -1198,7 +1275,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), null, $type$.class, length(), + opc, getClass(), null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, e, null, BIN_INT_IMPL.find(op, opc, $abstractvectortype$::broadcastIntOperations)); } @@ -1219,7 +1296,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { e &= SHIFT_MASK; int opc = opCode(op); return VectorSupport.broadcastInt( - opc, getClass(), maskClass, $type$.class, length(), + opc, getClass(), maskClass, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, e, m, BIN_INT_IMPL.find(op, opc, $abstractvectortype$::broadcastIntOperations)); } @@ -1303,7 +1380,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { #end[BITWISE] int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), null, $type$.class, length(), + opc, getClass(), null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, that, tother, null, TERN_IMPL.find(op, opc, $abstractvectortype$::ternaryOperations)); } @@ -1345,7 +1422,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { #end[BITWISE] int opc = opCode(op); return VectorSupport.ternaryOp( - opc, getClass(), maskClass, $type$.class, length(), + opc, getClass(), maskClass, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, that, tother, m, TERN_IMPL.find(op, opc, $abstractvectortype$::ternaryOperations)); } @@ -1357,8 +1434,13 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { private static TernaryOperation<$abstractvectortype$, VectorMask<$Boxtype$>> ternaryOperations(int opc_) { switch (opc_) { #if[FP] +#if[FP16] + case VECTOR_OP_FMA: return (v0, v1_, v2_, m) -> v0.tOp(v1_, v2_, m, (i, a, b, c) -> + Float16.float16ToRawShortBits(Float16.fma(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b), Float16.shortBitsToFloat16(c)))); +#else[FP16] case VECTOR_OP_FMA: return (v0, v1_, v2_, m) -> v0.tOp(v1_, v2_, m, (i, a, b, c) -> Math.fma(a, b, c)); +#end[FP16] #end[FP] default: return null; } @@ -2387,7 +2469,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // first kill the sign: bits = bits.and($Boxbitstype$.MAX_VALUE); // next find the bit pattern for infinity: - $bitstype$ infbits = ($bitstype$) toBits($Boxtype$.POSITIVE_INFINITY); + $bitstype$ infbits = ($bitstype$) toBits({#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}); // now compare: if (op == IS_FINITE) { m = bits.compare(LT, infbits); @@ -2441,7 +2523,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // first kill the sign: bits = bits.and($Boxbitstype$.MAX_VALUE); // next find the bit pattern for infinity: - $bitstype$ infbits = ($bitstype$) toBits($Boxtype$.POSITIVE_INFINITY); + $bitstype$ infbits = ($bitstype$) toBits({#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}); // now compare: if (op == IS_FINITE) { m = bits.compare(LT, infbits, m); @@ -2477,7 +2559,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { that.check(this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, $type$.class, length(), + opc, getClass(), maskType, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, that, null, (cond, v0, v1, m1) -> { AbstractMask<$Boxtype$> m @@ -2499,7 +2581,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { m.check(maskType, this); int opc = opCode(op); return VectorSupport.compare( - opc, getClass(), maskType, $type$.class, length(), + opc, getClass(), maskType, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, that, m, (cond, v0, v1, m1) -> { AbstractMask<$Boxtype$> cmpM @@ -2512,14 +2594,23 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } @ForceInline - private static boolean compareWithOp(int cond, $type$ a, $type$ b) { + private static boolean compareWithOp(int cond, $carriertype$ a, $carriertype$ b) { return switch (cond) { +#if[FP16] + case BT_eq -> Float.float16ToFloat(a) == Float.float16ToFloat(b); + case BT_ne -> Float.float16ToFloat(a) != Float.float16ToFloat(b); + case BT_lt -> Float.float16ToFloat(a) < Float.float16ToFloat(b); + case BT_le -> Float.float16ToFloat(a) <= Float.float16ToFloat(b); + case BT_gt -> Float.float16ToFloat(a) > Float.float16ToFloat(b); + case BT_ge -> Float.float16ToFloat(a) >= Float.float16ToFloat(b); +#else[FP16] case BT_eq -> a == b; case BT_ne -> a != b; case BT_lt -> a < b; case BT_le -> a <= b; case BT_gt -> a > b; case BT_ge -> a >= b; +#end[FP16] #if[!FP] case BT_ult -> $Boxtype$.compareUnsigned(a, b) < 0; case BT_ule -> $Boxtype$.compareUnsigned(a, b) <= 0; @@ -2634,7 +2725,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { blendTemplate(Class maskType, $abstractvectortype$ v, M m) { v.check(this); return VectorSupport.blend( - getClass(), maskType, $type$.class, length(), + getClass(), maskType, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, v, m, (v0, v1, m_) -> v0.bOp(v1, m_, (i, a, b) -> b)); } @@ -2651,7 +2742,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // make sure VLENGTH*scale doesn't overflow: vsp.checkScale(scale); return VectorSupport.indexVector( - getClass(), $type$.class, length(), + getClass(), $carriertype$.class, VECTOR_OPER_TYPE, length(), this, scale, vsp, (v, scale_, s) -> { @@ -2660,7 +2751,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // and multiply. $abstractvectortype$ iota = s.iota(); $type$ sc = ($type$) scale_; - return v.add(sc == 1 ? iota : iota.mul(sc)); + return v.add(sc == 1 ? iota : iota.mul({#if[FP16]?Float16.float16ToRawShortBits(Float16.valueOf(sc)):sc})); }); } @@ -2865,7 +2956,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ rearrangeTemplate(Class shuffletype, S shuffle) { Objects.requireNonNull(shuffle); return VectorSupport.rearrangeOp( - getClass(), shuffletype, null, $type$.class, length(), + getClass(), shuffletype, null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2892,7 +2983,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { Objects.requireNonNull(shuffle); m.check(masktype, this); return VectorSupport.rearrangeOp( - getClass(), shuffletype, masktype, $type$.class, length(), + getClass(), shuffletype, masktype, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, shuffle, m, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2918,7 +3009,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { VectorMask<$Boxtype$> valid = shuffle.laneIsValid(); $abstractvectortype$ r0 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, $type$.class, length(), + getClass(), shuffletype, null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, shuffle, null, (v0, s_, m_) -> v0.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v0.length()); @@ -2926,7 +3017,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { })); $abstractvectortype$ r1 = VectorSupport.rearrangeOp( - getClass(), shuffletype, null, $type$.class, length(), + getClass(), shuffletype, null, $carriertype$.class, VECTOR_OPER_TYPE, length(), v, shuffle, null, (v1, s_, m_) -> v1.uOp((i, a) -> { int ei = Integer.remainderUnsigned(s_.laneSource(i), v1.length()); @@ -2955,6 +3046,9 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { final VectorShuffle toShuffle(AbstractSpecies dsp, boolean wrap) { assert(dsp.elementSize() == vspecies().elementSize()); +#if[FP16] + ShortVector idx = convert(VectorOperators.H2S, 0).reinterpretAsShorts(); +#end[FP16] #if[float] IntVector idx = convert(VectorOperators.F2I, 0).reinterpretAsInts(); #end[float] @@ -2988,7 +3082,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $Type$Vector compressTemplate(Class masktype, M m) { m.check(masktype, this); return ($Type$Vector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_COMPRESS, getClass(), masktype, - $type$.class, length(), this, m, + $carriertype$.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> compressHelper(v1, m1)); } @@ -3007,7 +3101,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $Type$Vector expandTemplate(Class masktype, M m) { m.check(masktype, this); return ($Type$Vector) VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_EXPAND, getClass(), masktype, - $type$.class, length(), this, m, + $carriertype$.class, VECTOR_OPER_TYPE, length(), this, m, (v1, m1) -> expandHelper(v1, m1)); } @@ -3022,7 +3116,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { /*package-private*/ @ForceInline final $abstractvectortype$ selectFromTemplate($abstractvectortype$ v) { - return ($Type$Vector)VectorSupport.selectFromOp(getClass(), null, $type$.class, + return ($Type$Vector)VectorSupport.selectFromOp(getClass(), null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, v, null, (v1, v2, _m) -> v2.rearrange(v1.toShuffle())); @@ -3042,7 +3136,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ selectFromTemplate($abstractvectortype$ v, Class masktype, M m) { m.check(masktype, this); - return ($Type$Vector)VectorSupport.selectFromOp(getClass(), masktype, $type$.class, + return ($Type$Vector)VectorSupport.selectFromOp(getClass(), masktype, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, v, m, (v1, v2, _m) -> v2.rearrange(v1.toShuffle(), _m)); @@ -3060,7 +3154,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { /*package-private*/ @ForceInline final $abstractvectortype$ selectFromTemplate($abstractvectortype$ v1, $abstractvectortype$ v2) { - return VectorSupport.selectFromTwoVectorOp(getClass(), $type$.class, length(), this, v1, v2, + return VectorSupport.selectFromTwoVectorOp(getClass(), $carriertype$.class, VECTOR_OPER_TYPE, length(), this, v1, v2, (vec1, vec2, vec3) -> selectFromTwoVectorHelper(vec1, vec2, vec3)); } @@ -3409,7 +3503,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), maskClass, $type$.class, length(), + opc, getClass(), maskClass, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, m, REDUCE_IMPL.find(op, opc, $abstractvectortype$::reductionOperations))); } @@ -3427,7 +3521,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } int opc = opCode(op); return fromBits(VectorSupport.reductionCoerced( - opc, getClass(), null, $type$.class, length(), + opc, getClass(), null, $carriertype$.class, VECTOR_OPER_TYPE, length(), this, null, REDUCE_IMPL.find(op, opc, $abstractvectortype$::reductionOperations))); } @@ -3438,6 +3532,16 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { private static ReductionOperation<$abstractvectortype$, VectorMask<$Boxtype$>> reductionOperations(int opc_) { switch (opc_) { +#if[FP16] + case VECTOR_OP_ADD: return (v, m) -> + toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + case VECTOR_OP_MUL: return (v, m) -> + toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + case VECTOR_OP_MIN: return (v, m) -> + toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + case VECTOR_OP_MAX: return (v, m) -> + toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); +#else[FP16] case VECTOR_OP_ADD: return (v, m) -> toBits(v.rOp(($type$)0, m, (i, a, b) -> ($type$)(a + b))); case VECTOR_OP_MUL: return (v, m) -> @@ -3446,6 +3550,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) Math.min(a, b))); case VECTOR_OP_MAX: return (v, m) -> toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> ($type$) Math.max(a, b))); +#end[FP16] #if[!FP] case VECTOR_OP_UMIN: return (v, m) -> toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) VectorMath.minUnsigned(a, b))); @@ -3467,8 +3572,8 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } #if[FP] - private static final $type$ MIN_OR_INF = $Boxtype$.NEGATIVE_INFINITY; - private static final $type$ MAX_OR_INF = $Boxtype$.POSITIVE_INFINITY; + private static final $type$ MIN_OR_INF = {#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.NEGATIVE_INFINITY):$Boxtype$.NEGATIVE_INFINITY}; + private static final $type$ MAX_OR_INF = {#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}; #else[FP] private static final $type$ MIN_OR_INF = $Boxtype$.MIN_VALUE; private static final $type$ MAX_OR_INF = $Boxtype$.MAX_VALUE; @@ -3605,7 +3710,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] a = toArray(); long[] res = new long[a.length]; for (int i = 0; i < a.length; i++) { - $type$ e = a[i]; + $type$ e = {#if[FP16]?Float16.shortBitsToFloat16(a[i]).shortValue():a[i]}; res[i] = $Type$Species.toIntegralChecked(e, false); } return res; @@ -3646,7 +3751,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] a = toArray(); double[] res = new double[a.length]; for (int i = 0; i < a.length; i++) { - res[i] = (double) a[i]; + res[i] = (double) {#if[FP16]?Float16.shortBitsToFloat16(a[i]).doubleValue():a[i]}; } return res; } @@ -3787,7 +3892,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } return VectorSupport.loadWithMap( - vectorType, null, $type$.class, vsp.laneCount(), + vectorType, null, $carriertype$.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, vix2, vix3, null, a, offset, indexMap, mapOffset, vsp, @@ -3795,7 +3900,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { s.vOp(n -> c[idx + iMap[idy+n]])); #else[byte] return VectorSupport.loadWithMap( - vectorType, null, $type$.class, vsp.laneCount(), + vectorType, null, $carriertype$.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -3848,7 +3953,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, null, $type$.class, vsp.laneCount(), + vectorType, null, $carriertype$.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, null, a, offset, indexMap, mapOffset, vsp, @@ -4347,7 +4452,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { offset = checkFromIndexSize(offset, length(), a.length); $Type$Species vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, @@ -4474,7 +4579,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), null, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), null, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, null, @@ -4567,7 +4672,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { offset = checkFromIndexSize(offset, length(), a.length); $Type$Species vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, this, a, offset, @@ -4729,7 +4834,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $Type$Species vsp = vspecies(); ByteVector normalized = this.and((byte) 1); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, normalized, a, offset, @@ -4943,7 +5048,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ fromArray0Template($type$[] a, int offset) { $Type$Species vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -4960,7 +5065,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { m.check(species()); $Type$Species vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -5018,7 +5123,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } return VectorSupport.loadWithMap( - vectorType, maskClass, $type$.class, vsp.laneCount(), + vectorType, maskClass, $carriertype$.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, vix2, vix3, m, a, offset, indexMap, mapOffset, vsp, @@ -5026,7 +5131,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { s.vOp(vm, n -> c[idx + iMap[idy+n]])); #else[byte] return VectorSupport.loadWithMap( - vectorType, maskClass, $type$.class, vsp.laneCount(), + vectorType, maskClass, $carriertype$.class, VECTOR_OPER_TYPE, vsp.laneCount(), lsp.vectorType(), lsp.length(), a, ARRAY_BASE, vix0, vix1, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -5081,7 +5186,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { vix = VectorIntrinsics.checkIndex(vix, a.length); return VectorSupport.loadWithMap( - vectorType, maskClass, $type$.class, vsp.laneCount(), + vectorType, maskClass, $carriertype$.class, VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, ARRAY_BASE, vix, null, null, null, m, a, offset, indexMap, mapOffset, vsp, @@ -5099,7 +5204,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ fromCharArray0Template(char[] a, int offset) { $Type$Species vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -5116,7 +5221,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { m.check(species()); $Type$Species vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -5133,7 +5238,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ fromBooleanArray0Template(boolean[] a, int offset) { $Type$Species vsp = vspecies(); return VectorSupport.load( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, a, offset, vsp, (arr, off, s) -> s.ldOp(arr, (int) off, @@ -5150,7 +5255,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { m.check(species()); $Type$Species vsp = vspecies(); return VectorSupport.loadMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, m, offsetInRange, a, offset, vsp, (arr, off, s, vm) -> s.ldOp(arr, (int) off, vm, @@ -5165,7 +5270,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ fromMemorySegment0Template(MemorySegment ms, long offset) { $Type$Species vsp = vspecies(); return ScopedMemoryAccess.loadFromMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, vsp, (msp, off, s) -> { return s.ldLongOp((MemorySegment) msp, off, $abstractvectortype$::memorySegmentGet); @@ -5181,7 +5286,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $Type$Species vsp = vspecies(); m.check(vsp); return ScopedMemoryAccess.loadFromMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), (AbstractMemorySegmentImpl) ms, offset, m, vsp, offsetInRange, (msp, off, s, vm) -> { return s.ldLongOp((MemorySegment) msp, off, vm, $abstractvectortype$::memorySegmentGet); @@ -5199,7 +5304,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { void intoArray0Template($type$[] a, int offset) { $Type$Species vsp = vspecies(); VectorSupport.store( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, a, offset, (arr, off, v) @@ -5216,7 +5321,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { m.check(species()); $Type$Species vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, arrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -5272,7 +5377,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { vix = VectorIntrinsics.checkIndex(vix, a.length); VectorSupport.storeWithMap( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), isp.vectorType(), isp.length(), a, arrayAddress(a, 0), vix, this, m, @@ -5297,7 +5402,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $Type$Species vsp = vspecies(); ByteVector normalized = this.and((byte) 1); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, booleanArrayAddress(a, offset), false, normalized, m, a, offset, (arr, off, v, vm) @@ -5311,7 +5416,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { void intoMemorySegment0(MemorySegment ms, long offset) { $Type$Species vsp = vspecies(); ScopedMemoryAccess.storeIntoMemorySegment( - vsp.vectorType(), vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v) -> { @@ -5328,7 +5433,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $Type$Species vsp = vspecies(); m.check(vsp); ScopedMemoryAccess.storeIntoMemorySegmentMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), this, m, (AbstractMemorySegmentImpl) ms, offset, (msp, off, v, vm) -> { @@ -5347,7 +5452,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { m.check(species()); $Type$Species vsp = vspecies(); VectorSupport.storeMasked( - vsp.vectorType(), maskClass, vsp.elementType(), vsp.laneCount(), + vsp.vectorType(), maskClass, vsp.carrierType(), VECTOR_OPER_TYPE, vsp.laneCount(), a, charArrayAddress(a, offset), false, this, m, a, offset, (arr, off, v, vm) @@ -5477,18 +5582,22 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @ForceInline @Override public final - {#if[byteOrShort]?Vector:$Fptype$Vector} +#if[FP16] + $Type$Vector +#else[FP16] + {#if[byte]?Vector:$Fptype$Vector} +#end[FP16] viewAsFloatingLanes() { #if[FP] return this; #else[FP] LaneType flt = LaneType.$TYPE$.asFloating(); -#if[!byteOrShort] +#if[!byte] return ($Fptype$Vector) asVectorRaw(flt); -#else[!byteOrShort] +#else[!byte] // asFloating() will throw UnsupportedOperationException for the unsupported type $type$ throw new AssertionError("Cannot reach here"); -#end[!byteOrShort] +#end[!byte] #end[FP] } @@ -5562,7 +5671,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { Class> maskType, Class> shuffleType, Function vectorFactory) { - super(shape, LaneType.of($type$.class), + super(shape, LaneType.of($elemtype$.class), vectorType, maskType, shuffleType, vectorFactory); assert(this.elementSize() == $Boxtype$.SIZE); @@ -5570,10 +5679,23 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // Specializing overrides: + @ForceInline + final Class carrierType() { + return $carriertype$.class; + } + + @ForceInline + final int operType() { + if ($elemtype$.class.equals(Float16.class)) { + return VECTOR_TYPE_FP16; + } + return VECTOR_TYPE_PRIM; + } + @Override @ForceInline public final Class<$Boxtype$> elementType() { - return $type$.class; + return $elemtype$.class; } @Override @@ -5602,7 +5724,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { final $abstractvectortype$ broadcastBits(long bits) { return ($abstractvectortype$) VectorSupport.fromBitsCoerced( - vectorType, $type$.class, laneCount, + vectorType, $carriertype$.class, VECTOR_OPER_TYPE, laneCount, bits, MODE_BROADCAST, this, (bits_, s_) -> s_.rvOp(i -> bits_)); } @@ -5656,11 +5778,19 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] va = new $type$[laneCount()]; for (int i = 0; i < va.length; i++) { int lv = values[i]; +#if[FP16] + $type$ v = Float16.float16ToRawShortBits(Float16.valueOf(lv)); + va[i] = v; + if (Float16.valueOf(lv).intValue() != lv) { + throw badElementBits(lv, v); + } +#else[FP16] $type$ v = ($type$) lv; va[i] = v; if ((int)v != lv) { throw badElementBits(lv, v); } +#end[FP16] } return dummyVector().fromArray0(va, 0); } @@ -5896,6 +6026,6 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { * A preferred species is a species of maximal bit-size for the platform. */ public static final VectorSpecies<$Boxtype$> SPECIES_PREFERRED - = ($Type$Species) VectorSpecies.ofPreferred($type$.class); + = ($Type$Species) VectorSpecies.ofPreferred($elemtype$.class); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template index fa502e3f29a72..b8760d5aef459 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template @@ -54,7 +54,11 @@ final class $vectortype$ extends $abstractvectortype$ { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class<$Boxtype$> ETYPE = $type$.class; // used by the JVM + static final Class<$Carriertype$> CTYPE = $carriertype$.class; // carrier type used by the JVM + + static final Class<$Boxtype$> ETYPE = $elemtype$.class; // vector element type used by the JVM + + static final int VECTOR_OPER_TYPE = {#if[FP16]?VECTOR_TYPE_FP16:VECTOR_TYPE_PRIM}; $vectortype$($type$[] v) { super(v); @@ -88,9 +92,12 @@ final class $vectortype$ extends $abstractvectortype$ { return VSPECIES; } + @ForceInline + final Class<$Carriertype$> carrierType() { return CTYPE; } + @ForceInline @Override - public final Class<$Boxtype$> elementType() { return $type$.class; } + public final Class<$Boxtype$> elementType() { return ETYPE; } @ForceInline @Override @@ -559,6 +566,24 @@ final class $vectortype$ extends $abstractvectortype$ { case 13: bits = laneHelper(13); break; case 14: bits = laneHelper(14); break; case 15: bits = laneHelper(15); break; +#if[!16L] + case 16: bits = laneHelper(16); break; + case 17: bits = laneHelper(17); break; + case 18: bits = laneHelper(18); break; + case 19: bits = laneHelper(19); break; + case 20: bits = laneHelper(20); break; + case 21: bits = laneHelper(21); break; + case 22: bits = laneHelper(22); break; + case 23: bits = laneHelper(23); break; + case 24: bits = laneHelper(24); break; + case 25: bits = laneHelper(25); break; + case 26: bits = laneHelper(26); break; + case 27: bits = laneHelper(27); break; + case 28: bits = laneHelper(28); break; + case 29: bits = laneHelper(29); break; + case 30: bits = laneHelper(30); break; + case 31: bits = laneHelper(31); break; +#end[!16L] #end[!8L] #end[!4L] #end[!2L] @@ -571,17 +596,17 @@ final class $vectortype$ extends $abstractvectortype$ { } $bitstype$ bits = laneHelper(i); #end[!Max] - return $Type$.$bitstype$BitsTo$Fptype$(bits); + return {#if[FP16]?bits:$Type$.$bitstype$BitsTo$Fptype$(bits)}; } @ForceInline public $bitstype$ laneHelper(int i) { return ($bitstype$) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { $type$[] vecarr = vec.vec(); - return (long)$Type$.$type$ToRaw$Bitstype$Bits(vecarr[ix]); + return {#if[FP16]?vecarr[ix]:(long)$Type$.$type$ToRaw$Bitstype$Bits(vecarr[ix])}; }); } @@ -610,6 +635,24 @@ final class $vectortype$ extends $abstractvectortype$ { case 13: return withLaneHelper(13, e); case 14: return withLaneHelper(14, e); case 15: return withLaneHelper(15, e); +#if[!16L] + case 16: return withLaneHelper(16, e); + case 17: return withLaneHelper(17, e); + case 18: return withLaneHelper(18, e); + case 19: return withLaneHelper(19, e); + case 20: return withLaneHelper(20, e); + case 21: return withLaneHelper(21, e); + case 22: return withLaneHelper(22, e); + case 23: return withLaneHelper(23, e); + case 24: return withLaneHelper(24, e); + case 25: return withLaneHelper(25, e); + case 26: return withLaneHelper(26, e); + case 27: return withLaneHelper(27, e); + case 28: return withLaneHelper(28, e); + case 29: return withLaneHelper(29, e); + case 30: return withLaneHelper(30, e); + case 31: return withLaneHelper(31, e); +#end[!16L] #end[!8L] #end[!4L] #end[!2L] @@ -627,11 +670,11 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public $vectortype$ withLaneHelper(int i, $type$ e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, - this, i, (long)$Type$.$type$ToRaw$Bitstype$Bits(e), + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, + this, i, (long){#if[FP16]?e:$Type$.$type$ToRaw$Bitstype$Bits(e)}, (v, ix, bits) -> { $type$[] res = v.vec().clone(); - res[ix] = $Type$.$bitstype$BitsTo$Type$(($bitstype$)bits); + res[ix] = {#if[FP16]?e:$Type$.$bitstype$BitsTo$Type$(($bitstype$)bits)}; return v.vectorFactory(res); }); } @@ -730,7 +773,7 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public $type$ laneHelper(int i) { return ($type$) VectorSupport.extract( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (vec, ix) -> { $type$[] vecarr = vec.vec(); @@ -832,7 +875,7 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public $vectortype$ withLaneHelper(int i, $type$ e) { return VectorSupport.insert( - VCLASS, ETYPE, VLENGTH, + VCLASS, CTYPE, VECTOR_OPER_TYPE, VLENGTH, this, i, (long)e, (v, ix, bits) -> { $type$[] res = v.vec().clone(); @@ -846,7 +889,7 @@ final class $vectortype$ extends $abstractvectortype$ { static final class $masktype$ extends AbstractMask<$Boxtype$> { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class<$Boxtype$> ETYPE = $type$.class; // used by the JVM + static final Class<$Carriertype$> CTYPE = $carriertype$.class; // used by the JVM $masktype$(boolean[] bits) { this(bits, 0); @@ -948,7 +991,7 @@ final class $vectortype$ extends $abstractvectortype$ { /*package-private*/ $masktype$ indexPartiallyInUpperRange(long offset, long limit) { return ($masktype$) VectorSupport.indexPartiallyInUpperRange( - $masktype$.class, $type$.class, VLENGTH, offset, limit, + $masktype$.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, offset, limit, (o, l) -> ($masktype$) TRUE_MASK.indexPartiallyInRange(o, l)); } @@ -964,8 +1007,9 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public $masktype$ compress() { return ($masktype$)VectorSupport.compressExpandOp(VectorSupport.VECTOR_OP_MASK_COMPRESS, - $vectortype$.class, $masktype$.class, ETYPE, VLENGTH, null, this, - (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount())); + $vectortype$.class, $masktype$.class, CTYPE, VECTOR_OPER_TYPE, VLENGTH, null, this, + (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, + {#if[FP16]?Float16.float16ToShortBits(Float16.valueOf(m1.trueCount())):m1.trueCount()})); } @@ -976,7 +1020,7 @@ final class $vectortype$ extends $abstractvectortype$ { public $masktype$ and(VectorMask<$Boxtype$> mask) { Objects.requireNonNull(mask); $masktype$ m = ($masktype$)mask; - return VectorSupport.binaryOp(VECTOR_OP_AND, $masktype$.class, null, $bitstype$.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_AND, $masktype$.class, null, $bitstype$.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b)); } @@ -986,7 +1030,7 @@ final class $vectortype$ extends $abstractvectortype$ { public $masktype$ or(VectorMask<$Boxtype$> mask) { Objects.requireNonNull(mask); $masktype$ m = ($masktype$)mask; - return VectorSupport.binaryOp(VECTOR_OP_OR, $masktype$.class, null, $bitstype$.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_OR, $masktype$.class, null, $bitstype$.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b)); } @@ -996,7 +1040,7 @@ final class $vectortype$ extends $abstractvectortype$ { public $masktype$ xor(VectorMask<$Boxtype$> mask) { Objects.requireNonNull(mask); $masktype$ m = ($masktype$)mask; - return VectorSupport.binaryOp(VECTOR_OP_XOR, $masktype$.class, null, $bitstype$.class, VLENGTH, + return VectorSupport.binaryOp(VECTOR_OP_XOR, $masktype$.class, null, $bitstype$.class, VECTOR_OPER_TYPE, VLENGTH, this, m, null, (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a ^ b)); } @@ -1006,22 +1050,25 @@ final class $vectortype$ extends $abstractvectortype$ { @Override @ForceInline public int trueCount() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, $masktype$.class, $bitstype$.class, VLENGTH, this, - (m) -> trueCountHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TRUECOUNT, $masktype$.class, $bitstype$.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> trueCountHelper(m.getBits())); } @Override @ForceInline public int firstTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, $masktype$.class, $bitstype$.class, VLENGTH, this, - (m) -> firstTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_FIRSTTRUE, $masktype$.class, $bitstype$.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> firstTrueHelper(m.getBits())); } @Override @ForceInline public int lastTrue() { - return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, $masktype$.class, $bitstype$.class, VLENGTH, this, - (m) -> lastTrueHelper(m.getBits())); + return (int) VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_LASTTRUE, $masktype$.class, $bitstype$.class, + VECTOR_OPER_TYPE, VLENGTH, this, + (m) -> lastTrueHelper(m.getBits())); } @Override @@ -1030,7 +1077,8 @@ final class $vectortype$ extends $abstractvectortype$ { if (length() > Long.SIZE) { throw new UnsupportedOperationException("too many lanes for one long"); } - return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, $masktype$.class, $bitstype$.class, VLENGTH, this, + return VectorSupport.maskReductionCoerced(VECTOR_OP_MASK_TOLONG, $masktype$.class, $bitstype$.class, + VECTOR_OPER_TYPE, VLENGTH, this, (m) -> toLongHelper(m.getBits())); } @@ -1040,7 +1088,7 @@ final class $vectortype$ extends $abstractvectortype$ { @ForceInline public boolean laneIsSet(int i) { Objects.checkIndex(i, length()); - return VectorSupport.extract($masktype$.class, $type$.class, VLENGTH, + return VectorSupport.extract($masktype$.class, $type$.class, VECTOR_OPER_TYPE, VLENGTH, this, i, (m, idx) -> (m.getBits()[idx] ? 1L : 0L)) == 1L; } @@ -1049,23 +1097,23 @@ final class $vectortype$ extends $abstractvectortype$ { @Override @ForceInline public boolean anyTrue() { - return VectorSupport.test(BT_ne, $masktype$.class, $bitstype$.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> anyTrueHelper((($masktype$)m).getBits())); + return VectorSupport.test(BT_ne, $masktype$.class, $bitstype$.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> anyTrueHelper((($masktype$)m).getBits())); } @Override @ForceInline public boolean allTrue() { - return VectorSupport.test(BT_overflow, $masktype$.class, $bitstype$.class, VLENGTH, - this, vspecies().maskAll(true), - (m, __) -> allTrueHelper((($masktype$)m).getBits())); + return VectorSupport.test(BT_overflow, $masktype$.class, $bitstype$.class, VECTOR_OPER_TYPE, VLENGTH, + this, vspecies().maskAll(true), + (m, __) -> allTrueHelper((($masktype$)m).getBits())); } @ForceInline /*package-private*/ static $masktype$ maskAll(boolean bit) { - return VectorSupport.fromBitsCoerced($masktype$.class, $bitstype$.class, VLENGTH, + return VectorSupport.fromBitsCoerced($masktype$.class, $bitstype$.class, VECTOR_OPER_TYPE, VLENGTH, (bit ? -1 : 0), MODE_BROADCAST, null, (v, __) -> (v != 0 ? TRUE_MASK : FALSE_MASK)); } @@ -1093,7 +1141,7 @@ final class $vectortype$ extends $abstractvectortype$ { static final class $shuffletype$ extends AbstractShuffle<$Boxtype$> { static final int VLENGTH = VSPECIES.laneCount(); // used by the JVM - static final Class<$Boxbitstype$> ETYPE = $bitstype$.class; // used by the JVM + static final Class<$Boxbitstype$> CTYPE = $bitstype$.class; // used by the JVM $shuffletype$($bitstype$[] indices) { super(indices); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh index 6841a47c7574a..a5da883f3f5c4 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/gen-src.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2020, 2025, 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 @@ -53,39 +53,58 @@ typeprefix= globalArgs="" #globalArgs="$globalArgs -KextraOverrides" -for type in byte short int long float double +for type in byte short int long float double halffloat do + Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" + + case $type in + halffloat) + type=short + TYPE=SHORT + ;; + esac + args=$globalArgs args="$args -K$type -Dtype=$type -DType=$Type -DTYPE=$TYPE" Boxtype=$Type Wideboxtype=$Boxtype + ElemLayout=$Type kind=BITWISE bitstype=$type + maskbitstype=$type Bitstype=$Type Boxbitstype=$Boxtype fptype=$type Fptype=$Type Boxfptype=$Boxtype + carriertype=$type + Carriertype=$Type + elemtype=$type + FPtype=$type - case $type in - byte) + case $Type in + Byte) Wideboxtype=Integer sizeInBytes=1 args="$args -KbyteOrShort" ;; - short) + Short) + fptype=halffloat + Fptype=Halffloat + Boxfptype=Halffloat Wideboxtype=Integer sizeInBytes=2 args="$args -KbyteOrShort" ;; - int) + Int) Boxtype=Integer + Carriertype=Integer Wideboxtype=Integer Boxbitstype=Integer fptype=float @@ -94,35 +113,56 @@ do sizeInBytes=4 args="$args -KintOrLong -KintOrFP -KintOrFloat" ;; - long) + Long) fptype=double Fptype=Double Boxfptype=Double sizeInBytes=8 args="$args -KintOrLong -KlongOrDouble" ;; - float) + Float) kind=FP bitstype=int + maskbitstype=int Bitstype=Int Boxbitstype=Integer sizeInBytes=4 args="$args -KintOrFP -KintOrFloat" + FPtype=FP32 ;; - double) + Double) kind=FP bitstype=long + maskbitstype=long Bitstype=Long Boxbitstype=Long sizeInBytes=8 args="$args -KintOrFP -KlongOrDouble" + FPtype=FP64 + ;; + Halffloat) + kind=FP + bitstype=short + maskbitstype=short + Bitstype=Short + Boxbitstype=Short + sizeInBytes=2 + carriertype=short + Carriertype=Short + FPtype=FP16 + Boxtype=Float16 + elemtype=Float16 + ElemLayout=Short + args="$args -KbyteOrShort -KshortOrFP -KshortOrHalffloat" ;; esac - args="$args -K$kind -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype" - args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" + + args="$args -K$FPtype -K$kind -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype" + args="$args -DElemLayout=$ElemLayout -Dbitstype=$bitstype -Dmaskbitstype=$maskbitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" args="$args -DsizeInBytes=$sizeInBytes" + args="$args -Dcarriertype=$carriertype -Delemtype=$elemtype -DCarriertype=$Carriertype" abstractvectortype=${typeprefix}${Type}Vector abstractbitsvectortype=${typeprefix}${Bitstype}Vector diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index bea4d541987e3..219ab16c34348 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Byte128VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par } } + static byte genValue(int i) { + return (byte) i; + } + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; @@ -1019,15 +1029,15 @@ static byte bits(byte e) { static final List> BYTE_GENERATORS = List.of( withToString("byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(i * 5)); + i -> genValue(i * 5)); }), withToString("byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1))); + i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("byte[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3032,8 +3042,6 @@ static void ROLByte128VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MINByte128VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3042,15 +3050,13 @@ static void MINByte128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte128VectorTests::MIN); } - static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void minByte128VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3059,15 +3065,13 @@ static void minByte128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte128VectorTests::min); } - static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MINByte128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3078,15 +3082,13 @@ static void MINByte128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, mask, Byte128VectorTests::MIN); } - static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MAXByte128VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3095,15 +3097,13 @@ static void MAXByte128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte128VectorTests::MAX); } - static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void maxByte128VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3112,15 +3112,13 @@ static void maxByte128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte128VectorTests::max); } - static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MAXByte128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3131,7 +3129,7 @@ static void MAXByte128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6524,7 +6522,7 @@ static void ADDReduceLongByte128VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6565,7 +6563,7 @@ static void ADDReduceLongByte128VectorTestsMasked(IntFunction fa, IntFun } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index be5b3cf6198cf..39b74d64f0c01 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Byte256VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par } } + static byte genValue(int i) { + return (byte) i; + } + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; @@ -1019,15 +1029,15 @@ static byte bits(byte e) { static final List> BYTE_GENERATORS = List.of( withToString("byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(i * 5)); + i -> genValue(i * 5)); }), withToString("byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1))); + i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("byte[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3032,8 +3042,6 @@ static void ROLByte256VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MINByte256VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3042,15 +3050,13 @@ static void MINByte256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte256VectorTests::MIN); } - static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void minByte256VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3059,15 +3065,13 @@ static void minByte256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte256VectorTests::min); } - static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MINByte256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3078,15 +3082,13 @@ static void MINByte256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, mask, Byte256VectorTests::MIN); } - static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MAXByte256VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3095,15 +3097,13 @@ static void MAXByte256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte256VectorTests::MAX); } - static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void maxByte256VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3112,15 +3112,13 @@ static void maxByte256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte256VectorTests::max); } - static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MAXByte256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3131,7 +3129,7 @@ static void MAXByte256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6524,7 +6522,7 @@ static void ADDReduceLongByte256VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6565,7 +6563,7 @@ static void ADDReduceLongByte256VectorTestsMasked(IntFunction fa, IntFun } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index 0fd68b6f712d7..db8a7f5d02403 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Byte512VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par } } + static byte genValue(int i) { + return (byte) i; + } + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; @@ -1019,15 +1029,15 @@ static byte bits(byte e) { static final List> BYTE_GENERATORS = List.of( withToString("byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(i * 5)); + i -> genValue(i * 5)); }), withToString("byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1))); + i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("byte[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3032,8 +3042,6 @@ static void ROLByte512VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MINByte512VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3042,15 +3050,13 @@ static void MINByte512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte512VectorTests::MIN); } - static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void minByte512VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3059,15 +3065,13 @@ static void minByte512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte512VectorTests::min); } - static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MINByte512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3078,15 +3082,13 @@ static void MINByte512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, mask, Byte512VectorTests::MIN); } - static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MAXByte512VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3095,15 +3097,13 @@ static void MAXByte512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte512VectorTests::MAX); } - static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void maxByte512VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3112,15 +3112,13 @@ static void maxByte512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte512VectorTests::max); } - static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MAXByte512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3131,7 +3129,7 @@ static void MAXByte512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6524,7 +6522,7 @@ static void ADDReduceLongByte512VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6565,7 +6563,7 @@ static void ADDReduceLongByte512VectorTestsMasked(IntFunction fa, IntFun } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index 112b2e56b6f58..b3003635b0a4e 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Byte64VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par } } + static byte genValue(int i) { + return (byte) i; + } + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; @@ -1019,15 +1029,15 @@ static byte bits(byte e) { static final List> BYTE_GENERATORS = List.of( withToString("byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(i * 5)); + i -> genValue(i * 5)); }), withToString("byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1))); + i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("byte[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3032,8 +3042,6 @@ static void ROLByte64VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MINByte64VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3042,15 +3050,13 @@ static void MINByte64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte64VectorTests::MIN); } - static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void minByte64VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3059,15 +3065,13 @@ static void minByte64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte64VectorTests::min); } - static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MINByte64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3078,15 +3082,13 @@ static void MINByte64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunct for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, mask, Byte64VectorTests::MIN); } - static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MAXByte64VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3095,15 +3097,13 @@ static void MAXByte64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte64VectorTests::MAX); } - static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void maxByte64VectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3112,15 +3112,13 @@ static void maxByte64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, Byte64VectorTests::max); } - static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MAXByte64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3131,7 +3129,7 @@ static void MAXByte64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunct for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6524,7 +6522,7 @@ static void ADDReduceLongByte64VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6565,7 +6563,7 @@ static void ADDReduceLongByte64VectorTestsMasked(IntFunction fa, IntFunc } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index 435cacc013e2a..053cdae4a5e5e 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -329,15 +331,17 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -363,21 +367,23 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -971,6 +977,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par } } + static byte genValue(int i) { + return (byte) i; + } + static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; @@ -1024,15 +1034,15 @@ static byte bits(byte e) { static final List> BYTE_GENERATORS = List.of( withToString("byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (byte)(i * 5)); + i -> genValue(i * 5)); }), withToString("byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1))); + i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("byte[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3037,8 +3047,6 @@ static void ROLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, } - static ByteVector bv_MIN = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MINByteMaxVectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3047,15 +3055,13 @@ static void MINByteMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::MIN); } - static ByteVector bv_min = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void minByteMaxVectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3064,15 +3070,13 @@ static void minByteMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::min); } - static ByteVector bv_MIN_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MINByteMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3083,15 +3087,13 @@ static void MINByteMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, mask, ByteMaxVectorTests::MIN); } - static ByteVector bv_MAX = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void MAXByteMaxVectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3100,15 +3102,13 @@ static void MAXByteMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::MAX); } - static ByteVector bv_max = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpProvider") static void maxByteMaxVectorTestsWithMemOp(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); @@ -3117,15 +3117,13 @@ static void maxByteMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (byte)10, ByteMaxVectorTests::max); } - static ByteVector bv_MAX_M = ByteVector.broadcast(SPECIES, (byte)10); - @Test(dataProvider = "byteUnaryOpMaskProvider") static void MAXByteMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); @@ -3136,7 +3134,7 @@ static void MAXByteMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6529,7 +6527,7 @@ static void ADDReduceLongByteMaxVectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6570,7 +6568,7 @@ static void ADDReduceLongByteMaxVectorTestsMasked(IntFunction fa, IntFun } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java index f15ce88ddb897..0688a380d6ac0 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Double128VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, F isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i } } + static double genValue(int i) { + return (double) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static double genValue(long i) { + return (double) i; + } + static final List> LONG_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1150,29 +1164,29 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { } static long bits(double e) { - return Double.doubleToLongBits(e); + return Double.doubleToLongBits(e); } static final List> DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)0.01 + ((double)i / (i + 1))); + i -> ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (double)0.01 + ((double)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2096,8 +2110,6 @@ static void ADDDouble128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2106,15 +2118,13 @@ static void MINDouble128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double128VectorTests::MIN); } - static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void minDouble128VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2123,15 +2133,13 @@ static void minDouble128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double128VectorTests::min); } - static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MINDouble128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2142,15 +2150,13 @@ static void MINDouble128VectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, mask, Double128VectorTests::MIN); } - static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void MAXDouble128VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2159,15 +2165,13 @@ static void MAXDouble128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double128VectorTests::MAX); } - static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void maxDouble128VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2176,15 +2180,13 @@ static void maxDouble128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double128VectorTests::max); } - static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MAXDouble128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2195,7 +2197,7 @@ static void MAXDouble128VectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4919,7 +4921,7 @@ static void ADDReduceLongDouble128VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4960,7 +4962,7 @@ static void ADDReduceLongDouble128VectorTestsMasked(IntFunction fa, In } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java index e6c3662e0ad6e..86113790f8b4c 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Double256VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, F isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i } } + static double genValue(int i) { + return (double) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static double genValue(long i) { + return (double) i; + } + static final List> LONG_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1150,29 +1164,29 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { } static long bits(double e) { - return Double.doubleToLongBits(e); + return Double.doubleToLongBits(e); } static final List> DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)0.01 + ((double)i / (i + 1))); + i -> ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (double)0.01 + ((double)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2096,8 +2110,6 @@ static void ADDDouble256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2106,15 +2118,13 @@ static void MINDouble256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double256VectorTests::MIN); } - static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void minDouble256VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2123,15 +2133,13 @@ static void minDouble256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double256VectorTests::min); } - static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MINDouble256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2142,15 +2150,13 @@ static void MINDouble256VectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, mask, Double256VectorTests::MIN); } - static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void MAXDouble256VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2159,15 +2165,13 @@ static void MAXDouble256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double256VectorTests::MAX); } - static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void maxDouble256VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2176,15 +2180,13 @@ static void maxDouble256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double256VectorTests::max); } - static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MAXDouble256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2195,7 +2197,7 @@ static void MAXDouble256VectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4919,7 +4921,7 @@ static void ADDReduceLongDouble256VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4960,7 +4962,7 @@ static void ADDReduceLongDouble256VectorTestsMasked(IntFunction fa, In } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java index 7c37c9878e8f6..8c0d0531087ae 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Double512VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, F isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i } } + static double genValue(int i) { + return (double) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static double genValue(long i) { + return (double) i; + } + static final List> LONG_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1150,29 +1164,29 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { } static long bits(double e) { - return Double.doubleToLongBits(e); + return Double.doubleToLongBits(e); } static final List> DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)0.01 + ((double)i / (i + 1))); + i -> ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (double)0.01 + ((double)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2096,8 +2110,6 @@ static void ADDDouble512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2106,15 +2118,13 @@ static void MINDouble512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double512VectorTests::MIN); } - static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void minDouble512VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2123,15 +2133,13 @@ static void minDouble512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double512VectorTests::min); } - static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MINDouble512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2142,15 +2150,13 @@ static void MINDouble512VectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, mask, Double512VectorTests::MIN); } - static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void MAXDouble512VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2159,15 +2165,13 @@ static void MAXDouble512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double512VectorTests::MAX); } - static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void maxDouble512VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2176,15 +2180,13 @@ static void maxDouble512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double512VectorTests::max); } - static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MAXDouble512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2195,7 +2197,7 @@ static void MAXDouble512VectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4919,7 +4921,7 @@ static void ADDReduceLongDouble512VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4960,7 +4962,7 @@ static void ADDReduceLongDouble512VectorTestsMasked(IntFunction fa, In } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java index 85b96288b379b..4f01df5ba6d8f 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Double64VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, F isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i } } + static double genValue(int i) { + return (double) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static double genValue(long i) { + return (double) i; + } + static final List> LONG_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1150,29 +1164,29 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { } static long bits(double e) { - return Double.doubleToLongBits(e); + return Double.doubleToLongBits(e); } static final List> DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)0.01 + ((double)i / (i + 1))); + i -> ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (double)0.01 + ((double)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2096,8 +2110,6 @@ static void ADDDouble64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2106,15 +2118,13 @@ static void MINDouble64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double64VectorTests::MIN); } - static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void minDouble64VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2123,15 +2133,13 @@ static void minDouble64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double64VectorTests::min); } - static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MINDouble64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2142,15 +2150,13 @@ static void MINDouble64VectorTestsMaskedWithMemOp(IntFunction fa, IntF for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, mask, Double64VectorTests::MIN); } - static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void MAXDouble64VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2159,15 +2165,13 @@ static void MAXDouble64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double64VectorTests::MAX); } - static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void maxDouble64VectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2176,15 +2180,13 @@ static void maxDouble64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, Double64VectorTests::max); } - static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MAXDouble64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2195,7 +2197,7 @@ static void MAXDouble64VectorTestsMaskedWithMemOp(IntFunction fa, IntF for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4919,7 +4921,7 @@ static void ADDReduceLongDouble64VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4960,7 +4962,7 @@ static void ADDReduceLongDouble64VectorTestsMasked(IntFunction fa, Int } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java index 7245990d66c1e..6d3b80c906be2 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class DoubleMaxVectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -347,15 +349,17 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -381,21 +385,23 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -851,7 +857,7 @@ static void assertArraysEqualsWithinOneUlp(double[] r, double[] a, double[] b, F isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Double.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1063,6 +1069,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i } } + static double genValue(int i) { + return (double) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1081,15 +1091,15 @@ static int intCornerCaseValue(int i) { static final List> INT_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1123,18 +1133,22 @@ static long longCornerCaseValue(int i) { } } + static double genValue(long i) { + return (double) i; + } + static final List> LONG_DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1155,29 +1169,29 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { } static long bits(double e) { - return Double.doubleToLongBits(e); + return Double.doubleToLongBits(e); } static final List> DOUBLE_GENERATORS = List.of( withToString("double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)(i * 5)); + i -> genValue(i * 5)); }), withToString("double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((double)(i + 1) == 0) ? 1 : (double)(i + 1))); + i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("double[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (double)0.01 + ((double)i / (i + 1))); + i -> ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (double)0.01 + ((double)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((double)0.01 + ((double)i / (i + 1)))); }), withToString("double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2101,8 +2115,6 @@ static void ADDDoubleMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2111,15 +2123,13 @@ static void MINDoubleMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::MIN); } - static DoubleVector bv_min = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void minDoubleMaxVectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2128,15 +2138,13 @@ static void minDoubleMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::min); } - static DoubleVector bv_MIN_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MINDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2147,15 +2155,13 @@ static void MINDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, mask, DoubleMaxVectorTests::MIN); } - static DoubleVector bv_MAX = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void MAXDoubleMaxVectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2164,15 +2170,13 @@ static void MAXDoubleMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::MAX); } - static DoubleVector bv_max = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpProvider") static void maxDoubleMaxVectorTestsWithMemOp(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); @@ -2181,15 +2185,13 @@ static void maxDoubleMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (double)10, DoubleMaxVectorTests::max); } - static DoubleVector bv_MAX_M = DoubleVector.broadcast(SPECIES, (double)10); - @Test(dataProvider = "doubleUnaryOpMaskProvider") static void MAXDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { double[] a = fa.apply(SPECIES.length()); @@ -2200,7 +2202,7 @@ static void MAXDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, Int for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4924,7 +4926,7 @@ static void ADDReduceLongDoubleMaxVectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4965,7 +4967,7 @@ static void ADDReduceLongDoubleMaxVectorTestsMasked(IntFunction fa, In } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java index c4f4ed1b9661a..b85697cf753f5 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Float128VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBin isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int } } + static float genValue(int i) { + return (float) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static float genValue(long i) { + return (float) i; + } + static final List> LONG_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1161,29 +1175,29 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { } static int bits(float e) { - return Float.floatToIntBits(e); + return Float.floatToIntBits(e); } static final List> FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)0.01 + ((float)i / (i + 1))); + i -> ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (float)0.01 + ((float)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2107,8 +2121,6 @@ static void ADDFloat128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2117,15 +2129,13 @@ static void MINFloat128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float128VectorTests::MIN); } - static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void minFloat128VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2134,15 +2144,13 @@ static void minFloat128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float128VectorTests::min); } - static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MINFloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2153,15 +2161,13 @@ static void MINFloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, mask, Float128VectorTests::MIN); } - static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void MAXFloat128VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2170,15 +2176,13 @@ static void MAXFloat128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float128VectorTests::MAX); } - static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void maxFloat128VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2187,15 +2191,13 @@ static void maxFloat128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float128VectorTests::max); } - static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MAXFloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2206,7 +2208,7 @@ static void MAXFloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4898,7 +4900,7 @@ static void ADDReduceLongFloat128VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4939,7 +4941,7 @@ static void ADDReduceLongFloat128VectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java index 87cbc165d599e..578bfa4729109 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Float256VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBin isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int } } + static float genValue(int i) { + return (float) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static float genValue(long i) { + return (float) i; + } + static final List> LONG_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1161,29 +1175,29 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { } static int bits(float e) { - return Float.floatToIntBits(e); + return Float.floatToIntBits(e); } static final List> FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)0.01 + ((float)i / (i + 1))); + i -> ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (float)0.01 + ((float)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2107,8 +2121,6 @@ static void ADDFloat256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2117,15 +2129,13 @@ static void MINFloat256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float256VectorTests::MIN); } - static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void minFloat256VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2134,15 +2144,13 @@ static void minFloat256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float256VectorTests::min); } - static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MINFloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2153,15 +2161,13 @@ static void MINFloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, mask, Float256VectorTests::MIN); } - static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void MAXFloat256VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2170,15 +2176,13 @@ static void MAXFloat256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float256VectorTests::MAX); } - static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void maxFloat256VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2187,15 +2191,13 @@ static void maxFloat256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float256VectorTests::max); } - static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MAXFloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2206,7 +2208,7 @@ static void MAXFloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4898,7 +4900,7 @@ static void ADDReduceLongFloat256VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4939,7 +4941,7 @@ static void ADDReduceLongFloat256VectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java index beb9561d88215..a759f756cd3e4 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Float512VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBin isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int } } + static float genValue(int i) { + return (float) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static float genValue(long i) { + return (float) i; + } + static final List> LONG_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1161,29 +1175,29 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { } static int bits(float e) { - return Float.floatToIntBits(e); + return Float.floatToIntBits(e); } static final List> FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)0.01 + ((float)i / (i + 1))); + i -> ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (float)0.01 + ((float)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2107,8 +2121,6 @@ static void ADDFloat512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2117,15 +2129,13 @@ static void MINFloat512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float512VectorTests::MIN); } - static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void minFloat512VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2134,15 +2144,13 @@ static void minFloat512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float512VectorTests::min); } - static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MINFloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2153,15 +2161,13 @@ static void MINFloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, mask, Float512VectorTests::MIN); } - static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void MAXFloat512VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2170,15 +2176,13 @@ static void MAXFloat512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float512VectorTests::MAX); } - static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void maxFloat512VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2187,15 +2191,13 @@ static void maxFloat512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float512VectorTests::max); } - static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MAXFloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2206,7 +2208,7 @@ static void MAXFloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4898,7 +4900,7 @@ static void ADDReduceLongFloat512VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4939,7 +4941,7 @@ static void ADDReduceLongFloat512VectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java index ee630abd8e052..d47e9bd8d4a39 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class Float64VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -342,15 +344,17 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -376,21 +380,23 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -846,7 +852,7 @@ static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBin isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1058,6 +1064,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int } } + static float genValue(int i) { + return (float) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1076,15 +1086,15 @@ static int intCornerCaseValue(int i) { static final List> INT_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1118,18 +1128,22 @@ static long longCornerCaseValue(int i) { } } + static float genValue(long i) { + return (float) i; + } + static final List> LONG_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1161,29 +1175,29 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { } static int bits(float e) { - return Float.floatToIntBits(e); + return Float.floatToIntBits(e); } static final List> FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)0.01 + ((float)i / (i + 1))); + i -> ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (float)0.01 + ((float)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2107,8 +2121,6 @@ static void ADDFloat64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2117,15 +2129,13 @@ static void MINFloat64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float64VectorTests::MIN); } - static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void minFloat64VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2134,15 +2144,13 @@ static void minFloat64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float64VectorTests::min); } - static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MINFloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2153,15 +2161,13 @@ static void MINFloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFun for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, mask, Float64VectorTests::MIN); } - static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void MAXFloat64VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2170,15 +2176,13 @@ static void MAXFloat64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float64VectorTests::MAX); } - static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void maxFloat64VectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2187,15 +2191,13 @@ static void maxFloat64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, Float64VectorTests::max); } - static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MAXFloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2206,7 +2208,7 @@ static void MAXFloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFun for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4898,7 +4900,7 @@ static void ADDReduceLongFloat64VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4939,7 +4941,7 @@ static void ADDReduceLongFloat64VectorTestsMasked(IntFunction fa, IntFu } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java index 41e4d6e4a5de3..a5a17acc9496a 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -62,6 +62,8 @@ public class FloatMaxVectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -347,15 +349,17 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -381,21 +385,23 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -851,7 +857,7 @@ static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBin isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1063,6 +1069,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int } } + static float genValue(int i) { + return (float) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -1081,15 +1091,15 @@ static int intCornerCaseValue(int i) { static final List> INT_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1123,18 +1133,22 @@ static long longCornerCaseValue(int i) { } } + static float genValue(long i) { + return (float) i; + } + static final List> LONG_FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1166,29 +1180,29 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { } static int bits(float e) { - return Float.floatToIntBits(e); + return Float.floatToIntBits(e); } static final List> FLOAT_GENERATORS = List.of( withToString("float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)(i * 5)); + i -> genValue(i * 5)); }), withToString("float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1))); + i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("float[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (float)0.01 + ((float)i / (i + 1))); + i -> ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : (float)0.01 + ((float)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : ((float)0.01 + ((float)i / (i + 1)))); }), withToString("float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -2112,8 +2126,6 @@ static void ADDFloatMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2122,15 +2134,13 @@ static void MINFloatMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::MIN); } - static FloatVector bv_min = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void minFloatMaxVectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2139,15 +2149,13 @@ static void minFloatMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::min); } - static FloatVector bv_MIN_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MINFloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2158,15 +2166,13 @@ static void MINFloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, mask, FloatMaxVectorTests::MIN); } - static FloatVector bv_MAX = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void MAXFloatMaxVectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2175,15 +2181,13 @@ static void MAXFloatMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::MAX); } - static FloatVector bv_max = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpProvider") static void maxFloatMaxVectorTestsWithMemOp(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); @@ -2192,15 +2196,13 @@ static void maxFloatMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (float)10, FloatMaxVectorTests::max); } - static FloatVector bv_MAX_M = FloatVector.broadcast(SPECIES, (float)10); - @Test(dataProvider = "floatUnaryOpMaskProvider") static void MAXFloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { float[] a = fa.apply(SPECIES.length()); @@ -2211,7 +2213,7 @@ static void MAXFloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -4903,7 +4905,7 @@ static void ADDReduceLongFloatMaxVectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -4944,7 +4946,7 @@ static void ADDReduceLongFloatMaxVectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Halffloat128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Halffloat128VectorLoadStoreTests.java new file mode 100644 index 0000000000000..937f3b14331e2 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat128VectorLoadStoreTests.java @@ -0,0 +1,1016 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation + * @run testng/othervm -XX:-TieredCompilation Halffloat128VectorLoadStoreTests + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.Arena; +import java.lang.foreign.ValueLayout; +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.internal.vm.annotation.DontInline; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.nio.ByteOrder; +import java.util.List; +import java.util.function.*; + +@Test +public class Halffloat128VectorLoadStoreTests extends AbstractVectorLoadStoreTest { + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_128; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); + + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); + } + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + }) + ); + + // Relative to array.length + static final List> INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl + 1", (int l) -> { + return l - SPECIES.length() + 1; + }), + withToString("l + speciesl - 1", (int l) -> { + return l + SPECIES.length() - 1; + }), + withToString("l + speciesl", (int l) -> { + return l + SPECIES.length(); + }), + withToString("l + speciesl + 1", (int l) -> { + return l + SPECIES.length() + 1; + }) + ); + + // Relative to byte[] array.length or MemorySegment.byteSize() + static final List> BYTE_INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl*ebsize + 1", (int l) -> { + return l - SPECIES.vectorByteSize() + 1; + }), + withToString("l + speciesl*ebsize - 1", (int l) -> { + return l + SPECIES.vectorByteSize() - 1; + }), + withToString("l + speciesl*ebsize", (int l) -> { + return l + SPECIES.vectorByteSize(); + }), + withToString("l + speciesl*ebsize + 1", (int l) -> { + return l + SPECIES.vectorByteSize() + 1; + }) + ); + + @DataProvider + public Object[][] shortProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentProvider() { + return HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, bo}; + }))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, fm, bo}; + })))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + static MemorySegment toSegment(short[] a, IntFunction fb) { + MemorySegment ms = fb.apply(a.length * SPECIES.elementSize() / 8); + for (int i = 0; i < a.length; i++) { + ms.set(ELEMENT_LAYOUT, i * SPECIES.elementSize() / 8 , a[i]); + } + return ms; + } + + static short[] segmentToArray(MemorySegment ms) { + return ms.toArray(ELEMENT_LAYOUT); + } + + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + @DontInline + static VectorShuffle shuffleFromArray(int[] a, int i) { + return SPECIES.shuffleFromArray(a, i); + } + + @DontInline + static void shuffleIntoArray(VectorShuffle s, int[] a, int i) { + s.intoArray(a, i); + } + + @DontInline + static VectorShuffle shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { + return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo); + } + + @DontInline + static void shuffleIntoMemorySegment(VectorShuffle s, MemorySegment mem, int i, ByteOrder bo) { + s.intoMemorySegment(mem, i, bo); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromArray(a, i); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i, VectorMask m) { + return HalffloatVector.fromArray(SPECIES, a, i, m); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i) { + v.intoArray(a, i); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i, VectorMask m) { + v.intoArray(a, i, m); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromMemorySegment(a, i, bo); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask m) { + return HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, m); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo) { + v.intoMemorySegment(a, i, bo); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo, VectorMask m) { + v.intoMemorySegment(a, i, bo, m); + } + + @Test(dataProvider = "shortProvider") + static void loadStoreArray(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void loadArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + fromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void storeArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMaskArray(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, vmask); + av.intoArray(r, i); + } + } + assertArraysEquals(r, a, mask); + + + r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, vmask); + } + } + assertArraysEquals(r, a, mask); + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void loadArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i, vmask); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + fromArray(a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void storeArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i, vmask); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMask(IntFunction fa, + IntFunction fm) { + boolean[] mask = fm.apply(SPECIES.length()); + boolean[] r = new boolean[mask.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < mask.length; i += SPECIES.length()) { + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, mask); + } + + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo); + } + } + long m = r.mismatch(a); + Assert.assertEquals(m, -1, "Segments not equal"); + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void loadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder()); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void storeMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentMaskProvider") + static void loadStoreMemorySegmentMask(IntFunction fa, + IntFunction fb, + IntFunction fm, + ByteOrder bo) { + short[] _a = fa.apply(SPECIES.length()); + MemorySegment a = toSegment(_a, fb); + MemorySegment r = fb.apply((int) a.byteSize()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, vmask); + av.intoMemorySegment(r, i, bo); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + + + r = fb.apply((int) a.byteSize()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo, vmask); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void loadMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder(), vmask); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void storeMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder(), vmask); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreReadonlyMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb).asReadOnly(); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(true)) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(false)) + ); + + VectorMask m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) + .laneIsValid(); + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, m) + ); + } + + + @Test(dataProvider = "maskProvider") + static void loadStoreMask(IntFunction fm) { + boolean[] a = fm.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorMask vmask = SPECIES.loadMask(a, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + + @Test(dataProvider = "shuffleIntProvider") + static void loadStoreShuffleArray(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = VectorShuffle.fromArray(SPECIES, a, i); + shuffle.intoArray(r, i); + } + } + + for (int i = 0; i < a.length; i++) { + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]); + } + + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void storeShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffleIntoArray(shuffle, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + VectorShuffle shuffle = shuffleFromArray(a, index); + shuffleIntoArray(shuffle, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void loadShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffle.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + shuffleFromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntMemorySegmentProvider") + static void loadStoreShuffleMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); + shuffle.intoMemorySegment(r, i, bo); + } + } + + for (int i = 0; i < l / 4; i++) { + int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri); + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleLoadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); + shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleStoreMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + + + // Gather/Scatter load/store tests + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], a[i + indexMap[j]]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j); + } + } + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j); + } + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + if (mask[j % SPECIES.length()]) { + expected[i + indexMap[j]] = a[j]; + } + } + } + + Assert.assertEquals(r, expected); + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + expected[i + indexMap[j]] = a[j]; + } + } + + Assert.assertEquals(r, expected); + } + + @DataProvider + public Object[][] gatherScatterProvider() { + return INT_INDEX_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] gatherScatterMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm -> + HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm, fs}; + }))). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "gatherScatterProvider") + static void gather(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void gatherMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i, vmask); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b, mask); + } + + @Test(dataProvider = "gatherScatterProvider") + static void scatter(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i); + } + } + + assertScatterArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void scatterMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i, vmask); + } + } + + assertScatterArraysEquals(r, a, b, mask); + } + + + +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java new file mode 100644 index 0000000000000..8b5a7158cdb00 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java @@ -0,0 +1,3262 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat128VectorTests + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorOperators; +import jdk.incubator.vector.Vector; + +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.Integer; +import java.util.List; +import java.util.Arrays; +import java.util.function.BiFunction; +import java.util.function.IntFunction; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Test +public class Halffloat128VectorTests extends AbstractVectorTest { + + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_128; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + + + // for floating point addition reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; + + // for floating point multiplication reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (short)50.0; + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128); + + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + short ir = r[i]; + short ia = a[i]; + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + + interface FUnOp { + short apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + } + } + + interface FUnArrayOp { + short[] apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a[i])); + } + } catch (AssertionError e) { + short[] ref = f.apply(a[i]); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + interface FReductionOp { + short apply(short[] a, int idx); + } + + interface FReductionAllOp { + short apply(short[] a); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa) { + assertReductionArraysEquals(r, rc, a, f, fa, (short)0.0); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa, + short relativeErrorFactor) { + int i = 0; + try { + 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.ulp(r[i]) * relativeErrorFactor); + } + } catch (AssertionError e) { + 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); + } + } + + interface FReductionMaskedOp { + short apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOp { + short apply(short[] a, boolean[] mask); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa) { + assertReductionArraysEqualsMasked(r, rc, a, mask, f, fa, (short)0.0); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa, + short relativeError) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * +relativeError)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + } + } + + interface FReductionOpLong { + long apply(short[] a, int idx); + } + + interface FReductionAllOpLong { + long apply(short[] a); + } + + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, + FReductionOpLong f, FReductionAllOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FReductionMaskedOpLong { + long apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOpLong { + long apply(short[] a, boolean[] mask); + } + + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, + FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + } + } + + interface FBoolReductionOp { + boolean apply(boolean[] a, int idx); + } + + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FMaskReductionOp { + int apply(boolean[] a, int idx); + } + + static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + } + } + } catch (AssertionError e) { + int idx = i + j; + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + } + } + + static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + k], a[i + j]); + k++; + } + } + for (; k < vector_len; k++) { + Assert.assertEquals(r[i + k], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + k; + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + j], a[i + k]); + k++; + } else { + Assert.assertEquals(r[i + j], (short)0); + } + } + } + } catch (AssertionError e) { + int idx = i + j; + if (m[idx % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) { + int i = 0, j = 0; + boolean is_exceptional_idx = false; + int idx = 0, wrapped_index = 0, oidx = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = i + j; + wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + is_exceptional_idx = wrapped_index >= vector_len; + oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + j; + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a) { + int i = 0; + for (; i < a.length; i += SPECIES.length()) { + int idx = i; + for (int j = idx; j < (idx + SPECIES.length()); j++) + a[j]=a[idx]; + } + + try { + for (i = 0; i < a.length; i++) { + Assert.assertEquals(r[i], a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + } + } + + interface FBinOp { + short apply(short a, short b); + } + + interface FBinMaskOp { + short apply(short a, short b, boolean m); + + static FBinMaskOp lift(FBinOp f) { + return (a, b, m) -> m ? f.apply(a, b) : a; + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) { + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) { + int i = 0; + boolean mask_bit = false; + try { + for (; i < a.length; i++) { + mask_bit = mask[i % SPECIES.length()]; + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + } + } + + interface FBinConstOp { + short apply(short a); + } + + interface FBinConstMaskOp { + short apply(short a, boolean m); + + static FBinConstMaskOp lift(FBinConstOp f) { + return (a, m) -> m ? f.apply(a) : a; + } + } + + static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) { + assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + } + } + + interface FTernOp { + short apply(short a, short b, short c); + } + + interface FTernMaskOp { + short apply(short a, short b, short c, boolean m); + + static FTernMaskOp lift(FTernOp f) { + return (a, b, c, m) -> m ? f.apply(a, b, c) : a; + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + + static boolean isWithin1Ulp(short actual, short expected) { + Float16 act = Float16.shortBitsToFloat16(actual); + Float16 exp = Float16.shortBitsToFloat16(expected); + if (Float16.isNaN(exp) && !Float16.isNaN(act)) { + return false; + } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { + return false; + } + + Float16 low = Float16.nextDown(exp); + Float16 high = Float16.nextUp(exp); + + if (Float16.compare(low, exp) > 0) { + return false; + } + + if (Float16.compare(high, exp) < 0) { + return false; + } + + return true; + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FUnOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); + } + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); + } + } + + static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, + FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + Assert.assertTrue(isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])), + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], + b[(i / SPECIES.length()) * SPECIES.length()])); + } + } + + interface FGatherScatterOp { + short[] apply(short[] a, int ix, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + " at index #" + i); + } + } + + interface FGatherMaskedOp { + short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + interface FScatterMaskedOp { + short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(r, a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(r, a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", r: " + + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + interface FLaneOp { + short[] apply(short[] a, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + interface FLaneBop { + short[] apply(short[] a, short[] b, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLaneMaskedBop { + short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLanePartBop { + short[] apply(short[] a, short[] b, int origin, int part, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + interface FLanePartMaskedBop { + short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + static short genValue(int i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static int intCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Integer.MAX_VALUE; + case 1: + return Integer.MIN_VALUE; + case 2: + return Integer.MIN_VALUE; + case 3: + return Integer.MAX_VALUE; + default: + return (int)0; + } + } + + static final List> INT_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[intCornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)intCornerCaseValue(i)); + }) + ); + + static void assertArraysEquals(int[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static long longCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Long.MAX_VALUE; + case 1: + return Long.MIN_VALUE; + case 2: + return Long.MIN_VALUE; + case 3: + return Long.MAX_VALUE; + default: + return (long)0; + } + } + + static short genValue(long i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static final List> LONG_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)longCornerCaseValue(i)); + }) + ); + + + static void assertArraysEquals(long[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static void assertArraysEquals(double[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static short bits(short e) { + return e; + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[0.01 + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("Float16[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01f + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (i % 17 == 0) ? cornerCaseValue(i) : Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + // Create combinations of pairs + // @@@ Might be sensitive to order e.g. div by 0 + static final List>> HALFFLOAT_GENERATOR_PAIRS = + Stream.of(HALFFLOAT_GENERATORS.get(0)). + flatMap(fa -> HALFFLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] boolUnaryOpProvider() { + return BOOL_ARRAY_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_GENERATOR_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> HALFFLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + static final List> SELECT_FROM_INDEX_GENERATORS = List.of( + withToString("short[0..VECLEN*2)", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(RAND.nextInt())); + }) + ); + + static final List>> HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortBinaryOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortIndexedOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpProvider() { + return HALFFLOAT_GENERATOR_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortSelectFromTwoVectorOpProvider() { + return HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_TRIPLES.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoIntUnaryOpProvider() { + return INT_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoLongUnaryOpProvider() { + return LONG_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskCompareOpProvider() { + return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleCompareOpProvider() { + return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_SHUFFLE_GENERATORS = List.of( + withToStringBi("shuffle[random]", (Integer l, Integer m) -> { + short[] a = new short[l]; + int upper = m; + for (int i = 0; i < 1; i++) { + a[i] = (short)RAND.nextInt(upper); + } + return a; + }) + ); + + @DataProvider + public Object[][] shortUnaryOpSelectFromProvider() { + return HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpSelectFromMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_COMPARE_GENERATORS = List.of( + withToString("short[i]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)i); + }), + withToString("short[i - length / 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - (s * BUFFER_REPS / 2))); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i + 1)); + }), + withToString("short[i - 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - 2)); + }), + withToString("short[zigZag(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + static final List>> HALFFLOAT_TEST_GENERATOR_ARGS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + map(fa -> List.of(fa)). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortTestOpProvider() { + return HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTestOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_COMPARE_GENERATOR_PAIRS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + flatMap(fa -> HALFFLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortCompareOpProvider() { + return HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortCompareOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static short cornerCaseValue(int i) { + return switch(i % 8) { + case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); + case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); + case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + case 4 -> Float16.float16ToRawShortBits(Float16.NaN); + case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 6 -> ((short)0.0); + default -> ((short)-0.0); + }; + } + + static final IntFunction fr = (vl) -> { + int length = BUFFER_REPS * vl; + return new short[length]; + }; + + static final IntFunction fmr = (vl) -> { + int length = BUFFER_REPS * vl; + return new boolean[length]; + }; + + static final IntFunction lfr = (vl) -> { + int length = BUFFER_REPS * vl; + return new long[length]; + }; + + static boolean eq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() == bt.floatValue(); + } + + static boolean neq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() != bt.floatValue(); + } + + static boolean lt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() < bt.floatValue(); + } + + static boolean le(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() <= bt.floatValue(); + } + + static boolean gt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() > bt.floatValue(); + } + + static boolean ge(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() >= bt.floatValue(); + } + + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + @Test + static void smokeTest1() { + HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three2).allTrue()); + HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three3).allTrue()); + int scale = 2; + HalffloatVector higher = three.addIndex(scale); + VectorMask m = three.compare(VectorOperators.LE, higher); + assert(m.allTrue()); + m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + assert(m.allTrue()); + m = higher.test(VectorOperators.IS_FINITE); + assert(m.allTrue()); + short max = higher.reduceLanes(VectorOperators.MAX); + assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); + } + + private static short[] + bothToArray(HalffloatVector a, HalffloatVector b) { + short[] r = new short[a.length() + b.length()]; + a.intoArray(r, 0); + b.intoArray(r, a.length()); + return r; + } + + @Test + static void smokeTest2() { + // Do some zipping and shuffling. + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); + Assert.assertEquals(io, io2); + HalffloatVector a = io.add((short)1); //[1,2] + HalffloatVector b = a.neg(); //[-1,-2] + short[] abValues = bothToArray(a,b); //[1,2,-1,-2] + VectorShuffle zip0 = VectorShuffle.makeZip(SPECIES, 0); + VectorShuffle zip1 = VectorShuffle.makeZip(SPECIES, 1); + HalffloatVector zab0 = a.rearrange(zip0,b); //[1,-1] + HalffloatVector zab1 = a.rearrange(zip1,b); //[2,-2] + short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] + // manually zip + short[] manual = new short[zabValues.length]; + for (int i = 0; i < manual.length; i += 2) { + manual[i+0] = abValues[i/2]; + manual[i+1] = abValues[a.length() + i/2]; + } + Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); + VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); + HalffloatVector uab0 = zab0.rearrange(unz0,zab1); + HalffloatVector uab1 = zab0.rearrange(unz1,zab1); + short[] abValues1 = bothToArray(uab0, uab1); + Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + } + + static void iotaShuffle() { + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); + Assert.assertEquals(io, io2); + } + + @Test + // Test all shuffle related operations. + static void shuffleTest() { + // To test backend instructions, make sure that C2 is used. + for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { + iotaShuffle(); + } + } + + @Test + void viewAsIntegeralLanesTest() { + Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); + VectorSpecies asIntegralSpecies = asIntegral.species(); + Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); + Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + } + + @Test + void viewAsFloatingLanesTest() { + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + Assert.assertEquals(asFloating.species(), SPECIES); + } + + static short ADD(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::ADD); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::ADD); + } + + static short SUB(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void SUBHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::SUB); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void SUBHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::SUB); + } + + static short MUL(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MULHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::MUL); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MULHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::MUL); + } + + static short DIV(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void DIVHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::DIV); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void DIVHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::DIV); + } + + static short MAX(short a, short b) { + return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MAXHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::MAX); + } + + static short MIN(short a, short b) { + return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MINHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::MIN); + } + + static short ABS(short a) { + return (short)(Math.abs(a)); + } + + static short abs(short a) { + return (short)(Math.abs(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat128VectorTests::ABS); + } + + static short NEG(short a) { + return (short)(-a); + } + + static short neg(short a) { + return (short)(-a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat128VectorTests::NEG); + } + + static short FMA(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + static short fma(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat128VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat128VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, mask, Halffloat128VectorTests::FMA); + } + + static short SQRT(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + static short sqrt(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat128VectorTests::SQRT); + } + + static short SIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); + } + + static short strictSIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::SIN, Halffloat128VectorTests::strictSIN); + } + + static short EXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); + } + + static short strictEXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::EXP, Halffloat128VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); + } + + static short strictLOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG1P, Halffloat128VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + } + + static short strictLOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG, Halffloat128VectorTests::strictLOG); + } + + static short LOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + } + + static short strictLOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG10, Halffloat128VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + } + + static short strictEXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::EXPM1, Halffloat128VectorTests::strictEXPM1); + } + + static short COS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + } + + static short strictCOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::COS, Halffloat128VectorTests::strictCOS); + } + + static short TAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + } + + static short strictTAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::TAN, Halffloat128VectorTests::strictTAN); + } + + static short SINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + } + + static short strictSINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::SINH, Halffloat128VectorTests::strictSINH); + } + + static short COSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + } + + static short strictCOSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::COSH, Halffloat128VectorTests::strictCOSH); + } + + static short TANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + } + + static short strictTANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::TANH, Halffloat128VectorTests::strictTANH); + } + + static short ASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + } + + static short strictASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ASIN, Halffloat128VectorTests::strictASIN); + } + + static short ACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + } + + static short strictACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ACOS, Halffloat128VectorTests::strictACOS); + } + + static short ATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + } + + static short strictATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ATAN, Halffloat128VectorTests::strictATAN); + } + + static short CBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + } + + static short strictCBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::CBRT, Halffloat128VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictHYPOT(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::HYPOT, Halffloat128VectorTests::strictHYPOT); + } + + static short POW(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictPOW(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::POW, Halffloat128VectorTests::strictPOW); + } + + static short pow(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictpow(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::pow, Halffloat128VectorTests::strictpow); + } + + static short ATAN2(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictATAN2(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::ATAN2, Halffloat128VectorTests::strictATAN2); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::POW, Halffloat128VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::pow, Halffloat128VectorTests::strictpow); + } + + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat128VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::blend); + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.lt(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.eq(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shorttoIntUnaryOpProvider") + static void toIntArrayHalffloat128VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void toLongArrayHalffloat128VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toDoubleArrayHalffloat128VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toStringHalffloat128VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + String str = av.toString(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void hashCodeHalffloat128VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int hash = av.hashCode(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + + static long ADDReduceLong(short[] a, int idx) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLong(short[] a) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ADDReduceLongHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEquals(r, ra, a, + Halffloat128VectorTests::ADDReduceLong, Halffloat128VectorTests::ADDReduceAllLong); + } + + static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if(mask[i % SPECIES.length()]) + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceLongHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEqualsMasked(r, ra, a, mask, + Halffloat128VectorTests::ADDReduceLongMasked, Halffloat128VectorTests::ADDReduceAllLongMasked); + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void BroadcastLongHalffloat128VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); + } + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.blend((long)b[i], vmask).intoArray(r, i); + } + } + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat128VectorTests::blend); + } + + + @Test(dataProvider = "shortUnaryOpSelectFromProvider") + static void SelectFromHalffloat128VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") + static void SelectFromTwoVectorHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] idx = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < idx.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector idxv = HalffloatVector.fromArray(SPECIES, idx, i); + idxv.selectFrom(av, bv).intoArray(r, i); + } + } + assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") + static void SelectFromHalffloat128VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av, vmask).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleMiscellaneousHalffloat128VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + int hash = shuffle.hashCode(); + int length = shuffle.length(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + Assert.assertEquals(length, SPECIES.length()); + } + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleToStringHalffloat128VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + String str = shuffle.toString(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shuffleCompareOpProvider") + static void shuffleEqualsHalffloat128VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = VectorShuffle.fromArray(SPECIES, a, i); + var bv = VectorShuffle.fromArray(SPECIES, b, i); + boolean eq = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); + } + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqualsHalffloat128VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + boolean equals = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); + } + } + + static boolean band(boolean a, boolean b) { + return a & b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndHalffloat128VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.and(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat128VectorTests::band); + } + + static boolean bor(boolean a, boolean b) { + return a | b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskOrHalffloat128VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.or(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat128VectorTests::bor); + } + + static boolean bxor(boolean a, boolean b) { + return a != b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskXorHalffloat128VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.xor(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat128VectorTests::bxor); + } + + static boolean bandNot(boolean a, boolean b) { + return a & !b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndNotHalffloat128VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.andNot(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat128VectorTests::bandNot); + } + + static boolean beq(boolean a, boolean b) { + return (a == b); + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqHalffloat128VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.eq(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat128VectorTests::beq); + } + + @Test(dataProvider = "maskProvider") + static void maskHashCodeHalffloat128VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + int hash = vmask.hashCode(); + + boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + static int maskTrueCount(boolean[] a, int idx) { + int trueCount = 0; + for (int i = idx; i < idx + SPECIES.length(); i++) { + trueCount += a[i] ? 1 : 0; + } + return trueCount; + } + + @Test(dataProvider = "maskProvider") + static void maskTrueCountHalffloat128VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.trueCount(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat128VectorTests::maskTrueCount); + } + + static int maskLastTrue(boolean[] a, int idx) { + int i = idx + SPECIES.length() - 1; + for (; i >= idx; i--) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskLastTrueHalffloat128VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.lastTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat128VectorTests::maskLastTrue); + } + + static int maskFirstTrue(boolean[] a, int idx) { + int i = idx; + for (; i < idx + SPECIES.length(); i++) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskFirstTrueHalffloat128VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.firstTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat128VectorTests::maskFirstTrue); + } + + @Test(dataProvider = "maskProvider") + static void maskCompressHalffloat128VectorTestsSmokeTest(IntFunction fa) { + int trueCount = 0; + boolean[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + trueCount = vmask.trueCount(); + var rmask = vmask.compress(); + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); + } + } + } + } + + @DataProvider + public static Object[][] longMaskProvider() { + return new Object[][]{ + {0xFFFFFFFFFFFFFFFFL}, + {0x0000000000000000L}, + {0x5555555555555555L}, + {0x0123456789abcdefL}, + }; + } + + @Test(dataProvider = "longMaskProvider") + static void maskFromToLongHalffloat128VectorTestsSmokeTest(long inputLong) { + var vmask = VectorMask.fromLong(SPECIES, inputLong); + long outputLong = vmask.toLong(); + Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length())))))); + } + + @DataProvider + public static Object[][] offsetProvider() { + return new Object[][]{ + {0}, + {-1}, + {+1}, + {+2}, + {-2}, + }; + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeHalffloat128VectorTestsSmokeTest(int offset) { + int limit = SPECIES.length() * BUFFER_REPS; + for (int i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + int index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeLongHalffloat128VectorTestsSmokeTest(int offset) { + long limit = SPECIES.length() * BUFFER_REPS; + for (long i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + long index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @DataProvider + public static Object[][] lengthProvider() { + return new Object[][]{ + {0}, + {1}, + {32}, + {37}, + {1024}, + {1024+1}, + {1024+5}, + }; + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundHalffloat128VectorTestsSmokeTest(int length) { + int actualLoopBound = SPECIES.loopBound(length); + int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundLongHalffloat128VectorTestsSmokeTest(int _length) { + long length = _length; + long actualLoopBound = SPECIES.loopBound(length); + long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test + static void ElementSizeHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + int elsize = av.elementSize(); + Assert.assertEquals(elsize, Float16.SIZE); + } + + @Test + static void VectorShapeHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + assert(vsh.equals(VectorShape.S_128_BIT)); + } + + @Test + static void ShapeWithLanesHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = vsh.withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void ElementTypeHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementType() == Float16.class); + } + + @Test + static void SpeciesElementSizeHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementSize() == Float16.SIZE); + } + + @Test + static void VectorTypeHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().vectorType() == av.getClass()); + } + + @Test + static void WithLanesHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorSpecies species = av.species().withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void WithShapeHalffloat128VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = av.species().withShape(vsh); + assert(species.equals(SPECIES)); + } + + @Test + static void MaskAllTrueHalffloat128VectorTestsSmokeTest() { + for (int ic = 0; ic < INVOC_COUNT; ic++) { + Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); + } + } +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Halffloat256VectorLoadStoreTests.java new file mode 100644 index 0000000000000..922e8e0ff85ba --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat256VectorLoadStoreTests.java @@ -0,0 +1,1016 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation + * @run testng/othervm -XX:-TieredCompilation Halffloat256VectorLoadStoreTests + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.Arena; +import java.lang.foreign.ValueLayout; +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.internal.vm.annotation.DontInline; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.nio.ByteOrder; +import java.util.List; +import java.util.function.*; + +@Test +public class Halffloat256VectorLoadStoreTests extends AbstractVectorLoadStoreTest { + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_256; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); + + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); + } + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + }) + ); + + // Relative to array.length + static final List> INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl + 1", (int l) -> { + return l - SPECIES.length() + 1; + }), + withToString("l + speciesl - 1", (int l) -> { + return l + SPECIES.length() - 1; + }), + withToString("l + speciesl", (int l) -> { + return l + SPECIES.length(); + }), + withToString("l + speciesl + 1", (int l) -> { + return l + SPECIES.length() + 1; + }) + ); + + // Relative to byte[] array.length or MemorySegment.byteSize() + static final List> BYTE_INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl*ebsize + 1", (int l) -> { + return l - SPECIES.vectorByteSize() + 1; + }), + withToString("l + speciesl*ebsize - 1", (int l) -> { + return l + SPECIES.vectorByteSize() - 1; + }), + withToString("l + speciesl*ebsize", (int l) -> { + return l + SPECIES.vectorByteSize(); + }), + withToString("l + speciesl*ebsize + 1", (int l) -> { + return l + SPECIES.vectorByteSize() + 1; + }) + ); + + @DataProvider + public Object[][] shortProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentProvider() { + return HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, bo}; + }))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, fm, bo}; + })))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + static MemorySegment toSegment(short[] a, IntFunction fb) { + MemorySegment ms = fb.apply(a.length * SPECIES.elementSize() / 8); + for (int i = 0; i < a.length; i++) { + ms.set(ELEMENT_LAYOUT, i * SPECIES.elementSize() / 8 , a[i]); + } + return ms; + } + + static short[] segmentToArray(MemorySegment ms) { + return ms.toArray(ELEMENT_LAYOUT); + } + + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + @DontInline + static VectorShuffle shuffleFromArray(int[] a, int i) { + return SPECIES.shuffleFromArray(a, i); + } + + @DontInline + static void shuffleIntoArray(VectorShuffle s, int[] a, int i) { + s.intoArray(a, i); + } + + @DontInline + static VectorShuffle shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { + return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo); + } + + @DontInline + static void shuffleIntoMemorySegment(VectorShuffle s, MemorySegment mem, int i, ByteOrder bo) { + s.intoMemorySegment(mem, i, bo); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromArray(a, i); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i, VectorMask m) { + return HalffloatVector.fromArray(SPECIES, a, i, m); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i) { + v.intoArray(a, i); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i, VectorMask m) { + v.intoArray(a, i, m); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromMemorySegment(a, i, bo); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask m) { + return HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, m); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo) { + v.intoMemorySegment(a, i, bo); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo, VectorMask m) { + v.intoMemorySegment(a, i, bo, m); + } + + @Test(dataProvider = "shortProvider") + static void loadStoreArray(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void loadArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + fromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void storeArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMaskArray(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, vmask); + av.intoArray(r, i); + } + } + assertArraysEquals(r, a, mask); + + + r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, vmask); + } + } + assertArraysEquals(r, a, mask); + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void loadArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i, vmask); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + fromArray(a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void storeArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i, vmask); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMask(IntFunction fa, + IntFunction fm) { + boolean[] mask = fm.apply(SPECIES.length()); + boolean[] r = new boolean[mask.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < mask.length; i += SPECIES.length()) { + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, mask); + } + + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo); + } + } + long m = r.mismatch(a); + Assert.assertEquals(m, -1, "Segments not equal"); + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void loadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder()); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void storeMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentMaskProvider") + static void loadStoreMemorySegmentMask(IntFunction fa, + IntFunction fb, + IntFunction fm, + ByteOrder bo) { + short[] _a = fa.apply(SPECIES.length()); + MemorySegment a = toSegment(_a, fb); + MemorySegment r = fb.apply((int) a.byteSize()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, vmask); + av.intoMemorySegment(r, i, bo); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + + + r = fb.apply((int) a.byteSize()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo, vmask); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void loadMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder(), vmask); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void storeMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder(), vmask); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreReadonlyMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb).asReadOnly(); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(true)) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(false)) + ); + + VectorMask m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) + .laneIsValid(); + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, m) + ); + } + + + @Test(dataProvider = "maskProvider") + static void loadStoreMask(IntFunction fm) { + boolean[] a = fm.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorMask vmask = SPECIES.loadMask(a, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + + @Test(dataProvider = "shuffleIntProvider") + static void loadStoreShuffleArray(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = VectorShuffle.fromArray(SPECIES, a, i); + shuffle.intoArray(r, i); + } + } + + for (int i = 0; i < a.length; i++) { + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]); + } + + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void storeShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffleIntoArray(shuffle, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + VectorShuffle shuffle = shuffleFromArray(a, index); + shuffleIntoArray(shuffle, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void loadShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffle.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + shuffleFromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntMemorySegmentProvider") + static void loadStoreShuffleMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); + shuffle.intoMemorySegment(r, i, bo); + } + } + + for (int i = 0; i < l / 4; i++) { + int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri); + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleLoadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); + shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleStoreMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + + + // Gather/Scatter load/store tests + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], a[i + indexMap[j]]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j); + } + } + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j); + } + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + if (mask[j % SPECIES.length()]) { + expected[i + indexMap[j]] = a[j]; + } + } + } + + Assert.assertEquals(r, expected); + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + expected[i + indexMap[j]] = a[j]; + } + } + + Assert.assertEquals(r, expected); + } + + @DataProvider + public Object[][] gatherScatterProvider() { + return INT_INDEX_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] gatherScatterMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm -> + HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm, fs}; + }))). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "gatherScatterProvider") + static void gather(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void gatherMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i, vmask); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b, mask); + } + + @Test(dataProvider = "gatherScatterProvider") + static void scatter(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i); + } + } + + assertScatterArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void scatterMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i, vmask); + } + } + + assertScatterArraysEquals(r, a, b, mask); + } + + + +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java new file mode 100644 index 0000000000000..5c8e853ac1bb3 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java @@ -0,0 +1,3262 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat256VectorTests + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorOperators; +import jdk.incubator.vector.Vector; + +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.Integer; +import java.util.List; +import java.util.Arrays; +import java.util.function.BiFunction; +import java.util.function.IntFunction; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Test +public class Halffloat256VectorTests extends AbstractVectorTest { + + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_256; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + + + // for floating point addition reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; + + // for floating point multiplication reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (short)50.0; + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256); + + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + short ir = r[i]; + short ia = a[i]; + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + + interface FUnOp { + short apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + } + } + + interface FUnArrayOp { + short[] apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a[i])); + } + } catch (AssertionError e) { + short[] ref = f.apply(a[i]); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + interface FReductionOp { + short apply(short[] a, int idx); + } + + interface FReductionAllOp { + short apply(short[] a); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa) { + assertReductionArraysEquals(r, rc, a, f, fa, (short)0.0); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa, + short relativeErrorFactor) { + int i = 0; + try { + 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.ulp(r[i]) * relativeErrorFactor); + } + } catch (AssertionError e) { + 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); + } + } + + interface FReductionMaskedOp { + short apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOp { + short apply(short[] a, boolean[] mask); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa) { + assertReductionArraysEqualsMasked(r, rc, a, mask, f, fa, (short)0.0); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa, + short relativeError) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * +relativeError)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + } + } + + interface FReductionOpLong { + long apply(short[] a, int idx); + } + + interface FReductionAllOpLong { + long apply(short[] a); + } + + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, + FReductionOpLong f, FReductionAllOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FReductionMaskedOpLong { + long apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOpLong { + long apply(short[] a, boolean[] mask); + } + + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, + FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + } + } + + interface FBoolReductionOp { + boolean apply(boolean[] a, int idx); + } + + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FMaskReductionOp { + int apply(boolean[] a, int idx); + } + + static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + } + } + } catch (AssertionError e) { + int idx = i + j; + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + } + } + + static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + k], a[i + j]); + k++; + } + } + for (; k < vector_len; k++) { + Assert.assertEquals(r[i + k], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + k; + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + j], a[i + k]); + k++; + } else { + Assert.assertEquals(r[i + j], (short)0); + } + } + } + } catch (AssertionError e) { + int idx = i + j; + if (m[idx % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) { + int i = 0, j = 0; + boolean is_exceptional_idx = false; + int idx = 0, wrapped_index = 0, oidx = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = i + j; + wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + is_exceptional_idx = wrapped_index >= vector_len; + oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + j; + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a) { + int i = 0; + for (; i < a.length; i += SPECIES.length()) { + int idx = i; + for (int j = idx; j < (idx + SPECIES.length()); j++) + a[j]=a[idx]; + } + + try { + for (i = 0; i < a.length; i++) { + Assert.assertEquals(r[i], a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + } + } + + interface FBinOp { + short apply(short a, short b); + } + + interface FBinMaskOp { + short apply(short a, short b, boolean m); + + static FBinMaskOp lift(FBinOp f) { + return (a, b, m) -> m ? f.apply(a, b) : a; + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) { + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) { + int i = 0; + boolean mask_bit = false; + try { + for (; i < a.length; i++) { + mask_bit = mask[i % SPECIES.length()]; + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + } + } + + interface FBinConstOp { + short apply(short a); + } + + interface FBinConstMaskOp { + short apply(short a, boolean m); + + static FBinConstMaskOp lift(FBinConstOp f) { + return (a, m) -> m ? f.apply(a) : a; + } + } + + static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) { + assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + } + } + + interface FTernOp { + short apply(short a, short b, short c); + } + + interface FTernMaskOp { + short apply(short a, short b, short c, boolean m); + + static FTernMaskOp lift(FTernOp f) { + return (a, b, c, m) -> m ? f.apply(a, b, c) : a; + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + + static boolean isWithin1Ulp(short actual, short expected) { + Float16 act = Float16.shortBitsToFloat16(actual); + Float16 exp = Float16.shortBitsToFloat16(expected); + if (Float16.isNaN(exp) && !Float16.isNaN(act)) { + return false; + } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { + return false; + } + + Float16 low = Float16.nextDown(exp); + Float16 high = Float16.nextUp(exp); + + if (Float16.compare(low, exp) > 0) { + return false; + } + + if (Float16.compare(high, exp) < 0) { + return false; + } + + return true; + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FUnOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); + } + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); + } + } + + static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, + FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + Assert.assertTrue(isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])), + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], + b[(i / SPECIES.length()) * SPECIES.length()])); + } + } + + interface FGatherScatterOp { + short[] apply(short[] a, int ix, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + " at index #" + i); + } + } + + interface FGatherMaskedOp { + short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + interface FScatterMaskedOp { + short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(r, a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(r, a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", r: " + + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + interface FLaneOp { + short[] apply(short[] a, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + interface FLaneBop { + short[] apply(short[] a, short[] b, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLaneMaskedBop { + short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLanePartBop { + short[] apply(short[] a, short[] b, int origin, int part, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + interface FLanePartMaskedBop { + short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + static short genValue(int i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static int intCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Integer.MAX_VALUE; + case 1: + return Integer.MIN_VALUE; + case 2: + return Integer.MIN_VALUE; + case 3: + return Integer.MAX_VALUE; + default: + return (int)0; + } + } + + static final List> INT_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[intCornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)intCornerCaseValue(i)); + }) + ); + + static void assertArraysEquals(int[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static long longCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Long.MAX_VALUE; + case 1: + return Long.MIN_VALUE; + case 2: + return Long.MIN_VALUE; + case 3: + return Long.MAX_VALUE; + default: + return (long)0; + } + } + + static short genValue(long i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static final List> LONG_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)longCornerCaseValue(i)); + }) + ); + + + static void assertArraysEquals(long[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static void assertArraysEquals(double[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static short bits(short e) { + return e; + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[0.01 + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("Float16[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01f + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (i % 17 == 0) ? cornerCaseValue(i) : Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + // Create combinations of pairs + // @@@ Might be sensitive to order e.g. div by 0 + static final List>> HALFFLOAT_GENERATOR_PAIRS = + Stream.of(HALFFLOAT_GENERATORS.get(0)). + flatMap(fa -> HALFFLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] boolUnaryOpProvider() { + return BOOL_ARRAY_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_GENERATOR_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> HALFFLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + static final List> SELECT_FROM_INDEX_GENERATORS = List.of( + withToString("short[0..VECLEN*2)", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(RAND.nextInt())); + }) + ); + + static final List>> HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortBinaryOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortIndexedOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpProvider() { + return HALFFLOAT_GENERATOR_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortSelectFromTwoVectorOpProvider() { + return HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_TRIPLES.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoIntUnaryOpProvider() { + return INT_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoLongUnaryOpProvider() { + return LONG_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskCompareOpProvider() { + return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleCompareOpProvider() { + return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_SHUFFLE_GENERATORS = List.of( + withToStringBi("shuffle[random]", (Integer l, Integer m) -> { + short[] a = new short[l]; + int upper = m; + for (int i = 0; i < 1; i++) { + a[i] = (short)RAND.nextInt(upper); + } + return a; + }) + ); + + @DataProvider + public Object[][] shortUnaryOpSelectFromProvider() { + return HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpSelectFromMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_COMPARE_GENERATORS = List.of( + withToString("short[i]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)i); + }), + withToString("short[i - length / 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - (s * BUFFER_REPS / 2))); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i + 1)); + }), + withToString("short[i - 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - 2)); + }), + withToString("short[zigZag(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + static final List>> HALFFLOAT_TEST_GENERATOR_ARGS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + map(fa -> List.of(fa)). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortTestOpProvider() { + return HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTestOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_COMPARE_GENERATOR_PAIRS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + flatMap(fa -> HALFFLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortCompareOpProvider() { + return HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortCompareOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static short cornerCaseValue(int i) { + return switch(i % 8) { + case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); + case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); + case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + case 4 -> Float16.float16ToRawShortBits(Float16.NaN); + case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 6 -> ((short)0.0); + default -> ((short)-0.0); + }; + } + + static final IntFunction fr = (vl) -> { + int length = BUFFER_REPS * vl; + return new short[length]; + }; + + static final IntFunction fmr = (vl) -> { + int length = BUFFER_REPS * vl; + return new boolean[length]; + }; + + static final IntFunction lfr = (vl) -> { + int length = BUFFER_REPS * vl; + return new long[length]; + }; + + static boolean eq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() == bt.floatValue(); + } + + static boolean neq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() != bt.floatValue(); + } + + static boolean lt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() < bt.floatValue(); + } + + static boolean le(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() <= bt.floatValue(); + } + + static boolean gt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() > bt.floatValue(); + } + + static boolean ge(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() >= bt.floatValue(); + } + + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + @Test + static void smokeTest1() { + HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three2).allTrue()); + HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three3).allTrue()); + int scale = 2; + HalffloatVector higher = three.addIndex(scale); + VectorMask m = three.compare(VectorOperators.LE, higher); + assert(m.allTrue()); + m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + assert(m.allTrue()); + m = higher.test(VectorOperators.IS_FINITE); + assert(m.allTrue()); + short max = higher.reduceLanes(VectorOperators.MAX); + assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); + } + + private static short[] + bothToArray(HalffloatVector a, HalffloatVector b) { + short[] r = new short[a.length() + b.length()]; + a.intoArray(r, 0); + b.intoArray(r, a.length()); + return r; + } + + @Test + static void smokeTest2() { + // Do some zipping and shuffling. + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); + Assert.assertEquals(io, io2); + HalffloatVector a = io.add((short)1); //[1,2] + HalffloatVector b = a.neg(); //[-1,-2] + short[] abValues = bothToArray(a,b); //[1,2,-1,-2] + VectorShuffle zip0 = VectorShuffle.makeZip(SPECIES, 0); + VectorShuffle zip1 = VectorShuffle.makeZip(SPECIES, 1); + HalffloatVector zab0 = a.rearrange(zip0,b); //[1,-1] + HalffloatVector zab1 = a.rearrange(zip1,b); //[2,-2] + short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] + // manually zip + short[] manual = new short[zabValues.length]; + for (int i = 0; i < manual.length; i += 2) { + manual[i+0] = abValues[i/2]; + manual[i+1] = abValues[a.length() + i/2]; + } + Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); + VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); + HalffloatVector uab0 = zab0.rearrange(unz0,zab1); + HalffloatVector uab1 = zab0.rearrange(unz1,zab1); + short[] abValues1 = bothToArray(uab0, uab1); + Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + } + + static void iotaShuffle() { + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); + Assert.assertEquals(io, io2); + } + + @Test + // Test all shuffle related operations. + static void shuffleTest() { + // To test backend instructions, make sure that C2 is used. + for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { + iotaShuffle(); + } + } + + @Test + void viewAsIntegeralLanesTest() { + Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); + VectorSpecies asIntegralSpecies = asIntegral.species(); + Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); + Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + } + + @Test + void viewAsFloatingLanesTest() { + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + Assert.assertEquals(asFloating.species(), SPECIES); + } + + static short ADD(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::ADD); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::ADD); + } + + static short SUB(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void SUBHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::SUB); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void SUBHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::SUB); + } + + static short MUL(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MULHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::MUL); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MULHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::MUL); + } + + static short DIV(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void DIVHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::DIV); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void DIVHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::DIV); + } + + static short MAX(short a, short b) { + return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MAXHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::MAX); + } + + static short MIN(short a, short b) { + return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MINHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::MIN); + } + + static short ABS(short a) { + return (short)(Math.abs(a)); + } + + static short abs(short a) { + return (short)(Math.abs(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat256VectorTests::ABS); + } + + static short NEG(short a) { + return (short)(-a); + } + + static short neg(short a) { + return (short)(-a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat256VectorTests::NEG); + } + + static short FMA(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + static short fma(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat256VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat256VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, mask, Halffloat256VectorTests::FMA); + } + + static short SQRT(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + static short sqrt(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat256VectorTests::SQRT); + } + + static short SIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); + } + + static short strictSIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::SIN, Halffloat256VectorTests::strictSIN); + } + + static short EXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); + } + + static short strictEXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::EXP, Halffloat256VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); + } + + static short strictLOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG1P, Halffloat256VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + } + + static short strictLOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG, Halffloat256VectorTests::strictLOG); + } + + static short LOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + } + + static short strictLOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG10, Halffloat256VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + } + + static short strictEXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::EXPM1, Halffloat256VectorTests::strictEXPM1); + } + + static short COS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + } + + static short strictCOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::COS, Halffloat256VectorTests::strictCOS); + } + + static short TAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + } + + static short strictTAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::TAN, Halffloat256VectorTests::strictTAN); + } + + static short SINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + } + + static short strictSINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::SINH, Halffloat256VectorTests::strictSINH); + } + + static short COSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + } + + static short strictCOSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::COSH, Halffloat256VectorTests::strictCOSH); + } + + static short TANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + } + + static short strictTANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::TANH, Halffloat256VectorTests::strictTANH); + } + + static short ASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + } + + static short strictASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ASIN, Halffloat256VectorTests::strictASIN); + } + + static short ACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + } + + static short strictACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ACOS, Halffloat256VectorTests::strictACOS); + } + + static short ATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + } + + static short strictATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ATAN, Halffloat256VectorTests::strictATAN); + } + + static short CBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + } + + static short strictCBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::CBRT, Halffloat256VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictHYPOT(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::HYPOT, Halffloat256VectorTests::strictHYPOT); + } + + static short POW(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictPOW(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::POW, Halffloat256VectorTests::strictPOW); + } + + static short pow(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictpow(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::pow, Halffloat256VectorTests::strictpow); + } + + static short ATAN2(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictATAN2(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::ATAN2, Halffloat256VectorTests::strictATAN2); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::POW, Halffloat256VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::pow, Halffloat256VectorTests::strictpow); + } + + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat256VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::blend); + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.lt(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.eq(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shorttoIntUnaryOpProvider") + static void toIntArrayHalffloat256VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void toLongArrayHalffloat256VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toDoubleArrayHalffloat256VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toStringHalffloat256VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + String str = av.toString(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void hashCodeHalffloat256VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int hash = av.hashCode(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + + static long ADDReduceLong(short[] a, int idx) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLong(short[] a) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ADDReduceLongHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEquals(r, ra, a, + Halffloat256VectorTests::ADDReduceLong, Halffloat256VectorTests::ADDReduceAllLong); + } + + static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if(mask[i % SPECIES.length()]) + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceLongHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEqualsMasked(r, ra, a, mask, + Halffloat256VectorTests::ADDReduceLongMasked, Halffloat256VectorTests::ADDReduceAllLongMasked); + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void BroadcastLongHalffloat256VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); + } + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.blend((long)b[i], vmask).intoArray(r, i); + } + } + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat256VectorTests::blend); + } + + + @Test(dataProvider = "shortUnaryOpSelectFromProvider") + static void SelectFromHalffloat256VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") + static void SelectFromTwoVectorHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] idx = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < idx.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector idxv = HalffloatVector.fromArray(SPECIES, idx, i); + idxv.selectFrom(av, bv).intoArray(r, i); + } + } + assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") + static void SelectFromHalffloat256VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av, vmask).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleMiscellaneousHalffloat256VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + int hash = shuffle.hashCode(); + int length = shuffle.length(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + Assert.assertEquals(length, SPECIES.length()); + } + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleToStringHalffloat256VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + String str = shuffle.toString(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shuffleCompareOpProvider") + static void shuffleEqualsHalffloat256VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = VectorShuffle.fromArray(SPECIES, a, i); + var bv = VectorShuffle.fromArray(SPECIES, b, i); + boolean eq = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); + } + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqualsHalffloat256VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + boolean equals = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); + } + } + + static boolean band(boolean a, boolean b) { + return a & b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndHalffloat256VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.and(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat256VectorTests::band); + } + + static boolean bor(boolean a, boolean b) { + return a | b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskOrHalffloat256VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.or(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat256VectorTests::bor); + } + + static boolean bxor(boolean a, boolean b) { + return a != b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskXorHalffloat256VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.xor(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat256VectorTests::bxor); + } + + static boolean bandNot(boolean a, boolean b) { + return a & !b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndNotHalffloat256VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.andNot(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat256VectorTests::bandNot); + } + + static boolean beq(boolean a, boolean b) { + return (a == b); + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqHalffloat256VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.eq(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat256VectorTests::beq); + } + + @Test(dataProvider = "maskProvider") + static void maskHashCodeHalffloat256VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + int hash = vmask.hashCode(); + + boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + static int maskTrueCount(boolean[] a, int idx) { + int trueCount = 0; + for (int i = idx; i < idx + SPECIES.length(); i++) { + trueCount += a[i] ? 1 : 0; + } + return trueCount; + } + + @Test(dataProvider = "maskProvider") + static void maskTrueCountHalffloat256VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.trueCount(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat256VectorTests::maskTrueCount); + } + + static int maskLastTrue(boolean[] a, int idx) { + int i = idx + SPECIES.length() - 1; + for (; i >= idx; i--) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskLastTrueHalffloat256VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.lastTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat256VectorTests::maskLastTrue); + } + + static int maskFirstTrue(boolean[] a, int idx) { + int i = idx; + for (; i < idx + SPECIES.length(); i++) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskFirstTrueHalffloat256VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.firstTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat256VectorTests::maskFirstTrue); + } + + @Test(dataProvider = "maskProvider") + static void maskCompressHalffloat256VectorTestsSmokeTest(IntFunction fa) { + int trueCount = 0; + boolean[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + trueCount = vmask.trueCount(); + var rmask = vmask.compress(); + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); + } + } + } + } + + @DataProvider + public static Object[][] longMaskProvider() { + return new Object[][]{ + {0xFFFFFFFFFFFFFFFFL}, + {0x0000000000000000L}, + {0x5555555555555555L}, + {0x0123456789abcdefL}, + }; + } + + @Test(dataProvider = "longMaskProvider") + static void maskFromToLongHalffloat256VectorTestsSmokeTest(long inputLong) { + var vmask = VectorMask.fromLong(SPECIES, inputLong); + long outputLong = vmask.toLong(); + Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length())))))); + } + + @DataProvider + public static Object[][] offsetProvider() { + return new Object[][]{ + {0}, + {-1}, + {+1}, + {+2}, + {-2}, + }; + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeHalffloat256VectorTestsSmokeTest(int offset) { + int limit = SPECIES.length() * BUFFER_REPS; + for (int i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + int index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeLongHalffloat256VectorTestsSmokeTest(int offset) { + long limit = SPECIES.length() * BUFFER_REPS; + for (long i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + long index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @DataProvider + public static Object[][] lengthProvider() { + return new Object[][]{ + {0}, + {1}, + {32}, + {37}, + {1024}, + {1024+1}, + {1024+5}, + }; + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundHalffloat256VectorTestsSmokeTest(int length) { + int actualLoopBound = SPECIES.loopBound(length); + int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundLongHalffloat256VectorTestsSmokeTest(int _length) { + long length = _length; + long actualLoopBound = SPECIES.loopBound(length); + long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test + static void ElementSizeHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + int elsize = av.elementSize(); + Assert.assertEquals(elsize, Float16.SIZE); + } + + @Test + static void VectorShapeHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + assert(vsh.equals(VectorShape.S_256_BIT)); + } + + @Test + static void ShapeWithLanesHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = vsh.withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void ElementTypeHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementType() == Float16.class); + } + + @Test + static void SpeciesElementSizeHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementSize() == Float16.SIZE); + } + + @Test + static void VectorTypeHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().vectorType() == av.getClass()); + } + + @Test + static void WithLanesHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorSpecies species = av.species().withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void WithShapeHalffloat256VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = av.species().withShape(vsh); + assert(species.equals(SPECIES)); + } + + @Test + static void MaskAllTrueHalffloat256VectorTestsSmokeTest() { + for (int ic = 0; ic < INVOC_COUNT; ic++) { + Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); + } + } +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Halffloat512VectorLoadStoreTests.java new file mode 100644 index 0000000000000..fb3bf0b76b3ba --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat512VectorLoadStoreTests.java @@ -0,0 +1,1016 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation + * @run testng/othervm -XX:-TieredCompilation Halffloat512VectorLoadStoreTests + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.Arena; +import java.lang.foreign.ValueLayout; +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.internal.vm.annotation.DontInline; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.nio.ByteOrder; +import java.util.List; +import java.util.function.*; + +@Test +public class Halffloat512VectorLoadStoreTests extends AbstractVectorLoadStoreTest { + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_512; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); + + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); + } + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + }) + ); + + // Relative to array.length + static final List> INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl + 1", (int l) -> { + return l - SPECIES.length() + 1; + }), + withToString("l + speciesl - 1", (int l) -> { + return l + SPECIES.length() - 1; + }), + withToString("l + speciesl", (int l) -> { + return l + SPECIES.length(); + }), + withToString("l + speciesl + 1", (int l) -> { + return l + SPECIES.length() + 1; + }) + ); + + // Relative to byte[] array.length or MemorySegment.byteSize() + static final List> BYTE_INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl*ebsize + 1", (int l) -> { + return l - SPECIES.vectorByteSize() + 1; + }), + withToString("l + speciesl*ebsize - 1", (int l) -> { + return l + SPECIES.vectorByteSize() - 1; + }), + withToString("l + speciesl*ebsize", (int l) -> { + return l + SPECIES.vectorByteSize(); + }), + withToString("l + speciesl*ebsize + 1", (int l) -> { + return l + SPECIES.vectorByteSize() + 1; + }) + ); + + @DataProvider + public Object[][] shortProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentProvider() { + return HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, bo}; + }))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, fm, bo}; + })))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + static MemorySegment toSegment(short[] a, IntFunction fb) { + MemorySegment ms = fb.apply(a.length * SPECIES.elementSize() / 8); + for (int i = 0; i < a.length; i++) { + ms.set(ELEMENT_LAYOUT, i * SPECIES.elementSize() / 8 , a[i]); + } + return ms; + } + + static short[] segmentToArray(MemorySegment ms) { + return ms.toArray(ELEMENT_LAYOUT); + } + + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + @DontInline + static VectorShuffle shuffleFromArray(int[] a, int i) { + return SPECIES.shuffleFromArray(a, i); + } + + @DontInline + static void shuffleIntoArray(VectorShuffle s, int[] a, int i) { + s.intoArray(a, i); + } + + @DontInline + static VectorShuffle shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { + return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo); + } + + @DontInline + static void shuffleIntoMemorySegment(VectorShuffle s, MemorySegment mem, int i, ByteOrder bo) { + s.intoMemorySegment(mem, i, bo); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromArray(a, i); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i, VectorMask m) { + return HalffloatVector.fromArray(SPECIES, a, i, m); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i) { + v.intoArray(a, i); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i, VectorMask m) { + v.intoArray(a, i, m); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromMemorySegment(a, i, bo); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask m) { + return HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, m); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo) { + v.intoMemorySegment(a, i, bo); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo, VectorMask m) { + v.intoMemorySegment(a, i, bo, m); + } + + @Test(dataProvider = "shortProvider") + static void loadStoreArray(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void loadArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + fromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void storeArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMaskArray(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, vmask); + av.intoArray(r, i); + } + } + assertArraysEquals(r, a, mask); + + + r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, vmask); + } + } + assertArraysEquals(r, a, mask); + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void loadArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i, vmask); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + fromArray(a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void storeArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i, vmask); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMask(IntFunction fa, + IntFunction fm) { + boolean[] mask = fm.apply(SPECIES.length()); + boolean[] r = new boolean[mask.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < mask.length; i += SPECIES.length()) { + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, mask); + } + + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo); + } + } + long m = r.mismatch(a); + Assert.assertEquals(m, -1, "Segments not equal"); + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void loadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder()); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void storeMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentMaskProvider") + static void loadStoreMemorySegmentMask(IntFunction fa, + IntFunction fb, + IntFunction fm, + ByteOrder bo) { + short[] _a = fa.apply(SPECIES.length()); + MemorySegment a = toSegment(_a, fb); + MemorySegment r = fb.apply((int) a.byteSize()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, vmask); + av.intoMemorySegment(r, i, bo); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + + + r = fb.apply((int) a.byteSize()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo, vmask); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void loadMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder(), vmask); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void storeMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder(), vmask); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreReadonlyMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb).asReadOnly(); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(true)) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(false)) + ); + + VectorMask m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) + .laneIsValid(); + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, m) + ); + } + + + @Test(dataProvider = "maskProvider") + static void loadStoreMask(IntFunction fm) { + boolean[] a = fm.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorMask vmask = SPECIES.loadMask(a, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + + @Test(dataProvider = "shuffleIntProvider") + static void loadStoreShuffleArray(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = VectorShuffle.fromArray(SPECIES, a, i); + shuffle.intoArray(r, i); + } + } + + for (int i = 0; i < a.length; i++) { + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]); + } + + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void storeShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffleIntoArray(shuffle, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + VectorShuffle shuffle = shuffleFromArray(a, index); + shuffleIntoArray(shuffle, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void loadShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffle.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + shuffleFromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntMemorySegmentProvider") + static void loadStoreShuffleMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); + shuffle.intoMemorySegment(r, i, bo); + } + } + + for (int i = 0; i < l / 4; i++) { + int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri); + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleLoadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); + shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleStoreMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + + + // Gather/Scatter load/store tests + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], a[i + indexMap[j]]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j); + } + } + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j); + } + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + if (mask[j % SPECIES.length()]) { + expected[i + indexMap[j]] = a[j]; + } + } + } + + Assert.assertEquals(r, expected); + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + expected[i + indexMap[j]] = a[j]; + } + } + + Assert.assertEquals(r, expected); + } + + @DataProvider + public Object[][] gatherScatterProvider() { + return INT_INDEX_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] gatherScatterMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm -> + HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm, fs}; + }))). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "gatherScatterProvider") + static void gather(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void gatherMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i, vmask); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b, mask); + } + + @Test(dataProvider = "gatherScatterProvider") + static void scatter(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i); + } + } + + assertScatterArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void scatterMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i, vmask); + } + } + + assertScatterArraysEquals(r, a, b, mask); + } + + + +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java new file mode 100644 index 0000000000000..5916ba3e9c9c4 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java @@ -0,0 +1,3262 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat512VectorTests + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorOperators; +import jdk.incubator.vector.Vector; + +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.Integer; +import java.util.List; +import java.util.Arrays; +import java.util.function.BiFunction; +import java.util.function.IntFunction; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Test +public class Halffloat512VectorTests extends AbstractVectorTest { + + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_512; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + + + // for floating point addition reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; + + // for floating point multiplication reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (short)50.0; + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 512); + + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + short ir = r[i]; + short ia = a[i]; + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + + interface FUnOp { + short apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + } + } + + interface FUnArrayOp { + short[] apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a[i])); + } + } catch (AssertionError e) { + short[] ref = f.apply(a[i]); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + interface FReductionOp { + short apply(short[] a, int idx); + } + + interface FReductionAllOp { + short apply(short[] a); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa) { + assertReductionArraysEquals(r, rc, a, f, fa, (short)0.0); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa, + short relativeErrorFactor) { + int i = 0; + try { + 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.ulp(r[i]) * relativeErrorFactor); + } + } catch (AssertionError e) { + 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); + } + } + + interface FReductionMaskedOp { + short apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOp { + short apply(short[] a, boolean[] mask); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa) { + assertReductionArraysEqualsMasked(r, rc, a, mask, f, fa, (short)0.0); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa, + short relativeError) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * +relativeError)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + } + } + + interface FReductionOpLong { + long apply(short[] a, int idx); + } + + interface FReductionAllOpLong { + long apply(short[] a); + } + + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, + FReductionOpLong f, FReductionAllOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FReductionMaskedOpLong { + long apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOpLong { + long apply(short[] a, boolean[] mask); + } + + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, + FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + } + } + + interface FBoolReductionOp { + boolean apply(boolean[] a, int idx); + } + + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FMaskReductionOp { + int apply(boolean[] a, int idx); + } + + static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + } + } + } catch (AssertionError e) { + int idx = i + j; + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + } + } + + static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + k], a[i + j]); + k++; + } + } + for (; k < vector_len; k++) { + Assert.assertEquals(r[i + k], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + k; + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + j], a[i + k]); + k++; + } else { + Assert.assertEquals(r[i + j], (short)0); + } + } + } + } catch (AssertionError e) { + int idx = i + j; + if (m[idx % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) { + int i = 0, j = 0; + boolean is_exceptional_idx = false; + int idx = 0, wrapped_index = 0, oidx = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = i + j; + wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + is_exceptional_idx = wrapped_index >= vector_len; + oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + j; + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a) { + int i = 0; + for (; i < a.length; i += SPECIES.length()) { + int idx = i; + for (int j = idx; j < (idx + SPECIES.length()); j++) + a[j]=a[idx]; + } + + try { + for (i = 0; i < a.length; i++) { + Assert.assertEquals(r[i], a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + } + } + + interface FBinOp { + short apply(short a, short b); + } + + interface FBinMaskOp { + short apply(short a, short b, boolean m); + + static FBinMaskOp lift(FBinOp f) { + return (a, b, m) -> m ? f.apply(a, b) : a; + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) { + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) { + int i = 0; + boolean mask_bit = false; + try { + for (; i < a.length; i++) { + mask_bit = mask[i % SPECIES.length()]; + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + } + } + + interface FBinConstOp { + short apply(short a); + } + + interface FBinConstMaskOp { + short apply(short a, boolean m); + + static FBinConstMaskOp lift(FBinConstOp f) { + return (a, m) -> m ? f.apply(a) : a; + } + } + + static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) { + assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + } + } + + interface FTernOp { + short apply(short a, short b, short c); + } + + interface FTernMaskOp { + short apply(short a, short b, short c, boolean m); + + static FTernMaskOp lift(FTernOp f) { + return (a, b, c, m) -> m ? f.apply(a, b, c) : a; + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + + static boolean isWithin1Ulp(short actual, short expected) { + Float16 act = Float16.shortBitsToFloat16(actual); + Float16 exp = Float16.shortBitsToFloat16(expected); + if (Float16.isNaN(exp) && !Float16.isNaN(act)) { + return false; + } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { + return false; + } + + Float16 low = Float16.nextDown(exp); + Float16 high = Float16.nextUp(exp); + + if (Float16.compare(low, exp) > 0) { + return false; + } + + if (Float16.compare(high, exp) < 0) { + return false; + } + + return true; + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FUnOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); + } + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); + } + } + + static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, + FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + Assert.assertTrue(isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])), + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], + b[(i / SPECIES.length()) * SPECIES.length()])); + } + } + + interface FGatherScatterOp { + short[] apply(short[] a, int ix, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + " at index #" + i); + } + } + + interface FGatherMaskedOp { + short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + interface FScatterMaskedOp { + short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(r, a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(r, a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", r: " + + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + interface FLaneOp { + short[] apply(short[] a, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + interface FLaneBop { + short[] apply(short[] a, short[] b, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLaneMaskedBop { + short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLanePartBop { + short[] apply(short[] a, short[] b, int origin, int part, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + interface FLanePartMaskedBop { + short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + static short genValue(int i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static int intCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Integer.MAX_VALUE; + case 1: + return Integer.MIN_VALUE; + case 2: + return Integer.MIN_VALUE; + case 3: + return Integer.MAX_VALUE; + default: + return (int)0; + } + } + + static final List> INT_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[intCornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)intCornerCaseValue(i)); + }) + ); + + static void assertArraysEquals(int[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static long longCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Long.MAX_VALUE; + case 1: + return Long.MIN_VALUE; + case 2: + return Long.MIN_VALUE; + case 3: + return Long.MAX_VALUE; + default: + return (long)0; + } + } + + static short genValue(long i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static final List> LONG_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)longCornerCaseValue(i)); + }) + ); + + + static void assertArraysEquals(long[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static void assertArraysEquals(double[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static short bits(short e) { + return e; + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[0.01 + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("Float16[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01f + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (i % 17 == 0) ? cornerCaseValue(i) : Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + // Create combinations of pairs + // @@@ Might be sensitive to order e.g. div by 0 + static final List>> HALFFLOAT_GENERATOR_PAIRS = + Stream.of(HALFFLOAT_GENERATORS.get(0)). + flatMap(fa -> HALFFLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] boolUnaryOpProvider() { + return BOOL_ARRAY_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_GENERATOR_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> HALFFLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + static final List> SELECT_FROM_INDEX_GENERATORS = List.of( + withToString("short[0..VECLEN*2)", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(RAND.nextInt())); + }) + ); + + static final List>> HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortBinaryOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortIndexedOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpProvider() { + return HALFFLOAT_GENERATOR_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortSelectFromTwoVectorOpProvider() { + return HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_TRIPLES.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoIntUnaryOpProvider() { + return INT_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoLongUnaryOpProvider() { + return LONG_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskCompareOpProvider() { + return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleCompareOpProvider() { + return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_SHUFFLE_GENERATORS = List.of( + withToStringBi("shuffle[random]", (Integer l, Integer m) -> { + short[] a = new short[l]; + int upper = m; + for (int i = 0; i < 1; i++) { + a[i] = (short)RAND.nextInt(upper); + } + return a; + }) + ); + + @DataProvider + public Object[][] shortUnaryOpSelectFromProvider() { + return HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpSelectFromMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_COMPARE_GENERATORS = List.of( + withToString("short[i]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)i); + }), + withToString("short[i - length / 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - (s * BUFFER_REPS / 2))); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i + 1)); + }), + withToString("short[i - 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - 2)); + }), + withToString("short[zigZag(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + static final List>> HALFFLOAT_TEST_GENERATOR_ARGS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + map(fa -> List.of(fa)). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortTestOpProvider() { + return HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTestOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_COMPARE_GENERATOR_PAIRS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + flatMap(fa -> HALFFLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortCompareOpProvider() { + return HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortCompareOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static short cornerCaseValue(int i) { + return switch(i % 8) { + case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); + case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); + case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + case 4 -> Float16.float16ToRawShortBits(Float16.NaN); + case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 6 -> ((short)0.0); + default -> ((short)-0.0); + }; + } + + static final IntFunction fr = (vl) -> { + int length = BUFFER_REPS * vl; + return new short[length]; + }; + + static final IntFunction fmr = (vl) -> { + int length = BUFFER_REPS * vl; + return new boolean[length]; + }; + + static final IntFunction lfr = (vl) -> { + int length = BUFFER_REPS * vl; + return new long[length]; + }; + + static boolean eq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() == bt.floatValue(); + } + + static boolean neq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() != bt.floatValue(); + } + + static boolean lt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() < bt.floatValue(); + } + + static boolean le(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() <= bt.floatValue(); + } + + static boolean gt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() > bt.floatValue(); + } + + static boolean ge(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() >= bt.floatValue(); + } + + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + @Test + static void smokeTest1() { + HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three2).allTrue()); + HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three3).allTrue()); + int scale = 2; + HalffloatVector higher = three.addIndex(scale); + VectorMask m = three.compare(VectorOperators.LE, higher); + assert(m.allTrue()); + m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + assert(m.allTrue()); + m = higher.test(VectorOperators.IS_FINITE); + assert(m.allTrue()); + short max = higher.reduceLanes(VectorOperators.MAX); + assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); + } + + private static short[] + bothToArray(HalffloatVector a, HalffloatVector b) { + short[] r = new short[a.length() + b.length()]; + a.intoArray(r, 0); + b.intoArray(r, a.length()); + return r; + } + + @Test + static void smokeTest2() { + // Do some zipping and shuffling. + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); + Assert.assertEquals(io, io2); + HalffloatVector a = io.add((short)1); //[1,2] + HalffloatVector b = a.neg(); //[-1,-2] + short[] abValues = bothToArray(a,b); //[1,2,-1,-2] + VectorShuffle zip0 = VectorShuffle.makeZip(SPECIES, 0); + VectorShuffle zip1 = VectorShuffle.makeZip(SPECIES, 1); + HalffloatVector zab0 = a.rearrange(zip0,b); //[1,-1] + HalffloatVector zab1 = a.rearrange(zip1,b); //[2,-2] + short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] + // manually zip + short[] manual = new short[zabValues.length]; + for (int i = 0; i < manual.length; i += 2) { + manual[i+0] = abValues[i/2]; + manual[i+1] = abValues[a.length() + i/2]; + } + Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); + VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); + HalffloatVector uab0 = zab0.rearrange(unz0,zab1); + HalffloatVector uab1 = zab0.rearrange(unz1,zab1); + short[] abValues1 = bothToArray(uab0, uab1); + Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + } + + static void iotaShuffle() { + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); + Assert.assertEquals(io, io2); + } + + @Test + // Test all shuffle related operations. + static void shuffleTest() { + // To test backend instructions, make sure that C2 is used. + for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { + iotaShuffle(); + } + } + + @Test + void viewAsIntegeralLanesTest() { + Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); + VectorSpecies asIntegralSpecies = asIntegral.species(); + Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); + Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + } + + @Test + void viewAsFloatingLanesTest() { + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + Assert.assertEquals(asFloating.species(), SPECIES); + } + + static short ADD(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::ADD); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::ADD); + } + + static short SUB(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void SUBHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::SUB); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void SUBHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::SUB); + } + + static short MUL(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MULHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::MUL); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MULHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::MUL); + } + + static short DIV(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void DIVHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::DIV); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void DIVHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::DIV); + } + + static short MAX(short a, short b) { + return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MAXHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::MAX); + } + + static short MIN(short a, short b) { + return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MINHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::MIN); + } + + static short ABS(short a) { + return (short)(Math.abs(a)); + } + + static short abs(short a) { + return (short)(Math.abs(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat512VectorTests::ABS); + } + + static short NEG(short a) { + return (short)(-a); + } + + static short neg(short a) { + return (short)(-a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat512VectorTests::NEG); + } + + static short FMA(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + static short fma(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat512VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat512VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, mask, Halffloat512VectorTests::FMA); + } + + static short SQRT(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + static short sqrt(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat512VectorTests::SQRT); + } + + static short SIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); + } + + static short strictSIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::SIN, Halffloat512VectorTests::strictSIN); + } + + static short EXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); + } + + static short strictEXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::EXP, Halffloat512VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); + } + + static short strictLOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG1P, Halffloat512VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + } + + static short strictLOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG, Halffloat512VectorTests::strictLOG); + } + + static short LOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + } + + static short strictLOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG10, Halffloat512VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + } + + static short strictEXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::EXPM1, Halffloat512VectorTests::strictEXPM1); + } + + static short COS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + } + + static short strictCOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::COS, Halffloat512VectorTests::strictCOS); + } + + static short TAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + } + + static short strictTAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::TAN, Halffloat512VectorTests::strictTAN); + } + + static short SINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + } + + static short strictSINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::SINH, Halffloat512VectorTests::strictSINH); + } + + static short COSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + } + + static short strictCOSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::COSH, Halffloat512VectorTests::strictCOSH); + } + + static short TANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + } + + static short strictTANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::TANH, Halffloat512VectorTests::strictTANH); + } + + static short ASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + } + + static short strictASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ASIN, Halffloat512VectorTests::strictASIN); + } + + static short ACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + } + + static short strictACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ACOS, Halffloat512VectorTests::strictACOS); + } + + static short ATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + } + + static short strictATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ATAN, Halffloat512VectorTests::strictATAN); + } + + static short CBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + } + + static short strictCBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::CBRT, Halffloat512VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictHYPOT(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::HYPOT, Halffloat512VectorTests::strictHYPOT); + } + + static short POW(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictPOW(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::POW, Halffloat512VectorTests::strictPOW); + } + + static short pow(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictpow(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::pow, Halffloat512VectorTests::strictpow); + } + + static short ATAN2(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictATAN2(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::ATAN2, Halffloat512VectorTests::strictATAN2); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::POW, Halffloat512VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::pow, Halffloat512VectorTests::strictpow); + } + + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat512VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::blend); + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.lt(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.eq(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shorttoIntUnaryOpProvider") + static void toIntArrayHalffloat512VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void toLongArrayHalffloat512VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toDoubleArrayHalffloat512VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toStringHalffloat512VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + String str = av.toString(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void hashCodeHalffloat512VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int hash = av.hashCode(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + + static long ADDReduceLong(short[] a, int idx) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLong(short[] a) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ADDReduceLongHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEquals(r, ra, a, + Halffloat512VectorTests::ADDReduceLong, Halffloat512VectorTests::ADDReduceAllLong); + } + + static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if(mask[i % SPECIES.length()]) + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceLongHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEqualsMasked(r, ra, a, mask, + Halffloat512VectorTests::ADDReduceLongMasked, Halffloat512VectorTests::ADDReduceAllLongMasked); + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void BroadcastLongHalffloat512VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); + } + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.blend((long)b[i], vmask).intoArray(r, i); + } + } + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat512VectorTests::blend); + } + + + @Test(dataProvider = "shortUnaryOpSelectFromProvider") + static void SelectFromHalffloat512VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") + static void SelectFromTwoVectorHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] idx = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < idx.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector idxv = HalffloatVector.fromArray(SPECIES, idx, i); + idxv.selectFrom(av, bv).intoArray(r, i); + } + } + assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") + static void SelectFromHalffloat512VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av, vmask).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleMiscellaneousHalffloat512VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + int hash = shuffle.hashCode(); + int length = shuffle.length(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + Assert.assertEquals(length, SPECIES.length()); + } + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleToStringHalffloat512VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + String str = shuffle.toString(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shuffleCompareOpProvider") + static void shuffleEqualsHalffloat512VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = VectorShuffle.fromArray(SPECIES, a, i); + var bv = VectorShuffle.fromArray(SPECIES, b, i); + boolean eq = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); + } + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqualsHalffloat512VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + boolean equals = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); + } + } + + static boolean band(boolean a, boolean b) { + return a & b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndHalffloat512VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.and(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat512VectorTests::band); + } + + static boolean bor(boolean a, boolean b) { + return a | b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskOrHalffloat512VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.or(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat512VectorTests::bor); + } + + static boolean bxor(boolean a, boolean b) { + return a != b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskXorHalffloat512VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.xor(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat512VectorTests::bxor); + } + + static boolean bandNot(boolean a, boolean b) { + return a & !b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndNotHalffloat512VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.andNot(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat512VectorTests::bandNot); + } + + static boolean beq(boolean a, boolean b) { + return (a == b); + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqHalffloat512VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.eq(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat512VectorTests::beq); + } + + @Test(dataProvider = "maskProvider") + static void maskHashCodeHalffloat512VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + int hash = vmask.hashCode(); + + boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + static int maskTrueCount(boolean[] a, int idx) { + int trueCount = 0; + for (int i = idx; i < idx + SPECIES.length(); i++) { + trueCount += a[i] ? 1 : 0; + } + return trueCount; + } + + @Test(dataProvider = "maskProvider") + static void maskTrueCountHalffloat512VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.trueCount(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat512VectorTests::maskTrueCount); + } + + static int maskLastTrue(boolean[] a, int idx) { + int i = idx + SPECIES.length() - 1; + for (; i >= idx; i--) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskLastTrueHalffloat512VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.lastTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat512VectorTests::maskLastTrue); + } + + static int maskFirstTrue(boolean[] a, int idx) { + int i = idx; + for (; i < idx + SPECIES.length(); i++) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskFirstTrueHalffloat512VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.firstTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat512VectorTests::maskFirstTrue); + } + + @Test(dataProvider = "maskProvider") + static void maskCompressHalffloat512VectorTestsSmokeTest(IntFunction fa) { + int trueCount = 0; + boolean[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + trueCount = vmask.trueCount(); + var rmask = vmask.compress(); + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); + } + } + } + } + + @DataProvider + public static Object[][] longMaskProvider() { + return new Object[][]{ + {0xFFFFFFFFFFFFFFFFL}, + {0x0000000000000000L}, + {0x5555555555555555L}, + {0x0123456789abcdefL}, + }; + } + + @Test(dataProvider = "longMaskProvider") + static void maskFromToLongHalffloat512VectorTestsSmokeTest(long inputLong) { + var vmask = VectorMask.fromLong(SPECIES, inputLong); + long outputLong = vmask.toLong(); + Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length())))))); + } + + @DataProvider + public static Object[][] offsetProvider() { + return new Object[][]{ + {0}, + {-1}, + {+1}, + {+2}, + {-2}, + }; + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeHalffloat512VectorTestsSmokeTest(int offset) { + int limit = SPECIES.length() * BUFFER_REPS; + for (int i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + int index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeLongHalffloat512VectorTestsSmokeTest(int offset) { + long limit = SPECIES.length() * BUFFER_REPS; + for (long i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + long index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @DataProvider + public static Object[][] lengthProvider() { + return new Object[][]{ + {0}, + {1}, + {32}, + {37}, + {1024}, + {1024+1}, + {1024+5}, + }; + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundHalffloat512VectorTestsSmokeTest(int length) { + int actualLoopBound = SPECIES.loopBound(length); + int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundLongHalffloat512VectorTestsSmokeTest(int _length) { + long length = _length; + long actualLoopBound = SPECIES.loopBound(length); + long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test + static void ElementSizeHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + int elsize = av.elementSize(); + Assert.assertEquals(elsize, Float16.SIZE); + } + + @Test + static void VectorShapeHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + assert(vsh.equals(VectorShape.S_512_BIT)); + } + + @Test + static void ShapeWithLanesHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = vsh.withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void ElementTypeHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementType() == Float16.class); + } + + @Test + static void SpeciesElementSizeHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementSize() == Float16.SIZE); + } + + @Test + static void VectorTypeHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().vectorType() == av.getClass()); + } + + @Test + static void WithLanesHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorSpecies species = av.species().withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void WithShapeHalffloat512VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = av.species().withShape(vsh); + assert(species.equals(SPECIES)); + } + + @Test + static void MaskAllTrueHalffloat512VectorTestsSmokeTest() { + for (int ic = 0; ic < INVOC_COUNT; ic++) { + Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); + } + } +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Halffloat64VectorLoadStoreTests.java new file mode 100644 index 0000000000000..4671d93523ddd --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat64VectorLoadStoreTests.java @@ -0,0 +1,1016 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation + * @run testng/othervm -XX:-TieredCompilation Halffloat64VectorLoadStoreTests + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.Arena; +import java.lang.foreign.ValueLayout; +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.internal.vm.annotation.DontInline; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.nio.ByteOrder; +import java.util.List; +import java.util.function.*; + +@Test +public class Halffloat64VectorLoadStoreTests extends AbstractVectorLoadStoreTest { + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_64; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); + + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); + } + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + }) + ); + + // Relative to array.length + static final List> INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl + 1", (int l) -> { + return l - SPECIES.length() + 1; + }), + withToString("l + speciesl - 1", (int l) -> { + return l + SPECIES.length() - 1; + }), + withToString("l + speciesl", (int l) -> { + return l + SPECIES.length(); + }), + withToString("l + speciesl + 1", (int l) -> { + return l + SPECIES.length() + 1; + }) + ); + + // Relative to byte[] array.length or MemorySegment.byteSize() + static final List> BYTE_INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl*ebsize + 1", (int l) -> { + return l - SPECIES.vectorByteSize() + 1; + }), + withToString("l + speciesl*ebsize - 1", (int l) -> { + return l + SPECIES.vectorByteSize() - 1; + }), + withToString("l + speciesl*ebsize", (int l) -> { + return l + SPECIES.vectorByteSize(); + }), + withToString("l + speciesl*ebsize + 1", (int l) -> { + return l + SPECIES.vectorByteSize() + 1; + }) + ); + + @DataProvider + public Object[][] shortProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentProvider() { + return HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, bo}; + }))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, fm, bo}; + })))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + static MemorySegment toSegment(short[] a, IntFunction fb) { + MemorySegment ms = fb.apply(a.length * SPECIES.elementSize() / 8); + for (int i = 0; i < a.length; i++) { + ms.set(ELEMENT_LAYOUT, i * SPECIES.elementSize() / 8 , a[i]); + } + return ms; + } + + static short[] segmentToArray(MemorySegment ms) { + return ms.toArray(ELEMENT_LAYOUT); + } + + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + @DontInline + static VectorShuffle shuffleFromArray(int[] a, int i) { + return SPECIES.shuffleFromArray(a, i); + } + + @DontInline + static void shuffleIntoArray(VectorShuffle s, int[] a, int i) { + s.intoArray(a, i); + } + + @DontInline + static VectorShuffle shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { + return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo); + } + + @DontInline + static void shuffleIntoMemorySegment(VectorShuffle s, MemorySegment mem, int i, ByteOrder bo) { + s.intoMemorySegment(mem, i, bo); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromArray(a, i); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i, VectorMask m) { + return HalffloatVector.fromArray(SPECIES, a, i, m); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i) { + v.intoArray(a, i); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i, VectorMask m) { + v.intoArray(a, i, m); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromMemorySegment(a, i, bo); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask m) { + return HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, m); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo) { + v.intoMemorySegment(a, i, bo); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo, VectorMask m) { + v.intoMemorySegment(a, i, bo, m); + } + + @Test(dataProvider = "shortProvider") + static void loadStoreArray(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void loadArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + fromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void storeArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMaskArray(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, vmask); + av.intoArray(r, i); + } + } + assertArraysEquals(r, a, mask); + + + r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, vmask); + } + } + assertArraysEquals(r, a, mask); + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void loadArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i, vmask); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + fromArray(a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void storeArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i, vmask); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMask(IntFunction fa, + IntFunction fm) { + boolean[] mask = fm.apply(SPECIES.length()); + boolean[] r = new boolean[mask.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < mask.length; i += SPECIES.length()) { + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, mask); + } + + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo); + } + } + long m = r.mismatch(a); + Assert.assertEquals(m, -1, "Segments not equal"); + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void loadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder()); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void storeMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentMaskProvider") + static void loadStoreMemorySegmentMask(IntFunction fa, + IntFunction fb, + IntFunction fm, + ByteOrder bo) { + short[] _a = fa.apply(SPECIES.length()); + MemorySegment a = toSegment(_a, fb); + MemorySegment r = fb.apply((int) a.byteSize()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, vmask); + av.intoMemorySegment(r, i, bo); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + + + r = fb.apply((int) a.byteSize()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo, vmask); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void loadMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder(), vmask); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void storeMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder(), vmask); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreReadonlyMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb).asReadOnly(); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(true)) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(false)) + ); + + VectorMask m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) + .laneIsValid(); + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, m) + ); + } + + + @Test(dataProvider = "maskProvider") + static void loadStoreMask(IntFunction fm) { + boolean[] a = fm.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorMask vmask = SPECIES.loadMask(a, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + + @Test(dataProvider = "shuffleIntProvider") + static void loadStoreShuffleArray(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = VectorShuffle.fromArray(SPECIES, a, i); + shuffle.intoArray(r, i); + } + } + + for (int i = 0; i < a.length; i++) { + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]); + } + + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void storeShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffleIntoArray(shuffle, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + VectorShuffle shuffle = shuffleFromArray(a, index); + shuffleIntoArray(shuffle, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void loadShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffle.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + shuffleFromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntMemorySegmentProvider") + static void loadStoreShuffleMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); + shuffle.intoMemorySegment(r, i, bo); + } + } + + for (int i = 0; i < l / 4; i++) { + int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri); + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleLoadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); + shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleStoreMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + + + // Gather/Scatter load/store tests + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], a[i + indexMap[j]]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j); + } + } + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j); + } + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + if (mask[j % SPECIES.length()]) { + expected[i + indexMap[j]] = a[j]; + } + } + } + + Assert.assertEquals(r, expected); + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + expected[i + indexMap[j]] = a[j]; + } + } + + Assert.assertEquals(r, expected); + } + + @DataProvider + public Object[][] gatherScatterProvider() { + return INT_INDEX_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] gatherScatterMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm -> + HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm, fs}; + }))). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "gatherScatterProvider") + static void gather(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void gatherMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i, vmask); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b, mask); + } + + @Test(dataProvider = "gatherScatterProvider") + static void scatter(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i); + } + } + + assertScatterArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void scatterMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i, vmask); + } + } + + assertScatterArraysEquals(r, a, b, mask); + } + + + +} diff --git a/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java new file mode 100644 index 0000000000000..87e6311030dd4 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java @@ -0,0 +1,3262 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat64VectorTests + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorOperators; +import jdk.incubator.vector.Vector; + +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.Integer; +import java.util.List; +import java.util.Arrays; +import java.util.function.BiFunction; +import java.util.function.IntFunction; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Test +public class Halffloat64VectorTests extends AbstractVectorTest { + + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_64; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + + + // for floating point addition reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; + + // for floating point multiplication reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (short)50.0; + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 64); + + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + short ir = r[i]; + short ia = a[i]; + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + + interface FUnOp { + short apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + } + } + + interface FUnArrayOp { + short[] apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a[i])); + } + } catch (AssertionError e) { + short[] ref = f.apply(a[i]); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + interface FReductionOp { + short apply(short[] a, int idx); + } + + interface FReductionAllOp { + short apply(short[] a); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa) { + assertReductionArraysEquals(r, rc, a, f, fa, (short)0.0); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa, + short relativeErrorFactor) { + int i = 0; + try { + 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.ulp(r[i]) * relativeErrorFactor); + } + } catch (AssertionError e) { + 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); + } + } + + interface FReductionMaskedOp { + short apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOp { + short apply(short[] a, boolean[] mask); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa) { + assertReductionArraysEqualsMasked(r, rc, a, mask, f, fa, (short)0.0); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa, + short relativeError) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * +relativeError)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + } + } + + interface FReductionOpLong { + long apply(short[] a, int idx); + } + + interface FReductionAllOpLong { + long apply(short[] a); + } + + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, + FReductionOpLong f, FReductionAllOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FReductionMaskedOpLong { + long apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOpLong { + long apply(short[] a, boolean[] mask); + } + + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, + FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + } + } + + interface FBoolReductionOp { + boolean apply(boolean[] a, int idx); + } + + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FMaskReductionOp { + int apply(boolean[] a, int idx); + } + + static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + } + } + } catch (AssertionError e) { + int idx = i + j; + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + } + } + + static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + k], a[i + j]); + k++; + } + } + for (; k < vector_len; k++) { + Assert.assertEquals(r[i + k], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + k; + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + j], a[i + k]); + k++; + } else { + Assert.assertEquals(r[i + j], (short)0); + } + } + } + } catch (AssertionError e) { + int idx = i + j; + if (m[idx % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) { + int i = 0, j = 0; + boolean is_exceptional_idx = false; + int idx = 0, wrapped_index = 0, oidx = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = i + j; + wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + is_exceptional_idx = wrapped_index >= vector_len; + oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + j; + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a) { + int i = 0; + for (; i < a.length; i += SPECIES.length()) { + int idx = i; + for (int j = idx; j < (idx + SPECIES.length()); j++) + a[j]=a[idx]; + } + + try { + for (i = 0; i < a.length; i++) { + Assert.assertEquals(r[i], a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + } + } + + interface FBinOp { + short apply(short a, short b); + } + + interface FBinMaskOp { + short apply(short a, short b, boolean m); + + static FBinMaskOp lift(FBinOp f) { + return (a, b, m) -> m ? f.apply(a, b) : a; + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) { + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) { + int i = 0; + boolean mask_bit = false; + try { + for (; i < a.length; i++) { + mask_bit = mask[i % SPECIES.length()]; + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + } + } + + interface FBinConstOp { + short apply(short a); + } + + interface FBinConstMaskOp { + short apply(short a, boolean m); + + static FBinConstMaskOp lift(FBinConstOp f) { + return (a, m) -> m ? f.apply(a) : a; + } + } + + static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) { + assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + } + } + + interface FTernOp { + short apply(short a, short b, short c); + } + + interface FTernMaskOp { + short apply(short a, short b, short c, boolean m); + + static FTernMaskOp lift(FTernOp f) { + return (a, b, c, m) -> m ? f.apply(a, b, c) : a; + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + + static boolean isWithin1Ulp(short actual, short expected) { + Float16 act = Float16.shortBitsToFloat16(actual); + Float16 exp = Float16.shortBitsToFloat16(expected); + if (Float16.isNaN(exp) && !Float16.isNaN(act)) { + return false; + } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { + return false; + } + + Float16 low = Float16.nextDown(exp); + Float16 high = Float16.nextUp(exp); + + if (Float16.compare(low, exp) > 0) { + return false; + } + + if (Float16.compare(high, exp) < 0) { + return false; + } + + return true; + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FUnOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); + } + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); + } + } + + static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, + FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + Assert.assertTrue(isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])), + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], + b[(i / SPECIES.length()) * SPECIES.length()])); + } + } + + interface FGatherScatterOp { + short[] apply(short[] a, int ix, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + " at index #" + i); + } + } + + interface FGatherMaskedOp { + short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + interface FScatterMaskedOp { + short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(r, a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(r, a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", r: " + + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + interface FLaneOp { + short[] apply(short[] a, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + interface FLaneBop { + short[] apply(short[] a, short[] b, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLaneMaskedBop { + short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLanePartBop { + short[] apply(short[] a, short[] b, int origin, int part, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + interface FLanePartMaskedBop { + short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + static short genValue(int i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static int intCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Integer.MAX_VALUE; + case 1: + return Integer.MIN_VALUE; + case 2: + return Integer.MIN_VALUE; + case 3: + return Integer.MAX_VALUE; + default: + return (int)0; + } + } + + static final List> INT_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[intCornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)intCornerCaseValue(i)); + }) + ); + + static void assertArraysEquals(int[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static long longCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Long.MAX_VALUE; + case 1: + return Long.MIN_VALUE; + case 2: + return Long.MIN_VALUE; + case 3: + return Long.MAX_VALUE; + default: + return (long)0; + } + } + + static short genValue(long i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static final List> LONG_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)longCornerCaseValue(i)); + }) + ); + + + static void assertArraysEquals(long[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static void assertArraysEquals(double[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static short bits(short e) { + return e; + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[0.01 + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("Float16[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01f + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (i % 17 == 0) ? cornerCaseValue(i) : Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + // Create combinations of pairs + // @@@ Might be sensitive to order e.g. div by 0 + static final List>> HALFFLOAT_GENERATOR_PAIRS = + Stream.of(HALFFLOAT_GENERATORS.get(0)). + flatMap(fa -> HALFFLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] boolUnaryOpProvider() { + return BOOL_ARRAY_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_GENERATOR_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> HALFFLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + static final List> SELECT_FROM_INDEX_GENERATORS = List.of( + withToString("short[0..VECLEN*2)", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(RAND.nextInt())); + }) + ); + + static final List>> HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortBinaryOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortIndexedOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpProvider() { + return HALFFLOAT_GENERATOR_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortSelectFromTwoVectorOpProvider() { + return HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_TRIPLES.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoIntUnaryOpProvider() { + return INT_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoLongUnaryOpProvider() { + return LONG_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskCompareOpProvider() { + return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleCompareOpProvider() { + return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_SHUFFLE_GENERATORS = List.of( + withToStringBi("shuffle[random]", (Integer l, Integer m) -> { + short[] a = new short[l]; + int upper = m; + for (int i = 0; i < 1; i++) { + a[i] = (short)RAND.nextInt(upper); + } + return a; + }) + ); + + @DataProvider + public Object[][] shortUnaryOpSelectFromProvider() { + return HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpSelectFromMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_COMPARE_GENERATORS = List.of( + withToString("short[i]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)i); + }), + withToString("short[i - length / 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - (s * BUFFER_REPS / 2))); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i + 1)); + }), + withToString("short[i - 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - 2)); + }), + withToString("short[zigZag(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + static final List>> HALFFLOAT_TEST_GENERATOR_ARGS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + map(fa -> List.of(fa)). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortTestOpProvider() { + return HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTestOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_COMPARE_GENERATOR_PAIRS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + flatMap(fa -> HALFFLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortCompareOpProvider() { + return HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortCompareOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static short cornerCaseValue(int i) { + return switch(i % 8) { + case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); + case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); + case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + case 4 -> Float16.float16ToRawShortBits(Float16.NaN); + case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 6 -> ((short)0.0); + default -> ((short)-0.0); + }; + } + + static final IntFunction fr = (vl) -> { + int length = BUFFER_REPS * vl; + return new short[length]; + }; + + static final IntFunction fmr = (vl) -> { + int length = BUFFER_REPS * vl; + return new boolean[length]; + }; + + static final IntFunction lfr = (vl) -> { + int length = BUFFER_REPS * vl; + return new long[length]; + }; + + static boolean eq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() == bt.floatValue(); + } + + static boolean neq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() != bt.floatValue(); + } + + static boolean lt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() < bt.floatValue(); + } + + static boolean le(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() <= bt.floatValue(); + } + + static boolean gt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() > bt.floatValue(); + } + + static boolean ge(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() >= bt.floatValue(); + } + + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + @Test + static void smokeTest1() { + HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three2).allTrue()); + HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three3).allTrue()); + int scale = 2; + HalffloatVector higher = three.addIndex(scale); + VectorMask m = three.compare(VectorOperators.LE, higher); + assert(m.allTrue()); + m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + assert(m.allTrue()); + m = higher.test(VectorOperators.IS_FINITE); + assert(m.allTrue()); + short max = higher.reduceLanes(VectorOperators.MAX); + assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); + } + + private static short[] + bothToArray(HalffloatVector a, HalffloatVector b) { + short[] r = new short[a.length() + b.length()]; + a.intoArray(r, 0); + b.intoArray(r, a.length()); + return r; + } + + @Test + static void smokeTest2() { + // Do some zipping and shuffling. + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); + Assert.assertEquals(io, io2); + HalffloatVector a = io.add((short)1); //[1,2] + HalffloatVector b = a.neg(); //[-1,-2] + short[] abValues = bothToArray(a,b); //[1,2,-1,-2] + VectorShuffle zip0 = VectorShuffle.makeZip(SPECIES, 0); + VectorShuffle zip1 = VectorShuffle.makeZip(SPECIES, 1); + HalffloatVector zab0 = a.rearrange(zip0,b); //[1,-1] + HalffloatVector zab1 = a.rearrange(zip1,b); //[2,-2] + short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] + // manually zip + short[] manual = new short[zabValues.length]; + for (int i = 0; i < manual.length; i += 2) { + manual[i+0] = abValues[i/2]; + manual[i+1] = abValues[a.length() + i/2]; + } + Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); + VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); + HalffloatVector uab0 = zab0.rearrange(unz0,zab1); + HalffloatVector uab1 = zab0.rearrange(unz1,zab1); + short[] abValues1 = bothToArray(uab0, uab1); + Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + } + + static void iotaShuffle() { + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); + Assert.assertEquals(io, io2); + } + + @Test + // Test all shuffle related operations. + static void shuffleTest() { + // To test backend instructions, make sure that C2 is used. + for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { + iotaShuffle(); + } + } + + @Test + void viewAsIntegeralLanesTest() { + Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); + VectorSpecies asIntegralSpecies = asIntegral.species(); + Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); + Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + } + + @Test + void viewAsFloatingLanesTest() { + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + Assert.assertEquals(asFloating.species(), SPECIES); + } + + static short ADD(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::ADD); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::ADD); + } + + static short SUB(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void SUBHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::SUB); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void SUBHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::SUB); + } + + static short MUL(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MULHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::MUL); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MULHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::MUL); + } + + static short DIV(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void DIVHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::DIV); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void DIVHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::DIV); + } + + static short MAX(short a, short b) { + return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MAXHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::MAX); + } + + static short MIN(short a, short b) { + return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MINHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::MIN); + } + + static short ABS(short a) { + return (short)(Math.abs(a)); + } + + static short abs(short a) { + return (short)(Math.abs(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat64VectorTests::ABS); + } + + static short NEG(short a) { + return (short)(-a); + } + + static short neg(short a) { + return (short)(-a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat64VectorTests::NEG); + } + + static short FMA(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + static short fma(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat64VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat64VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, mask, Halffloat64VectorTests::FMA); + } + + static short SQRT(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + static short sqrt(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat64VectorTests::SQRT); + } + + static short SIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); + } + + static short strictSIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::SIN, Halffloat64VectorTests::strictSIN); + } + + static short EXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); + } + + static short strictEXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::EXP, Halffloat64VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); + } + + static short strictLOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG1P, Halffloat64VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + } + + static short strictLOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG, Halffloat64VectorTests::strictLOG); + } + + static short LOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + } + + static short strictLOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG10, Halffloat64VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + } + + static short strictEXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::EXPM1, Halffloat64VectorTests::strictEXPM1); + } + + static short COS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + } + + static short strictCOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::COS, Halffloat64VectorTests::strictCOS); + } + + static short TAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + } + + static short strictTAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::TAN, Halffloat64VectorTests::strictTAN); + } + + static short SINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + } + + static short strictSINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::SINH, Halffloat64VectorTests::strictSINH); + } + + static short COSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + } + + static short strictCOSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::COSH, Halffloat64VectorTests::strictCOSH); + } + + static short TANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + } + + static short strictTANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::TANH, Halffloat64VectorTests::strictTANH); + } + + static short ASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + } + + static short strictASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ASIN, Halffloat64VectorTests::strictASIN); + } + + static short ACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + } + + static short strictACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ACOS, Halffloat64VectorTests::strictACOS); + } + + static short ATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + } + + static short strictATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ATAN, Halffloat64VectorTests::strictATAN); + } + + static short CBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + } + + static short strictCBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::CBRT, Halffloat64VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictHYPOT(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::HYPOT, Halffloat64VectorTests::strictHYPOT); + } + + static short POW(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictPOW(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::POW, Halffloat64VectorTests::strictPOW); + } + + static short pow(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictpow(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::pow, Halffloat64VectorTests::strictpow); + } + + static short ATAN2(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictATAN2(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::ATAN2, Halffloat64VectorTests::strictATAN2); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::POW, Halffloat64VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::pow, Halffloat64VectorTests::strictpow); + } + + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat64VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::blend); + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.lt(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.eq(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shorttoIntUnaryOpProvider") + static void toIntArrayHalffloat64VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void toLongArrayHalffloat64VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toDoubleArrayHalffloat64VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toStringHalffloat64VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + String str = av.toString(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void hashCodeHalffloat64VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int hash = av.hashCode(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + + static long ADDReduceLong(short[] a, int idx) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLong(short[] a) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ADDReduceLongHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEquals(r, ra, a, + Halffloat64VectorTests::ADDReduceLong, Halffloat64VectorTests::ADDReduceAllLong); + } + + static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if(mask[i % SPECIES.length()]) + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceLongHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEqualsMasked(r, ra, a, mask, + Halffloat64VectorTests::ADDReduceLongMasked, Halffloat64VectorTests::ADDReduceAllLongMasked); + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void BroadcastLongHalffloat64VectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); + } + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.blend((long)b[i], vmask).intoArray(r, i); + } + } + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat64VectorTests::blend); + } + + + @Test(dataProvider = "shortUnaryOpSelectFromProvider") + static void SelectFromHalffloat64VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") + static void SelectFromTwoVectorHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] idx = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < idx.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector idxv = HalffloatVector.fromArray(SPECIES, idx, i); + idxv.selectFrom(av, bv).intoArray(r, i); + } + } + assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") + static void SelectFromHalffloat64VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av, vmask).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleMiscellaneousHalffloat64VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + int hash = shuffle.hashCode(); + int length = shuffle.length(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + Assert.assertEquals(length, SPECIES.length()); + } + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleToStringHalffloat64VectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + String str = shuffle.toString(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shuffleCompareOpProvider") + static void shuffleEqualsHalffloat64VectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = VectorShuffle.fromArray(SPECIES, a, i); + var bv = VectorShuffle.fromArray(SPECIES, b, i); + boolean eq = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); + } + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqualsHalffloat64VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + boolean equals = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); + } + } + + static boolean band(boolean a, boolean b) { + return a & b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndHalffloat64VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.and(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat64VectorTests::band); + } + + static boolean bor(boolean a, boolean b) { + return a | b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskOrHalffloat64VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.or(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat64VectorTests::bor); + } + + static boolean bxor(boolean a, boolean b) { + return a != b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskXorHalffloat64VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.xor(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat64VectorTests::bxor); + } + + static boolean bandNot(boolean a, boolean b) { + return a & !b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndNotHalffloat64VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.andNot(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat64VectorTests::bandNot); + } + + static boolean beq(boolean a, boolean b) { + return (a == b); + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqHalffloat64VectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.eq(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, Halffloat64VectorTests::beq); + } + + @Test(dataProvider = "maskProvider") + static void maskHashCodeHalffloat64VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + int hash = vmask.hashCode(); + + boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + static int maskTrueCount(boolean[] a, int idx) { + int trueCount = 0; + for (int i = idx; i < idx + SPECIES.length(); i++) { + trueCount += a[i] ? 1 : 0; + } + return trueCount; + } + + @Test(dataProvider = "maskProvider") + static void maskTrueCountHalffloat64VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.trueCount(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat64VectorTests::maskTrueCount); + } + + static int maskLastTrue(boolean[] a, int idx) { + int i = idx + SPECIES.length() - 1; + for (; i >= idx; i--) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskLastTrueHalffloat64VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.lastTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat64VectorTests::maskLastTrue); + } + + static int maskFirstTrue(boolean[] a, int idx) { + int i = idx; + for (; i < idx + SPECIES.length(); i++) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskFirstTrueHalffloat64VectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.firstTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, Halffloat64VectorTests::maskFirstTrue); + } + + @Test(dataProvider = "maskProvider") + static void maskCompressHalffloat64VectorTestsSmokeTest(IntFunction fa) { + int trueCount = 0; + boolean[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + trueCount = vmask.trueCount(); + var rmask = vmask.compress(); + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); + } + } + } + } + + @DataProvider + public static Object[][] longMaskProvider() { + return new Object[][]{ + {0xFFFFFFFFFFFFFFFFL}, + {0x0000000000000000L}, + {0x5555555555555555L}, + {0x0123456789abcdefL}, + }; + } + + @Test(dataProvider = "longMaskProvider") + static void maskFromToLongHalffloat64VectorTestsSmokeTest(long inputLong) { + var vmask = VectorMask.fromLong(SPECIES, inputLong); + long outputLong = vmask.toLong(); + Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length())))))); + } + + @DataProvider + public static Object[][] offsetProvider() { + return new Object[][]{ + {0}, + {-1}, + {+1}, + {+2}, + {-2}, + }; + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeHalffloat64VectorTestsSmokeTest(int offset) { + int limit = SPECIES.length() * BUFFER_REPS; + for (int i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + int index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeLongHalffloat64VectorTestsSmokeTest(int offset) { + long limit = SPECIES.length() * BUFFER_REPS; + for (long i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + long index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @DataProvider + public static Object[][] lengthProvider() { + return new Object[][]{ + {0}, + {1}, + {32}, + {37}, + {1024}, + {1024+1}, + {1024+5}, + }; + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundHalffloat64VectorTestsSmokeTest(int length) { + int actualLoopBound = SPECIES.loopBound(length); + int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundLongHalffloat64VectorTestsSmokeTest(int _length) { + long length = _length; + long actualLoopBound = SPECIES.loopBound(length); + long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test + static void ElementSizeHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + int elsize = av.elementSize(); + Assert.assertEquals(elsize, Float16.SIZE); + } + + @Test + static void VectorShapeHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + assert(vsh.equals(VectorShape.S_64_BIT)); + } + + @Test + static void ShapeWithLanesHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = vsh.withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void ElementTypeHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementType() == Float16.class); + } + + @Test + static void SpeciesElementSizeHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementSize() == Float16.SIZE); + } + + @Test + static void VectorTypeHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().vectorType() == av.getClass()); + } + + @Test + static void WithLanesHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorSpecies species = av.species().withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void WithShapeHalffloat64VectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = av.species().withShape(vsh); + assert(species.equals(SPECIES)); + } + + @Test + static void MaskAllTrueHalffloat64VectorTestsSmokeTest() { + for (int ic = 0; ic < INVOC_COUNT; ic++) { + Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); + } + } +} diff --git a/test/jdk/jdk/incubator/vector/HalffloatMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorLoadStoreTests.java new file mode 100644 index 0000000000000..d92127e700701 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorLoadStoreTests.java @@ -0,0 +1,1023 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation + * @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED + * -XX:-TieredCompilation HalffloatMaxVectorLoadStoreTests + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.Arena; +import java.lang.foreign.ValueLayout; +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.HalffloatVector; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.internal.vm.annotation.DontInline; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.nio.ByteOrder; +import java.util.List; +import java.util.function.*; + +@Test +public class HalffloatMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest { + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_MAX; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); + + static VectorShape getMaxBit() { + return VectorShape.S_Max_BIT; + } + + private static final int Max = 256; // juts so we can do N/Max + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? a[i] : (short) 0, "at index #" + i); + } + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + }) + ); + + // Relative to array.length + static final List> INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl + 1", (int l) -> { + return l - SPECIES.length() + 1; + }), + withToString("l + speciesl - 1", (int l) -> { + return l + SPECIES.length() - 1; + }), + withToString("l + speciesl", (int l) -> { + return l + SPECIES.length(); + }), + withToString("l + speciesl + 1", (int l) -> { + return l + SPECIES.length() + 1; + }) + ); + + // Relative to byte[] array.length or MemorySegment.byteSize() + static final List> BYTE_INDEX_GENERATORS = List.of( + withToString("-1", (int l) -> { + return -1; + }), + withToString("l", (int l) -> { + return l; + }), + withToString("l - 1", (int l) -> { + return l - 1; + }), + withToString("l + 1", (int l) -> { + return l + 1; + }), + withToString("l - speciesl*ebsize + 1", (int l) -> { + return l - SPECIES.vectorByteSize() + 1; + }), + withToString("l + speciesl*ebsize - 1", (int l) -> { + return l + SPECIES.vectorByteSize() - 1; + }), + withToString("l + speciesl*ebsize", (int l) -> { + return l + SPECIES.vectorByteSize(); + }), + withToString("l + speciesl*ebsize + 1", (int l) -> { + return l + SPECIES.vectorByteSize() + 1; + }) + ); + + @DataProvider + public Object[][] shortProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentProvider() { + return HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, bo}; + }))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortMemorySegmentMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream(). + flatMap(fa -> MEMORY_SEGMENT_GENERATORS.stream(). + flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> { + return new Object[]{fa, fb, fm, bo}; + })))). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi}; + }). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortByteMaskProviderForIOOBE() { + var f = HALFFLOAT_GENERATORS.get(0); + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_INDEX_GENERATORS.stream().map(fi -> { + return new Object[] {f, fi, fm}; + })). + toArray(Object[][]::new); + } + + static MemorySegment toSegment(short[] a, IntFunction fb) { + MemorySegment ms = fb.apply(a.length * SPECIES.elementSize() / 8); + for (int i = 0; i < a.length; i++) { + ms.set(ELEMENT_LAYOUT, i * SPECIES.elementSize() / 8 , a[i]); + } + return ms; + } + + static short[] segmentToArray(MemorySegment ms) { + return ms.toArray(ELEMENT_LAYOUT); + } + + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + @DontInline + static VectorShuffle shuffleFromArray(int[] a, int i) { + return SPECIES.shuffleFromArray(a, i); + } + + @DontInline + static void shuffleIntoArray(VectorShuffle s, int[] a, int i) { + s.intoArray(a, i); + } + + @DontInline + static VectorShuffle shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { + return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo); + } + + @DontInline + static void shuffleIntoMemorySegment(VectorShuffle s, MemorySegment mem, int i, ByteOrder bo) { + s.intoMemorySegment(mem, i, bo); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromArray(a, i); + } + + @DontInline + static HalffloatVector fromArray(short[] a, int i, VectorMask m) { + return HalffloatVector.fromArray(SPECIES, a, i, m); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i) { + v.intoArray(a, i); + } + + @DontInline + static void intoArray(HalffloatVector v, short[] a, int i, VectorMask m) { + v.intoArray(a, i, m); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo) { + // Tests the species method and the equivalent vector method it defers to + return (HalffloatVector) SPECIES.fromMemorySegment(a, i, bo); + } + + @DontInline + static HalffloatVector fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask m) { + return HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, m); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo) { + v.intoMemorySegment(a, i, bo); + } + + @DontInline + static void intoMemorySegment(HalffloatVector v, MemorySegment a, int i, ByteOrder bo, VectorMask m) { + v.intoMemorySegment(a, i, bo, m); + } + + @Test(dataProvider = "shortProvider") + static void loadStoreArray(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void loadArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + fromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortProviderForIOOBE") + static void storeArrayIOOBE(IntFunction fa, IntFunction fi) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMaskArray(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, vmask); + av.intoArray(r, i); + } + } + assertArraysEquals(r, a, mask); + + + r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, vmask); + } + } + assertArraysEquals(r, a, mask); + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void loadArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = fromArray(a, i, vmask); + av.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + fromArray(a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMaskProviderForIOOBE") + static void storeArrayMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + intoArray(av, r, i, vmask); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, a.length); + try { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, 0); + intoArray(av, a, index, vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + @Test(dataProvider = "shortMaskProvider") + static void loadStoreMask(IntFunction fa, + IntFunction fm) { + boolean[] mask = fm.apply(SPECIES.length()); + boolean[] r = new boolean[mask.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < mask.length; i += SPECIES.length()) { + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, mask); + } + + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo); + } + } + long m = r.mismatch(a); + Assert.assertEquals(m, -1, "Segments not equal"); + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void loadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder()); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteProviderForIOOBE") + static void storeMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(SPECIES.vectorByteSize(), index, (int) a.byteSize()); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentMaskProvider") + static void loadStoreMemorySegmentMask(IntFunction fa, + IntFunction fb, + IntFunction fm, + ByteOrder bo) { + short[] _a = fa.apply(SPECIES.length()); + MemorySegment a = toSegment(_a, fb); + MemorySegment r = fb.apply((int) a.byteSize()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo, vmask); + av.intoMemorySegment(r, i, bo); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + + + r = fb.apply((int) a.byteSize()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, bo); + av.intoMemorySegment(r, i, bo, vmask); + } + } + assertArraysEquals(segmentToArray(r), _a, mask); + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void loadMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = fromMemorySegment(a, i, ByteOrder.nativeOrder(), vmask); + av.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + fromMemorySegment(a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortByteMaskProviderForIOOBE") + static void storeMemorySegmentMaskIOOBE(IntFunction fa, IntFunction fi, IntFunction fm) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, Float16.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), Float16.SIZE); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromValues(SPECIES, mask); + + int l = (int) a.byteSize(); + int s = SPECIES.vectorByteSize(); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + intoMemorySegment(av, r, i, ByteOrder.nativeOrder(), vmask); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBoundsForMask(mask, index, (int) a.byteSize(), SPECIES.elementSize() / 8); + try { + HalffloatVector av = HalffloatVector.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + intoMemorySegment(av, a, index, ByteOrder.nativeOrder(), vmask); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shortMemorySegmentProvider") + static void loadStoreReadonlyMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toSegment(fa.apply(SPECIES.length()), fb).asReadOnly(); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(true)) + ); + + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(false)) + ); + + VectorMask m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) + .laneIsValid(); + Assert.assertThrows( + UnsupportedOperationException.class, + () -> SPECIES.zero().intoMemorySegment(a, 0, bo, m) + ); + } + + + @Test(dataProvider = "maskProvider") + static void loadStoreMask(IntFunction fm) { + boolean[] a = fm.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorMask vmask = SPECIES.loadMask(a, i); + vmask.intoArray(r, i); + } + } + Assert.assertEquals(r, a); + } + + + @Test(dataProvider = "shuffleIntProvider") + static void loadStoreShuffleArray(IntFunction fa) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = VectorShuffle.fromArray(SPECIES, a, i); + shuffle.intoArray(r, i); + } + } + + for (int i = 0; i < a.length; i++) { + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]); + } + + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void storeShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffleIntoArray(shuffle, r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + VectorShuffle shuffle = shuffleFromArray(a, index); + shuffleIntoArray(shuffle, r, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntProviderForIOOBE") + static void loadShuffleArrayIOOBE(IntFunction fa, IntFunction fi) { + int[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + VectorShuffle shuffle = shuffleFromArray(a, i); + shuffle.intoArray(r, i); + } + } + + int index = fi.apply(a.length); + boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); + try { + shuffleFromArray(a, index); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntMemorySegmentProvider") + static void loadStoreShuffleMemorySegment(IntFunction fa, + IntFunction fb, + ByteOrder bo) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb); + MemorySegment r = fb.apply((int) a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); + shuffle.intoMemorySegment(r, i, bo); + } + } + + for (int i = 0; i < l / 4; i++) { + int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i); + Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri); + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleLoadMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); + shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + @Test(dataProvider = "shuffleIntByteProviderForIOOBE") + static void shuffleStoreMemorySegmentIOOBE(IntFunction fa, IntFunction fi) { + MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize()); + + int l = (int) a.byteSize(); + int s = SPECIES.length() * 4; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < l; i += s) { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder()); + } + } + + int index = fi.apply((int) a.byteSize()); + boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); + try { + VectorShuffle shuffle = + VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); + shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder()); + if (shouldFail) { + Assert.fail("Failed to throw IndexOutOfBoundsException"); + } + } catch (IndexOutOfBoundsException e) { + if (!shouldFail) { + Assert.fail("Unexpected IndexOutOfBoundsException"); + } + } + } + + + + + // Gather/Scatter load/store tests + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], a[i + indexMap[j]]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[j], a[i + indexMap[j]], "at index #" + j); + } + } + + static void assertGatherArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + int i = 0; + int j = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + j = i; + for (; j < i + SPECIES.length(); j++) { + Assert.assertEquals(r[j], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[j % SPECIES.length()] ? a[i + indexMap[j]]: (short) 0, "at index #" + j); + } + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap, boolean[] mask) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + if (mask[j % SPECIES.length()]) { + expected[i + indexMap[j]] = a[j]; + } + } + } + + Assert.assertEquals(r, expected); + } + + static void assertScatterArraysEquals(short[] r, short[] a, int[] indexMap) { + short[] expected = new short[r.length]; + + // Store before checking, since the same location may be stored to more than once + for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int j = i; j < i + SPECIES.length(); j++) { + expected[i + indexMap[j]] = a[j]; + } + } + + Assert.assertEquals(r, expected); + } + + @DataProvider + public Object[][] gatherScatterProvider() { + return INT_INDEX_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] gatherScatterMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm -> + HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm, fs}; + }))). + toArray(Object[][]::new); + } + + + @Test(dataProvider = "gatherScatterProvider") + static void gather(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void gatherMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i, b, i, vmask); + av.intoArray(r, i); + } + } + + assertGatherArraysEquals(r, a, b, mask); + } + + @Test(dataProvider = "gatherScatterProvider") + static void scatter(IntFunction fa, BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i); + } + } + + assertScatterArraysEquals(r, a, b); + } + + @Test(dataProvider = "gatherScatterMaskProvider") + static void scatterMask(IntFunction fa, BiFunction fs, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] b = fs.apply(a.length, SPECIES.length()); + short[] r = new short[a.length]; + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.intoArray(r, i, b, i, vmask); + } + } + + assertScatterArraysEquals(r, a, b, mask); + } + + + +} diff --git a/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java new file mode 100644 index 0000000000000..0060ceaf43346 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java @@ -0,0 +1,3251 @@ +/* + * Copyright (c) 2018, 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @key randomness + * + * @library /test/lib + * @modules jdk.incubator.vector + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 HalffloatMaxVectorTests + */ + +// -- This file was mechanically generated: Do not edit! -- // + +import jdk.incubator.vector.VectorShape; +import jdk.incubator.vector.VectorSpecies; +import jdk.incubator.vector.VectorShuffle; +import jdk.incubator.vector.VectorMask; +import jdk.incubator.vector.VectorOperators; +import jdk.incubator.vector.Vector; + +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.Integer; +import java.util.List; +import java.util.Arrays; +import java.util.function.BiFunction; +import java.util.function.IntFunction; +import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Test +public class HalffloatMaxVectorTests extends AbstractVectorTest { + + static final VectorSpecies SPECIES = + HalffloatVector.SPECIES_MAX; + + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + + static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + + static VectorShape getMaxBit() { + return VectorShape.S_Max_BIT; + } + + private static final int Max = 256; // juts so we can do N/Max + + // for floating point addition reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; + + // for floating point multiplication reduction ops that may introduce rounding errors + private static final short RELATIVE_ROUNDING_ERROR_FACTOR_MUL = (short)50.0; + + static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / Max); + + static void assertArraysStrictlyEquals(short[] r, short[] a) { + for (int i = 0; i < a.length; i++) { + short ir = r[i]; + short ia = a[i]; + if (ir != ia) { + Assert.fail(String.format("at index #%d, expected = %016X, actual = %016X", i, ia, ir)); + } + } + } + + interface FUnOp { + short apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + } + } + + interface FUnArrayOp { + short[] apply(short a); + } + + static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a[i])); + } + } catch (AssertionError e) { + short[] ref = f.apply(a[i]); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + interface FReductionOp { + short apply(short[] a, int idx); + } + + interface FReductionAllOp { + short apply(short[] a); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa) { + assertReductionArraysEquals(r, rc, a, f, fa, (short)0.0); + } + + static void assertReductionArraysEquals(short[] r, short rc, short[] a, + FReductionOp f, FReductionAllOp fa, + short relativeErrorFactor) { + int i = 0; + try { + 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.ulp(r[i]) * relativeErrorFactor); + } + } catch (AssertionError e) { + 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); + } + } + + interface FReductionMaskedOp { + short apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOp { + short apply(short[] a, boolean[] mask); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa) { + assertReductionArraysEqualsMasked(r, rc, a, mask, f, fa, (short)0.0); + } + + static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, boolean[] mask, + FReductionMaskedOp f, FReductionAllMaskedOp fa, + short relativeError) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * +relativeError)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + } + } + + interface FReductionOpLong { + long apply(short[] a, int idx); + } + + interface FReductionAllOpLong { + long apply(short[] a); + } + + static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, + FReductionOpLong f, FReductionAllOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FReductionMaskedOpLong { + long apply(short[] a, int idx, boolean[] mask); + } + + interface FReductionAllMaskedOpLong { + long apply(short[] a, boolean[] mask); + } + + static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, boolean[] mask, + FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { + int i = 0; + try { + Assert.assertEquals(rc, fa.apply(a, mask)); + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i, mask)); + } + } catch (AssertionError e) { + Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + } + } + + interface FBoolReductionOp { + boolean apply(boolean[] a, int idx); + } + + static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + interface FMaskReductionOp { + int apply(boolean[] a, int idx); + } + + static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReductionOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(r[i], f.apply(a, i)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + } + } + } catch (AssertionError e) { + int idx = i + j; + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + } + } + + static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + k], a[i + j]); + k++; + } + } + for (; k < vector_len; k++) { + Assert.assertEquals(r[i + k], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + k; + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) { + int i = 0, j = 0, k = 0; + try { + for (; i < a.length; i += vector_len) { + k = 0; + for (j = 0; j < vector_len; j++) { + if (m[(i + j) % SPECIES.length()]) { + Assert.assertEquals(r[i + j], a[i + k]); + k++; + } else { + Assert.assertEquals(r[i + j], (short)0); + } + } + } + } catch (AssertionError e) { + int idx = i + j; + if (m[idx % SPECIES.length()]) { + Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + } else { + Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + } + } + } + + static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, short[] b, int vector_len) { + int i = 0, j = 0; + boolean is_exceptional_idx = false; + int idx = 0, wrapped_index = 0, oidx = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = i + j; + wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + is_exceptional_idx = wrapped_index >= vector_len; + oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + } + } + + static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + int idx = i + j; + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { + int i = 0, j = 0; + int idx = 0, wrapped_index = 0; + try { + for (; i < a.length; i += vector_len) { + for (j = 0; j < vector_len; j++) { + idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index]); + else + Assert.assertEquals(r[i+j], (short)0); + } + } + } catch (AssertionError e) { + if (mask[j % SPECIES.length()]) + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + else + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a) { + int i = 0; + for (; i < a.length; i += SPECIES.length()) { + int idx = i; + for (int j = idx; j < (idx + SPECIES.length()); j++) + a[j]=a[idx]; + } + + try { + for (i = 0; i < a.length; i++) { + Assert.assertEquals(r[i], a[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + } + } + + interface FBinOp { + short apply(short a, short b); + } + + interface FBinMaskOp { + short apply(short a, short b, boolean m); + + static FBinMaskOp lift(FBinOp f) { + return (a, b, m) -> m ? f.apply(a, b) : a; + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinOp f) { + assertArraysEqualsAssociative(rl, rr, a, b, c, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, short[] b, short[] c, boolean[] mask, FBinMaskOp f) { + int i = 0; + boolean mask_bit = false; + try { + for (; i < a.length; i++) { + mask_bit = mask[i % SPECIES.length()]; + //Left associative + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + + //Right associative + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + + //Results equal sanity check + Assert.assertEquals(rl[i], rr[i]); + } + } catch (AssertionError e) { + Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b)); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinOp f) { + assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinOp f) { + assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f)); + } + + static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, FBinMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + } + } + + interface FBinConstOp { + short apply(short a); + } + + interface FBinConstMaskOp { + short apply(short a, boolean m); + + static FBinConstMaskOp lift(FBinConstOp f) { + return (a, m) -> m ? f.apply(a) : a; + } + } + + static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j])); + } + } + } catch (AssertionError e) { + Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + } + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstOp f) { + assertShiftConstEquals(r, a, mask, FBinConstMaskOp.lift(f)); + } + + static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinConstMaskOp f) { + int i = 0; + int j = 0; + try { + for (; j < a.length; j += SPECIES.length()) { + for (i = 0; i < SPECIES.length(); i++) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + } + } + } catch (AssertionError err) { + Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + } + } + + interface FTernOp { + short apply(short a, short b, short c); + } + + interface FTernMaskOp { + short apply(short a, short b, short c, boolean m); + + static FTernMaskOp lift(FTernOp f) { + return (a, b, c, m) -> m ? f.apply(a, b, c) : a; + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + } + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernOp f) { + assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); + } + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, FTernOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + + c[(i / SPECIES.length()) * SPECIES.length()]); + } + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernOp f) { + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f)); + } + + static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] c, boolean[] mask, + FTernMaskOp f) { + int i = 0; + try { + for (; i < a.length; i++) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + } + } catch (AssertionError err) { + Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + + mask[i % SPECIES.length()]); + } + } + + + static boolean isWithin1Ulp(short actual, short expected) { + Float16 act = Float16.shortBitsToFloat16(actual); + Float16 exp = Float16.shortBitsToFloat16(expected); + if (Float16.isNaN(exp) && !Float16.isNaN(act)) { + return false; + } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { + return false; + } + + Float16 low = Float16.nextDown(exp); + Float16 high = Float16.nextUp(exp); + + if (Float16.compare(low, exp) > 0) { + return false; + } + + if (Float16.compare(high, exp) < 0) { + return false; + } + + return true; + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FUnOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); + } + } + + static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); + } + } + + static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, + FBinOp mathf, FBinOp strictmathf) { + int i = 0; + try { + // Check that result is within 1 ulp of strict math or equivalent to math implementation. + for (; i < a.length; i++) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); + } + } catch (AssertionError e) { + Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), + Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + Assert.assertTrue(isWithin1Ulp(r[i], + strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])), + "at index #" + i + ", input1 = " + a[i] + ", input2 = " + + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], + b[(i / SPECIES.length()) * SPECIES.length()])); + } + } + + interface FGatherScatterOp { + short[] apply(short[] a, int ix, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + " at index #" + i); + } + } + + interface FGatherMaskedOp { + short[] apply(short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + interface FScatterMaskedOp { + short[] apply(short[] r, short[] a, int ix, boolean[] mask, int[] b, int iy); + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FGatherMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FScatterMaskedOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(r, a, i, mask, b, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(r, a, i, mask, b, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, + "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + + ", b: " + + Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length())) + + ", r: " + + Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length())) + + ", mask: " + + Arrays.toString(mask) + + " at index #" + i); + } + } + + interface FLaneOp { + short[] apply(short[] a, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i); + } + } + + interface FLaneBop { + short[] apply(short[] a, short[] b, int origin, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLaneBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLaneMaskedBop { + short[] apply(short[] a, short[] b, int origin, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, boolean[] mask, FLaneMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin); + } + } + + interface FLanePartBop { + short[] apply(short[] a, short[] b, int origin, int part, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, FLanePartBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + interface FLanePartMaskedBop { + short[] apply(short[] a, short[] b, int origin, int part, boolean[] mask, int idx); + } + + static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) { + int i = 0; + try { + for (; i < a.length; i += SPECIES.length()) { + Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + f.apply(a, b, origin, part, mask, i)); + } + } catch (AssertionError e) { + short[] ref = f.apply(a, b, origin, part, mask, i); + short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); + Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + + ", res: " + Arrays.toString(res) + + "), at index #" + i + + ", at origin #" + origin + + ", with part #" + part); + } + } + + static short genValue(int i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static int intCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Integer.MAX_VALUE; + case 1: + return Integer.MIN_VALUE; + case 2: + return Integer.MIN_VALUE; + case 3: + return Integer.MAX_VALUE; + default: + return (int)0; + } + } + + static final List> INT_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[intCornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)intCornerCaseValue(i)); + }) + ); + + static void assertArraysEquals(int[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static long longCornerCaseValue(int i) { + switch(i % 5) { + case 0: + return Long.MAX_VALUE; + case 1: + return Long.MIN_VALUE; + case 2: + return Long.MIN_VALUE; + case 3: + return Long.MAX_VALUE; + default: + return (long)0; + } + } + + static short genValue(long i) { + return Float16.float16ToRawShortBits(Float16.valueOf(i)); + } + + static final List> LONG_HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)longCornerCaseValue(i)); + }) + ); + + + static void assertArraysEquals(long[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static void assertArraysEquals(double[] r, short[] a, int offs) { + int i = 0; + try { + for (; i < r.length; i++) { + Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + } + } catch (AssertionError e) { + Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + } + } + + static short bits(short e) { + return e; + } + + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("Float16[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(-i * 5)); + }), + withToString("Float16[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> genValue(i * 5)); + }), + withToString("Float16[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); + }), + withToString("Float16[0.01 + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("Float16[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01f + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (i % 17 == 0) ? cornerCaseValue(i) : Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + // Create combinations of pairs + // @@@ Might be sensitive to order e.g. div by 0 + static final List>> HALFFLOAT_GENERATOR_PAIRS = + Stream.of(HALFFLOAT_GENERATORS.get(0)). + flatMap(fa -> HALFFLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] boolUnaryOpProvider() { + return BOOL_ARRAY_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_GENERATOR_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> HALFFLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + static final List> SELECT_FROM_INDEX_GENERATORS = List.of( + withToString("short[0..VECLEN*2)", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(RAND.nextInt())); + }) + ); + + static final List>> HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES = + HALFFLOAT_GENERATOR_PAIRS.stream(). + flatMap(pair -> SELECT_FROM_INDEX_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortBinaryOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortIndexedOpProvider() { + return HALFFLOAT_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpProvider() { + return HALFFLOAT_GENERATOR_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortSelectFromTwoVectorOpProvider() { + return HALFFLOAT_GENERATOR_SELECT_FROM_TRIPLES.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTernaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATOR_TRIPLES.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpProvider() { + return HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fm}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoIntUnaryOpProvider() { + return INT_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shorttoLongUnaryOpProvider() { + return LONG_HALFFLOAT_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] maskCompareOpProvider() { + return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + map(f -> new Object[]{f}). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shuffleCompareOpProvider() { + return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleProvider() { + return INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpShuffleMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_SHUFFLE_GENERATORS = List.of( + withToStringBi("shuffle[random]", (Integer l, Integer m) -> { + short[] a = new short[l]; + int upper = m; + for (int i = 0; i < 1; i++) { + a[i] = (short)RAND.nextInt(upper); + } + return a; + }) + ); + + @DataProvider + public Object[][] shortUnaryOpSelectFromProvider() { + return HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs}; + })). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortUnaryOpSelectFromMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_SHUFFLE_GENERATORS.stream(). + flatMap(fs -> HALFFLOAT_GENERATORS.stream().map(fa -> { + return new Object[] {fa, fs, fm}; + }))). + toArray(Object[][]::new); + } + + static final List> HALFFLOAT_COMPARE_GENERATORS = List.of( + withToString("short[i]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)i); + }), + withToString("short[i - length / 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - (s * BUFFER_REPS / 2))); + }), + withToString("short[i + 1]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i + 1)); + }), + withToString("short[i - 2]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i - 2)); + }), + withToString("short[zigZag(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2))); + }), + withToString("short[cornerCaseValue(i)]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> cornerCaseValue(i)); + }) + ); + + static final List>> HALFFLOAT_TEST_GENERATOR_ARGS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + map(fa -> List.of(fa)). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortTestOpProvider() { + return HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortTestOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_TEST_GENERATOR_ARGS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + static final List>> HALFFLOAT_COMPARE_GENERATOR_PAIRS = + HALFFLOAT_COMPARE_GENERATORS.stream(). + flatMap(fa -> HALFFLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + + @DataProvider + public Object[][] shortCompareOpProvider() { + return HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + + @DataProvider + public Object[][] shortCompareOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> HALFFLOAT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill(int s , ToHalffloatF f) { + return fill(new short[s], f); + } + + static short[] fill(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + return a; + } + + static short cornerCaseValue(int i) { + return switch(i % 8) { + case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); + case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); + case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + case 4 -> Float16.float16ToRawShortBits(Float16.NaN); + case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 6 -> ((short)0.0); + default -> ((short)-0.0); + }; + } + + static final IntFunction fr = (vl) -> { + int length = BUFFER_REPS * vl; + return new short[length]; + }; + + static final IntFunction fmr = (vl) -> { + int length = BUFFER_REPS * vl; + return new boolean[length]; + }; + + static final IntFunction lfr = (vl) -> { + int length = BUFFER_REPS * vl; + return new long[length]; + }; + + static boolean eq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() == bt.floatValue(); + } + + static boolean neq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() != bt.floatValue(); + } + + static boolean lt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() < bt.floatValue(); + } + + static boolean le(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() <= bt.floatValue(); + } + + static boolean gt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() > bt.floatValue(); + } + + static boolean ge(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() >= bt.floatValue(); + } + + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + @Test + static void smokeTest1() { + HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three2).allTrue()); + HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three3).allTrue()); + int scale = 2; + HalffloatVector higher = three.addIndex(scale); + VectorMask m = three.compare(VectorOperators.LE, higher); + assert(m.allTrue()); + m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + assert(m.allTrue()); + m = higher.test(VectorOperators.IS_FINITE); + assert(m.allTrue()); + short max = higher.reduceLanes(VectorOperators.MAX); + assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); + } + + private static short[] + bothToArray(HalffloatVector a, HalffloatVector b) { + short[] r = new short[a.length() + b.length()]; + a.intoArray(r, 0); + b.intoArray(r, a.length()); + return r; + } + + @Test + static void smokeTest2() { + // Do some zipping and shuffling. + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); + Assert.assertEquals(io, io2); + HalffloatVector a = io.add((short)1); //[1,2] + HalffloatVector b = a.neg(); //[-1,-2] + short[] abValues = bothToArray(a,b); //[1,2,-1,-2] + VectorShuffle zip0 = VectorShuffle.makeZip(SPECIES, 0); + VectorShuffle zip1 = VectorShuffle.makeZip(SPECIES, 1); + HalffloatVector zab0 = a.rearrange(zip0,b); //[1,-1] + HalffloatVector zab1 = a.rearrange(zip1,b); //[2,-2] + short[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] + // manually zip + short[] manual = new short[zabValues.length]; + for (int i = 0; i < manual.length; i += 2) { + manual[i+0] = abValues[i/2]; + manual[i+1] = abValues[a.length() + i/2]; + } + Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); + VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); + HalffloatVector uab0 = zab0.rearrange(unz0,zab1); + HalffloatVector uab1 = zab0.rearrange(unz1,zab1); + short[] abValues1 = bothToArray(uab0, uab1); + Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + } + + static void iotaShuffle() { + HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); + HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); + Assert.assertEquals(io, io2); + } + + @Test + // Test all shuffle related operations. + static void shuffleTest() { + // To test backend instructions, make sure that C2 is used. + for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) { + iotaShuffle(); + } + } + + @Test + void viewAsIntegeralLanesTest() { + Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); + VectorSpecies asIntegralSpecies = asIntegral.species(); + Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); + Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + } + + @Test + void viewAsFloatingLanesTest() { + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + Assert.assertEquals(asFloating.species(), SPECIES); + } + + static short ADD(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::ADD); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::ADD); + } + + static short SUB(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void SUBHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::SUB); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void SUBHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::SUB); + } + + static short MUL(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MULHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::MUL); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MULHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::MUL); + } + + static short DIV(short a, short b) { + return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void DIVHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::DIV); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void DIVHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::DIV); + } + + static short MAX(short a, short b) { + return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::MAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MAXHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::MAX); + } + + static short MIN(short a, short b) { + return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::MIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void MINHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::MIN); + } + + static short ABS(short a) { + return (short)(Math.abs(a)); + } + + static short abs(short a) { + return (short)(Math.abs(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::ABS); + } + + static short NEG(short a) { + return (short)(-a); + } + + static short neg(short a) { + return (short)(-a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::NEG); + } + + static short FMA(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + static short fma(short a, short b, short c) { + return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, HalffloatMaxVectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, HalffloatMaxVectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, mask, HalffloatMaxVectorTests::FMA); + } + + static short SQRT(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + static short sqrt(short a) { + return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::SQRT); + } + + static short SIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); + } + + static short strictSIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::SIN, HalffloatMaxVectorTests::strictSIN); + } + + static short EXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); + } + + static short strictEXP(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::EXP, HalffloatMaxVectorTests::strictEXP); + } + + static short LOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); + } + + static short strictLOG1P(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG1P, HalffloatMaxVectorTests::strictLOG1P); + } + + static short LOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + } + + static short strictLOG(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG, HalffloatMaxVectorTests::strictLOG); + } + + static short LOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + } + + static short strictLOG10(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10HalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG10, HalffloatMaxVectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + } + + static short strictEXPM1(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1HalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::EXPM1, HalffloatMaxVectorTests::strictEXPM1); + } + + static short COS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + } + + static short strictCOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::COS, HalffloatMaxVectorTests::strictCOS); + } + + static short TAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + } + + static short strictTAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::TAN, HalffloatMaxVectorTests::strictTAN); + } + + static short SINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + } + + static short strictSINH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::SINH, HalffloatMaxVectorTests::strictSINH); + } + + static short COSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + } + + static short strictCOSH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::COSH, HalffloatMaxVectorTests::strictCOSH); + } + + static short TANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + } + + static short strictTANH(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::TANH, HalffloatMaxVectorTests::strictTANH); + } + + static short ASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + } + + static short strictASIN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ASIN, HalffloatMaxVectorTests::strictASIN); + } + + static short ACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + } + + static short strictACOS(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ACOS, HalffloatMaxVectorTests::strictACOS); + } + + static short ATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + } + + static short strictATAN(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ATAN, HalffloatMaxVectorTests::strictATAN); + } + + static short CBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + } + + static short strictCBRT(short a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::CBRT, HalffloatMaxVectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictHYPOT(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::HYPOT, HalffloatMaxVectorTests::strictHYPOT); + } + + static short POW(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictPOW(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::POW, HalffloatMaxVectorTests::strictPOW); + } + + static short pow(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictpow(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::pow, HalffloatMaxVectorTests::strictpow); + } + + static short ATAN2(short a, short b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + } + + static short strictATAN2(short a, short b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2HalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::ATAN2, HalffloatMaxVectorTests::strictATAN2); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::POW, HalffloatMaxVectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::pow, HalffloatMaxVectorTests::strictpow); + } + + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::blend); + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.lt(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.eq(b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shorttoIntUnaryOpProvider") + static void toIntArrayHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int[] r = av.toIntArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void toLongArrayHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + long[] r = av.toLongArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toDoubleArrayHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + double[] r = av.toDoubleArray(); + assertArraysEquals(r, a, i); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void toStringHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + String str = av.toString(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void hashCodeHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int hash = av.hashCode(); + + short subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + + static long ADDReduceLong(short[] a, int idx) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLong(short[] a) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ADDReduceLongHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEquals(r, ra, a, + HalffloatMaxVectorTests::ADDReduceLong, HalffloatMaxVectorTests::ADDReduceAllLong); + } + + static long ADDReduceLongMasked(short[] a, int idx, boolean[] mask) { + short res = 0; + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if(mask[i % SPECIES.length()]) + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); + } + + return (long)res; + } + + static long ADDReduceAllLongMasked(short[] a, boolean[] mask) { + long res = 0; + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); + } + + return res; + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceLongHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + long[] r = lfr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + long ra = 0; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask); + } + + ra = 0; + for (int i = 0; i < a.length; i++) { + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); + } + + assertReductionLongArraysEqualsMasked(r, ra, a, mask, + HalffloatMaxVectorTests::ADDReduceLongMasked, HalffloatMaxVectorTests::ADDReduceAllLongMasked); + } + + @Test(dataProvider = "shorttoLongUnaryOpProvider") + static void BroadcastLongHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i); + } + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.blend((long)b[i], vmask).intoArray(r, i); + } + } + assertBroadcastLongArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::blend); + } + + + @Test(dataProvider = "shortUnaryOpSelectFromProvider") + static void SelectFromHalffloatMaxVectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortSelectFromTwoVectorOpProvider") + static void SelectFromTwoVectorHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] idx = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < idx.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector idxv = HalffloatVector.fromArray(SPECIES, idx, i); + idxv.selectFrom(av, bv).intoArray(r, i); + } + } + assertSelectFromTwoVectorEquals(r, idx, a, b, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpSelectFromMaskProvider") + static void SelectFromHalffloatMaxVectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, order, i); + bv.selectFrom(av, vmask).intoArray(r, i); + } + + assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleMiscellaneousHalffloatMaxVectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + int hash = shuffle.hashCode(); + int length = shuffle.length(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + Assert.assertEquals(length, SPECIES.length()); + } + } + + @Test(dataProvider = "shuffleProvider") + static void shuffleToStringHalffloatMaxVectorTestsSmokeTest(BiFunction fs) { + int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var shuffle = VectorShuffle.fromArray(SPECIES, a, i); + String str = shuffle.toString(); + + int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " + + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str); + } + } + + @Test(dataProvider = "shuffleCompareOpProvider") + static void shuffleEqualsHalffloatMaxVectorTestsSmokeTest(BiFunction fa, BiFunction fb) { + int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = VectorShuffle.fromArray(SPECIES, a, i); + var bv = VectorShuffle.fromArray(SPECIES, b, i); + boolean eq = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); + } + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqualsHalffloatMaxVectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + boolean equals = av.equals(bv); + int to = i + SPECIES.length(); + Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); + } + } + + static boolean band(boolean a, boolean b) { + return a & b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndHalffloatMaxVectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.and(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::band); + } + + static boolean bor(boolean a, boolean b) { + return a | b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskOrHalffloatMaxVectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.or(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::bor); + } + + static boolean bxor(boolean a, boolean b) { + return a != b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskXorHalffloatMaxVectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.xor(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::bxor); + } + + static boolean bandNot(boolean a, boolean b) { + return a & !b; + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskAndNotHalffloatMaxVectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.andNot(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::bandNot); + } + + static boolean beq(boolean a, boolean b) { + return (a == b); + } + + @Test(dataProvider = "maskCompareOpProvider") + static void maskEqHalffloatMaxVectorTestsSmokeTest(IntFunction fa, IntFunction fb) { + boolean[] a = fa.apply(SPECIES.length()); + boolean[] b = fb.apply(SPECIES.length()); + boolean[] r = new boolean[a.length]; + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var av = SPECIES.loadMask(a, i); + var bv = SPECIES.loadMask(b, i); + var cv = av.eq(bv); + cv.intoArray(r, i); + } + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::beq); + } + + @Test(dataProvider = "maskProvider") + static void maskHashCodeHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + int hash = vmask.hashCode(); + + boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); + int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); + Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); + } + } + + static int maskTrueCount(boolean[] a, int idx) { + int trueCount = 0; + for (int i = idx; i < idx + SPECIES.length(); i++) { + trueCount += a[i] ? 1 : 0; + } + return trueCount; + } + + @Test(dataProvider = "maskProvider") + static void maskTrueCountHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.trueCount(); + } + } + + assertMaskReductionArraysEquals(r, a, HalffloatMaxVectorTests::maskTrueCount); + } + + static int maskLastTrue(boolean[] a, int idx) { + int i = idx + SPECIES.length() - 1; + for (; i >= idx; i--) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskLastTrueHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.lastTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, HalffloatMaxVectorTests::maskLastTrue); + } + + static int maskFirstTrue(boolean[] a, int idx) { + int i = idx; + for (; i < idx + SPECIES.length(); i++) { + if (a[i]) { + break; + } + } + return i - idx; + } + + @Test(dataProvider = "maskProvider") + static void maskFirstTrueHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + boolean[] a = fa.apply(SPECIES.length()); + int[] r = new int[a.length]; + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + r[i] = vmask.firstTrue(); + } + } + + assertMaskReductionArraysEquals(r, a, HalffloatMaxVectorTests::maskFirstTrue); + } + + @Test(dataProvider = "maskProvider") + static void maskCompressHalffloatMaxVectorTestsSmokeTest(IntFunction fa) { + int trueCount = 0; + boolean[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + var vmask = SPECIES.loadMask(a, i); + trueCount = vmask.trueCount(); + var rmask = vmask.compress(); + for (int j = 0; j < SPECIES.length(); j++) { + Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); + } + } + } + } + + + @DataProvider + public static Object[][] offsetProvider() { + return new Object[][]{ + {0}, + {-1}, + {+1}, + {+2}, + {-2}, + }; + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeHalffloatMaxVectorTestsSmokeTest(int offset) { + int limit = SPECIES.length() * BUFFER_REPS; + for (int i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + int index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @Test(dataProvider = "offsetProvider") + static void indexInRangeLongHalffloatMaxVectorTestsSmokeTest(int offset) { + long limit = SPECIES.length() * BUFFER_REPS; + for (long i = 0; i < limit; i += SPECIES.length()) { + var actualMask = SPECIES.indexInRange(i + offset, limit); + var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit); + assert(actualMask.equals(expectedMask)); + for (int j = 0; j < SPECIES.length(); j++) { + long index = i + j + offset; + Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + } + } + } + + @DataProvider + public static Object[][] lengthProvider() { + return new Object[][]{ + {0}, + {1}, + {32}, + {37}, + {1024}, + {1024+1}, + {1024+5}, + }; + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundHalffloatMaxVectorTestsSmokeTest(int length) { + int actualLoopBound = SPECIES.loopBound(length); + int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test(dataProvider = "lengthProvider") + static void loopBoundLongHalffloatMaxVectorTestsSmokeTest(int _length) { + long length = _length; + long actualLoopBound = SPECIES.loopBound(length); + long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); + Assert.assertEquals(actualLoopBound, expectedLoopBound); + } + + @Test + static void ElementSizeHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + int elsize = av.elementSize(); + Assert.assertEquals(elsize, Float16.SIZE); + } + + @Test + static void VectorShapeHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + assert(vsh.equals(VectorShape.S_Max_BIT)); + } + + @Test + static void ShapeWithLanesHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = vsh.withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void ElementTypeHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementType() == Float16.class); + } + + @Test + static void SpeciesElementSizeHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().elementSize() == Float16.SIZE); + } + + @Test + static void VectorTypeHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + assert(av.species().vectorType() == av.getClass()); + } + + @Test + static void WithLanesHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorSpecies species = av.species().withLanes(Float16.class); + assert(species.equals(SPECIES)); + } + + @Test + static void WithShapeHalffloatMaxVectorTestsSmokeTest() { + HalffloatVector av = HalffloatVector.zero(SPECIES); + VectorShape vsh = av.shape(); + VectorSpecies species = av.species().withShape(vsh); + assert(species.equals(SPECIES)); + } + + @Test + static void MaskAllTrueHalffloatMaxVectorTestsSmokeTest() { + for (int ic = 0; ic < INVOC_COUNT; ic++) { + Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); + } + } +} diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index d6bca96ea6e7c..2dff3ee250ea4 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Int128VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, } } + static int genValue(int i) { + return (int) i; + } + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static int bits(int e) { static final List> INT_GENERATORS = List.of( withToString("int[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("int[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(i * 5)); + i -> genValue(i * 5)); }), withToString("int[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1))); + i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("int[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3076,8 +3086,6 @@ static void ROLInt128VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MINInt128VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3094,13 @@ static void MINInt128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int128VectorTests::MIN); } - static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void minInt128VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3109,13 @@ static void minInt128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int128VectorTests::min); } - static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MINInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3122,15 +3126,13 @@ static void MINInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, mask, Int128VectorTests::MIN); } - static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MAXInt128VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3139,15 +3141,13 @@ static void MAXInt128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int128VectorTests::MAX); } - static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void maxInt128VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3156,15 +3156,13 @@ static void maxInt128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int128VectorTests::max); } - static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MAXInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3175,7 +3173,7 @@ static void MAXInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6557,7 +6555,7 @@ static void ADDReduceLongInt128VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6598,7 +6596,7 @@ static void ADDReduceLongInt128VectorTestsMasked(IntFunction fa, IntFunct } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index ac98217b71451..606e5504dee5d 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Int256VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, } } + static int genValue(int i) { + return (int) i; + } + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static int bits(int e) { static final List> INT_GENERATORS = List.of( withToString("int[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("int[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(i * 5)); + i -> genValue(i * 5)); }), withToString("int[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1))); + i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("int[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3076,8 +3086,6 @@ static void ROLInt256VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MINInt256VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3094,13 @@ static void MINInt256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int256VectorTests::MIN); } - static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void minInt256VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3109,13 @@ static void minInt256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int256VectorTests::min); } - static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MINInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3122,15 +3126,13 @@ static void MINInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, mask, Int256VectorTests::MIN); } - static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MAXInt256VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3139,15 +3141,13 @@ static void MAXInt256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int256VectorTests::MAX); } - static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void maxInt256VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3156,15 +3156,13 @@ static void maxInt256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int256VectorTests::max); } - static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MAXInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3175,7 +3173,7 @@ static void MAXInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6557,7 +6555,7 @@ static void ADDReduceLongInt256VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6598,7 +6596,7 @@ static void ADDReduceLongInt256VectorTestsMasked(IntFunction fa, IntFunct } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index b56236db322e5..5f67c3a4f7290 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Int512VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, } } + static int genValue(int i) { + return (int) i; + } + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static int bits(int e) { static final List> INT_GENERATORS = List.of( withToString("int[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("int[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(i * 5)); + i -> genValue(i * 5)); }), withToString("int[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1))); + i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("int[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3076,8 +3086,6 @@ static void ROLInt512VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MINInt512VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3094,13 @@ static void MINInt512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int512VectorTests::MIN); } - static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void minInt512VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3109,13 @@ static void minInt512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int512VectorTests::min); } - static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MINInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3122,15 +3126,13 @@ static void MINInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, mask, Int512VectorTests::MIN); } - static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MAXInt512VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3139,15 +3141,13 @@ static void MAXInt512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int512VectorTests::MAX); } - static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void maxInt512VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3156,15 +3156,13 @@ static void maxInt512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int512VectorTests::max); } - static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MAXInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3175,7 +3173,7 @@ static void MAXInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6557,7 +6555,7 @@ static void ADDReduceLongInt512VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6598,7 +6596,7 @@ static void ADDReduceLongInt512VectorTestsMasked(IntFunction fa, IntFunct } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index f87a0eb458c53..c872efcecd524 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Int64VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, } } + static int genValue(int i) { + return (int) i; + } + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static int bits(int e) { static final List> INT_GENERATORS = List.of( withToString("int[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("int[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(i * 5)); + i -> genValue(i * 5)); }), withToString("int[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1))); + i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("int[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3076,8 +3086,6 @@ static void ROLInt64VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MINInt64VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3094,13 @@ static void MINInt64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int64VectorTests::MIN); } - static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void minInt64VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3109,13 @@ static void minInt64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int64VectorTests::min); } - static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MINInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3122,15 +3126,13 @@ static void MINInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunctio for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, mask, Int64VectorTests::MIN); } - static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MAXInt64VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3139,15 +3141,13 @@ static void MAXInt64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int64VectorTests::MAX); } - static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void maxInt64VectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3156,15 +3156,13 @@ static void maxInt64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, Int64VectorTests::max); } - static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MAXInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3175,7 +3173,7 @@ static void MAXInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunctio for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6557,7 +6555,7 @@ static void ADDReduceLongInt64VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6598,7 +6596,7 @@ static void ADDReduceLongInt64VectorTestsMasked(IntFunction fa, IntFuncti } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index c61aab0013ee5..6b6f9576ad9c9 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class IntMaxVectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -329,15 +331,17 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -363,21 +367,23 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -971,6 +977,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, } } + static int genValue(int i) { + return (int) i; + } + static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; @@ -1014,15 +1024,15 @@ static int bits(int e) { static final List> INT_GENERATORS = List.of( withToString("int[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("int[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (int)(i * 5)); + i -> genValue(i * 5)); }), withToString("int[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1))); + i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("int[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3081,8 +3091,6 @@ static void ROLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, } - static IntVector bv_MIN = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MINIntMaxVectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3091,15 +3099,13 @@ static void MINIntMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, IntMaxVectorTests::MIN); } - static IntVector bv_min = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void minIntMaxVectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3108,15 +3114,13 @@ static void minIntMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, IntMaxVectorTests::min); } - static IntVector bv_MIN_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MINIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3127,15 +3131,13 @@ static void MINIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, mask, IntMaxVectorTests::MIN); } - static IntVector bv_MAX = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void MAXIntMaxVectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3144,15 +3146,13 @@ static void MAXIntMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, IntMaxVectorTests::MAX); } - static IntVector bv_max = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpProvider") static void maxIntMaxVectorTestsWithMemOp(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); @@ -3161,15 +3161,13 @@ static void maxIntMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (int)10, IntMaxVectorTests::max); } - static IntVector bv_MAX_M = IntVector.broadcast(SPECIES, (int)10); - @Test(dataProvider = "intUnaryOpMaskProvider") static void MAXIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); @@ -3180,7 +3178,7 @@ static void MAXIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6562,7 +6560,7 @@ static void ADDReduceLongIntMaxVectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6603,7 +6601,7 @@ static void ADDReduceLongIntMaxVectorTestsMasked(IntFunction fa, IntFunct } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index a8cf38c003a16..909a98367b249 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Long128VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -281,15 +283,17 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -315,21 +319,23 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -923,6 +929,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par } } + static long genValue(int i) { + return (long) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -941,15 +951,15 @@ static int intCornerCaseValue(int i) { static final List> INT_LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -999,15 +1009,15 @@ static long bits(long e) { static final List> LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3098,8 +3108,6 @@ static void ROLLong128VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MINLong128VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3108,15 +3116,13 @@ static void MINLong128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long128VectorTests::MIN); } - static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void minLong128VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3125,15 +3131,13 @@ static void minLong128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long128VectorTests::min); } - static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MINLong128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3144,15 +3148,13 @@ static void MINLong128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, mask, Long128VectorTests::MIN); } - static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MAXLong128VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3161,15 +3163,13 @@ static void MAXLong128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long128VectorTests::MAX); } - static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void maxLong128VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3178,15 +3178,13 @@ static void maxLong128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long128VectorTests::max); } - static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MAXLong128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3197,7 +3195,7 @@ static void MAXLong128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index a394a59699fd6..bcad310e6be83 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Long256VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -281,15 +283,17 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -315,21 +319,23 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -923,6 +929,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par } } + static long genValue(int i) { + return (long) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -941,15 +951,15 @@ static int intCornerCaseValue(int i) { static final List> INT_LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -999,15 +1009,15 @@ static long bits(long e) { static final List> LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3098,8 +3108,6 @@ static void ROLLong256VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MINLong256VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3108,15 +3116,13 @@ static void MINLong256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long256VectorTests::MIN); } - static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void minLong256VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3125,15 +3131,13 @@ static void minLong256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long256VectorTests::min); } - static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MINLong256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3144,15 +3148,13 @@ static void MINLong256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, mask, Long256VectorTests::MIN); } - static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MAXLong256VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3161,15 +3163,13 @@ static void MAXLong256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long256VectorTests::MAX); } - static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void maxLong256VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3178,15 +3178,13 @@ static void maxLong256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long256VectorTests::max); } - static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MAXLong256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3197,7 +3195,7 @@ static void MAXLong256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index 2f12ea983997f..3112e35fa1a07 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Long512VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -281,15 +283,17 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -315,21 +319,23 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -923,6 +929,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par } } + static long genValue(int i) { + return (long) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -941,15 +951,15 @@ static int intCornerCaseValue(int i) { static final List> INT_LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -999,15 +1009,15 @@ static long bits(long e) { static final List> LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3098,8 +3108,6 @@ static void ROLLong512VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MINLong512VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3108,15 +3116,13 @@ static void MINLong512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long512VectorTests::MIN); } - static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void minLong512VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3125,15 +3131,13 @@ static void minLong512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long512VectorTests::min); } - static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MINLong512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3144,15 +3148,13 @@ static void MINLong512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, mask, Long512VectorTests::MIN); } - static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MAXLong512VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3161,15 +3163,13 @@ static void MAXLong512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long512VectorTests::MAX); } - static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void maxLong512VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3178,15 +3178,13 @@ static void maxLong512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long512VectorTests::max); } - static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MAXLong512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3197,7 +3195,7 @@ static void MAXLong512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index 0fda0abed587d..60507fdaa6797 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Long64VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -281,15 +283,17 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -315,21 +319,23 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -923,6 +929,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par } } + static long genValue(int i) { + return (long) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -941,15 +951,15 @@ static int intCornerCaseValue(int i) { static final List> INT_LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -999,15 +1009,15 @@ static long bits(long e) { static final List> LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3098,8 +3108,6 @@ static void ROLLong64VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MINLong64VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3108,15 +3116,13 @@ static void MINLong64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long64VectorTests::MIN); } - static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void minLong64VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3125,15 +3131,13 @@ static void minLong64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long64VectorTests::min); } - static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MINLong64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3144,15 +3148,13 @@ static void MINLong64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunct for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, mask, Long64VectorTests::MIN); } - static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MAXLong64VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3161,15 +3163,13 @@ static void MAXLong64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long64VectorTests::MAX); } - static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void maxLong64VectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3178,15 +3178,13 @@ static void maxLong64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, Long64VectorTests::max); } - static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MAXLong64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3197,7 +3195,7 @@ static void MAXLong64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunct for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index 7aa2bc4c510da..1961fe5603614 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class LongMaxVectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -286,15 +288,17 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -320,21 +324,23 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -928,6 +934,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par } } + static long genValue(int i) { + return (long) i; + } + static int intCornerCaseValue(int i) { switch(i % 5) { case 0: @@ -946,15 +956,15 @@ static int intCornerCaseValue(int i) { static final List> INT_LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1004,15 +1014,15 @@ static long bits(long e) { static final List> LONG_GENERATORS = List.of( withToString("long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (long)(i * 5)); + i -> genValue(i * 5)); }), withToString("long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((long)(i + 1) == 0) ? 1 : (long)(i + 1))); + i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("long[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -3103,8 +3113,6 @@ static void ROLLongMaxVectorTestsScalarShiftMaskedConst(IntFunction fa, } - static LongVector bv_MIN = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MINLongMaxVectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3113,15 +3121,13 @@ static void MINLongMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, LongMaxVectorTests::MIN); } - static LongVector bv_min = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void minLongMaxVectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3130,15 +3136,13 @@ static void minLongMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, LongMaxVectorTests::min); } - static LongVector bv_MIN_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MINLongMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3149,15 +3153,13 @@ static void MINLongMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, mask, LongMaxVectorTests::MIN); } - static LongVector bv_MAX = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void MAXLongMaxVectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3166,15 +3168,13 @@ static void MAXLongMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, LongMaxVectorTests::MAX); } - static LongVector bv_max = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpProvider") static void maxLongMaxVectorTestsWithMemOp(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); @@ -3183,15 +3183,13 @@ static void maxLongMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (long)10, LongMaxVectorTests::max); } - static LongVector bv_MAX_M = LongVector.broadcast(SPECIES, (long)10); - @Test(dataProvider = "longUnaryOpMaskProvider") static void MAXLongMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); @@ -3202,7 +3200,7 @@ static void MAXLongMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunc for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index 5f4c54bb708c3..6ea7358d057c0 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Short128VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } } + static short genValue(int i) { + return (short) i; + } + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static short bits(short e) { static final List> SHORT_GENERATORS = List.of( withToString("short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(i * 5)); + i -> genValue(i * 5)); }), withToString("short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("short[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1565,9 +1575,14 @@ void viewAsIntegeralLanesTest() { Assert.assertEquals(asIntegral.species(), SPECIES); } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test void viewAsFloatingLanesTest() { - SPECIES.zero().viewAsFloatingLanes(); + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + VectorSpecies asFloatingSpecies = asFloating.species(); + Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); + Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test @@ -3023,8 +3038,6 @@ static void ROLShort128VectorTestsScalarShiftMaskedConst(IntFunction fa } - static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MINShort128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3033,15 +3046,13 @@ static void MINShort128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short128VectorTests::MIN); } - static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void minShort128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3050,15 +3061,13 @@ static void minShort128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short128VectorTests::min); } - static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MINShort128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3069,15 +3078,13 @@ static void MINShort128VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, mask, Short128VectorTests::MIN); } - static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MAXShort128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3093,13 @@ static void MAXShort128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short128VectorTests::MAX); } - static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void maxShort128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3108,13 @@ static void maxShort128VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short128VectorTests::max); } - static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MAXShort128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3122,7 +3125,7 @@ static void MAXShort128VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6504,7 +6507,7 @@ static void ADDReduceLongShort128VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6545,7 +6548,7 @@ static void ADDReduceLongShort128VectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index 88986575f6010..2b8080aac7075 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Short256VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } } + static short genValue(int i) { + return (short) i; + } + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static short bits(short e) { static final List> SHORT_GENERATORS = List.of( withToString("short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(i * 5)); + i -> genValue(i * 5)); }), withToString("short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("short[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1565,9 +1575,14 @@ void viewAsIntegeralLanesTest() { Assert.assertEquals(asIntegral.species(), SPECIES); } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test void viewAsFloatingLanesTest() { - SPECIES.zero().viewAsFloatingLanes(); + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + VectorSpecies asFloatingSpecies = asFloating.species(); + Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); + Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test @@ -3023,8 +3038,6 @@ static void ROLShort256VectorTestsScalarShiftMaskedConst(IntFunction fa } - static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MINShort256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3033,15 +3046,13 @@ static void MINShort256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short256VectorTests::MIN); } - static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void minShort256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3050,15 +3061,13 @@ static void minShort256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short256VectorTests::min); } - static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MINShort256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3069,15 +3078,13 @@ static void MINShort256VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, mask, Short256VectorTests::MIN); } - static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MAXShort256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3093,13 @@ static void MAXShort256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short256VectorTests::MAX); } - static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void maxShort256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3108,13 @@ static void maxShort256VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short256VectorTests::max); } - static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MAXShort256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3122,7 +3125,7 @@ static void MAXShort256VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6504,7 +6507,7 @@ static void ADDReduceLongShort256VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6545,7 +6548,7 @@ static void ADDReduceLongShort256VectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index 0f474375a47fc..f333a4c9edd7d 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Short512VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } } + static short genValue(int i) { + return (short) i; + } + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static short bits(short e) { static final List> SHORT_GENERATORS = List.of( withToString("short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(i * 5)); + i -> genValue(i * 5)); }), withToString("short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("short[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1565,9 +1575,14 @@ void viewAsIntegeralLanesTest() { Assert.assertEquals(asIntegral.species(), SPECIES); } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test void viewAsFloatingLanesTest() { - SPECIES.zero().viewAsFloatingLanes(); + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + VectorSpecies asFloatingSpecies = asFloating.species(); + Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); + Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test @@ -3023,8 +3038,6 @@ static void ROLShort512VectorTestsScalarShiftMaskedConst(IntFunction fa } - static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MINShort512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3033,15 +3046,13 @@ static void MINShort512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short512VectorTests::MIN); } - static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void minShort512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3050,15 +3061,13 @@ static void minShort512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short512VectorTests::min); } - static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MINShort512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3069,15 +3078,13 @@ static void MINShort512VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, mask, Short512VectorTests::MIN); } - static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MAXShort512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3093,13 @@ static void MAXShort512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short512VectorTests::MAX); } - static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void maxShort512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3108,13 @@ static void maxShort512VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short512VectorTests::max); } - static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MAXShort512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3122,7 +3125,7 @@ static void MAXShort512VectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6504,7 +6507,7 @@ static void ADDReduceLongShort512VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6545,7 +6548,7 @@ static void ADDReduceLongShort512VectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index 4b99ed6d84cf2..353bef63d1b8b 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class Short64VectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -324,15 +326,17 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -358,21 +362,23 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -966,6 +972,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } } + static short genValue(int i) { + return (short) i; + } + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; @@ -1009,15 +1019,15 @@ static short bits(short e) { static final List> SHORT_GENERATORS = List.of( withToString("short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(i * 5)); + i -> genValue(i * 5)); }), withToString("short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("short[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1565,9 +1575,14 @@ void viewAsIntegeralLanesTest() { Assert.assertEquals(asIntegral.species(), SPECIES); } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test void viewAsFloatingLanesTest() { - SPECIES.zero().viewAsFloatingLanes(); + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + VectorSpecies asFloatingSpecies = asFloating.species(); + Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); + Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test @@ -3023,8 +3038,6 @@ static void ROLShort64VectorTestsScalarShiftMaskedConst(IntFunction fa, } - static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MINShort64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3033,15 +3046,13 @@ static void MINShort64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short64VectorTests::MIN); } - static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void minShort64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3050,15 +3061,13 @@ static void minShort64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short64VectorTests::min); } - static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MINShort64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3069,15 +3078,13 @@ static void MINShort64VectorTestsMaskedWithMemOp(IntFunction fa, IntFun for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, mask, Short64VectorTests::MIN); } - static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MAXShort64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3086,15 +3093,13 @@ static void MAXShort64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short64VectorTests::MAX); } - static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void maxShort64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3103,15 +3108,13 @@ static void maxShort64VectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, Short64VectorTests::max); } - static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MAXShort64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3122,7 +3125,7 @@ static void MAXShort64VectorTestsMaskedWithMemOp(IntFunction fa, IntFun for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6504,7 +6507,7 @@ static void ADDReduceLongShort64VectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6545,7 +6548,7 @@ static void ADDReduceLongShort64VectorTestsMasked(IntFunction fa, IntFu } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index 2bb3b9c1557cd..67dac0c15a19b 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -63,6 +63,8 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -329,15 +331,17 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -363,21 +367,23 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = (int)order[i+j]; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -971,6 +977,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } } + static short genValue(int i) { + return (short) i; + } + static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; @@ -1014,15 +1024,15 @@ static short bits(short e) { static final List> SHORT_GENERATORS = List.of( withToString("short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(-i * 5)); + i -> genValue(-i * 5)); }), withToString("short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (short)(i * 5)); + i -> genValue(i * 5)); }), withToString("short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1))); + i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), withToString("short[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1570,9 +1580,14 @@ void viewAsIntegeralLanesTest() { Assert.assertEquals(asIntegral.species(), SPECIES); } - @Test(expectedExceptions = UnsupportedOperationException.class) + @Test void viewAsFloatingLanesTest() { - SPECIES.zero().viewAsFloatingLanes(); + Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); + VectorSpecies asFloatingSpecies = asFloating.species(); + Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); + Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); + Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test @@ -3028,8 +3043,6 @@ static void ROLShortMaxVectorTestsScalarShiftMaskedConst(IntFunction fa } - static ShortVector bv_MIN = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MINShortMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3038,15 +3051,13 @@ static void MINShortMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::MIN); } - static ShortVector bv_min = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void minShortMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3055,15 +3066,13 @@ static void minShortMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.min(bv_min).intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::min); } - static ShortVector bv_MIN_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MINShortMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3074,15 +3083,13 @@ static void MINShortMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MIN, bv_MIN_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, mask, ShortMaxVectorTests::MIN); } - static ShortVector bv_MAX = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void MAXShortMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3091,15 +3098,13 @@ static void MAXShortMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::MAX); } - static ShortVector bv_max = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpProvider") static void maxShortMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); @@ -3108,15 +3113,13 @@ static void maxShortMaxVectorTestsWithMemOp(IntFunction fa) { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.max(bv_max).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } assertArraysEquals(r, a, (short)10, ShortMaxVectorTests::max); } - static ShortVector bv_MAX_M = ShortVector.broadcast(SPECIES, (short)10); - @Test(dataProvider = "shortUnaryOpMaskProvider") static void MAXShortMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); @@ -3127,7 +3130,7 @@ static void MAXShortMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFu for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.MAX, bv_MAX_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } @@ -6509,7 +6512,7 @@ static void ADDReduceLongShortMaxVectorTests(IntFunction fa) { } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } @@ -6550,7 +6553,7 @@ static void ADDReduceLongShortMaxVectorTestsMasked(IntFunction fa, IntF } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { ra += r[i]; } diff --git a/test/jdk/jdk/incubator/vector/gen-template.sh b/test/jdk/jdk/incubator/vector/gen-template.sh index a6f794a555954..abc090bbdf085 100644 --- a/test/jdk/jdk/incubator/vector/gen-template.sh +++ b/test/jdk/jdk/incubator/vector/gen-template.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, 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 @@ -22,7 +22,7 @@ # questions. # -generate_perf_tests=$1 +generate_perf_tests=$2 TEMPLATE_FOLDER="templates/" @@ -69,8 +69,11 @@ reduction_op_masked_func="Reduction-Masked-op-func" reduction_saturating_op="SaturatingReduction-op" reduction_saturating_op_masked="SaturatingReduction-Masked-op" unary_math_template="Unary-op-math" +unary_math_hf_template="Unary-op-hf-math" binary_math_template="Binary-op-math" +binary_math_hf_template="Binary-op-hf-math" binary_math_broadcast_template="Binary-Broadcast-op-math" +binary_math_hf_broadcast_template="Binary-Broadcast-op-hf-math" bool_reduction_scalar="BoolReduction-Scalar-op" bool_reduction_template="BoolReduction-op" with_op_template="With-Op" @@ -102,6 +105,7 @@ function replace_variables { local masked=$8 local op_name=$9 local kernel_smoke=${10} + local attrib=${11} if [ "x${kernel}" != "x" ]; then local kernel_escaped=$(echo -e "$kernel" | tr '\n' '`') @@ -118,6 +122,7 @@ function replace_variables { # if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask") local test_func="" local withMask="" + local suffix="" local tests=($(awk -F+ '{$1=$1} 1' <<< $test)) if [ "${tests[2]}" == "withMask" ]; then test=${tests[0]} @@ -132,12 +137,23 @@ function replace_variables { test_func=${tests[1]} fi + if [ "${attrib}" == "associative" ]; then + suffix=${suffix}"_ASSOC" + fi + if [ "${attrib}" == "reduction" ]; then + suffix=${suffix}"_REDUCTION" + fi + if [ "${attrib}" == "memoryoper" ]; then + suffix=${suffix}"_MEM" + fi + sed_prog=" s/\\(.*\)\<\\OPTIONAL\>/\1/g s/\[\[TEST_TYPE\]\]/${masked}/g s/\[\[TEST_OP\]\]/${op}/g s/\[\[TEST_INIT\]\]/${init}/g s/\[\[OP_NAME\]\]/${op_name}/g + s/\[\[SUFFIX\]\]/${suffix}/g " sed_prog_2="$sed_prog s/\[\[TEST\]\]/${test_func}/g @@ -185,13 +201,18 @@ function gen_op_tmpl { local op=$3 local guard="" local init="" + local attrib="" if [ $# -gt 3 ]; then guard=$4 fi - if [ $# == 5 ]; then + if [ $# -gt 4 ]; then init=$5 fi + if [ $# -gt 5 ]; then + attrib=$6 + fi + local masked="" if [[ $template == *"Masked"* ]]; then masked="Masked" @@ -226,7 +247,7 @@ function gen_op_tmpl { fi # Replace template variables in unit test files (if any) - replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke" + replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke" "$attrib" local gen_perf_tests=$generate_perf_tests if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] || @@ -240,15 +261,15 @@ function gen_op_tmpl { local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template" if [ -f $perf_vector_filename ]; then - replace_variables $perf_vector_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" + replace_variables $perf_vector_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib" elif [ -f $kernel_filename ]; then - replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" + replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib" elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then echo "Warning: missing perf: $@" fi if [ -f $perf_scalar_filename ]; then - replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" + replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib" elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then echo "Warning: Missing PERF SCALAR: $perf_scalar_filename" fi @@ -263,8 +284,8 @@ function gen_binary_alu_op { function gen_binary_alu_mem_op { echo "Generating binary op $1 ($2)..." - gen_op_tmpl $binary_memop "$@" - gen_op_tmpl $binary_masked_memop "$@" + gen_op_tmpl $binary_memop "$@" "" "" "memoryoper" + gen_op_tmpl $binary_masked_memop "$@" "" "" "memoryoper" } function gen_binary_alu_bcst_op { @@ -332,8 +353,8 @@ function gen_saturating_binary_op { function gen_saturating_binary_op_associative { echo "Generating saturating binary associative op $1 ($2)..." - gen_op_tmpl $saturating_binary_assocative "$@" - gen_op_tmpl $saturating_binary_assocative_masked "$@" + gen_op_tmpl $saturating_binary_assocative "$@" "" "associative" + gen_op_tmpl $saturating_binary_assocative_masked "$@" "" "associative" } function gen_binary_op_no_masked { @@ -381,10 +402,10 @@ function gen_bool_reduction_op { } function gen_saturating_reduction_op { echo "Generating saturating reduction op $1 ($2)..." - gen_op_tmpl $reduction_scalar_func "$@" - gen_op_tmpl $reduction_saturating_op "$@" - gen_op_tmpl $reduction_scalar_masked_func "$@" - gen_op_tmpl $reduction_saturating_op_masked "$@" + gen_op_tmpl $reduction_scalar_func "$@" "reduction" + gen_op_tmpl $reduction_saturating_op "$@" "reduction" + gen_op_tmpl $reduction_scalar_masked_func "$@" "reduction" + gen_op_tmpl $reduction_saturating_op_masked "$@" "reduction" } function gen_with_op { @@ -428,202 +449,235 @@ if [ $generate_perf_tests == true ]; then gen_perf_scalar_header $perf_scalar_output fi -# ALU binary ops. -# Here "ADD+add+withMask" says VectorOperator name is "ADD", and we have a dedicate method too named 'add', and add() is also available with mask variant. -gen_binary_alu_op "ADD+add+withMask" "a + b" -gen_binary_alu_op "SUB+sub+withMask" "a - b" -gen_binary_alu_op "MUL+mul+withMask" "a \* b" -gen_binary_alu_op "DIV+div+withMask" "a \/ b" "FP" -gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" -gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" -gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b" -gen_binary_alu_op "AND+and" "a \& b" "BITWISE" -gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE" -gen_binary_alu_op "OR+or" "a | b" "BITWISE" -# Missing: "OR_UNCHECKED" -gen_binary_alu_op "XOR" "a ^ b" "BITWISE" -gen_binary_alu_op "COMPRESS_BITS" "\$Boxtype\$.compress(a, b)" "intOrLong" -gen_binary_alu_op "EXPAND_BITS" "\$Boxtype\$.expand(a, b)" "intOrLong" -# Generate the broadcast versions -gen_binary_alu_bcst_op "add+withMask" "a + b" -gen_binary_alu_bcst_op "sub+withMask" "a - b" -gen_binary_alu_bcst_op "mul+withMask" "a \* b" -gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP" -gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" -gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" -gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE" -gen_binary_alu_bcst_op "AND+and" "a \& b" "BITWISE" -gen_binary_alu_bcst_long_op "OR" "a | b" "BITWISE" -gen_binary_alu_bcst_long_op "ADD" "a + b" - -# Shifts -gen_binary_alu_op "LSHL" "(a << b)" "intOrLong" -gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte" -gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short" -gen_binary_alu_op "ASHR" "(a >> b)" "intOrLong" -gen_binary_alu_op "ASHR" "(a >> (b \& 0x7))" "byte" -gen_binary_alu_op "ASHR" "(a >> (b \& 0xF))" "short" -gen_binary_alu_op "LSHR" "(a >>> b)" "intOrLong" -gen_binary_alu_op "LSHR" "((a \& 0xFF) >>> (b \& 0x7))" "byte" -gen_binary_alu_op "LSHR" "((a \& 0xFFFF) >>> (b \& 0xF))" "short" -gen_shift_op "LSHL" "(a << b)" "intOrLong" -gen_shift_op "LSHL" "(a << (b \& 7))" "byte" -gen_shift_op "LSHL" "(a << (b \& 15))" "short" -gen_shift_op "LSHR" "(a >>> b)" "intOrLong" -gen_shift_op "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte" -gen_shift_op "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short" -gen_shift_op "ASHR" "(a >> b)" "intOrLong" -gen_shift_op "ASHR" "(a >> (b \& 7))" "byte" -gen_shift_op "ASHR" "(a >> (b \& 15))" "short" -gen_binary_alu_op "ROR" "ROR_scalar(a,b)" "BITWISE" -gen_binary_alu_op "ROL" "ROL_scalar(a,b)" "BITWISE" -gen_shift_op "ROR" "ROR_scalar(a, b)" "BITWISE" -gen_shift_op "ROL" "ROL_scalar(a, b)" "BITWISE" - -# Constant Shifts -gen_shift_cst_op "LSHR" "(a >>> CONST_SHIFT)" "intOrLong" -gen_shift_cst_op "LSHR" "((a \& 0xFF) >>> CONST_SHIFT)" "byte" -gen_shift_cst_op "LSHR" "((a \& 0xFFFF) >>> CONST_SHIFT)" "short" -gen_shift_cst_op "LSHL" "(a << CONST_SHIFT)" "BITWISE" -gen_shift_cst_op "ASHR" "(a >> CONST_SHIFT)" "BITWISE" -gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE" -gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" - -# Binary operation with one memory operand -gen_binary_alu_mem_op "MIN+min+withMask", "Math.min(a, b)" -gen_binary_alu_mem_op "MAX+max+withMask", "Math.max(a, b)" - -# Masked reductions. -gen_binary_op_no_masked "MIN+min" "Math.min(a, b)" -gen_binary_op_no_masked "MAX+max" "Math.max(a, b)" -gen_binary_op "UMIN" "VectorMath.minUnsigned(a, b)" "BITWISE" -gen_binary_op "UMAX" "VectorMath.maxUnsigned(a, b)" "BITWISE" -gen_saturating_binary_op "SADD" "VectorMath.addSaturating(a, b)" "BITWISE" -gen_saturating_binary_op "SSUB" "VectorMath.subSaturating(a, b)" "BITWISE" -gen_saturating_binary_op "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" -gen_saturating_binary_op "SUSUB" "VectorMath.subSaturatingUnsigned(a, b)" "BITWISE" -gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)" -gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)" -gen_saturating_binary_op_associative "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" - -# Reductions. -gen_reduction_op "AND" "\&" "BITWISE" "-1" -gen_reduction_op "OR" "|" "BITWISE" "0" -gen_reduction_op "XOR" "^" "BITWISE" "0" -gen_reduction_op "ADD" "+" "" "0" -gen_reduction_op "MUL" "*" "" "1" -gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "\$Wideboxtype\$.\$MaxValue\$" -gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "\$Wideboxtype\$.\$MinValue\$" -gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "\$Wideboxtype\$.\$MaxValue\$" -gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "\$Wideboxtype\$.\$MinValue\$" -gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0" - -# Boolean reductions. -gen_bool_reduction_op "anyTrue" "|" "BITWISE" "false" -gen_bool_reduction_op "allTrue" "\&" "BITWISE" "true" - -# Saturating reductions. -gen_saturating_reduction_op "SUADD" "(\$type\$) VectorMath.addSaturatingUnsigned" "BITWISE" "0" - -#Insert -gen_with_op "withLane" "" "" "" - -# Tests -gen_op_tmpl $test_template "IS_DEFAULT" "bits(a)==0" -gen_op_tmpl $test_template "IS_NEGATIVE" "bits(a)<0" -gen_op_tmpl $test_template "IS_FINITE" "\$Boxtype\$.isFinite(a)" "FP" -gen_op_tmpl $test_template "IS_NAN" "\$Boxtype\$.isNaN(a)" "FP" -gen_op_tmpl $test_template "IS_INFINITE" "\$Boxtype\$.isInfinite(a)" "FP" - -# Compares -gen_compare_op "LT+lt" "lt" -gen_compare_op "GT" "gt" -gen_compare_op "EQ+eq" "eq" -gen_compare_op "NE" "neq" -gen_compare_op "LE" "le" -gen_compare_op "GE" "ge" - -gen_compare_op "ULT" "ult" "BITWISE" -gen_compare_op "UGT" "ugt" "BITWISE" -gen_compare_op "ULE" "ule" "BITWISE" -gen_compare_op "UGE" "uge" "BITWISE" - - -gen_compare_bcst_op "LT" "<" -gen_compare_bcst_op "EQ" "==" - -# Blend. -gen_op_tmpl $blend "blend" "" - -# Rearrange -gen_op_tmpl $rearrange_template "rearrange" "" - -# Compress/Expand -gen_op_tmpl $compressexpand_template "compress_expand" "" - -# Get -gen_get_op "lane" "" - -# Broadcast -gen_op_tmpl $broadcast_template "broadcast" "" - -# Zero -gen_op_tmpl $zero_template "zero" "" - -# Slice -gen_op_tmpl $slice_template "sliceUnary" "" -gen_op_tmpl $slice1_template "sliceBinary" "" -gen_op_tmpl $slice1_masked_template "slice" "" - -# Unslice -gen_op_tmpl $unslice_template "unsliceUnary" "" -gen_op_tmpl $unslice1_template "unsliceBinary" "" -gen_op_tmpl $unslice1_masked_template "unslice" "" - -# Math -gen_op_tmpl $unary_math_template "SIN" "Math.sin((double)a)" "FP" -gen_op_tmpl $unary_math_template "EXP" "Math.exp((double)a)" "FP" -gen_op_tmpl $unary_math_template "LOG1P" "Math.log1p((double)a)" "FP" -gen_op_tmpl $unary_math_template "LOG" "Math.log((double)a)" "FP" -gen_op_tmpl $unary_math_template "LOG10" "Math.log10((double)a)" "FP" -gen_op_tmpl $unary_math_template "EXPM1" "Math.expm1((double)a)" "FP" -gen_op_tmpl $unary_math_template "COS" "Math.cos((double)a)" "FP" -gen_op_tmpl $unary_math_template "TAN" "Math.tan((double)a)" "FP" -gen_op_tmpl $unary_math_template "SINH" "Math.sinh((double)a)" "FP" -gen_op_tmpl $unary_math_template "COSH" "Math.cosh((double)a)" "FP" -gen_op_tmpl $unary_math_template "TANH" "Math.tanh((double)a)" "FP" -gen_op_tmpl $unary_math_template "ASIN" "Math.asin((double)a)" "FP" -gen_op_tmpl $unary_math_template "ACOS" "Math.acos((double)a)" "FP" -gen_op_tmpl $unary_math_template "ATAN" "Math.atan((double)a)" "FP" -gen_op_tmpl $unary_math_template "CBRT" "Math.cbrt((double)a)" "FP" -gen_op_tmpl $binary_math_template "HYPOT" "Math.hypot((double)a, (double)b)" "FP" -gen_op_tmpl $binary_math_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" -gen_op_tmpl $binary_math_template "ATAN2" "Math.atan2((double)a, (double)b)" "FP" -gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" - -# Ternary operations. -gen_ternary_alu_op "FMA+fma" "Math.fma(a, b, c)" "FP" -gen_ternary_alu_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" -gen_ternary_alu_bcst_op "FMA" "Math.fma(a, b, c)" "FP" -gen_ternary_alu_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" -gen_ternary_alu_double_bcst_op "FMA+fma" "Math.fma(a, b, c)" "FP" -gen_ternary_alu_double_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" - -# Unary operations. -gen_unary_alu_op "NEG+neg" "-((\$type\$)a)" -gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)" -gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE" -gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE" -gen_unary_alu_op "SQRT+sqrt" "Math.sqrt((double)a)" "FP" -gen_unary_alu_op "BIT_COUNT" "\$Boxtype\$.bitCount(a)" "intOrLong" -gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFF)" "byte" -gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFFFF)" "short" -gen_unary_alu_op "TRAILING_ZEROS_COUNT" "TRAILING_ZEROS_COUNT_scalar(a)" "BITWISE" -gen_unary_alu_op "LEADING_ZEROS_COUNT" "LEADING_ZEROS_COUNT_scalar(a)" "BITWISE" -gen_unary_alu_op "REVERSE" "REVERSE_scalar(a)" "BITWISE" -gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "intOrLong" -gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "short" -gen_unary_alu_op "REVERSE_BYTES" "a" "byte" +if [ "$1" == "ALL_PRIM_TYPES" ]; then + # ALU binary ops. + # Here "ADD+add+withMask" says VectorOperator name is "ADD", and we have a dedicate method too named 'add', and add() is also available with mask variant. + gen_binary_alu_op "ADD+add+withMask" "a + b" + gen_binary_alu_op "SUB+sub+withMask" "a - b" + gen_binary_alu_op "MUL+mul+withMask" "a \* b" + gen_binary_alu_op "DIV+div+withMask" "a \/ b" "FP" + gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" + gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" + gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b" + gen_binary_alu_op "AND+and" "a \& b" "BITWISE" + gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE" + gen_binary_alu_op "OR+or" "a | b" "BITWISE" + # Missing: "OR_UNCHECKED" + gen_binary_alu_op "XOR" "a ^ b" "BITWISE" + gen_binary_alu_op "COMPRESS_BITS" "\$Boxtype\$.compress(a, b)" "intOrLong" + gen_binary_alu_op "EXPAND_BITS" "\$Boxtype\$.expand(a, b)" "intOrLong" + # Generate the broadcast versions + gen_binary_alu_bcst_op "add+withMask" "a + b" + gen_binary_alu_bcst_op "sub+withMask" "a - b" + gen_binary_alu_bcst_op "mul+withMask" "a \* b" + gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP" + gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" + gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" + gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE" + gen_binary_alu_bcst_op "AND+and" "a \& b" "BITWISE" + gen_binary_alu_bcst_long_op "OR" "a | b" "BITWISE" + gen_binary_alu_bcst_long_op "ADD" "a + b" + + # Shifts + gen_binary_alu_op "LSHL" "(a << b)" "intOrLong" + gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte" + gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short" + gen_binary_alu_op "ASHR" "(a >> b)" "intOrLong" + gen_binary_alu_op "ASHR" "(a >> (b \& 0x7))" "byte" + gen_binary_alu_op "ASHR" "(a >> (b \& 0xF))" "short" + gen_binary_alu_op "LSHR" "(a >>> b)" "intOrLong" + gen_binary_alu_op "LSHR" "((a \& 0xFF) >>> (b \& 0x7))" "byte" + gen_binary_alu_op "LSHR" "((a \& 0xFFFF) >>> (b \& 0xF))" "short" + gen_shift_op "LSHL" "(a << b)" "intOrLong" + gen_shift_op "LSHL" "(a << (b \& 7))" "byte" + gen_shift_op "LSHL" "(a << (b \& 15))" "short" + gen_shift_op "LSHR" "(a >>> b)" "intOrLong" + gen_shift_op "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte" + gen_shift_op "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short" + gen_shift_op "ASHR" "(a >> b)" "intOrLong" + gen_shift_op "ASHR" "(a >> (b \& 7))" "byte" + gen_shift_op "ASHR" "(a >> (b \& 15))" "short" + gen_binary_alu_op "ROR" "ROR_scalar(a,b)" "BITWISE" + gen_binary_alu_op "ROL" "ROL_scalar(a,b)" "BITWISE" + gen_shift_op "ROR" "ROR_scalar(a, b)" "BITWISE" + gen_shift_op "ROL" "ROL_scalar(a, b)" "BITWISE" + + # Constant Shifts + gen_shift_cst_op "LSHR" "(a >>> CONST_SHIFT)" "intOrLong" + gen_shift_cst_op "LSHR" "((a \& 0xFF) >>> CONST_SHIFT)" "byte" + gen_shift_cst_op "LSHR" "((a \& 0xFFFF) >>> CONST_SHIFT)" "short" + gen_shift_cst_op "LSHL" "(a << CONST_SHIFT)" "BITWISE" + gen_shift_cst_op "ASHR" "(a >> CONST_SHIFT)" "BITWISE" + gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE" + gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" + + # Binary operation with one memory operand + gen_binary_alu_mem_op "MIN+min+withMask", "Math.min(a, b)" + gen_binary_alu_mem_op "MAX+max+withMask", "Math.max(a, b)" + + # Masked reductions. + gen_binary_op_no_masked "MIN+min" "Math.min(a, b)" + gen_binary_op_no_masked "MAX+max" "Math.max(a, b)" + gen_binary_op "UMIN" "VectorMath.minUnsigned(a, b)" "BITWISE" + gen_binary_op "UMAX" "VectorMath.maxUnsigned(a, b)" "BITWISE" + gen_saturating_binary_op "SADD" "VectorMath.addSaturating(a, b)" "BITWISE" + gen_saturating_binary_op "SSUB" "VectorMath.subSaturating(a, b)" "BITWISE" + gen_saturating_binary_op "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" + gen_saturating_binary_op "SUSUB" "VectorMath.subSaturatingUnsigned(a, b)" "BITWISE" + gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)" + gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)" + gen_saturating_binary_op_associative "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" + + # Reductions. + gen_reduction_op "AND" "\&" "BITWISE" "-1" + gen_reduction_op "OR" "|" "BITWISE" "0" + gen_reduction_op "XOR" "^" "BITWISE" "0" + gen_reduction_op "ADD" "+" "" "0" + gen_reduction_op "MUL" "*" "" "1" + gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "\$Wideboxtype\$.\$MaxValue\$" + gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "\$Wideboxtype\$.\$MinValue\$" + gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "\$Wideboxtype\$.\$MaxValue\$" + gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "\$Wideboxtype\$.\$MinValue\$" + gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0" + + # Boolean reductions. + gen_bool_reduction_op "anyTrue" "|" "BITWISE" "false" + gen_bool_reduction_op "allTrue" "\&" "BITWISE" "true" + + # Saturating reductions. + gen_saturating_reduction_op "SUADD" "(\$type\$) VectorMath.addSaturatingUnsigned" "BITWISE" "0" + + #Insert + gen_with_op "withLane" "" "" "" + + # Tests + gen_op_tmpl $test_template "IS_DEFAULT" "bits(a)==0" + gen_op_tmpl $test_template "IS_NEGATIVE" "bits(a)<0" + gen_op_tmpl $test_template "IS_FINITE" "\$Boxtype\$.isFinite(a)" "FP" + gen_op_tmpl $test_template "IS_NAN" "\$Boxtype\$.isNaN(a)" "FP" + gen_op_tmpl $test_template "IS_INFINITE" "\$Boxtype\$.isInfinite(a)" "FP" + + # Compares + gen_compare_op "LT+lt" "lt" + gen_compare_op "GT" "gt" + gen_compare_op "EQ+eq" "eq" + gen_compare_op "NE" "neq" + gen_compare_op "LE" "le" + gen_compare_op "GE" "ge" + + gen_compare_op "ULT" "ult" "BITWISE" + gen_compare_op "UGT" "ugt" "BITWISE" + gen_compare_op "ULE" "ule" "BITWISE" + gen_compare_op "UGE" "uge" "BITWISE" + + gen_compare_bcst_op "LT" "<" + gen_compare_bcst_op "EQ" "==" + + # Blend. + gen_op_tmpl $blend "blend" "" + + # Rearrange + gen_op_tmpl $rearrange_template "rearrange" "" + + # Compress/Expand + gen_op_tmpl $compressexpand_template "compress_expand" "" + + # Get + gen_get_op "lane" "" + + # Broadcast + gen_op_tmpl $broadcast_template "broadcast" "" + + # Zero + gen_op_tmpl $zero_template "zero" "" + + # Slice + gen_op_tmpl $slice_template "sliceUnary" "" + gen_op_tmpl $slice1_template "sliceBinary" "" + gen_op_tmpl $slice1_masked_template "slice" "" + + # Unslice + gen_op_tmpl $unslice_template "unsliceUnary" "" + gen_op_tmpl $unslice1_template "unsliceBinary" "" + gen_op_tmpl $unslice1_masked_template "unslice" "" + + # Math + gen_op_tmpl $unary_math_template "SIN" "Math.sin((double)a)" "FP" + gen_op_tmpl $unary_math_template "EXP" "Math.exp((double)a)" "FP" + gen_op_tmpl $unary_math_template "LOG1P" "Math.log1p((double)a)" "FP" + gen_op_tmpl $unary_math_template "LOG" "Math.log((double)a)" "FP" + gen_op_tmpl $unary_math_template "LOG10" "Math.log10((double)a)" "FP" + gen_op_tmpl $unary_math_template "EXPM1" "Math.expm1((double)a)" "FP" + gen_op_tmpl $unary_math_template "COS" "Math.cos((double)a)" "FP" + gen_op_tmpl $unary_math_template "TAN" "Math.tan((double)a)" "FP" + gen_op_tmpl $unary_math_template "SINH" "Math.sinh((double)a)" "FP" + gen_op_tmpl $unary_math_template "COSH" "Math.cosh((double)a)" "FP" + gen_op_tmpl $unary_math_template "TANH" "Math.tanh((double)a)" "FP" + gen_op_tmpl $unary_math_template "ASIN" "Math.asin((double)a)" "FP" + gen_op_tmpl $unary_math_template "ACOS" "Math.acos((double)a)" "FP" + gen_op_tmpl $unary_math_template "ATAN" "Math.atan((double)a)" "FP" + gen_op_tmpl $unary_math_template "CBRT" "Math.cbrt((double)a)" "FP" + gen_op_tmpl $binary_math_template "HYPOT" "Math.hypot((double)a, (double)b)" "FP" + gen_op_tmpl $binary_math_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" + gen_op_tmpl $binary_math_template "ATAN2" "Math.atan2((double)a, (double)b)" "FP" + gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" + + # Ternary operations. + gen_ternary_alu_op "FMA+fma" "Math.fma(a, b, c)" "FP" + gen_ternary_alu_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" + gen_ternary_alu_bcst_op "FMA" "Math.fma(a, b, c)" "FP" + gen_ternary_alu_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" + gen_ternary_alu_double_bcst_op "FMA+fma" "Math.fma(a, b, c)" "FP" + gen_ternary_alu_double_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" + + # Unary operations. + gen_unary_alu_op "NEG+neg" "-((\$type\$)a)" + gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)" + gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE" + gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE" + gen_unary_alu_op "SQRT+sqrt" "Math.sqrt((double)a)" "FP" + gen_unary_alu_op "BIT_COUNT" "\$Boxtype\$.bitCount(a)" "intOrLong" + gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFF)" "byte" + gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFFFF)" "short" + gen_unary_alu_op "TRAILING_ZEROS_COUNT" "TRAILING_ZEROS_COUNT_scalar(a)" "BITWISE" + gen_unary_alu_op "LEADING_ZEROS_COUNT" "LEADING_ZEROS_COUNT_scalar(a)" "BITWISE" + gen_unary_alu_op "REVERSE" "REVERSE_scalar(a)" "BITWISE" + gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "intOrLong" + gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "short" + gen_unary_alu_op "REVERSE_BYTES" "a" "byte" + +elif [ "$1" == "HALF_FLOAT_TYPE" ]; then + gen_binary_alu_op "ADD" "Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))" "Halffloat" + gen_binary_alu_op "SUB" "Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))" "Halffloat" + gen_binary_alu_op "MUL" "Float.floatToFloat16(Float.float16ToFloat(a) \* Float.float16ToFloat(b))" "Halffloat" + gen_binary_alu_op "DIV" "Float.floatToFloat16(Float.float16ToFloat(a) \/ Float.float16ToFloat(b))" "Halffloat" + gen_binary_alu_op "MAX" "Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))" "Halffloat" + gen_binary_alu_op "MIN" "Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))" "Halffloat" + gen_unary_alu_op "ABS+abs" "Math.abs(a)" "Halffloat" + gen_unary_alu_op "NEG+neg" "-a" "Halffloat" + gen_ternary_alu_op "FMA+fma" "Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))" "Halffloat" + gen_unary_alu_op "SQRT+sqrt" "Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "SIN" "Math.sin(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "EXP" "Math.exp(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "LOG1P" "Math.log1p(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "LOG" "Math.log(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "LOG10" "Math.log10(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "EXPM1" "Math.expm1(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "COS" "Math.cos(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "TAN" "Math.tan(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "SINH" "Math.sinh(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "COSH" "Math.cosh(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "TANH" "Math.tanh(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "ASIN" "Math.asin(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "ACOS" "Math.acos(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "ATAN" "Math.atan(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $unary_math_hf_template "CBRT" "Math.cbrt(Float.float16ToFloat(a))" "Halffloat" + gen_op_tmpl $binary_math_hf_template "HYPOT" "Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" + gen_op_tmpl $binary_math_hf_template "POW+pow" "Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" + gen_op_tmpl $binary_math_hf_template "ATAN2" "Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" + gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" + gen_op_tmpl $blend "blend" "Halffloat" +fi # Miscellaneous Smoke Tests gen_op_tmpl $miscellaneous_template "MISC" "" "" diff --git a/test/jdk/jdk/incubator/vector/gen-tests.sh b/test/jdk/jdk/incubator/vector/gen-tests.sh index 8b87d9d9efb23..9628bd48e2237 100644 --- a/test/jdk/jdk/incubator/vector/gen-tests.sh +++ b/test/jdk/jdk/incubator/vector/gen-tests.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2018, 2025, 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 @@ -26,226 +26,256 @@ # You can regenerate the source files, # and you can clean them up. # FIXME: Move this script under $REPO/make/gensrc/ -case $* in -'') CLASS_FILTER='*';; ---generate*) CLASS_FILTER=${2-'*'};; ---help|*) echo "Usage: $0 [--generate [file]]"; exit 1;; -esac +generate_test_cases() { + Log false "Generating Vector API tests, $(date)\n" -. config.sh + # Compile SPP + Log true "Compiling SPP... " + compilation=$(${JAVAC} -d . "${JDK_SRC_HOME}/make/jdk/src/classes/build/tools/spp/Spp.java") + Log false "$compilation\n" + Log true "done\n" -# Detect whether to generate the performance tests -generate_perf_tests=false -if [ -d "$PERF_DEST" ]; then - generate_perf_tests=true -fi + array=() + if [ $1 == "ALL_PRIM_TYPES" ]; then + array=("byte" "short" "int" "long" "float" "double") + elif [ $1 == "HALF_FLOAT_TYPE" ]; then + array=("halffloat") + fi -# First, generate the template file. -bash ./gen-template.sh $generate_perf_tests - -Log false "Generating Vector API tests, $(date)\n" - -# Compile SPP -Log true "Compiling SPP... " -compilation=$(${JAVAC} -d . "${JDK_SRC_HOME}/make/jdk/src/classes/build/tools/spp/Spp.java") -Log false "$compilation\n" -Log true "done\n" - -# For each type -for type in byte short int long float double -do - Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" - TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" - args="-K$type -Dtype=$type -DType=$Type -DTYPE=$TYPE" - - Boxtype=$Type - Wideboxtype=$Boxtype - MaxValue=MAX_VALUE - MinValue=MIN_VALUE - - kind=BITWISE - - bitstype=$type - Bitstype=$Type - Boxbitstype=$Boxtype - - fptype=$type - Fptype=$Type - Boxfptype=$Boxtype - - case $type in - byte) - Wideboxtype=Byte - args="$args -KbyteOrShort" - ;; - short) - Wideboxtype=Short - args="$args -KbyteOrShort" - ;; - int) - Boxtype=Integer - Wideboxtype=Integer - fptype=float - Fptype=Float - Boxfptype=Float - args="$args -KintOrLong" - ;; - long) - Wideboxtype=Long - fptype=double - Fptype=Double - Boxfptype=Double - args="$args -KintOrLong" - ;; - float) - kind=FP - bitstype=int - Bitstype=Int - Boxbitstype=Integer - Wideboxtype=Float - MaxValue=POSITIVE_INFINITY - MinValue=NEGATIVE_INFINITY - ;; - double) - kind=FP - bitstype=long - Bitstype=Long - Boxbitstype=Long - Wideboxtype=Double - MaxValue=POSITIVE_INFINITY - MinValue=NEGATIVE_INFINITY - ;; - esac - - args="$args -K$kind -K$Type -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype -DMaxValue=$MaxValue -DMinValue=$MinValue" - args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" - args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" - - abstractvectortype=${typeprefix}${Type}Vector - abstractvectorteststype=${typeprefix}${Type}VectorTests - abstractbitsvectortype=${typeprefix}${Bitstype}Vector - abstractfpvectortype=${typeprefix}${Fptype}Vector - args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" - - # Generate tests for operations - # For each size - Log true "${Type}:" - - for bits in 64 128 256 512 Max + # For each type + for type in ${array[@]} do - vectortype=${typeprefix}${Type}${bits}Vector - vectorteststype=${typeprefix}${Type}${bits}VectorTests - vectorbenchtype=${typeprefix}${Type}${bits}Vector - masktype=${typeprefix}${Type}${bits}Mask - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector - shape=S${bits}Bit - Shape=S_${bits}_BIT - if [[ "${vectortype}" == "ByteMaxVector" ]]; then - args="$args -KByteMax" - fi - bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" - if [ $bits == 'Max' ]; then - bitargs="$bitargs -KMaxBit" - fi - - # Generate jtreg tests - case $vectorteststype in - $CLASS_FILTER) - Log true " ${bits}_jtreg $vectorteststype.java" - Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " - TEST_DEST_FILE="${vectorteststype}.java" - rm -f ${TEST_DEST_FILE} - ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ - -i${TEMPLATE_FILE} \ - -o${TEST_DEST_FILE} - if [ VAR_OS_ENV==windows.cygwin ]; then - tr -d '\r' < ${TEST_DEST_FILE} > temp - mv temp ${TEST_DEST_FILE} + Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" + TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" + args="-K$type -Dtype=$type -DType=$Type -DTYPE=$TYPE" + + Boxtype=$Type + Wideboxtype=$Boxtype + MaxValue=MAX_VALUE + MinValue=MIN_VALUE + ElementType=$Type + kind=BITWISE + VecEleType=$Type + bitstype=$type + Bitstype=$Type + Boxbitstype=$Boxtype + fptype=$type + Fptype=$Type + Boxfptype=$Boxtype + ClassType=$type + fpkind="" + + case $type in + byte) + Wideboxtype=Byte + args="$args -KbyteOrShort" + ;; + short) + Wideboxtype=Short + args="$args -KbyteOrShort" + ;; + int) + ElementType=Int + VecEleType=Integer + Boxtype=Integer + Wideboxtype=Integer + fptype=float + Fptype=Float + Boxfptype=Float + args="$args -KintOrLong" + ;; + long) + Wideboxtype=Long + fptype=double + Fptype=Double + Boxfptype=Double + args="$args -KintOrLong" + ;; + float) + kind=FP + fpkind=FP32 + bitstype=int + Bitstype=Int + Boxbitstype=Integer + Wideboxtype=Float + MaxValue=POSITIVE_INFINITY + MinValue=NEGATIVE_INFINITY + args="$args -KfloatOrDouble" + ;; + double) + kind=FP + fpkind=FP64 + bitstype=long + Bitstype=Long + Boxbitstype=Long + Wideboxtype=Double + MaxValue=POSITIVE_INFINITY + MinValue=NEGATIVE_INFINITY + args="$args -KfloatOrDouble" + ;; + halffloat) + VecEleType=Short + ClassType=Float16 + kind=FP + fpkind=FP16 + bitstype=short + Bitstype=Short + Boxbitstype=Short + Wideboxtype=Float16 + args="$args -Dtype=short -DType=Halffloat -DTYPE=HALFFLOAT -DElementType=Halffloat" + ;; + esac + + args="$args -K$fpkind -K$kind -K$Type -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype -DMaxValue=$MaxValue -DMinValue=$MinValue" + args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype -DElementType=$Type -DVecEleType=$VecEleType -DClassType=$ClassType" + args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" + + abstractvectortype=${typeprefix}${Type}Vector + abstractvectorteststype=${typeprefix}${Type}VectorTests + abstractbitsvectortype=${typeprefix}${Bitstype}Vector + abstractfpvectortype=${typeprefix}${Fptype}Vector + args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" + + # Generate tests for operations + # For each size + Log true "${Type}:" + + for bits in 64 128 256 512 Max + do + vectortype=${typeprefix}${Type}${bits}Vector + vectorteststype=${typeprefix}${Type}${bits}VectorTests + vectorbenchtype=${typeprefix}${Type}${bits}Vector + masktype=${typeprefix}${Type}${bits}Mask + bitsvectortype=${typeprefix}${Bitstype}${bits}Vector + fpvectortype=${typeprefix}${Fptype}${bits}Vector + shape=S${bits}Bit + Shape=S_${bits}_BIT + if [[ "${vectortype}" == "ByteMaxVector" ]]; then + args="$args -KByteMax" + fi + bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" + if [ $bits == 'Max' ]; then + bitargs="$bitargs -KMaxBit" fi - ;; - esac - if [ $generate_perf_tests == true ]; then - # Generate jmh performance tests - case $vectorbenchtype in + # Generate jtreg tests + case $vectorteststype in $CLASS_FILTER) - Log true " ${bits}_jmh $vectorbenchtype.java" - Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " - PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" - rm -f ${PERF_DEST_FILE} + Log true " ${bits}_jtreg $vectorteststype.java" + Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " + TEST_DEST_FILE="${vectorteststype}.java" + rm -f ${TEST_DEST_FILE} ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ + -i${TEMPLATE_FILE} \ + -o${TEST_DEST_FILE} + if [ VAR_OS_ENV==windows.cygwin ]; then + tr -d '\r' < ${TEST_DEST_FILE} > temp + mv temp ${TEST_DEST_FILE} + fi + ;; + esac + + if [ $generate_perf_tests == true ]; then + # Generate jmh performance tests + case $vectorbenchtype in + $CLASS_FILTER) + Log true " ${bits}_jmh $vectorbenchtype.java" + Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " + PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" + rm -f ${PERF_DEST_FILE} + ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ -i${PERF_TEMPLATE_FILE} \ -o${PERF_DEST_FILE} + if [ VAR_OS_ENV==windows.cygwin ]; then + tr -d '\r' < ${PERF_DEST_FILE} > temp + mv temp ${PERF_DEST_FILE} + fi + ;; + esac + fi + done + + if [ $generate_perf_tests == true ]; then + # Generate jmh performance tests + case ${Type}Scalar in + $CLASS_FILTER) + Log true " scalar ${Type}Scalar.java" + PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" + rm -f ${PERF_DEST_FILE} + ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ + -i${PERF_SCALAR_TEMPLATE_FILE} \ + -o${PERF_DEST_FILE} if [ VAR_OS_ENV==windows.cygwin ]; then tr -d '\r' < ${PERF_DEST_FILE} > temp mv temp ${PERF_DEST_FILE} fi - ;; - esac - fi - done - - if [ $generate_perf_tests == true ]; then - # Generate jmh performance tests - case ${Type}Scalar in - $CLASS_FILTER) - Log true " scalar ${Type}Scalar.java" - PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" - rm -f ${PERF_DEST_FILE} - ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ - -i${PERF_SCALAR_TEMPLATE_FILE} \ - -o${PERF_DEST_FILE} - if [ VAR_OS_ENV==windows.cygwin ]; then - tr -d '\r' < ${PERF_DEST_FILE} > temp - mv temp ${PERF_DEST_FILE} - fi - ;; - esac - fi + ;; + esac + fi + # Generate tests for loads and stores + # For each size + for bits in 64 128 256 512 Max + do + vectortype=${typeprefix}${Type}${bits}Vector + vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests + vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore + masktype=${typeprefix}${Type}${bits}Mask + bitsvectortype=${typeprefix}${Bitstype}${bits}Vector + fpvectortype=${typeprefix}${Fptype}${bits}Vector + shape=S${bits}Bit + Shape=S_${bits}_BIT + if [[ "${vectortype}" == "ByteMaxVector" ]]; then + args="$args -KByteMax" + fi + bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" + if [ $bits == 'Max' ]; then + bitargs="$bitargs -KMaxBit" + fi - # Generate tests for loads and stores - # For each size - for bits in 64 128 256 512 Max - do - vectortype=${typeprefix}${Type}${bits}Vector - vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests - vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore - masktype=${typeprefix}${Type}${bits}Mask - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector - shape=S${bits}Bit - Shape=S_${bits}_BIT - if [[ "${vectortype}" == "ByteMaxVector" ]]; then - args="$args -KByteMax" - fi - bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" - if [ $bits == 'Max' ]; then - bitargs="$bitargs -KMaxBit" - fi - - # Generate - case $vectorteststype in - $CLASS_FILTER) + # Generate + case $vectorteststype in + $CLASS_FILTER) Log true " ${bits}_ls $vectorteststype.java" Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -itemplates/X-LoadStoreTest.java.template -o$vectorteststype.java " TEST_DEST_FILE="${vectorteststype}.java" rm -f ${TEST_DEST_FILE} ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ - -itemplates/X-LoadStoreTest.java.template \ - -o${TEST_DEST_FILE} + -itemplates/X-LoadStoreTest.java.template \ + -o${TEST_DEST_FILE} if [ VAR_OS_ENV==windows.cygwin ]; then tr -d '\r' < ${TEST_DEST_FILE} > temp mv temp ${TEST_DEST_FILE} fi - ;; - esac + ;; + esac + + # TODO: Generate jmh performance tests for LoadStore variants + done + + Log true " done\n" - # TODO: Generate jmh performance tests for LoadStore variants done +} - Log true " done\n" +case $* in +'') CLASS_FILTER='*';; +--generate*) CLASS_FILTER=${2-'*'};; +--help|*) echo "Usage: $0 [--generate [file]]"; exit 1;; +esac + +. config.sh -done +# Detect whether to generate the performance tests +generate_perf_tests=false +if [ -d "$PERF_DEST" ]; then + generate_perf_tests=true +fi +# First, generate the template files. +gen_type="ALL_PRIM_TYPES" +gen_half_type="HALF_FLOAT_TYPE" +bash gen-template.sh "ALL_PRIM_TYPES" $generate_perf_tests +generate_test_cases "ALL_PRIM_TYPES" +bash gen-template.sh "HALF_FLOAT_TYPE" $generate_perf_tests +generate_test_cases "HALF_FLOAT_TYPE" rm -fr build diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-mem-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-mem-op.template index f42e5be6f391d..4a7648745ee35 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-mem-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-Masked-mem-op.template @@ -6,6 +6,6 @@ for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.[[TEST]], bv_[[TEST]]_M, vmask).intoArray(r, i); + av.lanewise(VectorOperators.[[TEST]], bcast_vec, vmask).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-mem-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-mem-op.template index a0231b3f65329..f39186b88aa74 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-mem-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-mem-op.template @@ -4,6 +4,6 @@ for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.[[TEST]], bv_[[TEST]]).intoArray(r, i); + av.lanewise(VectorOperators.[[TEST]], bcast_vec).intoArray(r, i); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template new file mode 100644 index 0000000000000..b0a2dcc943315 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template @@ -0,0 +1,12 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.[[TEST]], bv).intoArray(r, i); + } + } + diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template new file mode 100644 index 0000000000000..a1a01cefaa256 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template @@ -0,0 +1,10 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.[[TEST]]).intoArray(r, i); + } + } + diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-mem-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-mem-op.template index 3c2ffd6860730..e5012a13e4312 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-mem-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-Masked-mem-op.template @@ -1,6 +1,4 @@ - static $abstractvectortype$ bv_[[TEST]]_M = $abstractvectortype$.broadcast(SPECIES, ($type$)10); - @Test(dataProvider = "$type$UnaryOpMaskProvider") static void [[TEST]]$vectorteststype$MaskedWithMemOp(IntFunction<$type$[]> fa, IntFunction fm) { [[KERNEL]] diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-mem-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-mem-op.template index 1fef6ddb98900..c5dfc666f264b 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-mem-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-mem-op.template @@ -1,6 +1,4 @@ - static $abstractvectortype$ bv_[[TEST]] = $abstractvectortype$.broadcast(SPECIES, ($type$)10); - @Test(dataProvider = "$type$UnaryOpProvider") static void [[TEST]]$vectorteststype$WithMemOp(IntFunction<$type$[]> fa) { [[KERNEL]] diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template new file mode 100644 index 0000000000000..5541acc37971c --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template @@ -0,0 +1,14 @@ + + static $type$ [[TEST]]($type$ a, $type$ b) { + return Float16.float16ToRawShortBits((Float16.valueOf((float) [[TEST_OP]]))); + } + + static $type$ strict[[TEST]]($type$ a, $type$ b) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Strict[[TEST_OP]])); + } + + @Test(dataProvider = "$type$BinaryOpProvider") + static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { +[[KERNEL]] + assertArraysEqualsWithinOneUlp(r, a, b, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); + } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template index 9a020c66d52f8..a4c8f734e52e4 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template @@ -10,7 +10,11 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { +#if[Halffloat] + Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); +#else[Halffloat] Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); +#end[Halffloat] } } } @@ -26,7 +30,11 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { +#if[Halffloat] + Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); +#else[Halffloat] Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); +#end[Halffloat] } } } @@ -123,7 +131,11 @@ static long ADDReduceLong($type$[] a, int idx) { $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { +#if[Halffloat] + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); +#else[Halffloat] res += a[i]; +#end[Halffloat] } return (long)res; @@ -132,7 +144,11 @@ static long ADDReduceAllLong($type$[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { +#if[Halffloat] + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); +#else[Halffloat] res += ADDReduceLong(a, i); +#end[Halffloat] } return res; @@ -150,8 +166,12 @@ } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { +#if[Halffloat] + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); +#else[Halffloat] ra += r[i]; +#end[Halffloat] } assertReductionLongArraysEquals(r, ra, a, @@ -162,7 +182,11 @@ $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if(mask[i % SPECIES.length()]) +#if[Halffloat] + res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); +#else[Halffloat] res += a[i]; +#end[Halffloat] } return (long)res; @@ -171,7 +195,11 @@ static long ADDReduceAllLongMasked($type$[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { +#if[Halffloat] + res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); +#else[Halffloat] res += ADDReduceLongMasked(a, i, mask); +#end[Halffloat] } return res; @@ -191,8 +219,12 @@ } ra = 0; - for (int i = 0; i < a.length; i ++) { + for (int i = 0; i < a.length; i++) { +#if[Halffloat] + ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); +#else[Halffloat] ra += r[i]; +#end[Halffloat] } assertReductionLongArraysEqualsMasked(r, ra, a, mask, @@ -699,14 +731,14 @@ static void ShapeWithLanes$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); VectorShape vsh = av.shape(); - VectorSpecies species = vsh.withLanes($type$.class); + VectorSpecies species = vsh.withLanes($ClassType$.class); assert(species.equals(SPECIES)); } @Test static void ElementType$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); - assert(av.species().elementType() == $type$.class); + assert(av.species().elementType() == $ClassType$.class); } @Test @@ -724,7 +756,7 @@ @Test static void WithLanes$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); - VectorSpecies species = av.species().withLanes($type$.class); + VectorSpecies species = av.species().withLanes($ClassType$.class); assert(species.equals(SPECIES)); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template new file mode 100644 index 0000000000000..5723988597902 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template @@ -0,0 +1,14 @@ + + static $type$ [[TEST]]($type$ a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) [[TEST_OP]])); + } + + static $type$ strict[[TEST]]($type$ a) { + return Float16.float16ToRawShortBits(Float16.valueOf((float) Strict[[TEST_OP]])); + } + + @Test(dataProvider = "$type$UnaryOpProvider") + static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { +[[KERNEL]] + assertArraysEqualsWithinOneUlp(r, a, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); + } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index 33c52f18c1c33..a6c118bf8edb6 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2025, 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 @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation $vectorteststype$ + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:{#if[FP16]?TieredStopAtLevel=3:-TieredCompilation} $vectorteststype$ */ #warn This file is preprocessed before being compiled @@ -48,6 +48,10 @@ import jdk.incubator.vector.ByteVector; #if[Float] import jdk.incubator.vector.FloatVector; #end[Float] +#if[Halffloat] +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +#end[Halffloat] #if[Int] import jdk.incubator.vector.IntVector; #end[Int] @@ -79,14 +83,16 @@ public class $vectorteststype$ extends AbstractVectorTest { #if[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $Type$Vector.SPECIES_MAX; + $ElementType$Vector.SPECIES_MAX; #else[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $Type$Vector.SPECIES_$bits$; + $ElementType$Vector.SPECIES_$bits$; #end[MaxBit] static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); + static $abstractvectortype$ bcast_vec = $abstractvectortype$.broadcast(SPECIES, ($type$)10); + #if[MaxBit] static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; @@ -111,8 +117,8 @@ public class $vectorteststype$ extends AbstractVectorTest { static void assertArraysStrictlyEquals($type$[] r, $type$[] a) { for (int i = 0; i < a.length; i++) { #if[FP] - $bitstype$ ir = $Wideboxtype$.$type$ToRaw$Bitstype$Bits(r[i]); - $bitstype$ ia = $Wideboxtype$.$type$ToRaw$Bitstype$Bits(a[i]); + $bitstype$ ir = {#if[FP16]?r[i]:$Wideboxtype$.$type$ToRaw$Bitstype$Bits(r[i])}; + $bitstype$ ia = {#if[FP16]?a[i]:$Wideboxtype$.$type$ToRaw$Bitstype$Bits(a[i])}; if (ir != ia) { #if[Float] Assert.fail(String.format("at index #%d, expected = %08X, actual = %08X", i, ia, ir)); @@ -408,7 +414,7 @@ relativeError)); for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); + wrapped_index = Math.floorMod({#if[FP16]?Float16.shortBitsToFloat16(order[idx]).intValue():(int)order[idx]}, 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -421,15 +427,17 @@ relativeError)); static void assertSelectFromArraysEquals($type$[] r, $type$[] a, $type$[] order, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + idx = {#if[FP16]?Float16.shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - int idx = i + j; - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -455,21 +463,23 @@ relativeError)); static void assertSelectFromArraysEquals($type$[] r, $type$[] a, $type$[] order, boolean[] mask, int vector_len) { int i = 0, j = 0; + int idx = 0, wrapped_index = 0; try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { + idx = {#if[FP16]?Float16.shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; + wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]); + Assert.assertEquals(r[i+j], a[i+wrapped_index]); else Assert.assertEquals(r[i+j], ($type$)0); } } } catch (AssertionError e) { - int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], ($type$)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + Assert.assertEquals(r[i+j], ($type$)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -883,6 +893,26 @@ relativeError)); #if[FP] static boolean isWithin1Ulp($type$ actual, $type$ expected) { +#if[Halffloat] + Float16 act = Float16.shortBitsToFloat16(actual); + Float16 exp = Float16.shortBitsToFloat16(expected); + if (Float16.isNaN(exp) && !Float16.isNaN(act)) { + return false; + } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { + return false; + } + + Float16 low = Float16.nextDown(exp); + Float16 high = Float16.nextUp(exp); + + if (Float16.compare(low, exp) > 0) { + return false; + } + + if (Float16.compare(high, exp) < 0) { + return false; + } +#else[Halffloat] if ($Type$.isNaN(expected) && !$Type$.isNaN(actual)) { return false; } else if (!$Type$.isNaN(expected) && $Type$.isNaN(actual)) { @@ -899,6 +929,7 @@ relativeError)); if ($Type$.compare(high, expected) < 0) { return false; } +#end[Halffloat] return true; } @@ -908,11 +939,11 @@ relativeError)); try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue($Type$.compare(r[i], mathf.apply(a[i])) == 0 || + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i])):mathf.apply(a[i])}) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue($Type$.compare(r[i], mathf.apply(a[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i])):mathf.apply(a[i])}) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -922,11 +953,11 @@ relativeError)); try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue($Type$.compare(r[i], mathf.apply(a[i], b[i])) == 0 || + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[i])):mathf.apply(a[i], b[i])}) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue($Type$.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[i])):mathf.apply(a[i], b[i])}) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -937,14 +968,14 @@ relativeError)); try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue($Type$.compare(r[i], - mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])) == 0 || + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, + {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])):mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])}) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue($Type$.compare(r[i], - mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])) == 0, + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, + {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])):mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])}) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1139,6 +1170,14 @@ relativeError)); } } + static $type$ genValue(int i) { +#if[Halffloat] + return Float16.float16ToRawShortBits(Float16.valueOf(i)); +#else[Halffloat] + return ($type$) i; +#end[Halffloat] + } + #if[!Int] #if[!byteOrShort] static int intCornerCaseValue(int i) { @@ -1157,19 +1196,19 @@ relativeError)); } static final List> INT_$TYPE$_GENERATORS = List.of( - withToString("$type$[-i * 5]", (int s) -> { + withToString("$ClassType$[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)(-i * 5)); + i -> genValue(-i * 5)); }), - withToString("$type$[i * 5]", (int s) -> { + withToString("$ClassType$[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)(i * 5)); + i -> genValue(i * 5)); }), - withToString("$type$[i + 1]", (int s) -> { + withToString("$ClassType$[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ((($type$)(i + 1) == 0) ? 1 : ($type$)(i + 1))); + i -> ((($type$)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("$type$[intCornerCaseValue(i)]", (int s) -> { + withToString("$ClassType$[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> ($type$)intCornerCaseValue(i)); }) @@ -1181,7 +1220,11 @@ relativeError)); int i = 0; try { for (; i < r.length; i++) { +#if[Halffloat] + Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); +#else[Halffloat] Assert.assertEquals(r[i], (int)(a[i+offs])); +#end[Halffloat] } } catch (AssertionError e) { Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); @@ -1205,20 +1248,28 @@ relativeError)); } } + static $type$ genValue(long i) { +#if[Halffloat] + return Float16.float16ToRawShortBits(Float16.valueOf(i)); +#else[Halffloat] + return ($type$) i; +#end[Halffloat] + } + static final List> LONG_$TYPE$_GENERATORS = List.of( - withToString("$type$[-i * 5]", (int s) -> { + withToString("$ClassType$[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)(-i * 5)); + i -> genValue(-i * 5)); }), - withToString("$type$[i * 5]", (int s) -> { + withToString("$ClassType$[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)(i * 5)); + i -> genValue(i * 5)); }), - withToString("$type$[i + 1]", (int s) -> { + withToString("$ClassType$[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ((($type$)(i + 1) == 0) ? 1 : ($type$)(i + 1))); + i -> ((($type$)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("$type$[cornerCaseValue(i)]", (int s) -> { + withToString("$ClassType$[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> ($type$)longCornerCaseValue(i)); }) @@ -1243,7 +1294,11 @@ relativeError)); int i = 0; try { for (; i < r.length; i++) { +#if[Halffloat] + Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); +#else[Halffloat] Assert.assertEquals(r[i], (long)(a[i+offs])); +#end[Halffloat] } } catch (AssertionError e) { Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); @@ -1255,7 +1310,11 @@ relativeError)); int i = 0; try { for (; i < r.length; i++) { +#if[Halffloat] + Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); +#else[Halffloat] Assert.assertEquals(r[i], (double)(a[i+offs])); +#end[Halffloat] } } catch (AssertionError e) { Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); @@ -1264,31 +1323,46 @@ relativeError)); #end[!Double] static $bitstype$ bits($type$ e) { - return {#if[FP]? $Type$.$type$To$Bitstype$Bits(e): e}; +#if[FP16] + return e; +#else[FP16] + return {#if[FP]?$Wideboxtype$.$type$To$Bitstype$Bits(e): e}; +#end[FP16] } static final List> $TYPE$_GENERATORS = List.of( - withToString("$type$[-i * 5]", (int s) -> { + withToString("$ClassType$[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)(-i * 5)); + i -> genValue(-i * 5)); }), - withToString("$type$[i * 5]", (int s) -> { + withToString("$ClassType$[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)(i * 5)); + i -> genValue(i * 5)); }), - withToString("$type$[i + 1]", (int s) -> { + withToString("$ClassType$[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ((($type$)(i + 1) == 0) ? 1 : ($type$)(i + 1))); + i -> ((($type$)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), #if[FP] +#if[FP16] + withToString("$Wideboxtype$[0.01 + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), + withToString("$Wideboxtype$[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01f + (i / (i + 1))]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (i % 17 == 0) ? cornerCaseValue(i) : Float.floatToFloat16((0.01f + ((float)i / (i + 1))))); + }), +#else[FP16] withToString("$type$[0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> ($type$)0.01 + (($type$)i / (i + 1))); + i -> (($type$)0.01 + (($type$)i / (i + 1)))); }), withToString("$type$[i -> i % 17 == 0 ? cornerCaseValue(i) : 0.01 + (i / (i + 1))]", (int s) -> { return fill(s * BUFFER_REPS, - i -> i % 17 == 0 ? cornerCaseValue(i) : ($type$)0.01 + (($type$)i / (i + 1))); + i -> (i % 17 == 0) ? cornerCaseValue(i) : (($type$)0.01 + (($type$)i / (i + 1)))); }), +#end[FP16] #end[FP] withToString("$type$[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, @@ -1678,6 +1752,18 @@ relativeError)); static $type$ cornerCaseValue(int i) { #if[FP] +#if[FP16] + return switch(i % 8) { + case 0 -> Float16.float16ToRawShortBits($Wideboxtype$.MAX_VALUE); + case 1 -> Float16.float16ToRawShortBits($Wideboxtype$.MIN_VALUE); + case 2 -> Float16.float16ToRawShortBits($Wideboxtype$.NEGATIVE_INFINITY); + case 3 -> Float16.float16ToRawShortBits($Wideboxtype$.POSITIVE_INFINITY); + case 4 -> Float16.float16ToRawShortBits($Wideboxtype$.NaN); + case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 6 -> (($type$)0.0); + default -> (($type$)-0.0); + }; +#else[FP16] return switch(i % 8) { case 0 -> $Wideboxtype$.MAX_VALUE; case 1 -> $Wideboxtype$.MIN_VALUE; @@ -1692,6 +1778,7 @@ relativeError)); case 6 -> ($type$)0.0; default -> ($type$)-0.0; }; +#end[FP16] #else[FP] switch(i % 5) { case 0: @@ -1809,6 +1896,44 @@ relativeError)); #end[intOrLong] } #end[BITWISE] +#if[Halffloat] + + static boolean eq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() == bt.floatValue(); + } + + static boolean neq(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() != bt.floatValue(); + } + + static boolean lt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() < bt.floatValue(); + } + + static boolean le(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() <= bt.floatValue(); + } + + static boolean gt(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() > bt.floatValue(); + } + + static boolean ge(short a, short b) { + Float16 at = Float16.shortBitsToFloat16(a); + Float16 bt = Float16.shortBitsToFloat16(b); + return at.floatValue() >= bt.floatValue(); + } +#else[Halffloat] static boolean eq($type$ a, $type$ b) { return a == b; @@ -1833,6 +1958,7 @@ relativeError)); static boolean ge($type$ a, $type$ b) { return a >= b; } +#end[Halffloat] #if[!FP] static boolean ult($type$ a, $type$ b) { @@ -1853,11 +1979,28 @@ relativeError)); #end[!FP] static $type$ firstNonZero($type$ a, $type$ b) { - return $Boxtype$.compare(a, ($type$) 0) != 0 ? a : b; + return $VecEleType$.compare(a, ($type$) 0) != 0 ? a : b; } @Test static void smokeTest1() { +#if[Halffloat] + $abstractvectortype$ three = $abstractvectortype$.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); + $abstractvectortype$ three2 = ($abstractvectortype$) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three2).allTrue()); + $abstractvectortype$ three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + assert(three.eq(three3).allTrue()); + int scale = 2; + $abstractvectortype$ higher = three.addIndex(scale); + VectorMask<$Wideboxtype$> m = three.compare(VectorOperators.LE, higher); + assert(m.allTrue()); + m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + assert(m.allTrue()); + m = higher.test(VectorOperators.IS_FINITE); + assert(m.allTrue()); + $type$ max = higher.reduceLanes(VectorOperators.MAX); + assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); +#else[Halffloat] $abstractvectortype$ three = $abstractvectortype$.broadcast(SPECIES, (byte)-3); $abstractvectortype$ three2 = ($abstractvectortype$) SPECIES.broadcast(-3); assert(three.eq(three2).allTrue()); @@ -1870,7 +2013,7 @@ relativeError)); else if (ETYPE == byte.class && SPECIES.length() >= 64) scale = 1; $abstractvectortype$ higher = three.addIndex(scale); - VectorMask<$Boxtype$> m = three.compare(VectorOperators.LE, higher); + VectorMask<$Wideboxtype$> m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); m = higher.min(($type$)-1).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); @@ -1880,6 +2023,7 @@ relativeError)); #end[FP] $type$ max = higher.reduceLanes(VectorOperators.MAX); assert(max == -3 + scale * (SPECIES.length()-1)); +#end[Halffloat] } private static $type$[] @@ -1899,8 +2043,8 @@ relativeError)); $abstractvectortype$ a = io.add(($type$)1); //[1,2] $abstractvectortype$ b = a.neg(); //[-1,-2] $type$[] abValues = bothToArray(a,b); //[1,2,-1,-2] - VectorShuffle<$Boxtype$> zip0 = VectorShuffle.makeZip(SPECIES, 0); - VectorShuffle<$Boxtype$> zip1 = VectorShuffle.makeZip(SPECIES, 1); + VectorShuffle<$Wideboxtype$> zip0 = VectorShuffle.makeZip(SPECIES, 0); + VectorShuffle<$Wideboxtype$> zip1 = VectorShuffle.makeZip(SPECIES, 1); $abstractvectortype$ zab0 = a.rearrange(zip0,b); //[1,-1] $abstractvectortype$ zab1 = a.rearrange(zip1,b); //[2,-2] $type$[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2] @@ -1911,8 +2055,8 @@ relativeError)); manual[i+1] = abValues[a.length() + i/2]; } Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); - VectorShuffle<$Boxtype$> unz0 = VectorShuffle.makeUnzip(SPECIES, 0); - VectorShuffle<$Boxtype$> unz1 = VectorShuffle.makeUnzip(SPECIES, 1); + VectorShuffle<$Wideboxtype$> unz0 = VectorShuffle.makeUnzip(SPECIES, 0); + VectorShuffle<$Wideboxtype$> unz1 = VectorShuffle.makeUnzip(SPECIES, 1); $abstractvectortype$ uab0 = zab0.rearrange(unz0,zab1); $abstractvectortype$ uab1 = zab0.rearrange(unz1,zab1); $type$[] abValues1 = bothToArray(uab0, uab1); @@ -1956,13 +2100,13 @@ relativeError)); Assert.assertEquals(asFloating.species(), SPECIES); } #else[FP] -#if[byteOrShort] +#if[byte] @Test(expectedExceptions = UnsupportedOperationException.class) void viewAsFloatingLanesTest() { SPECIES.zero().viewAsFloatingLanes(); } -#else[byteOrShort] +#else[byte] @Test void viewAsFloatingLanesTest() { @@ -1973,7 +2117,7 @@ relativeError)); Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } -#end[byteOrShort] +#end[byte] #end[FP] #if[BITWISE] diff --git a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template index a68103e106042..1c255c616f2ed 100644 --- a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template +++ b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template @@ -41,6 +41,10 @@ import java.lang.foreign.MemorySegment; import java.lang.foreign.Arena; import java.lang.foreign.ValueLayout; +#if[FP16] +import jdk.incubator.vector.Float16; +import jdk.incubator.vector.HalffloatVector; +#end[FP16] import jdk.incubator.vector.$Type$Vector; import jdk.incubator.vector.VectorMask; #if[MaxBit] @@ -61,15 +65,19 @@ import java.util.function.*; public class $vectorteststype$ extends AbstractVectorLoadStoreTest { #if[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $Type$Vector.SPECIES_MAX; + $ElementType$Vector.SPECIES_MAX; #else[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $Type$Vector.SPECIES_$bits$; + $ElementType$Vector.SPECIES_$bits$; #end[MaxBit] static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); +#if[Halffloat] + static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); +#else[Halffloat] static final ValueLayout.Of$Type$ ELEMENT_LAYOUT = ValueLayout.JAVA_$TYPE$.withByteAlignment(1); +#end[Halffloat] #if[MaxBit] static VectorShape getMaxBit() { @@ -270,22 +278,22 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static VectorShuffle<$Boxtype$> shuffleFromArray(int[] a, int i) { + static VectorShuffle<$Wideboxtype$> shuffleFromArray(int[] a, int i) { return SPECIES.shuffleFromArray(a, i); } @DontInline - static void shuffleIntoArray(VectorShuffle<$Boxtype$> s, int[] a, int i) { + static void shuffleIntoArray(VectorShuffle<$Wideboxtype$> s, int[] a, int i) { s.intoArray(a, i); } @DontInline - static VectorShuffle<$Boxtype$> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { + static VectorShuffle<$Wideboxtype$> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) { return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo); } @DontInline - static void shuffleIntoMemorySegment(VectorShuffle<$Boxtype$> s, MemorySegment mem, int i, ByteOrder bo) { + static void shuffleIntoMemorySegment(VectorShuffle<$Wideboxtype$> s, MemorySegment mem, int i, ByteOrder bo) { s.intoMemorySegment(mem, i, bo); } @@ -296,7 +304,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static $abstractvectortype$ fromArray($type$[] a, int i, VectorMask<$Boxtype$> m) { + static $abstractvectortype$ fromArray($type$[] a, int i, VectorMask<$Wideboxtype$> m) { return $abstractvectortype$.fromArray(SPECIES, a, i, m); } @@ -306,7 +314,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static void intoArray($abstractvectortype$ v, $type$[] a, int i, VectorMask<$Boxtype$> m) { + static void intoArray($abstractvectortype$ v, $type$[] a, int i, VectorMask<$Wideboxtype$> m) { v.intoArray(a, i, m); } @@ -317,7 +325,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static $abstractvectortype$ fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask<$Boxtype$> m) { + static $abstractvectortype$ fromMemorySegment(MemorySegment a, int i, ByteOrder bo, VectorMask<$Wideboxtype$> m) { return $abstractvectortype$.fromMemorySegment(SPECIES, a, i, bo, m); } @@ -327,7 +335,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static void intoMemorySegment($abstractvectortype$ v, MemorySegment a, int i, ByteOrder bo, VectorMask<$Boxtype$> m) { + static void intoMemorySegment($abstractvectortype$ v, MemorySegment a, int i, ByteOrder bo, VectorMask<$Wideboxtype$> m) { v.intoMemorySegment(a, i, bo, m); } @@ -405,7 +413,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { $type$[] a = fa.apply(SPECIES.length()); $type$[] r = new $type$[a.length]; boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -432,7 +440,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { $type$[] a = fa.apply(SPECIES.length()); $type$[] r = new $type$[a.length]; boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -460,7 +468,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { $type$[] a = fa.apply(SPECIES.length()); $type$[] r = new $type$[a.length]; boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -493,7 +501,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < mask.length; i += SPECIES.length()) { - VectorMask<$Boxtype$> vmask = VectorMask.fromArray(SPECIES, mask, i); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, i); vmask.intoArray(r, i); } } @@ -523,8 +531,8 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { @Test(dataProvider = "$type$ByteProviderForIOOBE") static void loadMemorySegmentIOOBE(IntFunction<$type$[]> fa, IntFunction fi) { - MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Boxtype$.SIZE)); - MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Boxtype$.SIZE); + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Wideboxtype$.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Wideboxtype$.SIZE); int l = (int) a.byteSize(); int s = SPECIES.vectorByteSize(); @@ -552,8 +560,8 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { @Test(dataProvider = "$type$ByteProviderForIOOBE") static void storeMemorySegmentIOOBE(IntFunction<$type$[]> fa, IntFunction fi) { - MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Boxtype$.SIZE)); - MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Boxtype$.SIZE); + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Wideboxtype$.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Wideboxtype$.SIZE); int l = (int) a.byteSize(); int s = SPECIES.vectorByteSize(); @@ -589,7 +597,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { MemorySegment a = toSegment(_a, fb); MemorySegment r = fb.apply((int) a.byteSize()); boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); int l = (int) a.byteSize(); int s = SPECIES.vectorByteSize(); @@ -616,10 +624,10 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { @Test(dataProvider = "$type$ByteMaskProviderForIOOBE") static void loadMemorySegmentMaskIOOBE(IntFunction<$type$[]> fa, IntFunction fi, IntFunction fm) { - MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Boxtype$.SIZE)); - MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Boxtype$.SIZE); + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Wideboxtype$.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Wideboxtype$.SIZE); boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); int l = (int) a.byteSize(); int s = SPECIES.vectorByteSize(); @@ -647,10 +655,10 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { @Test(dataProvider = "$type$ByteMaskProviderForIOOBE") static void storeMemorySegmentMaskIOOBE(IntFunction<$type$[]> fa, IntFunction fi, IntFunction fm) { - MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Boxtype$.SIZE)); - MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Boxtype$.SIZE); + MemorySegment a = toSegment(fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i, $Wideboxtype$.SIZE)); + MemorySegment r = Arena.ofAuto().allocate(a.byteSize(), $Wideboxtype$.SIZE); boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); int l = (int) a.byteSize(); int s = SPECIES.vectorByteSize(); @@ -698,7 +706,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { () -> SPECIES.zero().intoMemorySegment(a, 0, bo, SPECIES.maskAll(false)) ); - VectorMask<$Boxtype$> m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) + VectorMask<$Wideboxtype$> m = SPECIES.shuffleFromOp(i -> i % 2 == 0 ? 1 : -1) .laneIsValid(); Assert.assertThrows( UnsupportedOperationException.class, @@ -714,7 +722,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { - VectorMask<$Boxtype$> vmask = SPECIES.loadMask(a, i); + VectorMask<$Wideboxtype$> vmask = SPECIES.loadMask(a, i); vmask.intoArray(r, i); } } @@ -729,7 +737,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { - VectorShuffle<$Boxtype$> shuffle = VectorShuffle.fromArray(SPECIES, a, i); + VectorShuffle<$Wideboxtype$> shuffle = VectorShuffle.fromArray(SPECIES, a, i); shuffle.intoArray(r, i); } } @@ -747,7 +755,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { - VectorShuffle<$Boxtype$> shuffle = shuffleFromArray(a, i); + VectorShuffle<$Wideboxtype$> shuffle = shuffleFromArray(a, i); shuffleIntoArray(shuffle, r, i); } } @@ -755,7 +763,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { int index = fi.apply(a.length); boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length); try { - VectorShuffle<$Boxtype$> shuffle = shuffleFromArray(a, index); + VectorShuffle<$Wideboxtype$> shuffle = shuffleFromArray(a, index); shuffleIntoArray(shuffle, r, index); if (shouldFail) { Assert.fail("Failed to throw IndexOutOfBoundsException"); @@ -774,7 +782,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { - VectorShuffle<$Boxtype$> shuffle = shuffleFromArray(a, i); + VectorShuffle<$Wideboxtype$> shuffle = shuffleFromArray(a, i); shuffle.intoArray(r, i); } } @@ -805,7 +813,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < l; i += s) { - VectorShuffle<$Boxtype$> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); + VectorShuffle<$Wideboxtype$> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo); shuffle.intoMemorySegment(r, i, bo); } } @@ -827,7 +835,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < l; i += s) { - VectorShuffle<$Boxtype$> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); + VectorShuffle<$Wideboxtype$> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder()); shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder()); } } @@ -856,7 +864,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < l; i += s) { - VectorShuffle<$Boxtype$> shuffle = + VectorShuffle<$Wideboxtype$> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder()); shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder()); } @@ -865,7 +873,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { int index = fi.apply((int) a.byteSize()); boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize()); try { - VectorShuffle<$Boxtype$> shuffle = + VectorShuffle<$Wideboxtype$> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder()); shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder()); if (shouldFail) { @@ -957,7 +965,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static $abstractvectortype$ fromCharArray(char[] a, int i, VectorMask<$Boxtype$> m) { + static $abstractvectortype$ fromCharArray(char[] a, int i, VectorMask<$Wideboxtype$> m) { return $abstractvectortype$.fromCharArray(SPECIES, a, i, m); } @@ -967,7 +975,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { } @DontInline - static void intoCharArray($abstractvectortype$ v, char[] a, int i, VectorMask<$Boxtype$> m) { + static void intoCharArray($abstractvectortype$ v, char[] a, int i, VectorMask<$Wideboxtype$> m) { v.intoCharArray(a, i, m); } @@ -1044,7 +1052,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { char[] a = fa.apply(SPECIES.length()); char[] r = new char[a.length]; boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -1071,7 +1079,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { char[] a = fa.apply(SPECIES.length()); char[] r = new char[a.length]; boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -1099,7 +1107,7 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest { char[] a = fa.apply(SPECIES.length()); char[] r = new char[a.length]; boolean[] mask = fm.apply(SPECIES.length()); - VectorMask<$Boxtype$> vmask = VectorMask.fromValues(SPECIES, mask); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromValues(SPECIES, mask); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { From 2f43bb190e738564deae95fd8107a5a958043ad8 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Tue, 28 Oct 2025 06:44:31 +0000 Subject: [PATCH 02/10] Build failure fixes --- src/hotspot/share/opto/vectorIntrinsics.cpp | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 6fa2ade909b80..9ce8acff8d89c 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -35,18 +35,6 @@ static bool is_vector(ciKlass* klass) { return klass->is_subclass_of(ciEnv::current()->vector_VectorPayload_klass()); } -static const char* get_opertype_string(int operType) { - switch(operType) { - case VectorSupport::VECTOR_TYPE_PRIM: - return "VECTOR_TYPE_PRIM"; - case VectorSupport::VECTOR_TYPE_FP16: - return "VECTOR_TYPE_FP16"; - default: - ShouldNotReachHere(); - return nullptr; - } -} - static bool check_vbox(const TypeInstPtr* vbox_type) { assert(vbox_type->klass_is_exact(), ""); @@ -81,6 +69,18 @@ static bool check_vbox(const TypeInstPtr* vbox_type) { #define non_product_log_if_needed(...) #endif +static const char* get_opertype_string(int operType) { + switch(operType) { + case VectorSupport::VECTOR_TYPE_PRIM: + return "VECTOR_TYPE_PRIM"; + case VectorSupport::VECTOR_TYPE_FP16: + return "VECTOR_TYPE_FP16"; + default: + ShouldNotReachHere(); + return nullptr; + } +} + static bool is_vector_mask(ciKlass* klass) { return klass->is_subclass_of(ciEnv::current()->vector_VectorMask_klass()); } From adc1baa3a46c3418f369e3c6ff140ef63dc927c6 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Wed, 29 Oct 2025 12:24:04 +0000 Subject: [PATCH 03/10] Fix JTREG failures --- src/hotspot/cpu/x86/x86.ad | 1 + .../incubator/vector/Byte128VectorTests.java | 305 ++++++++------ .../incubator/vector/Byte256VectorTests.java | 305 ++++++++------ .../incubator/vector/Byte512VectorTests.java | 305 ++++++++------ .../incubator/vector/Byte64VectorTests.java | 305 ++++++++------ .../incubator/vector/ByteMaxVectorTests.java | 305 ++++++++------ .../vector/Double128VectorTests.java | 298 ++++++++------ .../vector/Double256VectorTests.java | 298 ++++++++------ .../vector/Double512VectorTests.java | 298 ++++++++------ .../incubator/vector/Double64VectorTests.java | 298 ++++++++------ .../vector/DoubleMaxVectorTests.java | 298 ++++++++------ .../incubator/vector/Float128VectorTests.java | 308 ++++++++------ .../incubator/vector/Float256VectorTests.java | 308 ++++++++------ .../incubator/vector/Float512VectorTests.java | 308 ++++++++------ .../incubator/vector/Float64VectorTests.java | 308 ++++++++------ .../incubator/vector/FloatMaxVectorTests.java | 308 ++++++++------ .../vector/Halffloat128VectorTests.java | 316 +++++++++------ .../vector/Halffloat256VectorTests.java | 316 +++++++++------ .../vector/Halffloat512VectorTests.java | 316 +++++++++------ .../vector/Halffloat64VectorTests.java | 316 +++++++++------ .../vector/HalffloatMaxVectorTests.java | 316 +++++++++------ .../incubator/vector/Int128VectorTests.java | 307 ++++++++------ .../incubator/vector/Int256VectorTests.java | 307 ++++++++------ .../incubator/vector/Int512VectorTests.java | 307 ++++++++------ .../incubator/vector/Int64VectorTests.java | 307 ++++++++------ .../incubator/vector/IntMaxVectorTests.java | 307 ++++++++------ .../incubator/vector/Long128VectorTests.java | 285 +++++++------ .../incubator/vector/Long256VectorTests.java | 285 +++++++------ .../incubator/vector/Long512VectorTests.java | 285 +++++++------ .../incubator/vector/Long64VectorTests.java | 285 +++++++------ .../incubator/vector/LongMaxVectorTests.java | 285 +++++++------ .../incubator/vector/Short128VectorTests.java | 307 ++++++++------ .../incubator/vector/Short256VectorTests.java | 307 ++++++++------ .../incubator/vector/Short512VectorTests.java | 307 ++++++++------ .../incubator/vector/Short64VectorTests.java | 307 ++++++++------ .../incubator/vector/ShortMaxVectorTests.java | 307 ++++++++------ .../vector/templates/Unit-header.template | 381 +++++++++++------- 37 files changed, 6276 insertions(+), 4736 deletions(-) diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index efe0482e095ff..90316c46cc4c0 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -10733,6 +10733,7 @@ instruct reinterpretHF2S(rRegI dst, regF src) format %{ "vmovw $dst, $src" %} ins_encode %{ __ vmovw($dst$$Register, $src$$XMMRegister); + __ movswl($dst$$Register, $dst$$Register); %} ins_pipe(pipe_slow); %} diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index 219ab16c34348..021f2fafd839a 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -65,6 +65,49 @@ public class Byte128VectorTests extends AbstractVectorTest { static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + static void AssertEquals(byte actual, byte expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte actual, byte expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(byte actual, byte expected, byte delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(byte actual, byte expected, byte delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(byte [] actual, byte [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte [] actual, byte [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, b FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (byte)0); + AssertEquals(r[i + k], (byte)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (byte)0); + AssertEquals(r[i + j], (byte)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -993,10 +1036,10 @@ static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1004,10 +1047,10 @@ static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1015,10 +1058,10 @@ static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1539,7 +1582,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ByteVector a = io.add((byte)1); //[1,2] ByteVector b = a.neg(); //[-1,-2] byte[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1554,19 +1597,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ByteVector uab0 = zab0.rearrange(unz0,zab1); ByteVector uab1 = zab0.rearrange(unz1,zab1); byte[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1581,7 +1624,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test(expectedExceptions = UnsupportedOperationException.class) diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index 39b74d64f0c01..30f3720235086 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -65,6 +65,49 @@ public class Byte256VectorTests extends AbstractVectorTest { static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + static void AssertEquals(byte actual, byte expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte actual, byte expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(byte actual, byte expected, byte delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(byte actual, byte expected, byte delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(byte [] actual, byte [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte [] actual, byte [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, b FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (byte)0); + AssertEquals(r[i + k], (byte)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (byte)0); + AssertEquals(r[i + j], (byte)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -993,10 +1036,10 @@ static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1004,10 +1047,10 @@ static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1015,10 +1058,10 @@ static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1539,7 +1582,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ByteVector a = io.add((byte)1); //[1,2] ByteVector b = a.neg(); //[-1,-2] byte[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1554,19 +1597,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ByteVector uab0 = zab0.rearrange(unz0,zab1); ByteVector uab1 = zab0.rearrange(unz1,zab1); byte[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1581,7 +1624,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test(expectedExceptions = UnsupportedOperationException.class) diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index db8a7f5d02403..d4af7040c7eba 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -65,6 +65,49 @@ public class Byte512VectorTests extends AbstractVectorTest { static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + static void AssertEquals(byte actual, byte expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte actual, byte expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(byte actual, byte expected, byte delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(byte actual, byte expected, byte delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(byte [] actual, byte [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte [] actual, byte [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, b FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (byte)0); + AssertEquals(r[i + k], (byte)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (byte)0); + AssertEquals(r[i + j], (byte)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -993,10 +1036,10 @@ static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1004,10 +1047,10 @@ static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1015,10 +1058,10 @@ static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1539,7 +1582,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ByteVector a = io.add((byte)1); //[1,2] ByteVector b = a.neg(); //[-1,-2] byte[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1554,19 +1597,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ByteVector uab0 = zab0.rearrange(unz0,zab1); ByteVector uab1 = zab0.rearrange(unz1,zab1); byte[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1581,7 +1624,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test(expectedExceptions = UnsupportedOperationException.class) diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index b3003635b0a4e..748e0b6ddefa3 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -65,6 +65,49 @@ public class Byte64VectorTests extends AbstractVectorTest { static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + static void AssertEquals(byte actual, byte expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte actual, byte expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(byte actual, byte expected, byte delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(byte actual, byte expected, byte delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(byte [] actual, byte [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte [] actual, byte [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final byte CONST_SHIFT = Byte.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, b FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (byte)0); + AssertEquals(r[i + k], (byte)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (byte)0); + AssertEquals(r[i + j], (byte)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -993,10 +1036,10 @@ static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1004,10 +1047,10 @@ static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1015,10 +1058,10 @@ static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1539,7 +1582,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ByteVector a = io.add((byte)1); //[1,2] ByteVector b = a.neg(); //[-1,-2] byte[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1554,19 +1597,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ByteVector uab0 = zab0.rearrange(unz0,zab1); ByteVector uab1 = zab0.rearrange(unz1,zab1); byte[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1581,7 +1624,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test(expectedExceptions = UnsupportedOperationException.class) diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index 053cdae4a5e5e..0ee2b1e10c0a4 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -65,6 +65,49 @@ public class ByteMaxVectorTests extends AbstractVectorTest { static ByteVector bcast_vec = ByteVector.broadcast(SPECIES, (byte)10); + static void AssertEquals(byte actual, byte expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte actual, byte expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(byte actual, byte expected, byte delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(byte actual, byte expected, byte delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(byte [] actual, byte [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(byte [] actual, byte [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -91,10 +134,10 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(byte[] r, byte[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { byte[] ref = f.apply(a[i]); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(byte[] r, byte[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -141,13 +184,13 @@ static void assertReductionArraysEquals(byte[] r, byte rc, byte[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -163,13 +206,13 @@ static void assertReductionArraysEqualsMasked(byte[] r, byte rc, byte[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -185,13 +228,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, byte[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -207,13 +250,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, byte[] a, b FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -225,10 +268,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -240,10 +283,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -252,12 +295,12 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -268,20 +311,20 @@ static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (byte)0); + AssertEquals(r[i + k], (byte)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -293,19 +336,19 @@ static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (byte)0); + AssertEquals(r[i + j], (byte)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (byte)0, "at index #" + idx); + AssertEquals(r[idx], (byte)0, "at index #" + idx); } } } @@ -321,11 +364,11 @@ static void assertSelectFromTwoVectorEquals(byte[] r, byte[] order, byte[] a, by wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -337,11 +380,11 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -351,17 +394,17 @@ static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -374,16 +417,16 @@ static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (byte)0); + AssertEquals(r[i+j], (byte)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (byte)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -397,10 +440,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -421,18 +464,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -447,18 +490,18 @@ static void assertArraysEqualsAssociative(byte[] rl, byte[] rr, byte[] a, byte[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -466,10 +509,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -477,10 +520,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -488,10 +531,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -500,10 +543,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -516,10 +559,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -531,10 +574,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -546,10 +589,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -564,10 +607,10 @@ static void assertBroadcastLongArraysEquals(byte[] r, byte[] a, byte[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (byte)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -580,11 +623,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -598,11 +641,11 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -624,11 +667,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -642,11 +685,11 @@ static void assertShiftConstEquals(byte[] r, byte[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -666,10 +709,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -681,10 +724,10 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -693,10 +736,10 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -706,10 +749,10 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -725,11 +768,11 @@ static void assertBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -746,11 +789,11 @@ static void assertAltBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -761,11 +804,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -782,11 +825,11 @@ static void assertDoubleBroadcastArraysEquals(byte[] r, byte[] a, byte[] b, byte int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -804,13 +847,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +874,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -852,13 +895,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { byte[] ref = f.apply(r, a, i, mask, b, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -879,13 +922,13 @@ static void assertArraysEquals(byte[] r, byte[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -899,13 +942,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -920,13 +963,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -941,13 +984,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -963,13 +1006,13 @@ static void assertArraysEquals(byte[] r, byte[] a, byte[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { byte[] ref = f.apply(a, b, origin, part, mask, i); byte[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -986,10 +1029,10 @@ static void assertArraysEquals(int[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -998,10 +1041,10 @@ static void assertArraysEquals(byte[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1009,10 +1052,10 @@ static void assertArraysEquals(long[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1020,10 +1063,10 @@ static void assertArraysEquals(double[] r, byte[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1544,7 +1587,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ByteVector a = io.add((byte)1); //[1,2] ByteVector b = a.neg(); //[-1,-2] byte[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1559,19 +1602,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ByteVector uab0 = zab0.rearrange(unz0,zab1); ByteVector uab1 = zab0.rearrange(unz1,zab1); byte[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ByteVector io = (ByteVector) SPECIES.broadcast(0).addIndex(1); ByteVector io2 = (ByteVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1586,7 +1629,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test(expectedExceptions = UnsupportedOperationException.class) diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java index 0688a380d6ac0..4b096db34bfcf 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java @@ -64,6 +64,43 @@ public class Double128VectorTests extends AbstractVectorTest { static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(double actual, double expected, double delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(double actual, double expected, double delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(double [] actual, double [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double [] actual, double [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -91,10 +128,10 @@ static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +143,13 @@ static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +159,10 @@ static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +184,13 @@ static void assertReductionArraysEquals(double[] r, double rc, double[] a, double relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +212,13 @@ static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, double relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +234,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +256,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +274,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +289,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +301,12 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +317,20 @@ static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (double)0); + AssertEquals(r[i + k], (double)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -306,19 +342,19 @@ static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (double)0); + AssertEquals(r[i + j], (double)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -334,11 +370,11 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +386,11 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +400,17 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +423,16 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +446,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +470,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +496,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +515,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +526,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +537,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBin int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +549,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +565,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +580,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +595,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +613,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +629,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +647,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[ try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +673,11 @@ static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +691,11 @@ static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinC try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +715,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +730,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +742,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +755,10 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +774,11 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +795,11 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +810,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +831,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +927,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +954,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +975,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1002,13 @@ static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1022,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, F int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1043,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, b int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1064,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1086,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1142,10 @@ static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1192,10 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1547,7 +1583,7 @@ static void smokeTest2() { // Do some zipping and shuffling. DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); DoubleVector a = io.add((double)1); //[1,2] DoubleVector b = a.neg(); //[-1,-2] double[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1562,19 +1598,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); DoubleVector uab0 = zab0.rearrange(unz0,zab1); DoubleVector uab1 = zab0.rearrange(unz1,zab1); double[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1591,15 +1627,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static double ADD(double a, double b) { diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java index 86113790f8b4c..9cedfba15f1bd 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java @@ -64,6 +64,43 @@ public class Double256VectorTests extends AbstractVectorTest { static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(double actual, double expected, double delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(double actual, double expected, double delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(double [] actual, double [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double [] actual, double [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -91,10 +128,10 @@ static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +143,13 @@ static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +159,10 @@ static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +184,13 @@ static void assertReductionArraysEquals(double[] r, double rc, double[] a, double relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +212,13 @@ static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, double relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +234,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +256,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +274,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +289,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +301,12 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +317,20 @@ static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (double)0); + AssertEquals(r[i + k], (double)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -306,19 +342,19 @@ static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (double)0); + AssertEquals(r[i + j], (double)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -334,11 +370,11 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +386,11 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +400,17 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +423,16 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +446,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +470,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +496,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +515,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +526,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +537,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBin int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +549,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +565,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +580,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +595,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +613,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +629,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +647,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[ try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +673,11 @@ static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +691,11 @@ static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinC try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +715,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +730,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +742,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +755,10 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +774,11 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +795,11 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +810,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +831,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +927,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +954,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +975,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1002,13 @@ static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1022,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, F int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1043,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, b int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1064,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1086,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1142,10 @@ static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1192,10 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1547,7 +1583,7 @@ static void smokeTest2() { // Do some zipping and shuffling. DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); DoubleVector a = io.add((double)1); //[1,2] DoubleVector b = a.neg(); //[-1,-2] double[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1562,19 +1598,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); DoubleVector uab0 = zab0.rearrange(unz0,zab1); DoubleVector uab1 = zab0.rearrange(unz1,zab1); double[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1591,15 +1627,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static double ADD(double a, double b) { diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java index 8c0d0531087ae..c0f2460ba19ad 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java @@ -64,6 +64,43 @@ public class Double512VectorTests extends AbstractVectorTest { static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(double actual, double expected, double delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(double actual, double expected, double delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(double [] actual, double [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double [] actual, double [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -91,10 +128,10 @@ static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +143,13 @@ static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +159,10 @@ static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +184,13 @@ static void assertReductionArraysEquals(double[] r, double rc, double[] a, double relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +212,13 @@ static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, double relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +234,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +256,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +274,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +289,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +301,12 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +317,20 @@ static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (double)0); + AssertEquals(r[i + k], (double)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -306,19 +342,19 @@ static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (double)0); + AssertEquals(r[i + j], (double)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -334,11 +370,11 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +386,11 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +400,17 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +423,16 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +446,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +470,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +496,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +515,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +526,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +537,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBin int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +549,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +565,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +580,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +595,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +613,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +629,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +647,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[ try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +673,11 @@ static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +691,11 @@ static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinC try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +715,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +730,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +742,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +755,10 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +774,11 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +795,11 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +810,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +831,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +927,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +954,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +975,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1002,13 @@ static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1022,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, F int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1043,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, b int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1064,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1086,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1142,10 @@ static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1192,10 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1547,7 +1583,7 @@ static void smokeTest2() { // Do some zipping and shuffling. DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); DoubleVector a = io.add((double)1); //[1,2] DoubleVector b = a.neg(); //[-1,-2] double[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1562,19 +1598,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); DoubleVector uab0 = zab0.rearrange(unz0,zab1); DoubleVector uab1 = zab0.rearrange(unz1,zab1); double[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1591,15 +1627,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static double ADD(double a, double b) { diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java index 4f01df5ba6d8f..bcce613c3d666 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java @@ -64,6 +64,43 @@ public class Double64VectorTests extends AbstractVectorTest { static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(double actual, double expected, double delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(double actual, double expected, double delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(double [] actual, double [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double [] actual, double [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final double RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (double)10.0; @@ -91,10 +128,10 @@ static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +143,13 @@ static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +159,10 @@ static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +184,13 @@ static void assertReductionArraysEquals(double[] r, double rc, double[] a, double relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +212,13 @@ static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, double relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +234,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +256,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +274,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +289,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +301,12 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +317,20 @@ static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (double)0); + AssertEquals(r[i + k], (double)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -306,19 +342,19 @@ static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (double)0); + AssertEquals(r[i + j], (double)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -334,11 +370,11 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +386,11 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +400,17 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +423,16 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +446,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +470,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +496,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +515,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +526,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +537,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBin int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +549,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +565,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +580,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +595,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +613,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +629,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +647,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[ try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +673,11 @@ static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +691,11 @@ static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinC try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +715,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +730,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +742,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +755,10 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +774,11 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +795,11 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +810,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +831,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +927,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +954,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +975,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1002,13 @@ static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1022,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, F int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1043,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, b int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1064,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1086,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1142,10 @@ static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1192,10 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1547,7 +1583,7 @@ static void smokeTest2() { // Do some zipping and shuffling. DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); DoubleVector a = io.add((double)1); //[1,2] DoubleVector b = a.neg(); //[-1,-2] double[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1562,19 +1598,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); DoubleVector uab0 = zab0.rearrange(unz0,zab1); DoubleVector uab1 = zab0.rearrange(unz1,zab1); double[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1591,15 +1627,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static double ADD(double a, double b) { diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java index 6d3b80c906be2..213b9edf6cf09 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java @@ -64,6 +64,43 @@ public class DoubleMaxVectorTests extends AbstractVectorTest { static DoubleVector bcast_vec = DoubleVector.broadcast(SPECIES, (double)10); + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(double actual, double expected, double delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(double actual, double expected, double delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(double [] actual, double [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double [] actual, double [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -96,10 +133,10 @@ static void assertArraysEquals(double[] r, double[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -111,13 +148,13 @@ static void assertArraysEquals(double[] r, double[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { double[] ref = f.apply(a[i]); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -127,10 +164,10 @@ static void assertArraysEquals(double[] r, double[] a, boolean[] mask, FUnOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -152,13 +189,13 @@ static void assertReductionArraysEquals(double[] r, double rc, double[] a, double relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -180,14 +217,13 @@ static void assertReductionArraysEqualsMasked(double[] r, double rc, double[] a, double relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -203,13 +239,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, double[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -225,13 +261,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, double[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -243,10 +279,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -258,10 +294,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -270,12 +306,12 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, int try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -286,20 +322,20 @@ static void assertcompressArraysEquals(double[] r, double[] a, boolean[] m, int k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (double)0); + AssertEquals(r[i + k], (double)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -311,19 +347,19 @@ static void assertexpandArraysEquals(double[] r, double[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (double)0); + AssertEquals(r[i + j], (double)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (double)0, "at index #" + idx); + AssertEquals(r[idx], (double)0, "at index #" + idx); } } } @@ -339,11 +375,11 @@ static void assertSelectFromTwoVectorEquals(double[] r, double[] order, double[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -355,11 +391,11 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -369,17 +405,17 @@ static void assertRearrangeArraysEquals(double[] r, double[] a, int[] order, boo for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,16 +428,16 @@ static void assertSelectFromArraysEquals(double[] r, double[] a, double[] order, idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (double)0); + AssertEquals(r[i+j], (double)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (double)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -415,10 +451,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -439,18 +475,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -465,18 +501,18 @@ static void assertArraysEqualsAssociative(double[] rl, double[] rr, double[] a, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -484,10 +520,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -495,10 +531,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -506,10 +542,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, FBin int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -518,10 +554,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -534,10 +570,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -549,10 +585,10 @@ static void assertArraysEquals(double[] r, double[] a, double b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -564,10 +600,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -582,10 +618,10 @@ static void assertBroadcastLongArraysEquals(double[] r, double[] a, double[] b, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (double)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -598,11 +634,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, FBinOp f try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -616,11 +652,11 @@ static void assertShiftArraysEquals(double[] r, double[] a, double[] b, boolean[ try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -642,11 +678,11 @@ static void assertShiftConstEquals(double[] r, double[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -660,11 +696,11 @@ static void assertShiftConstEquals(double[] r, double[] a, boolean[] mask, FBinC try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -684,10 +720,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -699,10 +735,10 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, double[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -711,10 +747,10 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -724,10 +760,10 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -743,11 +779,11 @@ static void assertBroadcastArraysEquals(double[] r, double[] a, double[] b, doub int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -764,11 +800,11 @@ static void assertAltBroadcastArraysEquals(double[] r, double[] a, double[] b, d int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -779,11 +815,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -800,11 +836,11 @@ static void assertDoubleBroadcastArraysEquals(double[] r, double[] a, double[] b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -896,13 +932,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, FGatherScatterOp int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -923,13 +959,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -944,13 +980,13 @@ static void assertArraysEquals(double[] r, double[] a, int[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { double[] ref = f.apply(r, a, i, mask, b, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -971,13 +1007,13 @@ static void assertArraysEquals(double[] r, double[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -991,13 +1027,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, F int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1012,13 +1048,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, b int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1033,13 +1069,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1055,13 +1091,13 @@ static void assertArraysEquals(double[] r, double[] a, double[] b, int origin, i int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { double[] ref = f.apply(a, b, origin, part, mask, i); double[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1111,10 +1147,10 @@ static void assertArraysEquals(int[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1161,10 +1197,10 @@ static void assertArraysEquals(long[] r, double[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1552,7 +1588,7 @@ static void smokeTest2() { // Do some zipping and shuffling. DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); DoubleVector a = io.add((double)1); //[1,2] DoubleVector b = a.neg(); //[-1,-2] double[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1567,19 +1603,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); DoubleVector uab0 = zab0.rearrange(unz0,zab1); DoubleVector uab1 = zab0.rearrange(unz1,zab1); double[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { DoubleVector io = (DoubleVector) SPECIES.broadcast(0).addIndex(1); DoubleVector io2 = (DoubleVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1596,15 +1632,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static double ADD(double a, double b) { diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java index b85697cf753f5..8140ad6ba11fd 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java @@ -64,6 +64,49 @@ public class Float128VectorTests extends AbstractVectorTest { static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + static void AssertEquals(float actual, float expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float actual, float expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(float actual, float expected, float delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(float actual, float expected, float delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(float [] actual, float [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float [] actual, float [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -91,10 +134,10 @@ static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +190,13 @@ static void assertReductionArraysEquals(float[] r, float rc, float[] a, float relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +218,13 @@ static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, bo float relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +240,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +262,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +280,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +295,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +307,12 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +323,20 @@ static void assertcompressArraysEquals(float[] r, float[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (float)0); + AssertEquals(r[i + k], (float)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -306,19 +348,19 @@ static void assertexpandArraysEquals(float[] r, float[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (float)0); + AssertEquals(r[i + j], (float)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -334,11 +376,11 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +392,11 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +406,17 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +429,16 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +452,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +476,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +502,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +521,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +532,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +543,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +555,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +571,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +586,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +601,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +619,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +635,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +653,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +679,11 @@ static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +697,11 @@ static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +721,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +736,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +748,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +761,10 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +780,11 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +801,11 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +816,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +837,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +933,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +960,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +981,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1008,13 @@ static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1028,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1049,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1070,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1092,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1148,10 @@ static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1198,10 @@ static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1167,10 +1209,10 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1558,7 +1600,7 @@ static void smokeTest2() { // Do some zipping and shuffling. FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); FloatVector a = io.add((float)1); //[1,2] FloatVector b = a.neg(); //[-1,-2] float[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1573,19 +1615,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); FloatVector uab0 = zab0.rearrange(unz0,zab1); FloatVector uab1 = zab0.rearrange(unz1,zab1); float[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1602,15 +1644,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static float ADD(float a, float b) { diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java index 578bfa4729109..b9068673dc217 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java @@ -64,6 +64,49 @@ public class Float256VectorTests extends AbstractVectorTest { static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + static void AssertEquals(float actual, float expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float actual, float expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(float actual, float expected, float delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(float actual, float expected, float delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(float [] actual, float [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float [] actual, float [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -91,10 +134,10 @@ static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +190,13 @@ static void assertReductionArraysEquals(float[] r, float rc, float[] a, float relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +218,13 @@ static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, bo float relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +240,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +262,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +280,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +295,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +307,12 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +323,20 @@ static void assertcompressArraysEquals(float[] r, float[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (float)0); + AssertEquals(r[i + k], (float)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -306,19 +348,19 @@ static void assertexpandArraysEquals(float[] r, float[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (float)0); + AssertEquals(r[i + j], (float)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -334,11 +376,11 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +392,11 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +406,17 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +429,16 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +452,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +476,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +502,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +521,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +532,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +543,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +555,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +571,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +586,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +601,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +619,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +635,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +653,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +679,11 @@ static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +697,11 @@ static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +721,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +736,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +748,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +761,10 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +780,11 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +801,11 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +816,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +837,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +933,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +960,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +981,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1008,13 @@ static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1028,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1049,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1070,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1092,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1148,10 @@ static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1198,10 @@ static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1167,10 +1209,10 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1558,7 +1600,7 @@ static void smokeTest2() { // Do some zipping and shuffling. FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); FloatVector a = io.add((float)1); //[1,2] FloatVector b = a.neg(); //[-1,-2] float[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1573,19 +1615,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); FloatVector uab0 = zab0.rearrange(unz0,zab1); FloatVector uab1 = zab0.rearrange(unz1,zab1); float[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1602,15 +1644,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static float ADD(float a, float b) { diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java index a759f756cd3e4..78726c99443f2 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java @@ -64,6 +64,49 @@ public class Float512VectorTests extends AbstractVectorTest { static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + static void AssertEquals(float actual, float expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float actual, float expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(float actual, float expected, float delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(float actual, float expected, float delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(float [] actual, float [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float [] actual, float [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -91,10 +134,10 @@ static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +190,13 @@ static void assertReductionArraysEquals(float[] r, float rc, float[] a, float relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +218,13 @@ static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, bo float relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +240,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +262,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +280,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +295,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +307,12 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +323,20 @@ static void assertcompressArraysEquals(float[] r, float[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (float)0); + AssertEquals(r[i + k], (float)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -306,19 +348,19 @@ static void assertexpandArraysEquals(float[] r, float[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (float)0); + AssertEquals(r[i + j], (float)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -334,11 +376,11 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +392,11 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +406,17 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +429,16 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +452,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +476,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +502,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +521,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +532,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +543,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +555,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +571,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +586,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +601,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +619,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +635,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +653,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +679,11 @@ static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +697,11 @@ static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +721,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +736,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +748,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +761,10 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +780,11 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +801,11 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +816,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +837,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +933,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +960,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +981,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1008,13 @@ static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1028,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1049,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1070,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1092,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1148,10 @@ static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1198,10 @@ static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1167,10 +1209,10 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1558,7 +1600,7 @@ static void smokeTest2() { // Do some zipping and shuffling. FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); FloatVector a = io.add((float)1); //[1,2] FloatVector b = a.neg(); //[-1,-2] float[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1573,19 +1615,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); FloatVector uab0 = zab0.rearrange(unz0,zab1); FloatVector uab1 = zab0.rearrange(unz1,zab1); float[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1602,15 +1644,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static float ADD(float a, float b) { diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java index d47e9bd8d4a39..93d08f7f95810 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java @@ -64,6 +64,49 @@ public class Float64VectorTests extends AbstractVectorTest { static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + static void AssertEquals(float actual, float expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float actual, float expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(float actual, float expected, float delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(float actual, float expected, float delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(float [] actual, float [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float [] actual, float [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final float RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (float)10.0; @@ -91,10 +134,10 @@ static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -147,13 +190,13 @@ static void assertReductionArraysEquals(float[] r, float rc, float[] a, float relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -175,14 +218,13 @@ static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, bo float relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -198,13 +240,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -220,13 +262,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -238,10 +280,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -253,10 +295,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -265,12 +307,12 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -281,20 +323,20 @@ static void assertcompressArraysEquals(float[] r, float[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (float)0); + AssertEquals(r[i + k], (float)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -306,19 +348,19 @@ static void assertexpandArraysEquals(float[] r, float[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (float)0); + AssertEquals(r[i + j], (float)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -334,11 +376,11 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -350,11 +392,11 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -364,17 +406,17 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -387,16 +429,16 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -410,10 +452,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -434,18 +476,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -460,18 +502,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -479,10 +521,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -490,10 +532,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -501,10 +543,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -513,10 +555,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -529,10 +571,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -544,10 +586,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -559,10 +601,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -577,10 +619,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -593,11 +635,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -611,11 +653,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -637,11 +679,11 @@ static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -655,11 +697,11 @@ static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -679,10 +721,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -694,10 +736,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -706,10 +748,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -719,10 +761,10 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -738,11 +780,11 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -759,11 +801,11 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -774,11 +816,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -795,11 +837,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -891,13 +933,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -918,13 +960,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -939,13 +981,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -966,13 +1008,13 @@ static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -986,13 +1028,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1007,13 +1049,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1028,13 +1070,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1050,13 +1092,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1106,10 +1148,10 @@ static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1156,10 +1198,10 @@ static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1167,10 +1209,10 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1558,7 +1600,7 @@ static void smokeTest2() { // Do some zipping and shuffling. FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); FloatVector a = io.add((float)1); //[1,2] FloatVector b = a.neg(); //[-1,-2] float[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1573,19 +1615,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); FloatVector uab0 = zab0.rearrange(unz0,zab1); FloatVector uab1 = zab0.rearrange(unz1,zab1); float[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1602,15 +1644,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static float ADD(float a, float b) { diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java index a5a17acc9496a..e0d806dddf6f5 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java @@ -64,6 +64,49 @@ public class FloatMaxVectorTests extends AbstractVectorTest { static FloatVector bcast_vec = FloatVector.broadcast(SPECIES, (float)10); + static void AssertEquals(float actual, float expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float actual, float expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(float actual, float expected, float delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(float actual, float expected, float delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(float [] actual, float [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(float [] actual, float [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -96,10 +139,10 @@ static void assertArraysEquals(float[] r, float[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -111,13 +154,13 @@ static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { float[] ref = f.apply(a[i]); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -127,10 +170,10 @@ static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -152,13 +195,13 @@ static void assertReductionArraysEquals(float[] r, float rc, float[] a, float relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + 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.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor, "at index #" + i); } } @@ -180,14 +223,13 @@ static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, bo float relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); } } @@ -203,13 +245,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, float[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -225,13 +267,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -243,10 +285,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -258,10 +300,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -270,12 +312,12 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -286,20 +328,20 @@ static void assertcompressArraysEquals(float[] r, float[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (float)0); + AssertEquals(r[i + k], (float)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -311,19 +353,19 @@ static void assertexpandArraysEquals(float[] r, float[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (float)0); + AssertEquals(r[i + j], (float)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (float)0, "at index #" + idx); + AssertEquals(r[idx], (float)0, "at index #" + idx); } } } @@ -339,11 +381,11 @@ static void assertSelectFromTwoVectorEquals(float[] r, float[] order, float[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -355,11 +397,11 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -369,17 +411,17 @@ static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,16 +434,16 @@ static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (float)0); + AssertEquals(r[i+j], (float)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -415,10 +457,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -439,18 +481,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -465,18 +507,18 @@ static void assertArraysEqualsAssociative(float[] rl, float[] rr, float[] a, flo for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -484,10 +526,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -495,10 +537,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -506,10 +548,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -518,10 +560,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -534,10 +576,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -549,10 +591,10 @@ static void assertArraysEquals(float[] r, float[] a, float b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -564,10 +606,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -582,10 +624,10 @@ static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -598,11 +640,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -616,11 +658,11 @@ static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -642,11 +684,11 @@ static void assertShiftConstEquals(float[] r, float[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -660,11 +702,11 @@ static void assertShiftConstEquals(float[] r, float[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -684,10 +726,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -699,10 +741,10 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -711,10 +753,10 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -724,10 +766,10 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -743,11 +785,11 @@ static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -764,11 +806,11 @@ static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, floa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -779,11 +821,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -800,11 +842,11 @@ static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -896,13 +938,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -923,13 +965,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -944,13 +986,13 @@ static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { float[] ref = f.apply(r, a, i, mask, b, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -971,13 +1013,13 @@ static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -991,13 +1033,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1012,13 +1054,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1033,13 +1075,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1055,13 +1097,13 @@ static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { float[] ref = f.apply(a, b, origin, part, mask, i); float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1111,10 +1153,10 @@ static void assertArraysEquals(int[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1161,10 +1203,10 @@ static void assertArraysEquals(long[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1172,10 +1214,10 @@ static void assertArraysEquals(double[] r, float[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1563,7 +1605,7 @@ static void smokeTest2() { // Do some zipping and shuffling. FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); FloatVector a = io.add((float)1); //[1,2] FloatVector b = a.neg(); //[-1,-2] float[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1578,19 +1620,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); FloatVector uab0 = zab0.rearrange(unz0,zab1); FloatVector uab1 = zab0.rearrange(unz1,zab1); float[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1); FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1607,15 +1649,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static float ADD(float a, float b) { diff --git a/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java index 8b5a7158cdb00..592a7d13702d0 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat128VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Halffloat128VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -65,6 +65,55 @@ public class Halffloat128VectorTests extends AbstractVectorTest { static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta)); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta), msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i])); + } + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i]), msg); + } + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; @@ -92,10 +141,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -107,13 +156,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -123,10 +172,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -148,13 +197,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -176,14 +225,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -199,13 +247,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -221,13 +269,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -239,10 +287,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -254,10 +302,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -266,12 +314,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -282,20 +330,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -307,19 +355,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -335,11 +383,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -351,11 +399,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -365,17 +413,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -388,16 +436,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -411,10 +459,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -435,18 +483,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,18 +509,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -480,10 +528,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -491,10 +539,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -502,10 +550,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -514,10 +562,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -530,10 +578,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -545,10 +593,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -560,10 +608,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -578,10 +626,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -594,11 +642,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -612,11 +660,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -638,11 +686,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -656,11 +704,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -680,10 +728,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -695,10 +743,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -707,10 +755,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -720,10 +768,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -739,11 +787,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -760,11 +808,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -775,11 +823,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -796,11 +844,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -894,13 +942,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -921,13 +969,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -942,13 +990,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -969,13 +1017,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -989,13 +1037,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1010,13 +1058,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1031,13 +1079,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1053,13 +1101,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1109,10 +1157,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1159,10 +1207,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1170,10 +1218,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1568,7 +1616,7 @@ static void smokeTest2() { // Do some zipping and shuffling. HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); HalffloatVector a = io.add((short)1); //[1,2] HalffloatVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1583,19 +1631,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); HalffloatVector uab0 = zab0.rearrange(unz0,zab1); HalffloatVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1612,15 +1660,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static short ADD(short a, short b) { diff --git a/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java index 5c8e853ac1bb3..d0e29d46b606f 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat256VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Halffloat256VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -65,6 +65,55 @@ public class Halffloat256VectorTests extends AbstractVectorTest { static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta)); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta), msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i])); + } + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i]), msg); + } + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; @@ -92,10 +141,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -107,13 +156,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -123,10 +172,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -148,13 +197,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -176,14 +225,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -199,13 +247,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -221,13 +269,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -239,10 +287,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -254,10 +302,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -266,12 +314,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -282,20 +330,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -307,19 +355,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -335,11 +383,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -351,11 +399,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -365,17 +413,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -388,16 +436,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -411,10 +459,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -435,18 +483,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,18 +509,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -480,10 +528,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -491,10 +539,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -502,10 +550,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -514,10 +562,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -530,10 +578,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -545,10 +593,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -560,10 +608,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -578,10 +626,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -594,11 +642,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -612,11 +660,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -638,11 +686,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -656,11 +704,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -680,10 +728,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -695,10 +743,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -707,10 +755,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -720,10 +768,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -739,11 +787,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -760,11 +808,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -775,11 +823,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -796,11 +844,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -894,13 +942,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -921,13 +969,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -942,13 +990,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -969,13 +1017,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -989,13 +1037,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1010,13 +1058,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1031,13 +1079,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1053,13 +1101,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1109,10 +1157,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1159,10 +1207,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1170,10 +1218,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1568,7 +1616,7 @@ static void smokeTest2() { // Do some zipping and shuffling. HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); HalffloatVector a = io.add((short)1); //[1,2] HalffloatVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1583,19 +1631,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); HalffloatVector uab0 = zab0.rearrange(unz0,zab1); HalffloatVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1612,15 +1660,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static short ADD(short a, short b) { diff --git a/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java index 5916ba3e9c9c4..82546dc8ca237 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat512VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Halffloat512VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -65,6 +65,55 @@ public class Halffloat512VectorTests extends AbstractVectorTest { static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta)); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta), msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i])); + } + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i]), msg); + } + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; @@ -92,10 +141,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -107,13 +156,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -123,10 +172,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -148,13 +197,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -176,14 +225,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -199,13 +247,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -221,13 +269,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -239,10 +287,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -254,10 +302,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -266,12 +314,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -282,20 +330,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -307,19 +355,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -335,11 +383,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -351,11 +399,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -365,17 +413,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -388,16 +436,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -411,10 +459,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -435,18 +483,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,18 +509,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -480,10 +528,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -491,10 +539,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -502,10 +550,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -514,10 +562,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -530,10 +578,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -545,10 +593,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -560,10 +608,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -578,10 +626,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -594,11 +642,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -612,11 +660,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -638,11 +686,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -656,11 +704,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -680,10 +728,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -695,10 +743,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -707,10 +755,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -720,10 +768,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -739,11 +787,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -760,11 +808,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -775,11 +823,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -796,11 +844,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -894,13 +942,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -921,13 +969,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -942,13 +990,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -969,13 +1017,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -989,13 +1037,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1010,13 +1058,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1031,13 +1079,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1053,13 +1101,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1109,10 +1157,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1159,10 +1207,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1170,10 +1218,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1568,7 +1616,7 @@ static void smokeTest2() { // Do some zipping and shuffling. HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); HalffloatVector a = io.add((short)1); //[1,2] HalffloatVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1583,19 +1631,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); HalffloatVector uab0 = zab0.rearrange(unz0,zab1); HalffloatVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1612,15 +1660,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static short ADD(short a, short b) { diff --git a/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java index 87e6311030dd4..4e4b36ac82c61 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 Halffloat64VectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation Halffloat64VectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -65,6 +65,55 @@ public class Halffloat64VectorTests extends AbstractVectorTest { static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta)); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta), msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i])); + } + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i]), msg); + } + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + // for floating point addition reduction ops that may introduce rounding errors private static final short RELATIVE_ROUNDING_ERROR_FACTOR_ADD = (short)10.0; @@ -92,10 +141,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -107,13 +156,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -123,10 +172,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -148,13 +197,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -176,14 +225,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -199,13 +247,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -221,13 +269,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -239,10 +287,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -254,10 +302,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -266,12 +314,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -282,20 +330,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -307,19 +355,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -335,11 +383,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -351,11 +399,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -365,17 +413,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -388,16 +436,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -411,10 +459,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -435,18 +483,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,18 +509,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -480,10 +528,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -491,10 +539,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -502,10 +550,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -514,10 +562,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -530,10 +578,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -545,10 +593,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -560,10 +608,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -578,10 +626,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -594,11 +642,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -612,11 +660,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -638,11 +686,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -656,11 +704,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -680,10 +728,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -695,10 +743,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -707,10 +755,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -720,10 +768,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -739,11 +787,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -760,11 +808,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -775,11 +823,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -796,11 +844,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -894,13 +942,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -921,13 +969,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -942,13 +990,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -969,13 +1017,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -989,13 +1037,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1010,13 +1058,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1031,13 +1079,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1053,13 +1101,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1109,10 +1157,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1159,10 +1207,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1170,10 +1218,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1568,7 +1616,7 @@ static void smokeTest2() { // Do some zipping and shuffling. HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); HalffloatVector a = io.add((short)1); //[1,2] HalffloatVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1583,19 +1631,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); HalffloatVector uab0 = zab0.rearrange(unz0,zab1); HalffloatVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1612,15 +1660,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static short ADD(short a, short b) { diff --git a/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java index 0060ceaf43346..3655ccbab8800 100644 --- a/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:TieredStopAtLevel=3 HalffloatMaxVectorTests + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation HalffloatMaxVectorTests */ // -- This file was mechanically generated: Do not edit! -- // @@ -65,6 +65,55 @@ public class HalffloatMaxVectorTests extends AbstractVectorTest { static HalffloatVector bcast_vec = HalffloatVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta)); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta), msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i])); + } + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i]), msg); + } + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -97,10 +146,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -112,13 +161,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -128,10 +177,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -153,13 +202,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -181,14 +230,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -204,13 +252,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -226,13 +274,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -244,10 +292,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -259,10 +307,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -271,12 +319,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -287,20 +335,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -312,19 +360,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -340,11 +388,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -356,11 +404,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -370,17 +418,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -393,16 +441,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -416,10 +464,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -440,18 +488,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -466,18 +514,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -485,10 +533,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -496,10 +544,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -507,10 +555,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -519,10 +567,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -535,10 +583,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -550,10 +598,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -565,10 +613,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -583,10 +631,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -599,11 +647,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -617,11 +665,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -643,11 +691,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -661,11 +709,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -685,10 +733,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -700,10 +748,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -712,10 +760,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -725,10 +773,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -744,11 +792,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -765,11 +813,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -780,11 +828,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -801,11 +849,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -899,13 +947,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -926,13 +974,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -947,13 +995,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -974,13 +1022,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -994,13 +1042,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1015,13 +1063,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1036,13 +1084,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1058,13 +1106,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1114,10 +1162,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1164,10 +1212,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1175,10 +1223,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1573,7 +1621,7 @@ static void smokeTest2() { // Do some zipping and shuffling. HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); HalffloatVector a = io.add((short)1); //[1,2] HalffloatVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1588,19 +1636,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); HalffloatVector uab0 = zab0.rearrange(unz0,zab1); HalffloatVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { HalffloatVector io = (HalffloatVector) SPECIES.broadcast(0).addIndex(1); HalffloatVector io2 = (HalffloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1617,15 +1665,15 @@ void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); } @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } static short ADD(short a, short b) { diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index 2dff3ee250ea4..19454bb8555bd 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -65,6 +65,49 @@ public class Int128VectorTests extends AbstractVectorTest { static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + static void AssertEquals(int actual, int expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int actual, int expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(int actual, int expected, int delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(int actual, int expected, int delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(int [] actual, int [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int [] actual, int [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[ FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, bo FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vecto try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(int[] r, int[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (int)0); + AssertEquals(r[i + k], (int)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(int[] r, int[] a, boolean[] m, int vector_l k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (int)0); + AssertEquals(r[i + j], (int)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vect for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[ idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, boolean[] mask, FBinMask int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, F try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMa try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTer int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGathe int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatt int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1496,7 +1539,7 @@ static void smokeTest2() { // Do some zipping and shuffling. IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); IntVector a = io.add((int)1); //[1,2] IntVector b = a.neg(); //[-1,-2] int[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1511,19 +1554,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); IntVector uab0 = zab0.rearrange(unz0,zab1); IntVector uab1 = zab0.rearrange(unz1,zab1); int[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1538,7 +1581,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1546,9 +1589,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index 606e5504dee5d..6bd7b67938f13 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -65,6 +65,49 @@ public class Int256VectorTests extends AbstractVectorTest { static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + static void AssertEquals(int actual, int expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int actual, int expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(int actual, int expected, int delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(int actual, int expected, int delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(int [] actual, int [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int [] actual, int [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[ FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, bo FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vecto try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(int[] r, int[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (int)0); + AssertEquals(r[i + k], (int)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(int[] r, int[] a, boolean[] m, int vector_l k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (int)0); + AssertEquals(r[i + j], (int)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vect for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[ idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, boolean[] mask, FBinMask int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, F try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMa try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTer int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGathe int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatt int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1496,7 +1539,7 @@ static void smokeTest2() { // Do some zipping and shuffling. IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); IntVector a = io.add((int)1); //[1,2] IntVector b = a.neg(); //[-1,-2] int[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1511,19 +1554,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); IntVector uab0 = zab0.rearrange(unz0,zab1); IntVector uab1 = zab0.rearrange(unz1,zab1); int[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1538,7 +1581,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1546,9 +1589,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index 5f67c3a4f7290..9dfa034eb8982 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -65,6 +65,49 @@ public class Int512VectorTests extends AbstractVectorTest { static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + static void AssertEquals(int actual, int expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int actual, int expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(int actual, int expected, int delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(int actual, int expected, int delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(int [] actual, int [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int [] actual, int [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[ FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, bo FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vecto try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(int[] r, int[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (int)0); + AssertEquals(r[i + k], (int)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(int[] r, int[] a, boolean[] m, int vector_l k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (int)0); + AssertEquals(r[i + j], (int)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vect for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[ idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, boolean[] mask, FBinMask int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, F try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMa try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTer int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGathe int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatt int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1496,7 +1539,7 @@ static void smokeTest2() { // Do some zipping and shuffling. IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); IntVector a = io.add((int)1); //[1,2] IntVector b = a.neg(); //[-1,-2] int[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1511,19 +1554,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); IntVector uab0 = zab0.rearrange(unz0,zab1); IntVector uab1 = zab0.rearrange(unz1,zab1); int[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1538,7 +1581,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1546,9 +1589,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index c872efcecd524..ccffe8c5e067e 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -65,6 +65,49 @@ public class Int64VectorTests extends AbstractVectorTest { static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + static void AssertEquals(int actual, int expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int actual, int expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(int actual, int expected, int delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(int actual, int expected, int delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(int [] actual, int [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int [] actual, int [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final int CONST_SHIFT = Integer.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[ FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, bo FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vecto try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(int[] r, int[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (int)0); + AssertEquals(r[i + k], (int)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(int[] r, int[] a, boolean[] m, int vector_l k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (int)0); + AssertEquals(r[i + j], (int)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vect for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[ idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, boolean[] mask, FBinMask int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, F try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMa try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTer int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGathe int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatt int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1496,7 +1539,7 @@ static void smokeTest2() { // Do some zipping and shuffling. IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); IntVector a = io.add((int)1); //[1,2] IntVector b = a.neg(); //[-1,-2] int[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1511,19 +1554,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); IntVector uab0 = zab0.rearrange(unz0,zab1); IntVector uab1 = zab0.rearrange(unz1,zab1); int[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1538,7 +1581,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1546,9 +1589,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index 6b6f9576ad9c9..fe2abe2450dea 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -65,6 +65,49 @@ public class IntMaxVectorTests extends AbstractVectorTest { static IntVector bcast_vec = IntVector.broadcast(SPECIES, (int)10); + static void AssertEquals(int actual, int expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int actual, int expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(int actual, int expected, int delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(int actual, int expected, int delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(int [] actual, int [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(int [] actual, int [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -91,10 +134,10 @@ static void assertArraysEquals(int[] r, int[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(int[] r, int[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { int[] ref = f.apply(a[i]); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(int[] r, int[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -141,13 +184,13 @@ static void assertReductionArraysEquals(int[] r, int rc, int[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -163,13 +206,13 @@ static void assertReductionArraysEqualsMasked(int[] r, int rc, int[] a, boolean[ FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -185,13 +228,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, int[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -207,13 +250,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, int[] a, bo FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -225,10 +268,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -240,10 +283,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -252,12 +295,12 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, int vecto try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -268,20 +311,20 @@ static void assertcompressArraysEquals(int[] r, int[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (int)0); + AssertEquals(r[i + k], (int)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -293,19 +336,19 @@ static void assertexpandArraysEquals(int[] r, int[] a, boolean[] m, int vector_l k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (int)0); + AssertEquals(r[i + j], (int)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (int)0, "at index #" + idx); + AssertEquals(r[idx], (int)0, "at index #" + idx); } } } @@ -321,11 +364,11 @@ static void assertSelectFromTwoVectorEquals(int[] r, int[] order, int[] a, int[] wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -337,11 +380,11 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, int vect for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -351,17 +394,17 @@ static void assertRearrangeArraysEquals(int[] r, int[] a, int[] order, boolean[] for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -374,16 +417,16 @@ static void assertSelectFromArraysEquals(int[] r, int[] a, int[] order, boolean[ idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (int)0); + AssertEquals(r[i+j], (int)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (int)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -397,10 +440,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -421,18 +464,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -447,18 +490,18 @@ static void assertArraysEqualsAssociative(int[] rl, int[] rr, int[] a, int[] b, for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -466,10 +509,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -477,10 +520,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -488,10 +531,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -500,10 +543,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -516,10 +559,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FBinMa int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -531,10 +574,10 @@ static void assertArraysEquals(int[] r, int[] a, int b, boolean[] mask, FBinMask int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -546,10 +589,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -564,10 +607,10 @@ static void assertBroadcastLongArraysEquals(int[] r, int[] a, int[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (int)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -580,11 +623,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -598,11 +641,11 @@ static void assertShiftArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, F try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -624,11 +667,11 @@ static void assertShiftConstEquals(int[] r, int[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -642,11 +685,11 @@ static void assertShiftConstEquals(int[] r, int[] a, boolean[] mask, FBinConstMa try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -666,10 +709,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, FTernOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -681,10 +724,10 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int[] c, boolean[] mas int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -693,10 +736,10 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, FTer int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -706,10 +749,10 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, F int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -725,11 +768,11 @@ static void assertBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, bool int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -746,11 +789,11 @@ static void assertAltBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c, b int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -761,11 +804,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -782,11 +825,11 @@ static void assertDoubleBroadcastArraysEquals(int[] r, int[] a, int[] b, int[] c int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -804,13 +847,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, FGatherScatterOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +874,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FGathe int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -852,13 +895,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, boolean[] mask, FScatt int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { int[] ref = f.apply(r, a, i, mask, b, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -879,13 +922,13 @@ static void assertArraysEquals(int[] r, int[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -899,13 +942,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, FLaneBop f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -920,13 +963,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, boolean[] int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -941,13 +984,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -963,13 +1006,13 @@ static void assertArraysEquals(int[] r, int[] a, int[] b, int origin, int part, int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { int[] ref = f.apply(a, b, origin, part, mask, i); int[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -986,10 +1029,10 @@ static void assertArraysEquals(int[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -999,10 +1042,10 @@ static void assertArraysEquals(long[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1010,10 +1053,10 @@ static void assertArraysEquals(double[] r, int[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1501,7 +1544,7 @@ static void smokeTest2() { // Do some zipping and shuffling. IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); IntVector a = io.add((int)1); //[1,2] IntVector b = a.neg(); //[-1,-2] int[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1516,19 +1559,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); IntVector uab0 = zab0.rearrange(unz0,zab1); IntVector uab1 = zab0.rearrange(unz1,zab1); int[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { IntVector io = (IntVector) SPECIES.broadcast(0).addIndex(1); IntVector io2 = (IntVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1543,7 +1586,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1551,9 +1594,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index 909a98367b249..054972cfd8447 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -65,6 +65,43 @@ public class Long128VectorTests extends AbstractVectorTest { static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected, long delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(long actual, long expected, long delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(long [] actual, long [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long [] actual, long [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -86,10 +123,10 @@ static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +138,13 @@ static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +154,10 @@ static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +173,13 @@ static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +195,13 @@ static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -177,10 +214,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -192,10 +229,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -204,12 +241,12 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -220,20 +257,20 @@ static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (long)0); + AssertEquals(r[i + k], (long)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -245,19 +282,19 @@ static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (long)0); + AssertEquals(r[i + j], (long)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -273,11 +310,11 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -289,11 +326,11 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -303,17 +340,17 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -326,16 +363,16 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -349,10 +386,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -373,18 +410,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -399,18 +436,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -418,10 +455,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -429,10 +466,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -440,10 +477,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -452,10 +489,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -468,10 +505,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -483,10 +520,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -498,10 +535,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -516,10 +553,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -532,11 +569,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -550,11 +587,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -576,11 +613,11 @@ static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -594,11 +631,11 @@ static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -618,10 +655,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -633,10 +670,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -645,10 +682,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -658,10 +695,10 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -677,11 +714,11 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -698,11 +735,11 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -713,11 +750,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -734,11 +771,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -756,13 +793,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -783,13 +820,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -804,13 +841,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +868,13 @@ static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -851,13 +888,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -872,13 +909,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -893,13 +930,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -915,13 +952,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -971,10 +1008,10 @@ static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -984,10 +1021,10 @@ static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -995,10 +1032,10 @@ static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1518,7 +1555,7 @@ static void smokeTest2() { // Do some zipping and shuffling. LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); LongVector a = io.add((long)1); //[1,2] LongVector b = a.neg(); //[-1,-2] long[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1533,19 +1570,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); LongVector uab0 = zab0.rearrange(unz0,zab1); LongVector uab1 = zab0.rearrange(unz1,zab1); long[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1560,7 +1597,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1568,9 +1605,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index bcad310e6be83..31e93fe9559a4 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -65,6 +65,43 @@ public class Long256VectorTests extends AbstractVectorTest { static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected, long delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(long actual, long expected, long delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(long [] actual, long [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long [] actual, long [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -86,10 +123,10 @@ static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +138,13 @@ static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +154,10 @@ static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +173,13 @@ static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +195,13 @@ static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -177,10 +214,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -192,10 +229,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -204,12 +241,12 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -220,20 +257,20 @@ static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (long)0); + AssertEquals(r[i + k], (long)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -245,19 +282,19 @@ static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (long)0); + AssertEquals(r[i + j], (long)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -273,11 +310,11 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -289,11 +326,11 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -303,17 +340,17 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -326,16 +363,16 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -349,10 +386,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -373,18 +410,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -399,18 +436,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -418,10 +455,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -429,10 +466,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -440,10 +477,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -452,10 +489,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -468,10 +505,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -483,10 +520,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -498,10 +535,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -516,10 +553,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -532,11 +569,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -550,11 +587,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -576,11 +613,11 @@ static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -594,11 +631,11 @@ static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -618,10 +655,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -633,10 +670,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -645,10 +682,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -658,10 +695,10 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -677,11 +714,11 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -698,11 +735,11 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -713,11 +750,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -734,11 +771,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -756,13 +793,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -783,13 +820,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -804,13 +841,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +868,13 @@ static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -851,13 +888,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -872,13 +909,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -893,13 +930,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -915,13 +952,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -971,10 +1008,10 @@ static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -984,10 +1021,10 @@ static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -995,10 +1032,10 @@ static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1518,7 +1555,7 @@ static void smokeTest2() { // Do some zipping and shuffling. LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); LongVector a = io.add((long)1); //[1,2] LongVector b = a.neg(); //[-1,-2] long[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1533,19 +1570,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); LongVector uab0 = zab0.rearrange(unz0,zab1); LongVector uab1 = zab0.rearrange(unz1,zab1); long[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1560,7 +1597,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1568,9 +1605,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index 3112e35fa1a07..19e115bb7bc7e 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -65,6 +65,43 @@ public class Long512VectorTests extends AbstractVectorTest { static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected, long delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(long actual, long expected, long delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(long [] actual, long [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long [] actual, long [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -86,10 +123,10 @@ static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +138,13 @@ static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +154,10 @@ static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +173,13 @@ static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +195,13 @@ static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -177,10 +214,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -192,10 +229,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -204,12 +241,12 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -220,20 +257,20 @@ static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (long)0); + AssertEquals(r[i + k], (long)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -245,19 +282,19 @@ static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (long)0); + AssertEquals(r[i + j], (long)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -273,11 +310,11 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -289,11 +326,11 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -303,17 +340,17 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -326,16 +363,16 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -349,10 +386,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -373,18 +410,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -399,18 +436,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -418,10 +455,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -429,10 +466,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -440,10 +477,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -452,10 +489,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -468,10 +505,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -483,10 +520,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -498,10 +535,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -516,10 +553,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -532,11 +569,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -550,11 +587,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -576,11 +613,11 @@ static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -594,11 +631,11 @@ static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -618,10 +655,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -633,10 +670,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -645,10 +682,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -658,10 +695,10 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -677,11 +714,11 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -698,11 +735,11 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -713,11 +750,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -734,11 +771,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -756,13 +793,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -783,13 +820,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -804,13 +841,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +868,13 @@ static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -851,13 +888,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -872,13 +909,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -893,13 +930,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -915,13 +952,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -971,10 +1008,10 @@ static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -984,10 +1021,10 @@ static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -995,10 +1032,10 @@ static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1518,7 +1555,7 @@ static void smokeTest2() { // Do some zipping and shuffling. LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); LongVector a = io.add((long)1); //[1,2] LongVector b = a.neg(); //[-1,-2] long[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1533,19 +1570,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); LongVector uab0 = zab0.rearrange(unz0,zab1); LongVector uab1 = zab0.rearrange(unz1,zab1); long[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1560,7 +1597,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1568,9 +1605,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index 60507fdaa6797..d5c4f3ae2459c 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -65,6 +65,43 @@ public class Long64VectorTests extends AbstractVectorTest { static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected, long delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(long actual, long expected, long delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(long [] actual, long [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long [] actual, long [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final long CONST_SHIFT = Long.SIZE / 2; @@ -86,10 +123,10 @@ static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +138,13 @@ static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +154,10 @@ static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +173,13 @@ static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +195,13 @@ static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -177,10 +214,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -192,10 +229,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -204,12 +241,12 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -220,20 +257,20 @@ static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (long)0); + AssertEquals(r[i + k], (long)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -245,19 +282,19 @@ static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (long)0); + AssertEquals(r[i + j], (long)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -273,11 +310,11 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -289,11 +326,11 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -303,17 +340,17 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -326,16 +363,16 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -349,10 +386,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -373,18 +410,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -399,18 +436,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -418,10 +455,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -429,10 +466,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -440,10 +477,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -452,10 +489,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -468,10 +505,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -483,10 +520,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -498,10 +535,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -516,10 +553,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -532,11 +569,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -550,11 +587,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -576,11 +613,11 @@ static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -594,11 +631,11 @@ static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -618,10 +655,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -633,10 +670,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -645,10 +682,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -658,10 +695,10 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -677,11 +714,11 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -698,11 +735,11 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -713,11 +750,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -734,11 +771,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -756,13 +793,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -783,13 +820,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -804,13 +841,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +868,13 @@ static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -851,13 +888,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -872,13 +909,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -893,13 +930,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -915,13 +952,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -971,10 +1008,10 @@ static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -984,10 +1021,10 @@ static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -995,10 +1032,10 @@ static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1518,7 +1555,7 @@ static void smokeTest2() { // Do some zipping and shuffling. LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); LongVector a = io.add((long)1); //[1,2] LongVector b = a.neg(); //[-1,-2] long[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1533,19 +1570,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); LongVector uab0 = zab0.rearrange(unz0,zab1); LongVector uab1 = zab0.rearrange(unz1,zab1); long[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1560,7 +1597,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1568,9 +1605,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index 1961fe5603614..027568e2588a0 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -65,6 +65,43 @@ public class LongMaxVectorTests extends AbstractVectorTest { static LongVector bcast_vec = LongVector.broadcast(SPECIES, (long)10); + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected, long delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(long actual, long expected, long delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(long [] actual, long [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long [] actual, long [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -91,10 +128,10 @@ static void assertArraysEquals(long[] r, long[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +143,13 @@ static void assertArraysEquals(long[] r, long[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { long[] ref = f.apply(a[i]); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +159,10 @@ static void assertArraysEquals(long[] r, long[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -141,13 +178,13 @@ static void assertReductionArraysEquals(long[] r, long rc, long[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -163,13 +200,13 @@ static void assertReductionArraysEqualsMasked(long[] r, long rc, long[] a, boole FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -182,10 +219,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -197,10 +234,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -209,12 +246,12 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, int vec try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -225,20 +262,20 @@ static void assertcompressArraysEquals(long[] r, long[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (long)0); + AssertEquals(r[i + k], (long)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -250,19 +287,19 @@ static void assertexpandArraysEquals(long[] r, long[] a, boolean[] m, int vector k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (long)0); + AssertEquals(r[i + j], (long)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (long)0, "at index #" + idx); + AssertEquals(r[idx], (long)0, "at index #" + idx); } } } @@ -278,11 +315,11 @@ static void assertSelectFromTwoVectorEquals(long[] r, long[] order, long[] a, lo wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -294,11 +331,11 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, int v for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -308,17 +345,17 @@ static void assertRearrangeArraysEquals(long[] r, long[] a, int[] order, boolean for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -331,16 +368,16 @@ static void assertSelectFromArraysEquals(long[] r, long[] a, long[] order, boole idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (long)0); + AssertEquals(r[i+j], (long)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (long)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -354,10 +391,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -378,18 +415,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -404,18 +441,18 @@ static void assertArraysEqualsAssociative(long[] rl, long[] rr, long[] a, long[] for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -423,10 +460,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -434,10 +471,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -445,10 +482,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, FBinOp f) int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -457,10 +494,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -473,10 +510,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, boolean[] mask, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -488,10 +525,10 @@ static void assertArraysEquals(long[] r, long[] a, long b, boolean[] mask, FBinM int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -503,10 +540,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -521,10 +558,10 @@ static void assertBroadcastLongArraysEquals(long[] r, long[] a, long[] b, boolea int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (long)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -537,11 +574,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -555,11 +592,11 @@ static void assertShiftArraysEquals(long[] r, long[] a, long[] b, boolean[] mask try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -581,11 +618,11 @@ static void assertShiftConstEquals(long[] r, long[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -599,11 +636,11 @@ static void assertShiftConstEquals(long[] r, long[] a, boolean[] mask, FBinConst try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -623,10 +660,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, FTernOp f int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -638,10 +675,10 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, long[] c, boolean[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -650,10 +687,10 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -663,10 +700,10 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -682,11 +719,11 @@ static void assertBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] c, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -703,11 +740,11 @@ static void assertAltBroadcastArraysEquals(long[] r, long[] a, long[] b, long[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -718,11 +755,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -739,11 +776,11 @@ static void assertDoubleBroadcastArraysEquals(long[] r, long[] a, long[] b, long int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -761,13 +798,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, FGatherScatterOp f) int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -788,13 +825,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FGat int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -809,13 +846,13 @@ static void assertArraysEquals(long[] r, long[] a, int[] b, boolean[] mask, FSca int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { long[] ref = f.apply(r, a, i, mask, b, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -836,13 +873,13 @@ static void assertArraysEquals(long[] r, long[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -856,13 +893,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, FLaneBo int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -877,13 +914,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, boolean int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -898,13 +935,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -920,13 +957,13 @@ static void assertArraysEquals(long[] r, long[] a, long[] b, int origin, int par int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { long[] ref = f.apply(a, b, origin, part, mask, i); long[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -976,10 +1013,10 @@ static void assertArraysEquals(int[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -989,10 +1026,10 @@ static void assertArraysEquals(long[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1000,10 +1037,10 @@ static void assertArraysEquals(double[] r, long[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1523,7 +1560,7 @@ static void smokeTest2() { // Do some zipping and shuffling. LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); LongVector a = io.add((long)1); //[1,2] LongVector b = a.neg(); //[-1,-2] long[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1538,19 +1575,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); LongVector uab0 = zab0.rearrange(unz0,zab1); LongVector uab1 = zab0.rearrange(unz1,zab1); long[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { LongVector io = (LongVector) SPECIES.broadcast(0).addIndex(1); LongVector io2 = (LongVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1565,7 +1602,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1573,9 +1610,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index 6ea7358d057c0..68357b1974b58 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -65,6 +65,49 @@ public class Short128VectorTests extends AbstractVectorTest { static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1530,7 +1573,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ShortVector a = io.add((short)1); //[1,2] ShortVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1545,19 +1588,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ShortVector uab0 = zab0.rearrange(unz0,zab1); ShortVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1572,7 +1615,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1580,9 +1623,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index 2b8080aac7075..7a4c39b7d9c36 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -65,6 +65,49 @@ public class Short256VectorTests extends AbstractVectorTest { static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1530,7 +1573,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ShortVector a = io.add((short)1); //[1,2] ShortVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1545,19 +1588,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ShortVector uab0 = zab0.rearrange(unz0,zab1); ShortVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1572,7 +1615,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1580,9 +1623,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index f333a4c9edd7d..05d3b877a686d 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -65,6 +65,49 @@ public class Short512VectorTests extends AbstractVectorTest { static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1530,7 +1573,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ShortVector a = io.add((short)1); //[1,2] ShortVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1545,19 +1588,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ShortVector uab0 = zab0.rearrange(unz0,zab1); ShortVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1572,7 +1615,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1580,9 +1623,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index 353bef63d1b8b..a35915426de01 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -65,6 +65,49 @@ public class Short64VectorTests extends AbstractVectorTest { static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + private static final short CONST_SHIFT = Short.SIZE / 2; @@ -86,10 +129,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -101,13 +144,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -117,10 +160,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -136,13 +179,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -158,13 +201,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -180,13 +223,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -202,13 +245,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -220,10 +263,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -235,10 +278,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -247,12 +290,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -263,20 +306,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -288,19 +331,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -316,11 +359,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -332,11 +375,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -346,17 +389,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -369,16 +412,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -392,10 +435,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -416,18 +459,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -442,18 +485,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -461,10 +504,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -472,10 +515,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -483,10 +526,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -495,10 +538,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -511,10 +554,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -526,10 +569,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -541,10 +584,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -559,10 +602,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -575,11 +618,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -593,11 +636,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -619,11 +662,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -637,11 +680,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -661,10 +704,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -676,10 +719,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -688,10 +731,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -701,10 +744,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -720,11 +763,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -741,11 +784,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -756,11 +799,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -777,11 +820,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -799,13 +842,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -826,13 +869,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -847,13 +890,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -874,13 +917,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -894,13 +937,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -915,13 +958,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -936,13 +979,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -958,13 +1001,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -981,10 +1024,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -994,10 +1037,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1005,10 +1048,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1530,7 +1573,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ShortVector a = io.add((short)1); //[1,2] ShortVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1545,19 +1588,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ShortVector uab0 = zab0.rearrange(unz0,zab1); ShortVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1572,7 +1615,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1580,9 +1623,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index 67dac0c15a19b..df1261272a9be 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -65,6 +65,49 @@ public class ShortMaxVectorTests extends AbstractVectorTest { static ShortVector bcast_vec = ShortVector.broadcast(SPECIES, (short)10); + static void AssertEquals(short actual, short expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short actual, short expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(short actual, short expected, short delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals(short actual, short expected, short delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals(short [] actual, short [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(short [] actual, short [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; } @@ -91,10 +134,10 @@ static void assertArraysEquals(short[] r, short[] a, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -106,13 +149,13 @@ static void assertArraysEquals(short[] r, short[] a, FUnArrayOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { short[] ref = f.apply(a[i]); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -122,10 +165,10 @@ static void assertArraysEquals(short[] r, short[] a, boolean[] mask, FUnOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -141,13 +184,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, FReductionOp f, FReductionAllOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -163,13 +206,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo FReductionMaskedOp f, FReductionAllMaskedOp fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -185,13 +228,13 @@ static void assertReductionLongArraysEquals(long[] r, long rc, short[] a, FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -207,13 +250,13 @@ static void assertReductionLongArraysEqualsMasked(long[] r, long rc, short[] a, FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } @@ -225,10 +268,10 @@ static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReduc int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -240,10 +283,10 @@ static void assertMaskReductionArraysEquals(int[] r, boolean[] a, FMaskReduction int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -252,12 +295,12 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int v try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -268,20 +311,20 @@ static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int ve k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], (short)0); + AssertEquals(r[i + k], (short)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -293,19 +336,19 @@ static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vect k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], (short)0); + AssertEquals(r[i + j], (short)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], (short)0, "at index #" + idx); + AssertEquals(r[idx], (short)0, "at index #" + idx); } } } @@ -321,11 +364,11 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, wrapped_index = Math.floorMod((int)order[idx], 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -337,11 +380,11 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in for (j = 0; j < vector_len; j++) { idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -351,17 +394,17 @@ static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boole for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -374,16 +417,16 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo idx = (int)order[i+j]; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], (short)0); + AssertEquals(r[i+j], (short)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], (short)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -397,10 +440,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a) { try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -421,18 +464,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -447,18 +490,18 @@ static void assertArraysEqualsAssociative(short[] rl, short[] rr, short[] a, sho for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -466,10 +509,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -477,10 +520,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, FBinOp f) { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -488,10 +531,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, FBinOp int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -500,10 +543,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, FBi int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -516,10 +559,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, boolean[] mask, int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -531,10 +574,10 @@ static void assertArraysEquals(short[] r, short[] a, short b, boolean[] mask, FB int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -546,10 +589,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, boolean int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -564,10 +607,10 @@ static void assertBroadcastLongArraysEquals(short[] r, short[] a, short[] b, boo int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], (short)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -580,11 +623,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, FBinOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -598,11 +641,11 @@ static void assertShiftArraysEquals(short[] r, short[] a, short[] b, boolean[] m try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -624,11 +667,11 @@ static void assertShiftConstEquals(short[] r, short[] a, FBinConstOp f) { try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -642,11 +685,11 @@ static void assertShiftConstEquals(short[] r, short[] a, boolean[] mask, FBinCon try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -666,10 +709,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, FTern int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -681,10 +724,10 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, short[] c, boole int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -693,10 +736,10 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -706,10 +749,10 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -725,11 +768,11 @@ static void assertBroadcastArraysEquals(short[] r, short[] a, short[] b, short[] int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -746,11 +789,11 @@ static void assertAltBroadcastArraysEquals(short[] r, short[] a, short[] b, shor int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -761,11 +804,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -782,11 +825,11 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -804,13 +847,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, FGatherScatterOp f int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -831,13 +874,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FG int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -852,13 +895,13 @@ static void assertArraysEquals(short[] r, short[] a, int[] b, boolean[] mask, FS int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { short[] ref = f.apply(r, a, i, mask, b, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -879,13 +922,13 @@ static void assertArraysEquals(short[] r, short[] a, int origin, FLaneOp f) { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -899,13 +942,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, FLan int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -920,13 +963,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, bool int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -941,13 +984,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -963,13 +1006,13 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { short[] ref = f.apply(a, b, origin, part, mask, i); short[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -986,10 +1029,10 @@ static void assertArraysEquals(int[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -999,10 +1042,10 @@ static void assertArraysEquals(long[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1010,10 +1053,10 @@ static void assertArraysEquals(double[] r, short[] a, int offs) { int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1535,7 +1578,7 @@ static void smokeTest2() { // Do some zipping and shuffling. ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); ShortVector a = io.add((short)1); //[1,2] ShortVector b = a.neg(); //[-1,-2] short[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -1550,19 +1593,19 @@ static void smokeTest2() { manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle unz1 = VectorShuffle.makeUnzip(SPECIES, 1); ShortVector uab0 = zab0.rearrange(unz0,zab1); ShortVector uab1 = zab0.rearrange(unz1,zab1); short[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { ShortVector io = (ShortVector) SPECIES.broadcast(0).addIndex(1); ShortVector io2 = (ShortVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -1577,7 +1620,7 @@ static void shuffleTest() { @Test void viewAsIntegeralLanesTest() { Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); } @Test @@ -1585,9 +1628,9 @@ void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } @Test diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index a6c118bf8edb6..cd4657b4db7b4 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -27,7 +27,7 @@ * * @library /test/lib * @modules jdk.incubator.vector - * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:{#if[FP16]?TieredStopAtLevel=3:-TieredCompilation} $vectorteststype$ + * @run testng/othervm/timeout=300 -ea -esa -Xbatch -XX:-TieredCompilation $vectorteststype$ */ #warn This file is preprocessed before being compiled @@ -93,6 +93,86 @@ public class $vectorteststype$ extends AbstractVectorTest { static $abstractvectortype$ bcast_vec = $abstractvectortype$.broadcast(SPECIES, ($type$)10); +#if[FP16] + static void AssertEquals($type$ actual, $type$ expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals($type$ actual, $type$ expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } + static void AssertEquals($type$ actual, $type$ expected, $type$ delta) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta)); + } + static void AssertEquals($type$ actual, $type$ expected, $type$ delta, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), Float.float16ToFloat((short)delta), msg); + } + static void AssertEquals($type$ [] actual, $type$ [] expected) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i])); + } + } + static void AssertEquals($type$ [] actual, $type$ [] expected, String msg) { + Assert.assertEquals(actual.length, expected.length); + for (int i = 0; i < actual.length; i++) { + Assert.assertEquals(Float.float16ToFloat((short)actual[i]), Float.float16ToFloat((short)expected[i]), msg); + } + } + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected)); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(Float.float16ToFloat((short)actual), Float.float16ToFloat((short)expected), msg); + } +#else[FP16] + static void AssertEquals($type$ actual, $type$ expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals($type$ actual, $type$ expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + static void AssertEquals($type$ actual, $type$ expected, $type$ delta) { + Assert.assertEquals(actual, expected, delta); + } + static void AssertEquals($type$ actual, $type$ expected, $type$ delta, String msg) { + Assert.assertEquals(actual, expected, delta, msg); + } + static void AssertEquals($type$ [] actual, $type$ [] expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals($type$ [] actual, $type$ [] expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } +#if[!long] + static void AssertEquals(long actual, long expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(long actual, long expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } +#end[!long] +#end[FP16] + static void AssertEquals(String actual, String expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(Object actual, Object expected) { + Assert.assertEquals(actual, expected); + } +#if[!FP64] + static void AssertEquals(double actual, double expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(double actual, double expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } +#end[!FP64] + static void AssertEquals(boolean actual, boolean expected) { + Assert.assertEquals(actual, expected); + } + static void AssertEquals(boolean actual, boolean expected, String msg) { + Assert.assertEquals(actual, expected, msg); + } + #if[MaxBit] static VectorShape getMaxBit() { return VectorShape.S_Max_BIT; @@ -142,10 +222,10 @@ public class $vectorteststype$ extends AbstractVectorTest { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i])); + AssertEquals(r[i], f.apply(a[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]); } } @@ -157,13 +237,13 @@ public class $vectorteststype$ extends AbstractVectorTest { int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a[i])); } } catch (AssertionError e) { $type$[] ref = f.apply(a[i]); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -173,10 +253,10 @@ public class $vectorteststype$ extends AbstractVectorTest { int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -195,13 +275,13 @@ public class $vectorteststype$ extends AbstractVectorTest { #else[FP] int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } #end[FP] } @@ -212,13 +292,13 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ relativeErrorFactor) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a), Math.ulp(rc) * relativeErrorFactor); + AssertEquals(rc, fa.apply(a), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(rc) * relativeErrorFactor}); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i), Math.ulp(r[i]) * relativeErrorFactor); + AssertEquals(r[i], f.apply(a, i), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(r[i]) * relativeErrorFactor}); } } catch (AssertionError e) { - 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); + AssertEquals(rc, fa.apply(a), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(rc) * relativeErrorFactor}, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(r[i]) * relativeErrorFactor}, "at index #" + i); } } #end[FP] @@ -238,13 +318,13 @@ public class $vectorteststype$ extends AbstractVectorTest { #else[FP] int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } #end[FP] } @@ -255,14 +335,13 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ relativeError) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError)); + AssertEquals(rc, fa.apply(a, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))):Math.abs(rc * relativeError)}); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * -relativeError)); + AssertEquals(r[i], f.apply(a, i, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))):Math.abs(r[i] * relativeError)}); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), Math.abs(rc * relativeError), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), Math.abs(r[i] * relativeError), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))):Math.abs(rc * relativeError)}, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))):Math.abs(r[i] * relativeError)}, "at index #" + i); } } #end[FP] @@ -280,13 +359,13 @@ relativeError)); FReductionOpLong f, FReductionAllOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a)); + AssertEquals(rc, fa.apply(a)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(rc, fa.apply(a), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -302,13 +381,13 @@ relativeError)); FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) { int i = 0; try { - Assert.assertEquals(rc, fa.apply(a, mask)); + AssertEquals(rc, fa.apply(a, mask)); for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i, mask)); + AssertEquals(r[i], f.apply(a, i, mask)); } } catch (AssertionError e) { - Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); - Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), "at index #" + i); } } #end[!Long] @@ -321,10 +400,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -336,10 +415,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(r[i], f.apply(a, i)); + AssertEquals(r[i], f.apply(a, i)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i); + AssertEquals(r[i], f.apply(a, i), "at index #" + i); } } @@ -348,12 +427,12 @@ relativeError)); try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); } } } catch (AssertionError e) { int idx = i + j; - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]); } } @@ -364,20 +443,20 @@ relativeError)); k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + k], a[i + j]); + AssertEquals(r[i + k], a[i + j]); k++; } } for (; k < vector_len; k++) { - Assert.assertEquals(r[i + k], ($type$)0); + AssertEquals(r[i + k], ($type$)0); } } } catch (AssertionError e) { int idx = i + k; if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + j], "at index #" + idx); + AssertEquals(r[idx], a[i + j], "at index #" + idx); } else { - Assert.assertEquals(r[idx], ($type$)0, "at index #" + idx); + AssertEquals(r[idx], ($type$)0, "at index #" + idx); } } } @@ -389,19 +468,19 @@ relativeError)); k = 0; for (j = 0; j < vector_len; j++) { if (m[(i + j) % SPECIES.length()]) { - Assert.assertEquals(r[i + j], a[i + k]); + AssertEquals(r[i + j], a[i + k]); k++; } else { - Assert.assertEquals(r[i + j], ($type$)0); + AssertEquals(r[i + j], ($type$)0); } } } } catch (AssertionError e) { int idx = i + j; if (m[idx % SPECIES.length()]) { - Assert.assertEquals(r[idx], a[i + k], "at index #" + idx); + AssertEquals(r[idx], a[i + k], "at index #" + idx); } else { - Assert.assertEquals(r[idx], ($type$)0, "at index #" + idx); + AssertEquals(r[idx], ($type$)0, "at index #" + idx); } } } @@ -417,11 +496,11 @@ relativeError)); wrapped_index = Math.floorMod({#if[FP16]?Float16.shortBitsToFloat16(order[idx]).intValue():(int)order[idx]}, 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); } } } catch (AssertionError e) { - Assert.assertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); + AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx]), "at index #" + idx + ", order = " + order[idx] + ", a = " + a[i + oidx] + ", b = " + b[i + oidx]); } } @@ -433,11 +512,11 @@ relativeError)); for (j = 0; j < vector_len; j++) { idx = {#if[FP16]?Float16.shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; wrapped_index = Integer.remainderUnsigned(idx, vector_len); - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index]); } } @@ -447,17 +526,17 @@ relativeError)); for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]]); + AssertEquals(r[i+j], a[i+order[i+j]]); else - Assert.assertEquals(r[i+j], ($type$)0); + AssertEquals(r[i+j], ($type$)0); } } } catch (AssertionError e) { int idx = i + j; if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], ($type$)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], ($type$)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -470,16 +549,16 @@ relativeError)); idx = {#if[FP16]?Float16.shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index]); + AssertEquals(r[i+j], a[i+wrapped_index]); else - Assert.assertEquals(r[i+j], ($type$)0); + AssertEquals(r[i+j], ($type$)0); } } } catch (AssertionError e) { if (mask[j % SPECIES.length()]) - Assert.assertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], a[i+wrapped_index], "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); else - Assert.assertEquals(r[i+j], ($type$)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); + AssertEquals(r[i+j], ($type$)0, "at index #" + idx + ", input = " + a[i+wrapped_index] + ", mask = " + mask[j % SPECIES.length()]); } } @@ -493,10 +572,10 @@ relativeError)); try { for (i = 0; i < a.length; i++) { - Assert.assertEquals(r[i], a[i]); + AssertEquals(r[i], a[i]); } } catch (AssertionError e) { - Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); + AssertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]); } } @@ -517,18 +596,18 @@ relativeError)); try { for (; i < a.length; i++) { //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i])); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i]))); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i]), c[i]), "left associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i])), "right associative test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -543,18 +622,18 @@ relativeError)); for (; i < a.length; i++) { mask_bit = mask[i % SPECIES.length()]; //Left associative - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit)); //Right associative - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit)); //Results equal sanity check - Assert.assertEquals(rl[i], rr[i]); + AssertEquals(rl[i], rr[i]); } } catch (AssertionError e) { - Assert.assertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); - Assert.assertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); + AssertEquals(rl[i], f.apply(f.apply(a[i], b[i], mask_bit), c[i], mask_bit), "left associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rr[i], f.apply(a[i], f.apply(b[i], c[i], mask_bit), mask_bit), "right associative masked test at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask_bit); + AssertEquals(rl[i], rr[i], "Result checks not equal at index #" + i + "leftRes = " + rl[i] + ", rightRes = " + rr[i]); } } @@ -562,10 +641,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i])); + AssertEquals(r[i], f.apply(a[i], b[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i); } } @@ -573,10 +652,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b)); + AssertEquals(r[i], f.apply(a[i], b)); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); + AssertEquals(r[i], f.apply(a[i], b), "(" + a[i] + ", " + b + ") at index #" + i); } } @@ -584,10 +663,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -596,10 +675,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); + AssertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()])), + AssertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()])), "(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i); } } @@ -612,10 +691,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -627,10 +706,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); + AssertEquals(r[i], f.apply(a[i], b, mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b + ", mask = " + mask[i % SPECIES.length()]); } } @@ -642,10 +721,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -660,10 +739,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()]), + AssertEquals(r[i], f.apply(a[i], ($type$)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -676,11 +755,11 @@ relativeError)); try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j); } } @@ -694,11 +773,11 @@ relativeError)); try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]); } } @@ -720,11 +799,11 @@ relativeError)); try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j])); + AssertEquals(r[i+j], f.apply(a[i+j])); } } } catch (AssertionError e) { - Assert.assertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); + AssertEquals(r[i+j], f.apply(a[i+j]), "at index #" + i + ", " + j); } } @@ -738,11 +817,11 @@ relativeError)); try { for (; j < a.length; j += SPECIES.length()) { for (i = 0; i < SPECIES.length(); i++) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i])); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i])); } } } catch (AssertionError err) { - Assert.assertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); + AssertEquals(r[i+j], f.apply(a[i+j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", mask = " + mask[i]); } } @@ -762,10 +841,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); + AssertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]); } } @@ -777,10 +856,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + AssertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); } } @@ -789,10 +868,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); } @@ -802,10 +881,10 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]); } @@ -821,11 +900,11 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + mask[i % SPECIES.length()]); @@ -842,11 +921,11 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]); @@ -857,11 +936,11 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()]); @@ -878,11 +957,11 @@ relativeError)); int i = 0; try { for (; i < a.length; i++) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()])); } } catch (AssertionError err) { - Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], + AssertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " + @@ -997,13 +1076,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, b, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, i, b, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -1024,13 +1103,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, i, mask, b, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, i, mask, b, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -1045,13 +1124,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(r, a, i, mask, b, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(r, a, i, mask, b, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: " + Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length())) + ", b: " @@ -1072,13 +1151,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, origin, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, origin, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i); } @@ -1092,13 +1171,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1113,13 +1192,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, mask, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, mask, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin); @@ -1134,13 +1213,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, part, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1156,13 +1235,13 @@ relativeError)); int i = 0; try { for (; i < a.length; i += SPECIES.length()) { - Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), + AssertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()), f.apply(a, b, origin, part, mask, i)); } } catch (AssertionError e) { $type$[] ref = f.apply(a, b, origin, part, mask, i); $type$[] res = Arrays.copyOfRange(r, i, i+SPECIES.length()); - Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref) + AssertEquals(res, ref, "(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + "), at index #" + i + ", at origin #" + origin @@ -1221,13 +1300,13 @@ relativeError)); try { for (; i < r.length; i++) { #if[Halffloat] - Assert.assertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); #else[Halffloat] - Assert.assertEquals(r[i], (int)(a[i+offs])); + AssertEquals(r[i], (int)(a[i+offs])); #end[Halffloat] } } catch (AssertionError e) { - Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } @@ -1282,10 +1361,10 @@ relativeError)); int i = 0; try { for (; i < r.length; i++) { - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } #end[byte] @@ -1295,13 +1374,13 @@ relativeError)); try { for (; i < r.length; i++) { #if[Halffloat] - Assert.assertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); #else[Halffloat] - Assert.assertEquals(r[i], (long)(a[i+offs])); + AssertEquals(r[i], (long)(a[i+offs])); #end[Halffloat] } } catch (AssertionError e) { - Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } #if[!Double] @@ -1311,13 +1390,13 @@ relativeError)); try { for (; i < r.length; i++) { #if[Halffloat] - Assert.assertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); + AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); #else[Halffloat] - Assert.assertEquals(r[i], (double)(a[i+offs])); + AssertEquals(r[i], (double)(a[i+offs])); #end[Halffloat] } } catch (AssertionError e) { - Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); + AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); } } #end[!Double] @@ -2039,7 +2118,7 @@ relativeError)); // Do some zipping and shuffling. $abstractvectortype$ io = ($abstractvectortype$) SPECIES.broadcast(0).addIndex(1); $abstractvectortype$ io2 = ($abstractvectortype$) VectorShuffle.iota(SPECIES,0,1,false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); $abstractvectortype$ a = io.add(($type$)1); //[1,2] $abstractvectortype$ b = a.neg(); //[-1,-2] $type$[] abValues = bothToArray(a,b); //[1,2,-1,-2] @@ -2054,19 +2133,19 @@ relativeError)); manual[i+0] = abValues[i/2]; manual[i+1] = abValues[a.length() + i/2]; } - Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); + AssertEquals(Arrays.toString(zabValues), Arrays.toString(manual)); VectorShuffle<$Wideboxtype$> unz0 = VectorShuffle.makeUnzip(SPECIES, 0); VectorShuffle<$Wideboxtype$> unz1 = VectorShuffle.makeUnzip(SPECIES, 1); $abstractvectortype$ uab0 = zab0.rearrange(unz0,zab1); $abstractvectortype$ uab1 = zab0.rearrange(unz1,zab1); $type$[] abValues1 = bothToArray(uab0, uab1); - Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); + AssertEquals(Arrays.toString(abValues), Arrays.toString(abValues1)); } static void iotaShuffle() { $abstractvectortype$ io = ($abstractvectortype$) SPECIES.broadcast(0).addIndex(1); $abstractvectortype$ io2 = ($abstractvectortype$) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector(); - Assert.assertEquals(io, io2); + AssertEquals(io, io2); } @Test @@ -2084,12 +2163,12 @@ relativeError)); Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); VectorSpecies asIntegralSpecies = asIntegral.species(); Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length()); - Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); + AssertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asIntegralSpecies.length(), SPECIES.length()); + AssertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES); #else[FP] Vector asIntegral = SPECIES.zero().viewAsIntegralLanes(); - Assert.assertEquals(asIntegral.species(), SPECIES); + AssertEquals(asIntegral.species(), SPECIES); #end[FP] } #if[FP] @@ -2097,7 +2176,7 @@ relativeError)); @Test void viewAsFloatingLanesTest() { Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); - Assert.assertEquals(asFloating.species(), SPECIES); + AssertEquals(asFloating.species(), SPECIES); } #else[FP] #if[byte] @@ -2113,9 +2192,9 @@ relativeError)); Vector asFloating = SPECIES.zero().viewAsFloatingLanes(); VectorSpecies asFloatingSpecies = asFloating.species(); Assert.assertNotEquals(asFloatingSpecies.elementType(), SPECIES.elementType()); - Assert.assertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); - Assert.assertEquals(asFloatingSpecies.length(), SPECIES.length()); - Assert.assertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); + AssertEquals(asFloatingSpecies.vectorShape(), SPECIES.vectorShape()); + AssertEquals(asFloatingSpecies.length(), SPECIES.length()); + AssertEquals(asFloating.viewAsIntegralLanes().species(), SPECIES); } #end[byte] #end[FP] From 295b2caafd7691e7f5d6da39fe9b17ff206c1635 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Thu, 30 Oct 2025 15:46:37 +0000 Subject: [PATCH 04/10] Adding IR Framework test --- src/hotspot/share/opto/vectorIntrinsics.cpp | 4 +- .../TestHalffloatVectorOperations.java | 585 ++++++++++++++++++ 2 files changed, 587 insertions(+), 2 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 9ce8acff8d89c..7234a39c38ef8 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -727,7 +727,8 @@ bool LibraryCallKit::inline_vector_frombits_coerced() { } - if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM) { + int bcast_mode = mode->get_con(); + if (operType->get_con() != VectorSupport::VECTOR_TYPE_PRIM && bcast_mode != VectorSupport::MODE_BROADCAST) { log_if_needed(" ** unhandled operType=%s", get_opertype_string(operType->get_con())); return false; } @@ -747,7 +748,6 @@ bool LibraryCallKit::inline_vector_frombits_coerced() { const TypeInstPtr* vbox_type = TypeInstPtr::make_exact(TypePtr::NotNull, vbox_klass); bool is_mask = is_vector_mask(vbox_klass); - int bcast_mode = mode->get_con(); VectorMaskUseType checkFlags = (VectorMaskUseType)(is_mask ? VecMaskUseAll : VecMaskNotUsed); int opc = bcast_mode == VectorSupport::MODE_BITS_COERCED_LONG_TO_MASK ? Op_VectorLongToMask : Op_Replicate; diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java b/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java new file mode 100644 index 0000000000000..634566b4f57aa --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java @@ -0,0 +1,585 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** +* @test +* @bug 8370691 +* @summary Test intrinsification of HalffloatVector operations +* @modules jdk.incubator.vector +* @library /test/lib / +* @compile TestHalffloatVectorOperations.java +* @run driver/timeout=480 compiler.vectorapi.TestHalffloatVectorOperations +*/ + +package compiler.vectorapi; +import compiler.lib.ir_framework.*; +import jdk.incubator.vector.*; +import static jdk.incubator.vector.Float16.*; +import static java.lang.Float.*; +import java.util.Arrays; +import jdk.test.lib.*; +import compiler.lib.generators.Generator; +import static compiler.lib.generators.Generators.G; + +public class TestHalffloatVectorOperations { + short[] input1; + short[] input2; + short[] input3; + short[] output; + static final int LEN = 2048; + static short FP16_SCALAR = (short)0x7777; + + static final Float16 FP16_CONST = Float16.valueOf(1023.0f); + static final VectorSpecies SPECIES = HalffloatVector.SPECIES_PREFERRED; + + public static void main(String args[]) { + // Test with default MaxVectorSize + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector"); + + // Test with different values of MaxVectorSize + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector", "-XX:MaxVectorSize=8"); + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector", "-XX:MaxVectorSize=16"); + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector", "-XX:MaxVectorSize=32"); + TestFramework.runWithFlags("--add-modules=jdk.incubator.vector", "-XX:MaxVectorSize=64"); + } + + static void assertResults(int arity, short ... values) { + assert values.length == (arity + 2); + Float16 expected_fp16 = shortBitsToFloat16(values[arity]); + Float16 actual_fp16 = shortBitsToFloat16(values[arity + 1]); + if(!expected_fp16.equals(actual_fp16)) { + String inputs = Arrays.toString(Arrays.copyOfRange(values, 0, arity - 1)); + throw new AssertionError("Result Mismatch!, input = " + inputs + " actual = " + actual_fp16 + " expected = " + expected_fp16); + } + } + + public TestHalffloatVectorOperations() { + input1 = new short[LEN]; + input2 = new short[LEN]; + input3 = new short[LEN]; + output = new short[LEN]; + + short min_value = float16ToRawShortBits(Float16.MIN_VALUE); + short max_value = float16ToRawShortBits(Float16.MAX_VALUE); + Generator gen = G.float16s(); + for (int i = 0; i < LEN; ++i) { + input1[i] = gen.next(); + input2[i] = gen.next(); + input3[i] = gen.next(); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.ADD_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.ADD_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorAddFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.ADD, + HalffloatVector.fromArray(SPECIES, input2, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + add(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorAddFloat16") + void checkResultAdd() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input1[i]) + float16ToFloat(input2[i])); + assertResults(2, input1[i], input2[i], expected, output[i]); + } + } + + + @Test + @Warmup(50) + @IR(counts = {IRNode.SUB_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.SUB_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorSubFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.SUB, + HalffloatVector.fromArray(SPECIES, input2, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + subtract(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorSubFloat16") + void checkResultSub() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input1[i]) - float16ToFloat(input2[i])); + assertResults(2, input1[i], input2[i], expected, output[i]); + } + } + + + @Test + @Warmup(50) + @IR(counts = {IRNode.MUL_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.MUL_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorMulFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.MUL, + HalffloatVector.fromArray(SPECIES, input2, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + multiply(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorMulFloat16") + void checkResultMul() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input1[i]) * float16ToFloat(input2[i])); + assertResults(2, input1[i], input2[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.DIV_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.DIV_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorDivFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.DIV, + HalffloatVector.fromArray(SPECIES, input2, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + divide(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorDivFloat16") + void checkResultDiv() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input1[i]) / float16ToFloat(input2[i])); + assertResults(2, input1[i], input2[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.MIN_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.MIN_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorMinFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.MIN, + HalffloatVector.fromArray(SPECIES, input2, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + min(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorMinFloat16") + void checkResultMin() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(Math.min(float16ToFloat(input1[i]), float16ToFloat(input2[i]))); + assertResults(2, input1[i], input2[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.MAX_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.MAX_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorMaxFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.MAX, + HalffloatVector.fromArray(SPECIES, input2, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + max(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorMaxFloat16") + void checkResultMax() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(Math.max(float16ToFloat(input1[i]), float16ToFloat(input2[i]))); + assertResults(2, input1[i], input2[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.SQRT_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.SQRT_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorSqrtFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.SQRT) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits(shortBitsToFloat16(input1[i])); + } + } + + @Check(test="vectorSqrtFloat16") + void checkResultSqrt() { + for (int i = 0; i < LEN; ++i) { + short expected = float16ToRawShortBits(sqrt(shortBitsToFloat16(input1[i]))); + assertResults(1, input1[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorFmaFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.FMA, + HalffloatVector.fromArray(SPECIES, input2, i), + HalffloatVector.fromArray(SPECIES, input3, i)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits( + fma(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]), + shortBitsToFloat16(input3[i]))); + } + } + + @Check(test="vectorFmaFloat16") + void checkResultFma() { + for (int i = 0; i < LEN; ++i) { + short expected = float16ToRawShortBits(fma(shortBitsToFloat16(input1[i]), shortBitsToFloat16(input2[i]), + shortBitsToFloat16(input3[i]))); + assertResults(3, input1[i], input2[i], input3[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorFmaFloat16ScalarMixedConstants() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.FMA, + FP16_SCALAR, + floatToFloat16(3.0f)) + .intoArray(output, i); + } + for (; i < LEN; i++) { + output[i] = float16ToRawShortBits(fma(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(FP16_SCALAR), + shortBitsToFloat16(floatToFloat16(3.0f)))); + } + } + + @Check(test="vectorFmaFloat16ScalarMixedConstants") + void checkResultFmaScalarMixedConstants() { + for (int i = 0; i < LEN; ++i) { + short expected = float16ToRawShortBits(fma(shortBitsToFloat16(input1[i]), shortBitsToFloat16(FP16_SCALAR), + shortBitsToFloat16(floatToFloat16(3.0f)))); + assertResults(2, input1[i], FP16_SCALAR, expected, output[i]); + } + } + + + @Test + @Warmup(50) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorFmaFloat16MixedConstants() { + short input3 = floatToFloat16(3.0f); + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.FMA, + HalffloatVector.fromArray(SPECIES, input2, i), + input3) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(fma(shortBitsToFloat16(input1[i]), + shortBitsToFloat16(input2[i]), + shortBitsToFloat16(input3))); + } + } + + + @Check(test="vectorFmaFloat16MixedConstants") + void checkResultFmaMixedConstants() { + short input3 = floatToFloat16(3.0f); + for (int i = 0; i < LEN; ++i) { + short expected = float16ToRawShortBits(fma(shortBitsToFloat16(input1[i]), shortBitsToFloat16(input2[i]), shortBitsToFloat16(input3))); + assertResults(3, input1[i], input2[i], input3, expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.FMA_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.FMA_VHF, " 0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorFmaFloat16AllConstants() { + short input1 = floatToFloat16(1.0f); + short input2 = floatToFloat16(2.0f); + short input3 = floatToFloat16(3.0f); + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, input1) + .lanewise(VectorOperators.FMA, + input2, + input3) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(fma(shortBitsToFloat16(input1), + shortBitsToFloat16(input2), + shortBitsToFloat16(input3))); + } + } + + @Check(test="vectorFmaFloat16AllConstants") + void checkResultFmaAllConstants() { + short input1 = floatToFloat16(1.0f); + short input2 = floatToFloat16(2.0f); + short input3 = floatToFloat16(3.0f); + for (int i = 0; i < LEN; ++i) { + short expected = float16ToRawShortBits(fma(shortBitsToFloat16(input1), shortBitsToFloat16(input2), shortBitsToFloat16(input3))); + assertResults(3, input1, input2, input3, expected, output[i]); + } + } + + + @Test + @Warmup(50) + @IR(counts = {IRNode.ADD_VHF, " >0 "}, + applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) + @IR(counts = {IRNode.ADD_VHF, " >0 "}, + applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"}) + void vectorAddConstInputFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.ADD, + float16ToRawShortBits(FP16_CONST)) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(add(shortBitsToFloat16(input1[i]), + FP16_CONST)); + } + } + + @Check(test="vectorAddConstInputFloat16") + void checkResultAddConstantInputFloat16() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input1[i]) + FP16_CONST.floatValue()); + assertResults(2, input1[i], float16ToRawShortBits(FP16_CONST), expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.SUB_VHF, " >0 "}, + applyIfCPUFeature = {"avx512_fp16", "true"}) + void vectorSubConstInputFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input1, i) + .lanewise(VectorOperators.SUB, + float16ToRawShortBits(FP16_CONST)) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(subtract(shortBitsToFloat16(input1[i]), + FP16_CONST)); + } + } + + @Check(test="vectorSubConstInputFloat16") + void checkResultSubConstantInputFloat16() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input1[i]) - FP16_CONST.floatValue()); + assertResults(2, input1[i], float16ToRawShortBits(FP16_CONST), expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.MUL_VHF, " >0 "}, + applyIfCPUFeature = {"avx512_fp16", "true"}) + void vectorMulConstantInputFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input2, i) + .lanewise(VectorOperators.MUL, + float16ToRawShortBits(FP16_CONST)) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(multiply(FP16_CONST, + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorMulConstantInputFloat16") + void checkResultMulConstantInputFloat16() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(FP16_CONST.floatValue() * float16ToFloat(input2[i])); + assertResults(2, float16ToRawShortBits(FP16_CONST), input2[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.DIV_VHF, " >0 "}, + applyIfCPUFeature = {"avx512_fp16", "true"}) + void vectorDivConstantInputFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input2, i) + .lanewise(VectorOperators.DIV, + float16ToRawShortBits(FP16_CONST)) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(divide(shortBitsToFloat16(input2[i]), + FP16_CONST)); + } + } + + @Check(test="vectorDivConstantInputFloat16") + void checkResultDivConstantInputFloat16() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(float16ToFloat(input2[i]) / FP16_CONST.floatValue()); + assertResults(2, input2[i], float16ToRawShortBits(FP16_CONST), expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.MAX_VHF, " >0 "}, + applyIfCPUFeature = {"avx512_fp16", "true"}) + void vectorMaxConstantInputFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input2, i) + .lanewise(VectorOperators.MAX, + float16ToRawShortBits(FP16_CONST)) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(max(FP16_CONST, + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorMaxConstantInputFloat16") + void checkResultMaxConstantInputFloat16() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(Math.max(FP16_CONST.floatValue(), float16ToFloat(input2[i]))); + assertResults(2, float16ToRawShortBits(FP16_CONST), input2[i], expected, output[i]); + } + } + + @Test + @Warmup(50) + @IR(counts = {IRNode.MIN_VHF, " >0 "}, + applyIfCPUFeature = {"avx512_fp16", "true"}) + void vectorMinConstantInputFloat16() { + int i = 0; + for (; i < SPECIES.loopBound(LEN); i += SPECIES.length()) { + HalffloatVector.fromArray(SPECIES, input2, i) + .lanewise(VectorOperators.MIN, + float16ToRawShortBits(FP16_CONST)) + .intoArray(output, i); + } + for (; i < LEN; ++i) { + output[i] = float16ToRawShortBits(min(FP16_CONST, + shortBitsToFloat16(input2[i]))); + } + } + + @Check(test="vectorMinConstantInputFloat16") + void checkResultMinConstantInputFloat16() { + for (int i = 0; i < LEN; ++i) { + short expected = floatToFloat16(Math.min(FP16_CONST.floatValue(), float16ToFloat(input2[i]))); + assertResults(2, float16ToRawShortBits(FP16_CONST), input2[i], expected, output[i]); + } + } +} From 911c816cc69164fd63d04c719b236df1f4c4bf12 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Fri, 31 Oct 2025 12:02:24 +0000 Subject: [PATCH 05/10] Adding a HalffloatVectorBenchmark having benchmarking kernel parity with Float16OperationsBenchmark --- .../vector/HalffloatOperationsBenchmark.java | 328 ++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 test/micro/org/openjdk/bench/jdk/incubator/vector/HalffloatOperationsBenchmark.java diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/HalffloatOperationsBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/HalffloatOperationsBenchmark.java new file mode 100644 index 0000000000000..90dd4a18aa524 --- /dev/null +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/HalffloatOperationsBenchmark.java @@ -0,0 +1,328 @@ +/* + * Copyright (c) 2025, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.java.lang; + +import java.util.stream.IntStream; +import java.util.concurrent.TimeUnit; +import jdk.incubator.vector.*; +import org.openjdk.jmh.annotations.*; +import static jdk.incubator.vector.Float16.*; +import static java.lang.Float.*; + +@OutputTimeUnit(TimeUnit.MILLISECONDS) +@State(Scope.Thread) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector", "-Xbatch", "-XX:-TieredCompilation"}) +public class HalffloatOperationsBenchmark { + @Param({"256", "512", "1024", "2048"}) + int vectorDim; + + int [] rexp; + short [] vectorRes; + short [] vector1; + short [] vector2; + short [] vector3; + short [] vector4; + short [] vector5; + boolean [] vectorPredicate; + + static final short f16_one = Float.floatToFloat16(1.0f); + static final short f16_two = Float.floatToFloat16(2.0f); + + @Setup(Level.Trial) + public void BmSetup() { + rexp = new int[vectorDim]; + vectorRes = new short[vectorDim]; + vector1 = new short[vectorDim]; + vector2 = new short[vectorDim]; + vector3 = new short[vectorDim]; + vector4 = new short[vectorDim]; + vector5 = new short[vectorDim]; + vectorPredicate = new boolean[vectorDim]; + + IntStream.range(0, vectorDim).forEach(i -> {vector1[i] = Float.floatToFloat16((float)i);}); + IntStream.range(0, vectorDim).forEach(i -> {vector2[i] = Float.floatToFloat16((float)i);}); + IntStream.range(0, vectorDim).forEach(i -> {vector3[i] = Float.floatToFloat16((float)i);}); + IntStream.range(0, vectorDim).forEach(i -> {vector4[i] = ((i & 0x1) == 0) ? + float16ToRawShortBits(Float16.POSITIVE_INFINITY) : + Float.floatToFloat16((float)i);}); + IntStream.range(0, vectorDim).forEach(i -> {vector5[i] = ((i & 0x1) == 0) ? + float16ToRawShortBits(Float16.NaN) : + Float.floatToFloat16((float)i);}); + // Special Values + Float16 [] specialValues = {Float16.NaN, Float16.NEGATIVE_INFINITY, Float16.valueOf(0.0), Float16.valueOf(-0.0), Float16.POSITIVE_INFINITY}; + IntStream.range(0, vectorDim).forEach( + i -> { + if ((i % 64) == 0) { + int idx1 = i % specialValues.length; + int idx2 = (i + 1) % specialValues.length; + int idx3 = (i + 2) % specialValues.length; + vector1[i] = float16ToRawShortBits(specialValues[idx1]); + vector2[i] = float16ToRawShortBits(specialValues[idx2]); + vector3[i] = float16ToRawShortBits(specialValues[idx3]); + } + } + ); + } + + static final VectorSpecies HSPECIES = HalffloatVector.SPECIES_PREFERRED; + static final VectorSpecies FSPECIES = FloatVector.SPECIES_PREFERRED; + + @Benchmark + public void addBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.ADD, + HalffloatVector.fromArray(HSPECIES, vector2, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(add(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]))); + } + } + + @Benchmark + public void subBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.SUB, + HalffloatVector.fromArray(HSPECIES, vector2, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(subtract(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]))); + } + } + + @Benchmark + public void mulBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.MUL, + HalffloatVector.fromArray(HSPECIES, vector2, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(multiply(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]))); + } + } + + @Benchmark + public void divBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.DIV, + HalffloatVector.fromArray(HSPECIES, vector2, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(divide(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]))); + } + } + + @Benchmark + public void fmaBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.FMA, + HalffloatVector.fromArray(HSPECIES, vector2, i), + HalffloatVector.fromArray(HSPECIES, vector3, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(fma(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]), + shortBitsToFloat16(vector3[i]))); + } + } + + @Benchmark + public void maxBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.MAX, + HalffloatVector.fromArray(HSPECIES, vector2, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(max(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]))); + } + } + + @Benchmark + public void minBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.MIN, + HalffloatVector.fromArray(HSPECIES, vector2, i)) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(min(shortBitsToFloat16(vector1[i]), + shortBitsToFloat16(vector2[i]))); + } + } + + @Benchmark + public void sqrtBenchmark() { + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.SQRT) + .intoArray(vectorRes, i); + } + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(sqrt(shortBitsToFloat16(vector1[i]))); + } + } + + @Benchmark + public short cosineSimilarityDoubleRoundingFP16() { + int i = 0; + HalffloatVector macResVec = HalffloatVector.broadcast(HSPECIES, (short)0); + HalffloatVector vector1SquareVec = HalffloatVector.broadcast(HSPECIES, (short)0); + HalffloatVector vector2SquareVec = HalffloatVector.broadcast(HSPECIES, (short)0); + // cosine distance = (VEC1 . VEC2) / ||VEC1||.||VEC2|| + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + // Explicit add and multiply operation ensures double rounding. + HalffloatVector vec1 = HalffloatVector.fromArray(HSPECIES, vector1, i); + HalffloatVector vec2 = HalffloatVector.fromArray(HSPECIES, vector2, i); + macResVec = vec1.lanewise(VectorOperators.MUL, vec2) + .lanewise(VectorOperators.ADD, macResVec); + vector1SquareVec = vec1.lanewise(VectorOperators.MUL, vec1) + .lanewise(VectorOperators.ADD, vector1SquareVec); + vector2SquareVec = vec2.lanewise(VectorOperators.MUL, vec2) + .lanewise(VectorOperators.ADD, vector2SquareVec); + } + short macRes = macResVec.lanewise(VectorOperators.DIV, + vector1SquareVec.lanewise(VectorOperators.MUL, + vector2SquareVec)) + .reduceLanes(VectorOperators.ADD); + + short vector1Square = floatToFloat16(0.0f); + short vector2Square = floatToFloat16(0.0f); + for (; i < vectorDim; i++) { + // Explicit add and multiply operation ensures double rounding. + Float16 vec1 = shortBitsToFloat16(vector1[i]); + Float16 vec2 = shortBitsToFloat16(vector2[i]); + macRes = float16ToRawShortBits(add(multiply(vec1, vec2), + shortBitsToFloat16(macRes))); + vector1Square = float16ToRawShortBits(add(multiply(vec1, vec1), + shortBitsToFloat16(vector1Square))); + vector2Square = float16ToRawShortBits(add(multiply(vec2, vec2), + shortBitsToFloat16(vector2Square))); + } + return float16ToRawShortBits(divide(shortBitsToFloat16(macRes), + multiply(shortBitsToFloat16(vector1Square), + shortBitsToFloat16(vector2Square)))); + } + + @Benchmark + public short cosineSimilaritySingleRoundingFP16() { + int i = 0; + HalffloatVector macResVec = HalffloatVector.broadcast(HSPECIES, (short)0); + HalffloatVector vector1SquareVec = HalffloatVector.broadcast(HSPECIES, (short)0); + HalffloatVector vector2SquareVec = HalffloatVector.broadcast(HSPECIES, (short)0); + // cosine distance = (VEC1 . VEC2) / ||VEC1||.||VEC2|| + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + // Explicit add and multiply operation ensures double rounding. + HalffloatVector vec1 = HalffloatVector.fromArray(HSPECIES, vector1, i); + HalffloatVector vec2 = HalffloatVector.fromArray(HSPECIES, vector2, i); + macResVec = vec1.lanewise(VectorOperators.FMA, vec2, macResVec); + vector1SquareVec = vec1.lanewise(VectorOperators.FMA, vec1, vector1SquareVec); + vector2SquareVec = vec2.lanewise(VectorOperators.FMA, vec2, vector2SquareVec); + } + short macRes = macResVec.lanewise(VectorOperators.DIV, + vector1SquareVec.lanewise(VectorOperators.MUL, + vector2SquareVec)) + .reduceLanes(VectorOperators.ADD); + + short vector1Square = floatToFloat16(0.0f); + short vector2Square = floatToFloat16(0.0f); + for (; i < vectorDim; i++) { + // Explicit add and multiply operation ensures double rounding. + Float16 vec1 = shortBitsToFloat16(vector1[i]); + Float16 vec2 = shortBitsToFloat16(vector2[i]); + macRes = float16ToRawShortBits(fma(vec1, vec2, + shortBitsToFloat16(macRes))); + vector1Square = float16ToRawShortBits(fma(vec1, vec1, + shortBitsToFloat16(vector1Square))); + vector2Square = float16ToRawShortBits(fma(vec2, vec2, + shortBitsToFloat16(vector2Square))); + } + return float16ToRawShortBits(divide(shortBitsToFloat16(macRes), + multiply(shortBitsToFloat16(vector1Square), + shortBitsToFloat16(vector2Square)))); + } + + @Benchmark + public short euclideanDistanceFP16() { + HalffloatVector resVec = HalffloatVector.broadcast(HSPECIES, (short)0); + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + HalffloatVector diffVec = HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.SUB, + HalffloatVector.fromArray(HSPECIES, vector2, i)); + resVec = diffVec.lanewise(VectorOperators.FMA, diffVec, resVec); + } + short distRes = resVec.lanewise(VectorOperators.SQRT) + .reduceLanes(VectorOperators.ADD); + short squareRes = floatToFloat16(0.0f); + for (; i < vectorDim; i++) { + squareRes = float16ToRawShortBits(subtract(shortBitsToFloat16(vector1[i]), shortBitsToFloat16(vector2[i]))); + distRes = float16ToRawShortBits(fma(shortBitsToFloat16(squareRes), shortBitsToFloat16(squareRes), shortBitsToFloat16(distRes))); + } + return float16ToRawShortBits(sqrt(shortBitsToFloat16(distRes))); + } + + @Benchmark + public short dotProductFP16() { + HalffloatVector distResVec = HalffloatVector.broadcast(HSPECIES, (short)0); + int i = 0; + for (; i < HSPECIES.loopBound(vectorDim); i += HSPECIES.length()) { + distResVec = HalffloatVector.fromArray(HSPECIES, vector1, i) + .lanewise(VectorOperators.FMA, + HalffloatVector.fromArray(HSPECIES, vector2, i), + distResVec); + } + short distRes = distResVec.reduceLanes(VectorOperators.ADD); + for (; i < vectorDim; i++) { + vectorRes[i] = float16ToRawShortBits(multiply(shortBitsToFloat16(vector1[i]), shortBitsToFloat16(vector2[i]))); + } + for (; i < vectorDim; i++) { + distRes = float16ToRawShortBits(add(shortBitsToFloat16(vectorRes[i]), shortBitsToFloat16(distRes))); + } + return distRes; + } +} From 86a6a29f5b62ac3ac401cef7417f1e6ff635f34a Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Mon, 3 Nov 2025 06:25:00 +0000 Subject: [PATCH 06/10] Removing redundant warmup constraint --- .../TestHalffloatVectorOperations.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java b/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java index 634566b4f57aa..c0ab7f93a1833 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java +++ b/test/hotspot/jtreg/compiler/vectorapi/TestHalffloatVectorOperations.java @@ -90,7 +90,6 @@ public TestHalffloatVectorOperations() { } @Test - @Warmup(50) @IR(counts = {IRNode.ADD_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.ADD_VHF, " >0 "}, @@ -120,7 +119,6 @@ void checkResultAdd() { @Test - @Warmup(50) @IR(counts = {IRNode.SUB_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.SUB_VHF, " >0 "}, @@ -150,7 +148,6 @@ void checkResultSub() { @Test - @Warmup(50) @IR(counts = {IRNode.MUL_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.MUL_VHF, " >0 "}, @@ -179,7 +176,6 @@ void checkResultMul() { } @Test - @Warmup(50) @IR(counts = {IRNode.DIV_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.DIV_VHF, " >0 "}, @@ -208,7 +204,6 @@ void checkResultDiv() { } @Test - @Warmup(50) @IR(counts = {IRNode.MIN_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.MIN_VHF, " >0 "}, @@ -237,7 +232,6 @@ void checkResultMin() { } @Test - @Warmup(50) @IR(counts = {IRNode.MAX_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.MAX_VHF, " >0 "}, @@ -266,7 +260,6 @@ void checkResultMax() { } @Test - @Warmup(50) @IR(counts = {IRNode.SQRT_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.SQRT_VHF, " >0 "}, @@ -292,7 +285,6 @@ void checkResultSqrt() { } @Test - @Warmup(50) @IR(counts = {IRNode.FMA_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.FMA_VHF, " >0 "}, @@ -324,7 +316,6 @@ void checkResultFma() { } @Test - @Warmup(50) @IR(counts = {IRNode.FMA_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.FMA_VHF, " >0 "}, @@ -356,7 +347,6 @@ void checkResultFmaScalarMixedConstants() { @Test - @Warmup(50) @IR(counts = {IRNode.FMA_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.FMA_VHF, " >0 "}, @@ -389,7 +379,6 @@ void checkResultFmaMixedConstants() { } @Test - @Warmup(50) @IR(counts = {IRNode.FMA_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.FMA_VHF, " 0 "}, @@ -426,7 +415,6 @@ void checkResultFmaAllConstants() { @Test - @Warmup(50) @IR(counts = {IRNode.ADD_VHF, " >0 "}, applyIfCPUFeatureOr = {"avx512_fp16", "true", "zvfh", "true", "sve", "true"}) @IR(counts = {IRNode.ADD_VHF, " >0 "}, @@ -454,7 +442,6 @@ void checkResultAddConstantInputFloat16() { } @Test - @Warmup(50) @IR(counts = {IRNode.SUB_VHF, " >0 "}, applyIfCPUFeature = {"avx512_fp16", "true"}) void vectorSubConstInputFloat16() { @@ -480,7 +467,6 @@ void checkResultSubConstantInputFloat16() { } @Test - @Warmup(50) @IR(counts = {IRNode.MUL_VHF, " >0 "}, applyIfCPUFeature = {"avx512_fp16", "true"}) void vectorMulConstantInputFloat16() { @@ -506,7 +492,6 @@ void checkResultMulConstantInputFloat16() { } @Test - @Warmup(50) @IR(counts = {IRNode.DIV_VHF, " >0 "}, applyIfCPUFeature = {"avx512_fp16", "true"}) void vectorDivConstantInputFloat16() { @@ -532,7 +517,6 @@ void checkResultDivConstantInputFloat16() { } @Test - @Warmup(50) @IR(counts = {IRNode.MAX_VHF, " >0 "}, applyIfCPUFeature = {"avx512_fp16", "true"}) void vectorMaxConstantInputFloat16() { @@ -558,7 +542,6 @@ void checkResultMaxConstantInputFloat16() { } @Test - @Warmup(50) @IR(counts = {IRNode.MIN_VHF, " >0 "}, applyIfCPUFeature = {"avx512_fp16", "true"}) void vectorMinConstantInputFloat16() { From 68a1f78e612e07a3e096cf93438ed4746e9cbb66 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Mon, 3 Nov 2025 08:48:06 +0000 Subject: [PATCH 07/10] Cleanups --- src/hotspot/share/opto/vectorIntrinsics.cpp | 32 ++------------------- src/hotspot/share/opto/vectornode.cpp | 1 - src/hotspot/share/opto/vectornode.hpp | 2 -- 3 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 7234a39c38ef8..5264f25131339 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -300,7 +300,6 @@ static bool is_klass_initialized(const TypeInstPtr* vec_klass) { } // -// public static // , // M extends VectorMask, // E> @@ -310,7 +309,6 @@ static bool is_klass_initialized(const TypeInstPtr* vec_klass) { // V v, M m, // UnaryOperation defaultImpl) { // -// public static // , // E> @@ -321,7 +319,6 @@ static bool is_klass_initialized(const TypeInstPtr* vec_klass) { // BinaryOperation defaultImpl) { // // -// public static // , // M extends VectorMask, // E> @@ -502,13 +499,11 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { } // -// public static // , E> // V libraryUnaryOp(long addr, Class vClass, Class cClass, int operType, int length, String debugName, // V v, // UnaryOperation defaultImpl) // -// public static // // V libraryBinaryOp(long addr, Class vClass, Class cClass, int operType, int length, String debugName, // V v1, V v2, @@ -614,7 +609,6 @@ bool LibraryCallKit::inline_vector_call(int arity) { } // -// public static // , // E> // long maskReductionCoerced(int oper, @@ -691,7 +685,6 @@ bool LibraryCallKit::inline_vector_mask_operation() { } // -// public static // , // E> @@ -833,7 +826,6 @@ static bool elem_consistent_with_arr(BasicType elem_bt, const TypeAryPtr* arr_ty } // -// public static // defaultImpl) // // -// public static // // void store(Class vClass, Class cClass, int operType, @@ -1030,7 +1021,6 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) { } // -// public static // , // E, @@ -1042,7 +1032,6 @@ bool LibraryCallKit::inline_vector_mem_operation(bool is_store) { // C container, long index, S s, // LoadVectorMaskedOperation defaultImpl) // -// public static // , // M extends VectorMask, @@ -1259,7 +1248,6 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { } // -// public static // , // W extends Vector, @@ -1273,7 +1261,6 @@ bool LibraryCallKit::inline_vector_mem_masked_operation(bool is_store) { // W indexVector1, W indexVector2, W indexVector3, W indexVector4, // M m, C container, int index, int[] indexMap, int indexM, S s, // LoadVectorOperationWithMap defaultImpl) -// public static // , // W extends Vector, @@ -1469,7 +1456,6 @@ bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) { } // -// public static // , // M extends VectorMask, // E> @@ -1625,7 +1611,6 @@ bool LibraryCallKit::inline_vector_reduction() { // -// public static // , // E> // boolean test(int cond, @@ -1707,7 +1692,6 @@ bool LibraryCallKit::inline_vector_test() { } // -// public static // , // M extends VectorMask, // E> @@ -1779,7 +1763,6 @@ bool LibraryCallKit::inline_vector_blend() { // -// public static // , // M extends VectorMask, // E> @@ -1897,7 +1880,6 @@ bool LibraryCallKit::inline_vector_compare() { } // -// public static // , // SH extends VectorShuffle, // M extends VectorMask, @@ -2042,7 +2024,6 @@ bool LibraryCallKit::inline_vector_rearrange() { } // -// public static // , // M extends VectorMask, // E> @@ -2207,7 +2188,6 @@ bool LibraryCallKit::inline_vector_select_from() { } // -// public static // , // M extends VectorMask, // E> @@ -2356,9 +2336,9 @@ bool LibraryCallKit::inline_vector_broadcast_int() { return true; } -// public static +// // VOUT convert(int oprId, // Class fromVectorClass, Class fromElementType, int fromVLen, // Class toVectorClass, Class toElementType, int toVLen, @@ -2552,7 +2532,6 @@ bool LibraryCallKit::inline_vector_convert() { } // -// public static // , // E> // V insert(Class vClass, Class cClass, int operType, @@ -2647,7 +2626,6 @@ bool LibraryCallKit::inline_vector_insert() { } // -// public static // // long extract(Class vClass, Class cClass, int operType, @@ -2842,7 +2820,6 @@ static Node* LowerSelectFromTwoVectorOperation(PhaseGVN& phase, Node* index_vec, } // -// public static // , // E> // V selectFromTwoVectorOp(Class vClass, Class cClass, int operType, int length, @@ -2975,7 +2952,6 @@ bool LibraryCallKit::inline_vector_select_from_two_vectors() { } // -// public static // , // M extends VectorMask, // E> @@ -3062,7 +3038,6 @@ bool LibraryCallKit::inline_vector_compress_expand() { } // -// public static // , // E, // S extends VectorSpecies> @@ -3208,7 +3183,6 @@ bool LibraryCallKit::inline_index_vector() { } // -// public static // > // M indexPartiallyInUpperRange(Class mClass, Class cClass, int operType, diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index 8710659966f66..6ae8bbe8aa0af 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -292,7 +292,6 @@ int VectorNode::opcode(int sopc, BasicType bt) { } } - // Limits on vector size (number of elements) for auto-vectorization. bool VectorNode::vector_size_supported_auto_vectorization(const BasicType bt, int size) { return Matcher::max_vector_size_auto_vectorization(bt) >= size && diff --git a/src/hotspot/share/opto/vectornode.hpp b/src/hotspot/share/opto/vectornode.hpp index 6717cadc5e19e..427aeff53fcf9 100644 --- a/src/hotspot/share/opto/vectornode.hpp +++ b/src/hotspot/share/opto/vectornode.hpp @@ -82,8 +82,6 @@ class VectorNode : public TypeNode { static VectorNode* make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt); static VectorNode* make(int vopc, Node* n1, Node* n2, Node* n3, const TypeVect* vt); static VectorNode* make_mask_node(int vopc, Node* n1, Node* n2, uint vlen, BasicType bt); - static VectorNode* make(int vopc, Node* n1, Node* n2, uint vlen); - static VectorNode* make(int vopc, Node* n1, Node* n2, Node* n3, uint vlen); static bool is_shift_opcode(int opc); static bool can_use_RShiftI_instead_of_URShiftI(Node* n, BasicType bt); From 55ef3a01fb99f8e71a3518ecbb69b16bc84690da Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Fri, 7 Nov 2025 00:19:14 +0000 Subject: [PATCH 08/10] Revamped JTreg test generation and bug fixes --- src/hotspot/share/prims/vectorSupport.cpp | 8 + .../jdk/incubator/vector/ByteVector.java | 1 + .../jdk/incubator/vector/DoubleVector.java | 1 + .../jdk/incubator/vector/FloatVector.java | 1 + .../incubator/vector/Halffloat128Vector.java | 2 +- .../incubator/vector/Halffloat256Vector.java | 2 +- .../incubator/vector/Halffloat512Vector.java | 2 +- .../incubator/vector/Halffloat64Vector.java | 2 +- .../incubator/vector/HalffloatMaxVector.java | 2 +- .../jdk/incubator/vector/HalffloatVector.java | 86 +- .../jdk/incubator/vector/IntVector.java | 1 + .../jdk/incubator/vector/LongVector.java | 1 + .../jdk/incubator/vector/ShortVector.java | 1 + .../incubator/vector/X-Vector.java.template | 91 +- .../vector/X-VectorBits.java.template | 2 +- .../vector/AbstractVectorConversionTest.java | 110 +- .../incubator/vector/Byte128VectorTests.java | 571 ++- .../incubator/vector/Byte256VectorTests.java | 571 ++- .../incubator/vector/Byte512VectorTests.java | 571 ++- .../incubator/vector/Byte64VectorTests.java | 571 ++- .../incubator/vector/ByteMaxVectorTests.java | 569 ++- .../vector/Double128VectorTests.java | 587 ++- .../vector/Double256VectorTests.java | 587 ++- .../vector/Double512VectorTests.java | 587 ++- .../incubator/vector/Double64VectorTests.java | 587 ++- .../vector/DoubleMaxVectorTests.java | 585 ++- .../incubator/vector/Float128VectorTests.java | 587 ++- .../incubator/vector/Float256VectorTests.java | 587 ++- .../incubator/vector/Float512VectorTests.java | 587 ++- .../incubator/vector/Float64VectorTests.java | 587 ++- .../incubator/vector/FloatMaxVectorTests.java | 585 ++- .../vector/Halffloat128VectorTests.java | 3282 ++++++++++++++--- .../vector/Halffloat256VectorTests.java | 3282 ++++++++++++++--- .../vector/Halffloat512VectorTests.java | 3282 ++++++++++++++--- .../vector/Halffloat64VectorTests.java | 3282 ++++++++++++++--- .../vector/HalffloatMaxVectorTests.java | 3280 +++++++++++++--- .../incubator/vector/Int128VectorTests.java | 571 ++- .../incubator/vector/Int256VectorTests.java | 571 ++- .../incubator/vector/Int512VectorTests.java | 571 ++- .../incubator/vector/Int64VectorTests.java | 571 ++- .../incubator/vector/IntMaxVectorTests.java | 569 ++- .../incubator/vector/Long128VectorTests.java | 571 ++- .../incubator/vector/Long256VectorTests.java | 571 ++- .../incubator/vector/Long512VectorTests.java | 571 ++- .../incubator/vector/Long64VectorTests.java | 571 ++- .../incubator/vector/LongMaxVectorTests.java | 569 ++- .../incubator/vector/Short128VectorTests.java | 571 ++- .../incubator/vector/Short256VectorTests.java | 571 ++- .../incubator/vector/Short512VectorTests.java | 571 ++- .../incubator/vector/Short64VectorTests.java | 571 ++- .../incubator/vector/ShortMaxVectorTests.java | 569 ++- .../vector/Vector128ConversionTests.java | 2 +- .../vector/Vector256ConversionTests.java | 2 +- .../vector/Vector512ConversionTests.java | 2 +- .../vector/Vector64ConversionTests.java | 2 +- .../vector/VectorMaxConversionTests.java | 2 +- test/jdk/jdk/incubator/vector/gen-template.sh | 477 ++- test/jdk/jdk/incubator/vector/gen-tests.sh | 425 ++- .../Kernel-Binary-op-hf-math.template | 12 - .../Kernel-Reduction-Masked-op-func.template | 4 +- .../Kernel-Reduction-Masked-op.template | 2 +- .../Kernel-Reduction-op-func.template | 4 +- .../templates/Kernel-Reduction-op.template | 2 +- ...nel-SaturatingReduction-Masked-op.template | 4 +- .../Kernel-SaturatingReduction-op.template | 4 +- .../Kernel-Unary-op-hf-math.template | 10 - .../templates/Unit-Binary-op-hf-math.template | 14 - .../templates/Unit-Binary-op-math.template | 2 +- .../templates/Unit-Compare-Broadcast.template | 8 +- .../templates/Unit-Compare-Masked.template | 2 +- .../vector/templates/Unit-Compare.template | 2 +- .../templates/Unit-Miscellaneous.template | 86 +- ...t-Reduction-Scalar-Masked-op-func.template | 4 +- .../Unit-Reduction-Scalar-Masked-op.template | 4 +- .../Unit-Reduction-Scalar-op-func.template | 4 +- .../Unit-Reduction-Scalar-op.template | 4 +- .../vector/templates/Unit-Test.template | 4 +- .../templates/Unit-Unary-op-hf-math.template | 14 - .../templates/Unit-Unary-op-math.template | 2 +- .../vector/templates/Unit-Zero.template | 2 +- .../vector/templates/Unit-header.template | 641 +++- .../templates/X-LoadStoreTest.java.template | 10 +- 82 files changed, 27486 insertions(+), 8270 deletions(-) delete mode 100644 test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template delete mode 100644 test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template delete mode 100644 test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template delete mode 100644 test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index aa5c78c41208f..a4c4579ebbc9f 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -322,6 +322,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt, int operType) { switch (bt) { case T_BYTE: // fall-through case T_SHORT: // fall-through + if (operType == VECTOR_TYPE_FP16) { + return 0; + } + // fall-through case T_INT: return Op_AbsI; case T_LONG: return Op_AbsL; case T_FLOAT: return Op_AbsF; @@ -334,6 +338,10 @@ int VectorSupport::vop2ideal(jint id, BasicType bt, int operType) { switch (bt) { case T_BYTE: // fall-through case T_SHORT: // fall-through + if (operType == VECTOR_TYPE_FP16) { + return 0; + } + // fall-through case T_INT: return Op_NegI; case T_LONG: return Op_NegL; case T_FLOAT: return Op_NegF; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index ab250b46b9b53..f1cba9d3fc376 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -2890,6 +2890,7 @@ private static ReductionOperation> reductionOperati } } + private static final byte MIN_OR_INF = Byte.MIN_VALUE; private static final byte MAX_OR_INF = Byte.MAX_VALUE; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java index 9c20a7c755c43..4cd4367490a18 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java @@ -2704,6 +2704,7 @@ private static ReductionOperation> reductionOpe } } + private static final double MIN_OR_INF = Double.NEGATIVE_INFINITY; private static final double MAX_OR_INF = Double.POSITIVE_INFINITY; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java index ad52d6dcf6623..d2174005c3a70 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java @@ -2724,6 +2724,7 @@ private static ReductionOperation> reductionOpera } } + private static final float MIN_OR_INF = Float.NEGATIVE_INFINITY; private static final float MAX_OR_INF = Float.POSITIVE_INFINITY; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java index e4a2c7300c5ae..49dababacdbd4 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat128Vector.java @@ -560,7 +560,7 @@ public Halffloat128Vector withLaneHelper(int i, short e) { this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); - res[ix] = e; + res[ix] = (short)bits; return v.vectorFactory(res); }); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java index f92c4ed8f7956..282f90ab230f2 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat256Vector.java @@ -576,7 +576,7 @@ public Halffloat256Vector withLaneHelper(int i, short e) { this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); - res[ix] = e; + res[ix] = (short)bits; return v.vectorFactory(res); }); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java index 15e86b35b42a0..89d65d4fb3336 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat512Vector.java @@ -608,7 +608,7 @@ public Halffloat512Vector withLaneHelper(int i, short e) { this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); - res[ix] = e; + res[ix] = (short)bits; return v.vectorFactory(res); }); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java index 2fced0182d35e..a56d1113c2019 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Halffloat64Vector.java @@ -552,7 +552,7 @@ public Halffloat64Vector withLaneHelper(int i, short e) { this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); - res[ix] = e; + res[ix] = (short)bits; return v.vectorFactory(res); }); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java index dae70528a5a02..76ced2ee6541b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatMaxVector.java @@ -545,7 +545,7 @@ public HalffloatMaxVector withLaneHelper(int i, short e) { this, i, (long)e, (v, ix, bits) -> { short[] res = v.vec().clone(); - res[ix] = e; + res[ix] = (short)bits; return v.vectorFactory(res); }); } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java index ef117e79a8a88..e2d2855fc8392 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/HalffloatVector.java @@ -42,6 +42,7 @@ import static jdk.incubator.vector.VectorOperators.*; import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; // -- This file was mechanically generated: Do not edit! -- // @@ -495,7 +496,7 @@ static long toBits(short e) { /*package-private*/ @ForceInline static short fromBits(long bits) { - return Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)bits)); + return (short)bits; } static HalffloatVector expandHelper(Vector v, VectorMask m) { @@ -535,7 +536,7 @@ static HalffloatVector selectFromTwoVectorHelper(Vector indexes, Vector short[] vecPayload2 = ((HalffloatVector)src1).vec(); short[] vecPayload3 = ((HalffloatVector)src2).vec(); for (int i = 0; i < vlen; i++) { - int index = Float16.shortBitsToFloat16(vecPayload1[i]).intValue(); + int index = shortBitsToFloat16(vecPayload1[i]).intValue(); int wrapped_index = VectorIntrinsics.wrapToRange(index, 2 * vlen); res[i] = wrapped_index >= vlen ? vecPayload3[wrapped_index - vlen] : vecPayload2[wrapped_index]; } @@ -735,41 +736,41 @@ HalffloatVector unaryMathOp(VectorOperators.Unary op) { private static UnaryOperation> unaryOperations(int opc_) { switch (opc_) { case VECTOR_OP_NEG: return (v0, m) -> - v0.uOp(m, (i, a) -> (short) -a); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(-(shortBitsToFloat16((short)a).floatValue())))); case VECTOR_OP_ABS: return (v0, m) -> - v0.uOp(m, (i, a) -> (short) Math.abs(a)); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.abs(shortBitsToFloat16((short)a)))); case VECTOR_OP_SIN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sin(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_COS: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cos(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_TAN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tan(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_ASIN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.asin(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_ACOS: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.acos(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_ATAN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_EXP: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.exp(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_LOG: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_LOG10: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log10(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_SQRT: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sqrt(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_CBRT: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cbrt(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_SINH: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sinh(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_COSH: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cosh(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_TANH: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tanh(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_EXPM1: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.expm1(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_LOG1P: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log1p(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue())))); default: return null; } } @@ -862,23 +863,23 @@ HalffloatVector binaryMathOp(VectorOperators.Binary op, HalffloatVector that) { private static BinaryOperation> binaryOperations(int opc_) { switch (opc_) { case VECTOR_OP_ADD: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.add(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_SUB: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.subtract(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.subtract(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_MUL: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.multiply(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_DIV: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.divide(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.divide(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_MAX: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.max(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_MIN: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.min(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_ATAN2: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan2(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).floatValue(), shortBitsToFloat16(b).floatValue())))); case VECTOR_OP_POW: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.pow(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).floatValue(), shortBitsToFloat16(b).floatValue())))); case VECTOR_OP_HYPOT: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.hypot(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).floatValue(), shortBitsToFloat16(b).floatValue())))); default: return null; } } @@ -1070,7 +1071,7 @@ opc, getClass(), maskClass, short.class, VECTOR_OPER_TYPE, length(), private static TernaryOperation> ternaryOperations(int opc_) { switch (opc_) { case VECTOR_OP_FMA: return (v0, v1_, v2_, m) -> v0.tOp(v1_, v2_, m, (i, a, b, c) -> - Float16.float16ToRawShortBits(Float16.fma(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b), Float16.shortBitsToFloat16(c)))); + float16ToShortBits(Float16.fma(shortBitsToFloat16(a), shortBitsToFloat16(b), shortBitsToFloat16(c)))); default: return null; } } @@ -1847,7 +1848,7 @@ else if (op == IS_FINITE || // first kill the sign: bits = bits.and(Short.MAX_VALUE); // next find the bit pattern for infinity: - short infbits = (short) toBits(Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY)); + short infbits = (short) toBits(float16ToShortBits(Float16.POSITIVE_INFINITY)); // now compare: if (op == IS_FINITE) { m = bits.compare(LT, infbits); @@ -1895,7 +1896,7 @@ else if (op == IS_FINITE || // first kill the sign: bits = bits.and(Short.MAX_VALUE); // next find the bit pattern for infinity: - short infbits = (short) toBits(Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY)); + short infbits = (short) toBits(float16ToShortBits(Float16.POSITIVE_INFINITY)); // now compare: if (op == IS_FINITE) { m = bits.compare(LT, infbits, m); @@ -2105,7 +2106,7 @@ final HalffloatVector addIndexTemplate(int scale) { // and multiply. HalffloatVector iota = s.iota(); short sc = (short) scale_; - return v.add(sc == 1 ? iota : iota.mul(Float16.float16ToRawShortBits(Float16.valueOf(sc)))); + return v.add(sc == 1 ? iota : iota.mul(float16ToShortBits(Float16.valueOf(sc)))); }); } @@ -2693,19 +2694,20 @@ opc, getClass(), null, short.class, VECTOR_OPER_TYPE, length(), private static ReductionOperation> reductionOperations(int opc_) { switch (opc_) { case VECTOR_OP_ADD: return (v, m) -> - toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp((short)0, m, (i, a, b) -> float16ToShortBits(Float16.add(shortBitsToFloat16(a), shortBitsToFloat16(b))))); case VECTOR_OP_MUL: return (v, m) -> - toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(float16ToShortBits(Float16.valueOf(1.0f)), m, (i, a, b) -> float16ToShortBits(Float16.multiply(shortBitsToFloat16(a), shortBitsToFloat16(b))))); case VECTOR_OP_MIN: return (v, m) -> - toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> float16ToShortBits(Float16.min(shortBitsToFloat16(a), shortBitsToFloat16(b))))); case VECTOR_OP_MAX: return (v, m) -> - toBits(v.rOp((short)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> float16ToShortBits(Float16.max(shortBitsToFloat16(a), shortBitsToFloat16(b))))); default: return null; } } - private static final short MIN_OR_INF = Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); - private static final short MAX_OR_INF = Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + + private static final short MIN_OR_INF = float16ToShortBits(Float16.NEGATIVE_INFINITY); + private static final short MAX_OR_INF = float16ToShortBits(Float16.POSITIVE_INFINITY); public @Override abstract long reduceLanesToLong(VectorOperators.Associative op); public @Override abstract long reduceLanesToLong(VectorOperators.Associative op, @@ -2791,7 +2793,7 @@ public final long[] toLongArray() { short[] a = toArray(); long[] res = new long[a.length]; for (int i = 0; i < a.length; i++) { - short e = Float16.shortBitsToFloat16(a[i]).shortValue(); + short e = shortBitsToFloat16(a[i]).shortValue(); res[i] = HalffloatSpecies.toIntegralChecked(e, false); } return res; @@ -2809,7 +2811,7 @@ public final double[] toDoubleArray() { short[] a = toArray(); double[] res = new double[a.length]; for (int i = 0; i < a.length; i++) { - res[i] = (double) Float16.shortBitsToFloat16(a[i]).doubleValue(); + res[i] = (double) shortBitsToFloat16(a[i]).doubleValue(); } return res; } @@ -4117,7 +4119,7 @@ final HalffloatVector fromIntValues(int[] values) { short[] va = new short[laneCount()]; for (int i = 0; i < va.length; i++) { int lv = values[i]; - short v = Float16.float16ToRawShortBits(Float16.valueOf(lv)); + short v = float16ToShortBits(Float16.valueOf(lv)); va[i] = v; if (Float16.valueOf(lv).intValue() != lv) { throw badElementBits(lv, v); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index 89976a052183b..1a6016f6275e0 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -2875,6 +2875,7 @@ private static ReductionOperation> reductionOpera } } + private static final int MIN_OR_INF = Integer.MIN_VALUE; private static final int MAX_OR_INF = Integer.MAX_VALUE; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 8bbb5e09db80c..b8d44cf743f5f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -2741,6 +2741,7 @@ private static ReductionOperation> reductionOperati } } + private static final long MIN_OR_INF = Long.MIN_VALUE; private static final long MAX_OR_INF = Long.MAX_VALUE; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index b203b39997229..65851921bdb0b 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -2891,6 +2891,7 @@ private static ReductionOperation> reductionOpera } } + private static final short MIN_OR_INF = Short.MIN_VALUE; private static final short MAX_OR_INF = Short.MAX_VALUE; diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index 9380e3f23896d..9116798da0f39 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -43,6 +43,7 @@ import static jdk.incubator.vector.VectorIntrinsics.*; import static jdk.incubator.vector.VectorOperators.*; #if[FP16] import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; #end[FP16] #warn This file is preprocessed before being compiled @@ -518,7 +519,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { static long toBits($type$ e) { #if[FP16] return e; -#else[FP16] +#else[FP16] return {#if[FP]? $Type$.$type$ToRaw$Bitstype$Bits(e): e}; #end[FP16] } @@ -527,7 +528,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { @ForceInline static $type$ fromBits(long bits) { #if[FP16] - return Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)bits)); + return (short)bits; #else[FP16] return {#if[FP]?$Type$.$bitstype$BitsTo$Type$}(($bitstype$)bits); #end[FP16] @@ -571,7 +572,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] vecPayload3 = (($abstractvectortype$)src2).vec(); for (int i = 0; i < vlen; i++) { #if[FP16] - int index = Float16.shortBitsToFloat16(vecPayload1[i]).intValue(); + int index = shortBitsToFloat16(vecPayload1[i]).intValue(); int wrapped_index = VectorIntrinsics.wrapToRange(index, 2 * vlen); #else[FP16] int wrapped_index = VectorIntrinsics.wrapToRange((int)vecPayload1[i], 2 * vlen); @@ -797,10 +798,17 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { private static UnaryOperation<$abstractvectortype$, VectorMask<$Boxtype$>> unaryOperations(int opc_) { switch (opc_) { +#if[FP16] + case VECTOR_OP_NEG: return (v0, m) -> + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(-(shortBitsToFloat16(($type$)a).floatValue())))); + case VECTOR_OP_ABS: return (v0, m) -> + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.abs(shortBitsToFloat16(($type$)a)))); +#else[FP16] case VECTOR_OP_NEG: return (v0, m) -> v0.uOp(m, (i, a) -> ($type$) -a); case VECTOR_OP_ABS: return (v0, m) -> v0.uOp(m, (i, a) -> ($type$) Math.abs(a)); +#end[FP16] #if[!FP] #if[intOrLong] case VECTOR_OP_BIT_COUNT: return (v0, m) -> @@ -867,37 +875,37 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { v0.uOp(m, (i, a) -> ($type$) Math.log1p(a)); #else[!FP16] case VECTOR_OP_SIN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sin(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_COS: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cos(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_TAN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tan(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_ASIN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.asin(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_ACOS: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.acos(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_ATAN: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_EXP: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.exp(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_LOG: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_LOG10: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log10(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_SQRT: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sqrt(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_CBRT: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cbrt(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_SINH: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.sinh(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_COSH: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.cosh(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_TANH: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.tanh(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_EXPM1: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.expm1(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue())))); case VECTOR_OP_LOG1P: return (v0, m) -> - v0.uOp(m, (i, a) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.log1p(Float16.shortBitsToFloat16(a).doubleValue())))); + v0.uOp(m, (i, a) -> float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue())))); #end[!FP16] #end[FP] default: return null; @@ -1045,17 +1053,17 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { switch (opc_) { #if[FP16] case VECTOR_OP_ADD: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.add(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_SUB: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.subtract(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.subtract(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_MUL: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.multiply(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_DIV: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.divide(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.divide(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_MAX: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.max(shortBitsToFloat16(a), shortBitsToFloat16(b)))); case VECTOR_OP_MIN: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b)))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.min(shortBitsToFloat16(a), shortBitsToFloat16(b)))); #else[FP16] case VECTOR_OP_ADD: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, b) -> ($type$)(a + b)); @@ -1118,11 +1126,11 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { v0.bOp(v1, vm, (i, a, b) -> ($type$) Math.hypot(a, b)); #else[!FP16] case VECTOR_OP_ATAN2: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.atan2(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).floatValue(), shortBitsToFloat16(b).floatValue())))); case VECTOR_OP_POW: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.pow(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).floatValue(), shortBitsToFloat16(b).floatValue())))); case VECTOR_OP_HYPOT: return (v0, v1, vm) -> - v0.bOp(v1, vm, (i, a, b) -> Float16.float16ToRawShortBits(Float16.valueOf(Math.hypot(Float16.shortBitsToFloat16(a).floatValue(), Float16.shortBitsToFloat16(b).floatValue())))); + v0.bOp(v1, vm, (i, a, b) -> float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).floatValue(), shortBitsToFloat16(b).floatValue())))); #end[!FP16] #end[FP] default: return null; @@ -1436,7 +1444,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { #if[FP] #if[FP16] case VECTOR_OP_FMA: return (v0, v1_, v2_, m) -> v0.tOp(v1_, v2_, m, (i, a, b, c) -> - Float16.float16ToRawShortBits(Float16.fma(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b), Float16.shortBitsToFloat16(c)))); + float16ToShortBits(Float16.fma(shortBitsToFloat16(a), shortBitsToFloat16(b), shortBitsToFloat16(c)))); #else[FP16] case VECTOR_OP_FMA: return (v0, v1_, v2_, m) -> v0.tOp(v1_, v2_, m, (i, a, b, c) -> Math.fma(a, b, c)); @@ -2469,7 +2477,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // first kill the sign: bits = bits.and($Boxbitstype$.MAX_VALUE); // next find the bit pattern for infinity: - $bitstype$ infbits = ($bitstype$) toBits({#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}); + $bitstype$ infbits = ($bitstype$) toBits({#if[FP16]?float16ToShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}); // now compare: if (op == IS_FINITE) { m = bits.compare(LT, infbits); @@ -2523,7 +2531,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // first kill the sign: bits = bits.and($Boxbitstype$.MAX_VALUE); // next find the bit pattern for infinity: - $bitstype$ infbits = ($bitstype$) toBits({#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}); + $bitstype$ infbits = ($bitstype$) toBits({#if[FP16]?float16ToShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}); // now compare: if (op == IS_FINITE) { m = bits.compare(LT, infbits, m); @@ -2751,7 +2759,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { // and multiply. $abstractvectortype$ iota = s.iota(); $type$ sc = ($type$) scale_; - return v.add(sc == 1 ? iota : iota.mul({#if[FP16]?Float16.float16ToRawShortBits(Float16.valueOf(sc)):sc})); + return v.add(sc == 1 ? iota : iota.mul({#if[FP16]?float16ToShortBits(Float16.valueOf(sc)):sc})); }); } @@ -3534,13 +3542,13 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { switch (opc_) { #if[FP16] case VECTOR_OP_ADD: return (v, m) -> - toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(($type$)0, m, (i, a, b) -> float16ToShortBits(Float16.add(shortBitsToFloat16(a), shortBitsToFloat16(b))))); case VECTOR_OP_MUL: return (v, m) -> - toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.multiply(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(float16ToShortBits(Float16.valueOf(1.0f)), m, (i, a, b) -> float16ToShortBits(Float16.multiply(shortBitsToFloat16(a), shortBitsToFloat16(b))))); case VECTOR_OP_MIN: return (v, m) -> - toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.min(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> float16ToShortBits(Float16.min(shortBitsToFloat16(a), shortBitsToFloat16(b))))); case VECTOR_OP_MAX: return (v, m) -> - toBits(v.rOp(($type$)0, m, (i, a, b) -> Float16.float16ToRawShortBits(Float16.max(Float16.shortBitsToFloat16(a), Float16.shortBitsToFloat16(b))))); + toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> float16ToShortBits(Float16.max(shortBitsToFloat16(a), shortBitsToFloat16(b))))); #else[FP16] case VECTOR_OP_ADD: return (v, m) -> toBits(v.rOp(($type$)0, m, (i, a, b) -> ($type$)(a + b))); @@ -3571,9 +3579,10 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { } } + #if[FP] - private static final $type$ MIN_OR_INF = {#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.NEGATIVE_INFINITY):$Boxtype$.NEGATIVE_INFINITY}; - private static final $type$ MAX_OR_INF = {#if[FP16]?Float16.float16ToRawShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}; + private static final $type$ MIN_OR_INF = {#if[FP16]?float16ToShortBits($Boxtype$.NEGATIVE_INFINITY):$Boxtype$.NEGATIVE_INFINITY}; + private static final $type$ MAX_OR_INF = {#if[FP16]?float16ToShortBits($Boxtype$.POSITIVE_INFINITY):$Boxtype$.POSITIVE_INFINITY}; #else[FP] private static final $type$ MIN_OR_INF = $Boxtype$.MIN_VALUE; private static final $type$ MAX_OR_INF = $Boxtype$.MAX_VALUE; @@ -3710,7 +3719,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] a = toArray(); long[] res = new long[a.length]; for (int i = 0; i < a.length; i++) { - $type$ e = {#if[FP16]?Float16.shortBitsToFloat16(a[i]).shortValue():a[i]}; + $type$ e = {#if[FP16]?shortBitsToFloat16(a[i]).shortValue():a[i]}; res[i] = $Type$Species.toIntegralChecked(e, false); } return res; @@ -3751,7 +3760,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $type$[] a = toArray(); double[] res = new double[a.length]; for (int i = 0; i < a.length; i++) { - res[i] = (double) {#if[FP16]?Float16.shortBitsToFloat16(a[i]).doubleValue():a[i]}; + res[i] = (double) {#if[FP16]?shortBitsToFloat16(a[i]).doubleValue():a[i]}; } return res; } @@ -5779,7 +5788,7 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { for (int i = 0; i < va.length; i++) { int lv = values[i]; #if[FP16] - $type$ v = Float16.float16ToRawShortBits(Float16.valueOf(lv)); + $type$ v = float16ToShortBits(Float16.valueOf(lv)); va[i] = v; if (Float16.valueOf(lv).intValue() != lv) { throw badElementBits(lv, v); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template index b8760d5aef459..fedd7bcb5516c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template @@ -674,7 +674,7 @@ final class $vectortype$ extends $abstractvectortype$ { this, i, (long){#if[FP16]?e:$Type$.$type$ToRaw$Bitstype$Bits(e)}, (v, ix, bits) -> { $type$[] res = v.vec().clone(); - res[ix] = {#if[FP16]?e:$Type$.$bitstype$BitsTo$Type$(($bitstype$)bits)}; + res[ix] = {#if[FP16]?($bitstype$)bits:$Type$.$bitstype$BitsTo$Type$(($bitstype$)bits)}; return v.vectorFactory(res); }); } diff --git a/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java b/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java index 6f0625d7985e1..d0c885186000a 100644 --- a/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java +++ b/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 @@ -41,6 +41,7 @@ import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.IntFunction; +import jdk.incubator.vector.Float16; abstract class AbstractVectorConversionTest { @@ -156,6 +157,31 @@ static double[] fill_double(double[] a, ToDoubleF f) { return a; } + interface ToHalffloatF { + short apply(int i); + } + + static short[] fill_halffloat(int s, ToHalffloatF f) { + return fill_halffloat(new short[s], f); + } + + static short[] fill_halffloat(short[] a, ToHalffloatF f) { + for (int i = 0; i < a.length; i++) { + a[i] = f.apply(i); + } + if (a.length > 7) { + a[0] = Float16.float16ToRawShortBits(Float16.MAX_VALUE); + a[1] = Float16.float16ToRawShortBits(Float16.MIN_VALUE); + a[2] = Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); + a[3] = Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); + a[4] = Float16.float16ToRawShortBits(Float16.NaN); + a[5] = (short)0.0; + a[6] = Short.MIN_VALUE; + } + return a; + } + + static final List> BYTE_GENERATORS = List.of( withToString("byte(i)", (int s) -> fill_byte(s, i -> (byte) (i + 1))) ); @@ -180,6 +206,10 @@ static double[] fill_double(double[] a, ToDoubleF f) { withToString("double(i)", (int s) -> fill_double(s, i -> (double) (i * 10 + 0.1))) ); + static final List> HALFFLOAT_GENERATORS = List.of( + withToString("Float16(i)", (int s) -> fill_halffloat(s, i -> (short) (i * 100 + 1))) + ); + static List sourceGenerators(Class src) { if (src == byte.class) { return BYTE_GENERATORS; @@ -199,6 +229,9 @@ else if (src == float.class) { else if (src == double.class) { return DOUBLE_GENERATORS; } + else if (src == Float16.class) { + return HALFFLOAT_GENERATORS; + } else throw new IllegalStateException(); } @@ -206,11 +239,11 @@ else if (src == double.class) { static Object[][] fixedShapeXFixedShapeSpeciesArgs(VectorShape shape) { List args = new ArrayList<>(); - for (Class srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) { + for (Class srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class, Float16.class)) { VectorSpecies src = VectorSpecies.of(srcE, shape); List srcGens = sourceGenerators(srcE); - for (Class dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) { + for (Class dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class, Float16.class)) { VectorSpecies dst = VectorSpecies.of(dstE, shape); for (Object srcGen : srcGens) { @@ -225,12 +258,12 @@ static Object[][] fixedShapeXFixedShapeSpeciesArgs(VectorShape shape) { static Object[][] fixedShapeXShapeSpeciesArgs(VectorShape srcShape) { List args = new ArrayList<>(); - for (Class srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) { + for (Class srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class, Float16.class)) { VectorSpecies src = VectorSpecies.of(srcE, srcShape); List srcGens = sourceGenerators(srcE); for (VectorShape dstShape : VectorShape.values()) { - for (Class dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) { + for (Class dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class, Float16.class)) { VectorSpecies dst = VectorSpecies.of(dstE, dstShape); for (Object srcGen : srcGens) { @@ -245,10 +278,10 @@ static Object[][] fixedShapeXShapeSpeciesArgs(VectorShape srcShape) { static Object[][] fixedShapeXSegmentedCastSpeciesArgs(VectorShape srcShape, boolean legal) { List args = new ArrayList<>(); - for (Class srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) { + for (Class srcE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class, Float16.class)) { VectorSpecies src = VectorSpecies.of(srcE, srcShape); for (VectorShape dstShape : VectorShape.values()) { - for (Class dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class)) { + for (Class dstE : List.of(byte.class, short.class, int.class, long.class, float.class, double.class, Float16.class)) { VectorSpecies dst = VectorSpecies.of(dstE, dstShape); if (legal == (dst.length() == src.length())) { args.add(new Object[]{src, dst}); @@ -261,6 +294,22 @@ static Object[][] fixedShapeXSegmentedCastSpeciesArgs(VectorShape srcShape, bool public enum ConvAPI {CONVERT, CONVERTSHAPE, CASTSHAPE, REINTERPRETSHAPE} + static Short float16_conversion_adapter(Number in) { + if (in.getClass() == Short.class) + return Float16.float16ToRawShortBits(Float16.valueOf(in.shortValue())); + else if (in.getClass() == Integer.class) + return Float16.float16ToRawShortBits(Float16.valueOf(in.intValue())); + else if (in.getClass() == Long.class) + return Float16.float16ToRawShortBits(Float16.valueOf(in.longValue())); + else if (in.getClass() == Float.class) + return Float16.float16ToRawShortBits(Float16.valueOf(in.floatValue())); + else if (in.getClass() == Double.class) + return Float16.float16ToRawShortBits(Float16.valueOf(in.doubleValue())); + else if (in.getClass() == Byte.class) + return Float16.float16ToRawShortBits(Float16.valueOf(in.byteValue())); + else + throw new IllegalStateException(); + } static Function convertValueFunction(Class to) { if (to == byte.class) @@ -273,6 +322,8 @@ else if (to == long.class) return Number::longValue; else if (to == float.class) return Number::floatValue; + else if (to == Float16.class) + return (N) -> float16_conversion_adapter(N); else if (to == double.class) return Number::doubleValue; else @@ -282,7 +333,7 @@ else if (to == double.class) static BiConsumer putBufferValueFunction(Class from) { if (from == byte.class) return (bb, o) -> bb.put((byte) o); - else if (from == short.class) + else if (from == short.class || from == Float16.class) return (bb, o) -> bb.putShort((short) o); else if (from == int.class) return (bb, o) -> bb.putInt((int) o); @@ -299,7 +350,7 @@ else if (from == double.class) static Function getBufferValueFunction(Class to) { if (to == byte.class) return ByteBuffer::get; - else if (to == short.class) + else if (to == short.class || to == Float16.class) return ByteBuffer::getShort; else if (to == int.class) return ByteBuffer::getInt; @@ -335,10 +386,23 @@ static void zeroArray(Object a, int offset, int length) { static void copyConversionArray(Object src, int srcPos, Object dest, int destPos, int length, + VectorSpecies srcSpecies, + VectorSpecies dstSpecies, Function c) { + if (srcSpecies.elementType() == dstSpecies.elementType()) { + System.arraycopy(src, srcPos, dest, destPos, length); + return; + } for (int i = 0; i < length; i++) { Number v = (Number) Array.get(src, srcPos + i); - Array.set(dest, destPos + i, c.apply(v)); + if (srcSpecies.elementType() == Float16.class) { + v = (Number) Float16.shortBitsToFloat16(v.shortValue()); + } + v = (Number) c.apply(v); + if (dstSpecies.elementType() == Float16.class) { + v = (Number) v.shortValue(); + } + Array.set(dest, destPos + i, v); } } @@ -420,8 +484,14 @@ static void conversion_kernel(VectorSpecies srcSpecies, VectorSpecies< int[] parts = getPartsArray(m, is_contracting_conv); - Object expected = Array.newInstance(destSpecies.elementType(), out_len); - Object actual = Array.newInstance(destSpecies.elementType(), out_len); + Object expected = null, actual = null; + if (destSpecies.elementType() == Float16.class) { + expected = Array.newInstance(short.class, out_len); + actual = Array.newInstance(short.class, out_len); + } else { + expected = Array.newInstance(destSpecies.elementType(), out_len); + actual = Array.newInstance(destSpecies.elementType(), out_len); + } Function convertValue = convertValueFunction(destSpecies.elementType()); @@ -432,11 +502,12 @@ static void conversion_kernel(VectorSpecies srcSpecies, VectorSpecies< if (is_contracting_conv) { int start_idx = -part * src_species_len; zeroArray(expected, j, dst_species_len); - copyConversionArray(in, i, expected, start_idx + j, src_species_len, convertValue); + copyConversionArray(in, i, expected, start_idx + j, src_species_len, srcSpecies, destSpecies, convertValue); } else { int start_idx = part * dst_species_len; - copyConversionArray(in, start_idx + i, expected, j, dst_species_len, convertValue); + copyConversionArray(in, start_idx + i, expected, j, dst_species_len, srcSpecies, destSpecies, convertValue); } + } for (int ic = 0; ic < INVOC_COUNT; ic++) { @@ -452,7 +523,6 @@ static void conversion_kernel(VectorSpecies srcSpecies, VectorSpecies< System.arraycopy(rv.toArray(), 0, actual, j, dst_species_len); } } - Assert.assertEquals(actual, expected); } @@ -469,8 +539,14 @@ static void reinterpret_kernel(VectorSpecies srcSpecies, VectorSpecies int[] parts = getPartsArray(m, is_contracting_conv); - Object expected = Array.newInstance(dstSpecies.elementType(), out_len); - Object actual = Array.newInstance(dstSpecies.elementType(), out_len); + Object expected = null, actual = null; + if (dstSpecies.elementType() == Float16.class) { + expected = Array.newInstance(short.class, out_len); + actual = Array.newInstance(short.class, out_len); + } else { + expected = Array.newInstance(dstSpecies.elementType(), out_len); + actual = Array.newInstance(dstSpecies.elementType(), out_len); + } BiConsumer putValue = putBufferValueFunction(srcSpecies.elementType()); Function getValue = getBufferValueFunction(dstSpecies.elementType()); diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index 021f2fafd839a..d57bfdd02ab12 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -1070,15 +1070,15 @@ static byte bits(byte e) { } static final List> BYTE_GENERATORS = List.of( - withToString("byte[-i * 5]", (int s) -> { + withToString("Byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("byte[i * 5]", (int s) -> { + withToString("Byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("byte[i + 1]", (int s) -> { + withToString("Byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1527,6 +1527,218 @@ static boolean ge(byte a, byte b) { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte multiplicativeIdentity() { + return (byte)1; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static byte scalar_sin(byte a) { + return (byte)Math.sin((double)a); + } + + static byte scalar_exp(byte a) { + return (byte)Math.exp((double)a); + } + + static byte scalar_log1p(byte a) { + return (byte)Math.log1p((double)a); + } + + static byte scalar_log(byte a) { + return (byte)Math.log((double)a); + } + + static byte scalar_log10(byte a) { + return (byte)Math.log10((double)a); + } + + static byte scalar_expm1(byte a) { + return (byte)Math.expm1((double)a); + } + + static byte scalar_cos(byte a) { + return (byte)Math.cos((double)a); + } + + static byte scalar_tan(byte a) { + return (byte)Math.tan((double)a); + } + + static byte scalar_sinh(byte a) { + return (byte)Math.sinh((double)a); + } + + static byte scalar_cosh(byte a) { + return (byte)Math.cosh((double)a); + } + + static byte scalar_tanh(byte a) { + return (byte)Math.tanh((double)a); + } + + static byte scalar_asin(byte a) { + return (byte)Math.asin((double)a); + } + + static byte scalar_acos(byte a) { + return (byte)Math.acos((double)a); + } + + static byte scalar_atan(byte a) { + return (byte)Math.atan((double)a); + } + + static byte scalar_cbrt(byte a) { + return (byte)Math.cbrt((double)a); + } + + static byte scalar_sqrt(byte a) { + return (byte)Math.sqrt((double)a); + } + + static byte scalar_hypot(byte a, byte b) { + return (byte)Math.hypot((double)a, (double)b); + } + + static byte scalar_pow(byte a, byte b) { + return (byte)Math.pow((double)a, (double)b); + } + + static byte scalar_atan2(byte a, byte b) { + return (byte)Math.atan2((double)a, (double)b); + } + + static byte strict_scalar_sin(byte a) { + return (byte)StrictMath.sin((double)a); + } + + static byte strict_scalar_exp(byte a) { + return (byte)StrictMath.exp((double)a); + } + + static byte strict_scalar_log1p(byte a) { + return (byte)StrictMath.log1p((double)a); + } + + static byte strict_scalar_log(byte a) { + return (byte)StrictMath.log((double)a); + } + + static byte strict_scalar_log10(byte a) { + return (byte)StrictMath.log10((double)a); + } + + static byte strict_scalar_expm1(byte a) { + return (byte)StrictMath.expm1((double)a); + } + + static byte strict_scalar_cos(byte a) { + return (byte)StrictMath.cos((double)a); + } + + static byte strict_scalar_tan(byte a) { + return (byte)StrictMath.tan((double)a); + } + + static byte strict_scalar_sinh(byte a) { + return (byte)StrictMath.sinh((double)a); + } + + static byte strict_scalar_cosh(byte a) { + return (byte)StrictMath.cosh((double)a); + } + + static byte strict_scalar_tanh(byte a) { + return (byte)StrictMath.tanh((double)a); + } + + static byte strict_scalar_asin(byte a) { + return (byte)StrictMath.asin((double)a); + } + + static byte strict_scalar_acos(byte a) { + return (byte)StrictMath.acos((double)a); + } + + static byte strict_scalar_atan(byte a) { + return (byte)StrictMath.atan((double)a); + } + + static byte strict_scalar_cbrt(byte a) { + return (byte)StrictMath.cbrt((double)a); + } + + static byte strict_scalar_sqrt(byte a) { + return (byte)StrictMath.sqrt((double)a); + } + + static byte strict_scalar_hypot(byte a, byte b) { + return (byte)StrictMath.hypot((double)a, (double)b); + } + + static byte strict_scalar_pow(byte a, byte b) { + return (byte)StrictMath.pow((double)a, (double)b); + } + + static byte strict_scalar_atan2(byte a, byte b) { + return (byte)StrictMath.atan2((double)a, (double)b); + } + static byte additiveIdentity() { + return (byte)0; + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1543,10 +1755,19 @@ static boolean uge(byte a, byte b) { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; + static byte zeroValue() { + return (short) 0; + } + + static byte maxValue() { + return Byte.MAX_VALUE; + } + + static byte minValue() { + return Byte.MIN_VALUE; } + @Test static void smokeTest1() { ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); @@ -1654,7 +1875,7 @@ static void bitwiseDivByZeroSmokeTest() { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1675,7 +1896,7 @@ static void ADDByte128VectorTests(IntFunction fa, IntFunction fb } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1732,7 +1953,7 @@ static void addByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1810,7 +2031,7 @@ static void subByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1978,7 +2199,7 @@ static void divByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3201,7 +3422,7 @@ static void MINByte128VectorTests(IntFunction fa, IntFunction fb } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3220,7 +3441,7 @@ static void minByte128VectorTests(IntFunction fa, IntFunction fb } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3241,7 +3462,7 @@ static void MAXByte128VectorTests(IntFunction fa, IntFunction fb } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3609,7 +3830,7 @@ static void SUADDAssocByte128VectorTestsMasked(IntFunction fa, IntFuncti static byte ANDReduce(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3618,7 +3839,7 @@ static byte ANDReduce(byte[] a, int idx) { static byte ANDReduceAll(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3641,7 +3862,7 @@ static void ANDReduceByte128VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3653,7 +3874,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3687,7 +3908,7 @@ static void ANDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3698,7 +3919,7 @@ static void ANDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio static byte ORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3707,7 +3928,7 @@ static byte ORReduce(byte[] a, int idx) { static byte ORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3730,7 +3951,7 @@ static void ORReduceByte128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3742,7 +3963,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3776,7 +3997,7 @@ static void ORReduceByte128VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3787,7 +4008,7 @@ static void ORReduceByte128VectorTestsMasked(IntFunction fa, IntFunction static byte XORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3796,7 +4017,7 @@ static byte XORReduce(byte[] a, int idx) { static byte XORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3819,7 +4040,7 @@ static void XORReduceByte128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3831,7 +4052,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3840,7 +4061,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3865,7 +4086,7 @@ static void XORReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3874,18 +4095,18 @@ static void XORReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } static byte ADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAll(byte[] a) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3895,7 +4116,7 @@ static byte ADDReduceAll(byte[] a) { static void ADDReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3905,10 +4126,10 @@ static void ADDReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3917,19 +4138,19 @@ static void ADDReduceByte128VectorTests(IntFunction fa) { } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3941,7 +4162,7 @@ static void ADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3951,10 +4172,10 @@ static void ADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3963,18 +4184,18 @@ static void ADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } static byte MULReduce(byte[] a, int idx) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAll(byte[] a) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3984,7 +4205,7 @@ static byte MULReduceAll(byte[] a) { static void MULReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3994,10 +4215,10 @@ static void MULReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4006,19 +4227,19 @@ static void MULReduceByte128VectorTests(IntFunction fa) { } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4030,7 +4251,7 @@ static void MULReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4040,10 +4261,10 @@ static void MULReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4052,18 +4273,18 @@ static void MULReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } static byte MINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4073,7 +4294,7 @@ static byte MINReduceAll(byte[] a) { static void MINReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4083,10 +4304,10 @@ static void MINReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4095,19 +4316,19 @@ static void MINReduceByte128VectorTests(IntFunction fa) { } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4119,7 +4340,7 @@ static void MINReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4129,10 +4350,10 @@ static void MINReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4141,18 +4362,18 @@ static void MINReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } static byte MAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4162,7 +4383,7 @@ static byte MAXReduceAll(byte[] a) { static void MAXReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4172,10 +4393,10 @@ static void MAXReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4184,19 +4405,19 @@ static void MAXReduceByte128VectorTests(IntFunction fa) { } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4208,7 +4429,7 @@ static void MAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4218,10 +4439,10 @@ static void MAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4230,7 +4451,7 @@ static void MAXReduceByte128VectorTestsMasked(IntFunction fa, IntFunctio } static byte UMINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.minUnsigned(res, a[i]); } @@ -4239,7 +4460,7 @@ static byte UMINReduce(byte[] a, int idx) { } static byte UMINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4251,7 +4472,7 @@ static byte UMINReduceAll(byte[] a) { static void UMINReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4261,7 +4482,7 @@ static void UMINReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4273,7 +4494,7 @@ static void UMINReduceByte128VectorTests(IntFunction fa) { } static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.minUnsigned(res, a[i]); @@ -4283,7 +4504,7 @@ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4297,7 +4518,7 @@ static void UMINReduceByte128VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4307,7 +4528,7 @@ static void UMINReduceByte128VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4319,7 +4540,7 @@ static void UMINReduceByte128VectorTestsMasked(IntFunction fa, IntFuncti } static byte UMAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.maxUnsigned(res, a[i]); } @@ -4328,7 +4549,7 @@ static byte UMAXReduce(byte[] a, int idx) { } static byte UMAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4340,7 +4561,7 @@ static byte UMAXReduceAll(byte[] a) { static void UMAXReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4350,7 +4571,7 @@ static void UMAXReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4362,7 +4583,7 @@ static void UMAXReduceByte128VectorTests(IntFunction fa) { } static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.maxUnsigned(res, a[i]); @@ -4372,7 +4593,7 @@ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4386,7 +4607,7 @@ static void UMAXReduceByte128VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4396,7 +4617,7 @@ static void UMAXReduceByte128VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4408,7 +4629,7 @@ static void UMAXReduceByte128VectorTestsMasked(IntFunction fa, IntFuncti } static byte FIRST_NONZEROReduce(byte[] a, int idx) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4417,7 +4638,7 @@ static byte FIRST_NONZEROReduce(byte[] a, int idx) { } static byte FIRST_NONZEROReduceAll(byte[] a) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4429,7 +4650,7 @@ static byte FIRST_NONZEROReduceAll(byte[] a) { static void FIRST_NONZEROReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4439,7 +4660,7 @@ static void FIRST_NONZEROReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4451,7 +4672,7 @@ static void FIRST_NONZEROReduceByte128VectorTests(IntFunction fa) { } static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4461,7 +4682,7 @@ static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4475,7 +4696,7 @@ static void FIRST_NONZEROReduceByte128VectorTestsMasked(IntFunction fa, byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4485,7 +4706,7 @@ static void FIRST_NONZEROReduceByte128VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4545,7 +4766,7 @@ static void allTrueByte128VectorTests(IntFunction fm) { } static byte SUADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4554,7 +4775,7 @@ static byte SUADDReduce(byte[] a, int idx) { } static byte SUADDReduceAll(byte[] a) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4566,7 +4787,7 @@ static byte SUADDReduceAll(byte[] a) { static void SUADDReduceByte128VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4576,7 +4797,7 @@ static void SUADDReduceByte128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4588,7 +4809,7 @@ static void SUADDReduceByte128VectorTests(IntFunction fa) { } static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4598,7 +4819,7 @@ static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4611,7 +4832,7 @@ static void SUADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunct byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4621,7 +4842,7 @@ static void SUADDReduceByte128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4666,7 +4887,7 @@ static void IS_DEFAULTByte128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4686,7 +4907,7 @@ static void IS_DEFAULTMaskedByte128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4707,7 +4928,7 @@ static void IS_NEGATIVEByte128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4727,7 +4948,7 @@ static void IS_NEGATIVEMaskedByte128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void LTByte128VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4765,7 +4986,7 @@ static void ltByte128VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4788,7 +5009,7 @@ static void LTByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4830,7 +5051,7 @@ static void GTByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4868,7 +5089,7 @@ static void eqByte128VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4891,7 +5112,7 @@ static void EQByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4933,7 +5154,7 @@ static void NEByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4975,7 +5196,7 @@ static void LEByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5017,7 +5238,7 @@ static void GEByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5059,7 +5280,7 @@ static void ULTByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5101,7 +5322,7 @@ static void UGTByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5143,7 +5364,7 @@ static void ULEByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5185,7 +5406,7 @@ static void UGEByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5222,7 +5443,7 @@ static void LTByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5238,7 +5459,7 @@ static void LTByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @@ -5258,7 +5479,7 @@ static void LTByte128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(byte)((long)b[i])))); } } } @@ -5274,7 +5495,7 @@ static void EQByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5294,7 +5515,7 @@ static void EQByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5310,7 +5531,7 @@ static void EQByte128VectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @@ -5330,7 +5551,7 @@ static void EQByte128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(byte)((long)b[i])))); } } } @@ -5611,7 +5832,7 @@ static void ZeroByte128VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static byte[] sliceUnary(byte[] a, int origin, int idx) { @@ -6042,11 +6263,11 @@ static void BITWISE_BLENDByte128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6098,11 +6319,11 @@ static void NEGMaskedByte128VectorTests(IntFunction fa, } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6442,7 +6663,7 @@ static void ltByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6458,7 +6679,7 @@ static void eqByte128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6709,7 +6930,7 @@ static void shuffleMiscellaneousByte128VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index 30f3720235086..427da26a5b932 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -1070,15 +1070,15 @@ static byte bits(byte e) { } static final List> BYTE_GENERATORS = List.of( - withToString("byte[-i * 5]", (int s) -> { + withToString("Byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("byte[i * 5]", (int s) -> { + withToString("Byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("byte[i + 1]", (int s) -> { + withToString("Byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1527,6 +1527,218 @@ static boolean ge(byte a, byte b) { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte multiplicativeIdentity() { + return (byte)1; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static byte scalar_sin(byte a) { + return (byte)Math.sin((double)a); + } + + static byte scalar_exp(byte a) { + return (byte)Math.exp((double)a); + } + + static byte scalar_log1p(byte a) { + return (byte)Math.log1p((double)a); + } + + static byte scalar_log(byte a) { + return (byte)Math.log((double)a); + } + + static byte scalar_log10(byte a) { + return (byte)Math.log10((double)a); + } + + static byte scalar_expm1(byte a) { + return (byte)Math.expm1((double)a); + } + + static byte scalar_cos(byte a) { + return (byte)Math.cos((double)a); + } + + static byte scalar_tan(byte a) { + return (byte)Math.tan((double)a); + } + + static byte scalar_sinh(byte a) { + return (byte)Math.sinh((double)a); + } + + static byte scalar_cosh(byte a) { + return (byte)Math.cosh((double)a); + } + + static byte scalar_tanh(byte a) { + return (byte)Math.tanh((double)a); + } + + static byte scalar_asin(byte a) { + return (byte)Math.asin((double)a); + } + + static byte scalar_acos(byte a) { + return (byte)Math.acos((double)a); + } + + static byte scalar_atan(byte a) { + return (byte)Math.atan((double)a); + } + + static byte scalar_cbrt(byte a) { + return (byte)Math.cbrt((double)a); + } + + static byte scalar_sqrt(byte a) { + return (byte)Math.sqrt((double)a); + } + + static byte scalar_hypot(byte a, byte b) { + return (byte)Math.hypot((double)a, (double)b); + } + + static byte scalar_pow(byte a, byte b) { + return (byte)Math.pow((double)a, (double)b); + } + + static byte scalar_atan2(byte a, byte b) { + return (byte)Math.atan2((double)a, (double)b); + } + + static byte strict_scalar_sin(byte a) { + return (byte)StrictMath.sin((double)a); + } + + static byte strict_scalar_exp(byte a) { + return (byte)StrictMath.exp((double)a); + } + + static byte strict_scalar_log1p(byte a) { + return (byte)StrictMath.log1p((double)a); + } + + static byte strict_scalar_log(byte a) { + return (byte)StrictMath.log((double)a); + } + + static byte strict_scalar_log10(byte a) { + return (byte)StrictMath.log10((double)a); + } + + static byte strict_scalar_expm1(byte a) { + return (byte)StrictMath.expm1((double)a); + } + + static byte strict_scalar_cos(byte a) { + return (byte)StrictMath.cos((double)a); + } + + static byte strict_scalar_tan(byte a) { + return (byte)StrictMath.tan((double)a); + } + + static byte strict_scalar_sinh(byte a) { + return (byte)StrictMath.sinh((double)a); + } + + static byte strict_scalar_cosh(byte a) { + return (byte)StrictMath.cosh((double)a); + } + + static byte strict_scalar_tanh(byte a) { + return (byte)StrictMath.tanh((double)a); + } + + static byte strict_scalar_asin(byte a) { + return (byte)StrictMath.asin((double)a); + } + + static byte strict_scalar_acos(byte a) { + return (byte)StrictMath.acos((double)a); + } + + static byte strict_scalar_atan(byte a) { + return (byte)StrictMath.atan((double)a); + } + + static byte strict_scalar_cbrt(byte a) { + return (byte)StrictMath.cbrt((double)a); + } + + static byte strict_scalar_sqrt(byte a) { + return (byte)StrictMath.sqrt((double)a); + } + + static byte strict_scalar_hypot(byte a, byte b) { + return (byte)StrictMath.hypot((double)a, (double)b); + } + + static byte strict_scalar_pow(byte a, byte b) { + return (byte)StrictMath.pow((double)a, (double)b); + } + + static byte strict_scalar_atan2(byte a, byte b) { + return (byte)StrictMath.atan2((double)a, (double)b); + } + static byte additiveIdentity() { + return (byte)0; + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1543,10 +1755,19 @@ static boolean uge(byte a, byte b) { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; + static byte zeroValue() { + return (short) 0; + } + + static byte maxValue() { + return Byte.MAX_VALUE; + } + + static byte minValue() { + return Byte.MIN_VALUE; } + @Test static void smokeTest1() { ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); @@ -1654,7 +1875,7 @@ static void bitwiseDivByZeroSmokeTest() { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1675,7 +1896,7 @@ static void ADDByte256VectorTests(IntFunction fa, IntFunction fb } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1732,7 +1953,7 @@ static void addByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1810,7 +2031,7 @@ static void subByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1978,7 +2199,7 @@ static void divByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3201,7 +3422,7 @@ static void MINByte256VectorTests(IntFunction fa, IntFunction fb } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3220,7 +3441,7 @@ static void minByte256VectorTests(IntFunction fa, IntFunction fb } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3241,7 +3462,7 @@ static void MAXByte256VectorTests(IntFunction fa, IntFunction fb } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3609,7 +3830,7 @@ static void SUADDAssocByte256VectorTestsMasked(IntFunction fa, IntFuncti static byte ANDReduce(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3618,7 +3839,7 @@ static byte ANDReduce(byte[] a, int idx) { static byte ANDReduceAll(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3641,7 +3862,7 @@ static void ANDReduceByte256VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3653,7 +3874,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3687,7 +3908,7 @@ static void ANDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3698,7 +3919,7 @@ static void ANDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio static byte ORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3707,7 +3928,7 @@ static byte ORReduce(byte[] a, int idx) { static byte ORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3730,7 +3951,7 @@ static void ORReduceByte256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3742,7 +3963,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3776,7 +3997,7 @@ static void ORReduceByte256VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3787,7 +4008,7 @@ static void ORReduceByte256VectorTestsMasked(IntFunction fa, IntFunction static byte XORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3796,7 +4017,7 @@ static byte XORReduce(byte[] a, int idx) { static byte XORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3819,7 +4040,7 @@ static void XORReduceByte256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3831,7 +4052,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3840,7 +4061,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3865,7 +4086,7 @@ static void XORReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3874,18 +4095,18 @@ static void XORReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } static byte ADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAll(byte[] a) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3895,7 +4116,7 @@ static byte ADDReduceAll(byte[] a) { static void ADDReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3905,10 +4126,10 @@ static void ADDReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3917,19 +4138,19 @@ static void ADDReduceByte256VectorTests(IntFunction fa) { } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3941,7 +4162,7 @@ static void ADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3951,10 +4172,10 @@ static void ADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3963,18 +4184,18 @@ static void ADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } static byte MULReduce(byte[] a, int idx) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAll(byte[] a) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3984,7 +4205,7 @@ static byte MULReduceAll(byte[] a) { static void MULReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3994,10 +4215,10 @@ static void MULReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4006,19 +4227,19 @@ static void MULReduceByte256VectorTests(IntFunction fa) { } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4030,7 +4251,7 @@ static void MULReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4040,10 +4261,10 @@ static void MULReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4052,18 +4273,18 @@ static void MULReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } static byte MINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4073,7 +4294,7 @@ static byte MINReduceAll(byte[] a) { static void MINReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4083,10 +4304,10 @@ static void MINReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4095,19 +4316,19 @@ static void MINReduceByte256VectorTests(IntFunction fa) { } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4119,7 +4340,7 @@ static void MINReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4129,10 +4350,10 @@ static void MINReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4141,18 +4362,18 @@ static void MINReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } static byte MAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4162,7 +4383,7 @@ static byte MAXReduceAll(byte[] a) { static void MAXReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4172,10 +4393,10 @@ static void MAXReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4184,19 +4405,19 @@ static void MAXReduceByte256VectorTests(IntFunction fa) { } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4208,7 +4429,7 @@ static void MAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4218,10 +4439,10 @@ static void MAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4230,7 +4451,7 @@ static void MAXReduceByte256VectorTestsMasked(IntFunction fa, IntFunctio } static byte UMINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.minUnsigned(res, a[i]); } @@ -4239,7 +4460,7 @@ static byte UMINReduce(byte[] a, int idx) { } static byte UMINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4251,7 +4472,7 @@ static byte UMINReduceAll(byte[] a) { static void UMINReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4261,7 +4482,7 @@ static void UMINReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4273,7 +4494,7 @@ static void UMINReduceByte256VectorTests(IntFunction fa) { } static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.minUnsigned(res, a[i]); @@ -4283,7 +4504,7 @@ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4297,7 +4518,7 @@ static void UMINReduceByte256VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4307,7 +4528,7 @@ static void UMINReduceByte256VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4319,7 +4540,7 @@ static void UMINReduceByte256VectorTestsMasked(IntFunction fa, IntFuncti } static byte UMAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.maxUnsigned(res, a[i]); } @@ -4328,7 +4549,7 @@ static byte UMAXReduce(byte[] a, int idx) { } static byte UMAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4340,7 +4561,7 @@ static byte UMAXReduceAll(byte[] a) { static void UMAXReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4350,7 +4571,7 @@ static void UMAXReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4362,7 +4583,7 @@ static void UMAXReduceByte256VectorTests(IntFunction fa) { } static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.maxUnsigned(res, a[i]); @@ -4372,7 +4593,7 @@ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4386,7 +4607,7 @@ static void UMAXReduceByte256VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4396,7 +4617,7 @@ static void UMAXReduceByte256VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4408,7 +4629,7 @@ static void UMAXReduceByte256VectorTestsMasked(IntFunction fa, IntFuncti } static byte FIRST_NONZEROReduce(byte[] a, int idx) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4417,7 +4638,7 @@ static byte FIRST_NONZEROReduce(byte[] a, int idx) { } static byte FIRST_NONZEROReduceAll(byte[] a) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4429,7 +4650,7 @@ static byte FIRST_NONZEROReduceAll(byte[] a) { static void FIRST_NONZEROReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4439,7 +4660,7 @@ static void FIRST_NONZEROReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4451,7 +4672,7 @@ static void FIRST_NONZEROReduceByte256VectorTests(IntFunction fa) { } static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4461,7 +4682,7 @@ static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4475,7 +4696,7 @@ static void FIRST_NONZEROReduceByte256VectorTestsMasked(IntFunction fa, byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4485,7 +4706,7 @@ static void FIRST_NONZEROReduceByte256VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4545,7 +4766,7 @@ static void allTrueByte256VectorTests(IntFunction fm) { } static byte SUADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4554,7 +4775,7 @@ static byte SUADDReduce(byte[] a, int idx) { } static byte SUADDReduceAll(byte[] a) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4566,7 +4787,7 @@ static byte SUADDReduceAll(byte[] a) { static void SUADDReduceByte256VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4576,7 +4797,7 @@ static void SUADDReduceByte256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4588,7 +4809,7 @@ static void SUADDReduceByte256VectorTests(IntFunction fa) { } static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4598,7 +4819,7 @@ static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4611,7 +4832,7 @@ static void SUADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunct byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4621,7 +4842,7 @@ static void SUADDReduceByte256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4666,7 +4887,7 @@ static void IS_DEFAULTByte256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4686,7 +4907,7 @@ static void IS_DEFAULTMaskedByte256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4707,7 +4928,7 @@ static void IS_NEGATIVEByte256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4727,7 +4948,7 @@ static void IS_NEGATIVEMaskedByte256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void LTByte256VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4765,7 +4986,7 @@ static void ltByte256VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4788,7 +5009,7 @@ static void LTByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4830,7 +5051,7 @@ static void GTByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4868,7 +5089,7 @@ static void eqByte256VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4891,7 +5112,7 @@ static void EQByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4933,7 +5154,7 @@ static void NEByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4975,7 +5196,7 @@ static void LEByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5017,7 +5238,7 @@ static void GEByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5059,7 +5280,7 @@ static void ULTByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5101,7 +5322,7 @@ static void UGTByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5143,7 +5364,7 @@ static void ULEByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5185,7 +5406,7 @@ static void UGEByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5222,7 +5443,7 @@ static void LTByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5238,7 +5459,7 @@ static void LTByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @@ -5258,7 +5479,7 @@ static void LTByte256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(byte)((long)b[i])))); } } } @@ -5274,7 +5495,7 @@ static void EQByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5294,7 +5515,7 @@ static void EQByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5310,7 +5531,7 @@ static void EQByte256VectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @@ -5330,7 +5551,7 @@ static void EQByte256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(byte)((long)b[i])))); } } } @@ -5611,7 +5832,7 @@ static void ZeroByte256VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static byte[] sliceUnary(byte[] a, int origin, int idx) { @@ -6042,11 +6263,11 @@ static void BITWISE_BLENDByte256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6098,11 +6319,11 @@ static void NEGMaskedByte256VectorTests(IntFunction fa, } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6442,7 +6663,7 @@ static void ltByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6458,7 +6679,7 @@ static void eqByte256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6709,7 +6930,7 @@ static void shuffleMiscellaneousByte256VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index d4af7040c7eba..8ea962780641a 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -1070,15 +1070,15 @@ static byte bits(byte e) { } static final List> BYTE_GENERATORS = List.of( - withToString("byte[-i * 5]", (int s) -> { + withToString("Byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("byte[i * 5]", (int s) -> { + withToString("Byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("byte[i + 1]", (int s) -> { + withToString("Byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1527,6 +1527,218 @@ static boolean ge(byte a, byte b) { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte multiplicativeIdentity() { + return (byte)1; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static byte scalar_sin(byte a) { + return (byte)Math.sin((double)a); + } + + static byte scalar_exp(byte a) { + return (byte)Math.exp((double)a); + } + + static byte scalar_log1p(byte a) { + return (byte)Math.log1p((double)a); + } + + static byte scalar_log(byte a) { + return (byte)Math.log((double)a); + } + + static byte scalar_log10(byte a) { + return (byte)Math.log10((double)a); + } + + static byte scalar_expm1(byte a) { + return (byte)Math.expm1((double)a); + } + + static byte scalar_cos(byte a) { + return (byte)Math.cos((double)a); + } + + static byte scalar_tan(byte a) { + return (byte)Math.tan((double)a); + } + + static byte scalar_sinh(byte a) { + return (byte)Math.sinh((double)a); + } + + static byte scalar_cosh(byte a) { + return (byte)Math.cosh((double)a); + } + + static byte scalar_tanh(byte a) { + return (byte)Math.tanh((double)a); + } + + static byte scalar_asin(byte a) { + return (byte)Math.asin((double)a); + } + + static byte scalar_acos(byte a) { + return (byte)Math.acos((double)a); + } + + static byte scalar_atan(byte a) { + return (byte)Math.atan((double)a); + } + + static byte scalar_cbrt(byte a) { + return (byte)Math.cbrt((double)a); + } + + static byte scalar_sqrt(byte a) { + return (byte)Math.sqrt((double)a); + } + + static byte scalar_hypot(byte a, byte b) { + return (byte)Math.hypot((double)a, (double)b); + } + + static byte scalar_pow(byte a, byte b) { + return (byte)Math.pow((double)a, (double)b); + } + + static byte scalar_atan2(byte a, byte b) { + return (byte)Math.atan2((double)a, (double)b); + } + + static byte strict_scalar_sin(byte a) { + return (byte)StrictMath.sin((double)a); + } + + static byte strict_scalar_exp(byte a) { + return (byte)StrictMath.exp((double)a); + } + + static byte strict_scalar_log1p(byte a) { + return (byte)StrictMath.log1p((double)a); + } + + static byte strict_scalar_log(byte a) { + return (byte)StrictMath.log((double)a); + } + + static byte strict_scalar_log10(byte a) { + return (byte)StrictMath.log10((double)a); + } + + static byte strict_scalar_expm1(byte a) { + return (byte)StrictMath.expm1((double)a); + } + + static byte strict_scalar_cos(byte a) { + return (byte)StrictMath.cos((double)a); + } + + static byte strict_scalar_tan(byte a) { + return (byte)StrictMath.tan((double)a); + } + + static byte strict_scalar_sinh(byte a) { + return (byte)StrictMath.sinh((double)a); + } + + static byte strict_scalar_cosh(byte a) { + return (byte)StrictMath.cosh((double)a); + } + + static byte strict_scalar_tanh(byte a) { + return (byte)StrictMath.tanh((double)a); + } + + static byte strict_scalar_asin(byte a) { + return (byte)StrictMath.asin((double)a); + } + + static byte strict_scalar_acos(byte a) { + return (byte)StrictMath.acos((double)a); + } + + static byte strict_scalar_atan(byte a) { + return (byte)StrictMath.atan((double)a); + } + + static byte strict_scalar_cbrt(byte a) { + return (byte)StrictMath.cbrt((double)a); + } + + static byte strict_scalar_sqrt(byte a) { + return (byte)StrictMath.sqrt((double)a); + } + + static byte strict_scalar_hypot(byte a, byte b) { + return (byte)StrictMath.hypot((double)a, (double)b); + } + + static byte strict_scalar_pow(byte a, byte b) { + return (byte)StrictMath.pow((double)a, (double)b); + } + + static byte strict_scalar_atan2(byte a, byte b) { + return (byte)StrictMath.atan2((double)a, (double)b); + } + static byte additiveIdentity() { + return (byte)0; + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1543,10 +1755,19 @@ static boolean uge(byte a, byte b) { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; + static byte zeroValue() { + return (short) 0; + } + + static byte maxValue() { + return Byte.MAX_VALUE; + } + + static byte minValue() { + return Byte.MIN_VALUE; } + @Test static void smokeTest1() { ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); @@ -1654,7 +1875,7 @@ static void bitwiseDivByZeroSmokeTest() { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1675,7 +1896,7 @@ static void ADDByte512VectorTests(IntFunction fa, IntFunction fb } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1732,7 +1953,7 @@ static void addByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1810,7 +2031,7 @@ static void subByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1978,7 +2199,7 @@ static void divByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3201,7 +3422,7 @@ static void MINByte512VectorTests(IntFunction fa, IntFunction fb } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3220,7 +3441,7 @@ static void minByte512VectorTests(IntFunction fa, IntFunction fb } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3241,7 +3462,7 @@ static void MAXByte512VectorTests(IntFunction fa, IntFunction fb } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3609,7 +3830,7 @@ static void SUADDAssocByte512VectorTestsMasked(IntFunction fa, IntFuncti static byte ANDReduce(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3618,7 +3839,7 @@ static byte ANDReduce(byte[] a, int idx) { static byte ANDReduceAll(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3641,7 +3862,7 @@ static void ANDReduceByte512VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3653,7 +3874,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3687,7 +3908,7 @@ static void ANDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3698,7 +3919,7 @@ static void ANDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio static byte ORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3707,7 +3928,7 @@ static byte ORReduce(byte[] a, int idx) { static byte ORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3730,7 +3951,7 @@ static void ORReduceByte512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3742,7 +3963,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3776,7 +3997,7 @@ static void ORReduceByte512VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3787,7 +4008,7 @@ static void ORReduceByte512VectorTestsMasked(IntFunction fa, IntFunction static byte XORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3796,7 +4017,7 @@ static byte XORReduce(byte[] a, int idx) { static byte XORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3819,7 +4040,7 @@ static void XORReduceByte512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3831,7 +4052,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3840,7 +4061,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3865,7 +4086,7 @@ static void XORReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3874,18 +4095,18 @@ static void XORReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } static byte ADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAll(byte[] a) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3895,7 +4116,7 @@ static byte ADDReduceAll(byte[] a) { static void ADDReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3905,10 +4126,10 @@ static void ADDReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3917,19 +4138,19 @@ static void ADDReduceByte512VectorTests(IntFunction fa) { } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3941,7 +4162,7 @@ static void ADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3951,10 +4172,10 @@ static void ADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3963,18 +4184,18 @@ static void ADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } static byte MULReduce(byte[] a, int idx) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAll(byte[] a) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3984,7 +4205,7 @@ static byte MULReduceAll(byte[] a) { static void MULReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3994,10 +4215,10 @@ static void MULReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4006,19 +4227,19 @@ static void MULReduceByte512VectorTests(IntFunction fa) { } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4030,7 +4251,7 @@ static void MULReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4040,10 +4261,10 @@ static void MULReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4052,18 +4273,18 @@ static void MULReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } static byte MINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4073,7 +4294,7 @@ static byte MINReduceAll(byte[] a) { static void MINReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4083,10 +4304,10 @@ static void MINReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4095,19 +4316,19 @@ static void MINReduceByte512VectorTests(IntFunction fa) { } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4119,7 +4340,7 @@ static void MINReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4129,10 +4350,10 @@ static void MINReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4141,18 +4362,18 @@ static void MINReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } static byte MAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4162,7 +4383,7 @@ static byte MAXReduceAll(byte[] a) { static void MAXReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4172,10 +4393,10 @@ static void MAXReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4184,19 +4405,19 @@ static void MAXReduceByte512VectorTests(IntFunction fa) { } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4208,7 +4429,7 @@ static void MAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4218,10 +4439,10 @@ static void MAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4230,7 +4451,7 @@ static void MAXReduceByte512VectorTestsMasked(IntFunction fa, IntFunctio } static byte UMINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.minUnsigned(res, a[i]); } @@ -4239,7 +4460,7 @@ static byte UMINReduce(byte[] a, int idx) { } static byte UMINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4251,7 +4472,7 @@ static byte UMINReduceAll(byte[] a) { static void UMINReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4261,7 +4482,7 @@ static void UMINReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4273,7 +4494,7 @@ static void UMINReduceByte512VectorTests(IntFunction fa) { } static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.minUnsigned(res, a[i]); @@ -4283,7 +4504,7 @@ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4297,7 +4518,7 @@ static void UMINReduceByte512VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4307,7 +4528,7 @@ static void UMINReduceByte512VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4319,7 +4540,7 @@ static void UMINReduceByte512VectorTestsMasked(IntFunction fa, IntFuncti } static byte UMAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.maxUnsigned(res, a[i]); } @@ -4328,7 +4549,7 @@ static byte UMAXReduce(byte[] a, int idx) { } static byte UMAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4340,7 +4561,7 @@ static byte UMAXReduceAll(byte[] a) { static void UMAXReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4350,7 +4571,7 @@ static void UMAXReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4362,7 +4583,7 @@ static void UMAXReduceByte512VectorTests(IntFunction fa) { } static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.maxUnsigned(res, a[i]); @@ -4372,7 +4593,7 @@ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4386,7 +4607,7 @@ static void UMAXReduceByte512VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4396,7 +4617,7 @@ static void UMAXReduceByte512VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4408,7 +4629,7 @@ static void UMAXReduceByte512VectorTestsMasked(IntFunction fa, IntFuncti } static byte FIRST_NONZEROReduce(byte[] a, int idx) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4417,7 +4638,7 @@ static byte FIRST_NONZEROReduce(byte[] a, int idx) { } static byte FIRST_NONZEROReduceAll(byte[] a) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4429,7 +4650,7 @@ static byte FIRST_NONZEROReduceAll(byte[] a) { static void FIRST_NONZEROReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4439,7 +4660,7 @@ static void FIRST_NONZEROReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4451,7 +4672,7 @@ static void FIRST_NONZEROReduceByte512VectorTests(IntFunction fa) { } static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4461,7 +4682,7 @@ static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4475,7 +4696,7 @@ static void FIRST_NONZEROReduceByte512VectorTestsMasked(IntFunction fa, byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4485,7 +4706,7 @@ static void FIRST_NONZEROReduceByte512VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4545,7 +4766,7 @@ static void allTrueByte512VectorTests(IntFunction fm) { } static byte SUADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4554,7 +4775,7 @@ static byte SUADDReduce(byte[] a, int idx) { } static byte SUADDReduceAll(byte[] a) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4566,7 +4787,7 @@ static byte SUADDReduceAll(byte[] a) { static void SUADDReduceByte512VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4576,7 +4797,7 @@ static void SUADDReduceByte512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4588,7 +4809,7 @@ static void SUADDReduceByte512VectorTests(IntFunction fa) { } static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4598,7 +4819,7 @@ static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4611,7 +4832,7 @@ static void SUADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunct byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4621,7 +4842,7 @@ static void SUADDReduceByte512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4666,7 +4887,7 @@ static void IS_DEFAULTByte512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4686,7 +4907,7 @@ static void IS_DEFAULTMaskedByte512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4707,7 +4928,7 @@ static void IS_NEGATIVEByte512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4727,7 +4948,7 @@ static void IS_NEGATIVEMaskedByte512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void LTByte512VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4765,7 +4986,7 @@ static void ltByte512VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4788,7 +5009,7 @@ static void LTByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4830,7 +5051,7 @@ static void GTByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4868,7 +5089,7 @@ static void eqByte512VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4891,7 +5112,7 @@ static void EQByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4933,7 +5154,7 @@ static void NEByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4975,7 +5196,7 @@ static void LEByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5017,7 +5238,7 @@ static void GEByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5059,7 +5280,7 @@ static void ULTByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5101,7 +5322,7 @@ static void UGTByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5143,7 +5364,7 @@ static void ULEByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5185,7 +5406,7 @@ static void UGEByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5222,7 +5443,7 @@ static void LTByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5238,7 +5459,7 @@ static void LTByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @@ -5258,7 +5479,7 @@ static void LTByte512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(byte)((long)b[i])))); } } } @@ -5274,7 +5495,7 @@ static void EQByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5294,7 +5515,7 @@ static void EQByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5310,7 +5531,7 @@ static void EQByte512VectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @@ -5330,7 +5551,7 @@ static void EQByte512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(byte)((long)b[i])))); } } } @@ -5611,7 +5832,7 @@ static void ZeroByte512VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static byte[] sliceUnary(byte[] a, int origin, int idx) { @@ -6042,11 +6263,11 @@ static void BITWISE_BLENDByte512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6098,11 +6319,11 @@ static void NEGMaskedByte512VectorTests(IntFunction fa, } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6442,7 +6663,7 @@ static void ltByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6458,7 +6679,7 @@ static void eqByte512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6709,7 +6930,7 @@ static void shuffleMiscellaneousByte512VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index 748e0b6ddefa3..0293ecc1604c1 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -1070,15 +1070,15 @@ static byte bits(byte e) { } static final List> BYTE_GENERATORS = List.of( - withToString("byte[-i * 5]", (int s) -> { + withToString("Byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("byte[i * 5]", (int s) -> { + withToString("Byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("byte[i + 1]", (int s) -> { + withToString("Byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1527,6 +1527,218 @@ static boolean ge(byte a, byte b) { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte multiplicativeIdentity() { + return (byte)1; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static byte scalar_sin(byte a) { + return (byte)Math.sin((double)a); + } + + static byte scalar_exp(byte a) { + return (byte)Math.exp((double)a); + } + + static byte scalar_log1p(byte a) { + return (byte)Math.log1p((double)a); + } + + static byte scalar_log(byte a) { + return (byte)Math.log((double)a); + } + + static byte scalar_log10(byte a) { + return (byte)Math.log10((double)a); + } + + static byte scalar_expm1(byte a) { + return (byte)Math.expm1((double)a); + } + + static byte scalar_cos(byte a) { + return (byte)Math.cos((double)a); + } + + static byte scalar_tan(byte a) { + return (byte)Math.tan((double)a); + } + + static byte scalar_sinh(byte a) { + return (byte)Math.sinh((double)a); + } + + static byte scalar_cosh(byte a) { + return (byte)Math.cosh((double)a); + } + + static byte scalar_tanh(byte a) { + return (byte)Math.tanh((double)a); + } + + static byte scalar_asin(byte a) { + return (byte)Math.asin((double)a); + } + + static byte scalar_acos(byte a) { + return (byte)Math.acos((double)a); + } + + static byte scalar_atan(byte a) { + return (byte)Math.atan((double)a); + } + + static byte scalar_cbrt(byte a) { + return (byte)Math.cbrt((double)a); + } + + static byte scalar_sqrt(byte a) { + return (byte)Math.sqrt((double)a); + } + + static byte scalar_hypot(byte a, byte b) { + return (byte)Math.hypot((double)a, (double)b); + } + + static byte scalar_pow(byte a, byte b) { + return (byte)Math.pow((double)a, (double)b); + } + + static byte scalar_atan2(byte a, byte b) { + return (byte)Math.atan2((double)a, (double)b); + } + + static byte strict_scalar_sin(byte a) { + return (byte)StrictMath.sin((double)a); + } + + static byte strict_scalar_exp(byte a) { + return (byte)StrictMath.exp((double)a); + } + + static byte strict_scalar_log1p(byte a) { + return (byte)StrictMath.log1p((double)a); + } + + static byte strict_scalar_log(byte a) { + return (byte)StrictMath.log((double)a); + } + + static byte strict_scalar_log10(byte a) { + return (byte)StrictMath.log10((double)a); + } + + static byte strict_scalar_expm1(byte a) { + return (byte)StrictMath.expm1((double)a); + } + + static byte strict_scalar_cos(byte a) { + return (byte)StrictMath.cos((double)a); + } + + static byte strict_scalar_tan(byte a) { + return (byte)StrictMath.tan((double)a); + } + + static byte strict_scalar_sinh(byte a) { + return (byte)StrictMath.sinh((double)a); + } + + static byte strict_scalar_cosh(byte a) { + return (byte)StrictMath.cosh((double)a); + } + + static byte strict_scalar_tanh(byte a) { + return (byte)StrictMath.tanh((double)a); + } + + static byte strict_scalar_asin(byte a) { + return (byte)StrictMath.asin((double)a); + } + + static byte strict_scalar_acos(byte a) { + return (byte)StrictMath.acos((double)a); + } + + static byte strict_scalar_atan(byte a) { + return (byte)StrictMath.atan((double)a); + } + + static byte strict_scalar_cbrt(byte a) { + return (byte)StrictMath.cbrt((double)a); + } + + static byte strict_scalar_sqrt(byte a) { + return (byte)StrictMath.sqrt((double)a); + } + + static byte strict_scalar_hypot(byte a, byte b) { + return (byte)StrictMath.hypot((double)a, (double)b); + } + + static byte strict_scalar_pow(byte a, byte b) { + return (byte)StrictMath.pow((double)a, (double)b); + } + + static byte strict_scalar_atan2(byte a, byte b) { + return (byte)StrictMath.atan2((double)a, (double)b); + } + static byte additiveIdentity() { + return (byte)0; + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1543,10 +1755,19 @@ static boolean uge(byte a, byte b) { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; + static byte zeroValue() { + return (short) 0; + } + + static byte maxValue() { + return Byte.MAX_VALUE; + } + + static byte minValue() { + return Byte.MIN_VALUE; } + @Test static void smokeTest1() { ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); @@ -1654,7 +1875,7 @@ static void bitwiseDivByZeroSmokeTest() { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1675,7 +1896,7 @@ static void ADDByte64VectorTests(IntFunction fa, IntFunction fb) } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1732,7 +1953,7 @@ static void addByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1810,7 +2031,7 @@ static void subByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1978,7 +2199,7 @@ static void divByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunct } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3201,7 +3422,7 @@ static void MINByte64VectorTests(IntFunction fa, IntFunction fb) } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3220,7 +3441,7 @@ static void minByte64VectorTests(IntFunction fa, IntFunction fb) } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3241,7 +3462,7 @@ static void MAXByte64VectorTests(IntFunction fa, IntFunction fb) } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3609,7 +3830,7 @@ static void SUADDAssocByte64VectorTestsMasked(IntFunction fa, IntFunctio static byte ANDReduce(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3618,7 +3839,7 @@ static byte ANDReduce(byte[] a, int idx) { static byte ANDReduceAll(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3641,7 +3862,7 @@ static void ANDReduceByte64VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3653,7 +3874,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3687,7 +3908,7 @@ static void ANDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3698,7 +3919,7 @@ static void ANDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction static byte ORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3707,7 +3928,7 @@ static byte ORReduce(byte[] a, int idx) { static byte ORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3730,7 +3951,7 @@ static void ORReduceByte64VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3742,7 +3963,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3776,7 +3997,7 @@ static void ORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction< ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3787,7 +4008,7 @@ static void ORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction< static byte XORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3796,7 +4017,7 @@ static byte XORReduce(byte[] a, int idx) { static byte XORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3819,7 +4040,7 @@ static void XORReduceByte64VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3831,7 +4052,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3840,7 +4061,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3865,7 +4086,7 @@ static void XORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3874,18 +4095,18 @@ static void XORReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } static byte ADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAll(byte[] a) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3895,7 +4116,7 @@ static byte ADDReduceAll(byte[] a) { static void ADDReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3905,10 +4126,10 @@ static void ADDReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3917,19 +4138,19 @@ static void ADDReduceByte64VectorTests(IntFunction fa) { } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3941,7 +4162,7 @@ static void ADDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3951,10 +4172,10 @@ static void ADDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3963,18 +4184,18 @@ static void ADDReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } static byte MULReduce(byte[] a, int idx) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAll(byte[] a) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3984,7 +4205,7 @@ static byte MULReduceAll(byte[] a) { static void MULReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3994,10 +4215,10 @@ static void MULReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4006,19 +4227,19 @@ static void MULReduceByte64VectorTests(IntFunction fa) { } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4030,7 +4251,7 @@ static void MULReduceByte64VectorTestsMasked(IntFunction fa, IntFunction byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4040,10 +4261,10 @@ static void MULReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4052,18 +4273,18 @@ static void MULReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } static byte MINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4073,7 +4294,7 @@ static byte MINReduceAll(byte[] a) { static void MINReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4083,10 +4304,10 @@ static void MINReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4095,19 +4316,19 @@ static void MINReduceByte64VectorTests(IntFunction fa) { } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4119,7 +4340,7 @@ static void MINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4129,10 +4350,10 @@ static void MINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4141,18 +4362,18 @@ static void MINReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } static byte MAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4162,7 +4383,7 @@ static byte MAXReduceAll(byte[] a) { static void MAXReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4172,10 +4393,10 @@ static void MAXReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4184,19 +4405,19 @@ static void MAXReduceByte64VectorTests(IntFunction fa) { } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4208,7 +4429,7 @@ static void MAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4218,10 +4439,10 @@ static void MAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4230,7 +4451,7 @@ static void MAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunction } static byte UMINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.minUnsigned(res, a[i]); } @@ -4239,7 +4460,7 @@ static byte UMINReduce(byte[] a, int idx) { } static byte UMINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4251,7 +4472,7 @@ static byte UMINReduceAll(byte[] a) { static void UMINReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4261,7 +4482,7 @@ static void UMINReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4273,7 +4494,7 @@ static void UMINReduceByte64VectorTests(IntFunction fa) { } static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.minUnsigned(res, a[i]); @@ -4283,7 +4504,7 @@ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4297,7 +4518,7 @@ static void UMINReduceByte64VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4307,7 +4528,7 @@ static void UMINReduceByte64VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4319,7 +4540,7 @@ static void UMINReduceByte64VectorTestsMasked(IntFunction fa, IntFunctio } static byte UMAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.maxUnsigned(res, a[i]); } @@ -4328,7 +4549,7 @@ static byte UMAXReduce(byte[] a, int idx) { } static byte UMAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4340,7 +4561,7 @@ static byte UMAXReduceAll(byte[] a) { static void UMAXReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4350,7 +4571,7 @@ static void UMAXReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4362,7 +4583,7 @@ static void UMAXReduceByte64VectorTests(IntFunction fa) { } static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.maxUnsigned(res, a[i]); @@ -4372,7 +4593,7 @@ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4386,7 +4607,7 @@ static void UMAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4396,7 +4617,7 @@ static void UMAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4408,7 +4629,7 @@ static void UMAXReduceByte64VectorTestsMasked(IntFunction fa, IntFunctio } static byte FIRST_NONZEROReduce(byte[] a, int idx) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4417,7 +4638,7 @@ static byte FIRST_NONZEROReduce(byte[] a, int idx) { } static byte FIRST_NONZEROReduceAll(byte[] a) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4429,7 +4650,7 @@ static byte FIRST_NONZEROReduceAll(byte[] a) { static void FIRST_NONZEROReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4439,7 +4660,7 @@ static void FIRST_NONZEROReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4451,7 +4672,7 @@ static void FIRST_NONZEROReduceByte64VectorTests(IntFunction fa) { } static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4461,7 +4682,7 @@ static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4475,7 +4696,7 @@ static void FIRST_NONZEROReduceByte64VectorTestsMasked(IntFunction fa, I byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4485,7 +4706,7 @@ static void FIRST_NONZEROReduceByte64VectorTestsMasked(IntFunction fa, I } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4545,7 +4766,7 @@ static void allTrueByte64VectorTests(IntFunction fm) { } static byte SUADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4554,7 +4775,7 @@ static byte SUADDReduce(byte[] a, int idx) { } static byte SUADDReduceAll(byte[] a) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4566,7 +4787,7 @@ static byte SUADDReduceAll(byte[] a) { static void SUADDReduceByte64VectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4576,7 +4797,7 @@ static void SUADDReduceByte64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4588,7 +4809,7 @@ static void SUADDReduceByte64VectorTests(IntFunction fa) { } static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4598,7 +4819,7 @@ static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4611,7 +4832,7 @@ static void SUADDReduceByte64VectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4621,7 +4842,7 @@ static void SUADDReduceByte64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4666,7 +4887,7 @@ static void IS_DEFAULTByte64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4686,7 +4907,7 @@ static void IS_DEFAULTMaskedByte64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4707,7 +4928,7 @@ static void IS_NEGATIVEByte64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4727,7 +4948,7 @@ static void IS_NEGATIVEMaskedByte64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void LTByte64VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4765,7 +4986,7 @@ static void ltByte64VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4788,7 +5009,7 @@ static void LTByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4830,7 +5051,7 @@ static void GTByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4868,7 +5089,7 @@ static void eqByte64VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4891,7 +5112,7 @@ static void EQByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4933,7 +5154,7 @@ static void NEByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4975,7 +5196,7 @@ static void LEByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5017,7 +5238,7 @@ static void GEByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5059,7 +5280,7 @@ static void ULTByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5101,7 +5322,7 @@ static void UGTByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5143,7 +5364,7 @@ static void ULEByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5185,7 +5406,7 @@ static void UGEByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFun // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5222,7 +5443,7 @@ static void LTByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5238,7 +5459,7 @@ static void LTByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, In // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @@ -5258,7 +5479,7 @@ static void LTByte64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(byte)((long)b[i])))); } } } @@ -5274,7 +5495,7 @@ static void EQByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5294,7 +5515,7 @@ static void EQByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5310,7 +5531,7 @@ static void EQByte64VectorTestsBroadcastLongSmokeTest(IntFunction fa, In // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @@ -5330,7 +5551,7 @@ static void EQByte64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(byte)((long)b[i])))); } } } @@ -5611,7 +5832,7 @@ static void ZeroByte64VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static byte[] sliceUnary(byte[] a, int origin, int idx) { @@ -6042,11 +6263,11 @@ static void BITWISE_BLENDByte64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunc } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6098,11 +6319,11 @@ static void NEGMaskedByte64VectorTests(IntFunction fa, } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6442,7 +6663,7 @@ static void ltByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6458,7 +6679,7 @@ static void eqByte64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6709,7 +6930,7 @@ static void shuffleMiscellaneousByte64VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index 0ee2b1e10c0a4..e788d29156bd9 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -1075,15 +1075,15 @@ static byte bits(byte e) { } static final List> BYTE_GENERATORS = List.of( - withToString("byte[-i * 5]", (int s) -> { + withToString("Byte[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("byte[i * 5]", (int s) -> { + withToString("Byte[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("byte[i + 1]", (int s) -> { + withToString("Byte[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((byte)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1532,6 +1532,218 @@ static boolean ge(byte a, byte b) { return a >= b; } + static byte firstNonZero(byte a, byte b) { + return Byte.compare(a, (byte) 0) != 0 ? a : b; + } + + static byte multiplicativeIdentity() { + return (byte)1; + } + + static byte scalar_or(byte a, byte b) { + return (byte)(a | b); + } + + static byte scalar_and(byte a, byte b) { + return (byte)(a & b); + } + + static byte scalar_xor(byte a, byte b) { + return (byte)(a ^ b); + } + + static byte scalar_add(byte a, byte b) { + return (byte)(a + b); + } + + static byte scalar_sub(byte a, byte b) { + return (byte)(a - b); + } + + static byte scalar_mul(byte a, byte b) { + return (byte)(a * b); + } + + static byte scalar_min(byte a, byte b) { + return (byte)(Math.min(a, b)); + } + + static byte scalar_max(byte a, byte b) { + return (byte)(Math.max(a, b)); + } + + static byte scalar_div(byte a, byte b) { + return (byte)(a / b); + } + + static byte scalar_fma(byte a, byte b, byte c) { + return (byte)(Math.fma(a, b, c)); + } + + static byte scalar_abs(byte a) { + return (byte)(Math.abs(a)); + } + + static byte scalar_neg(byte a) { + return ((byte)-a); + } + + static byte scalar_sin(byte a) { + return (byte)Math.sin((double)a); + } + + static byte scalar_exp(byte a) { + return (byte)Math.exp((double)a); + } + + static byte scalar_log1p(byte a) { + return (byte)Math.log1p((double)a); + } + + static byte scalar_log(byte a) { + return (byte)Math.log((double)a); + } + + static byte scalar_log10(byte a) { + return (byte)Math.log10((double)a); + } + + static byte scalar_expm1(byte a) { + return (byte)Math.expm1((double)a); + } + + static byte scalar_cos(byte a) { + return (byte)Math.cos((double)a); + } + + static byte scalar_tan(byte a) { + return (byte)Math.tan((double)a); + } + + static byte scalar_sinh(byte a) { + return (byte)Math.sinh((double)a); + } + + static byte scalar_cosh(byte a) { + return (byte)Math.cosh((double)a); + } + + static byte scalar_tanh(byte a) { + return (byte)Math.tanh((double)a); + } + + static byte scalar_asin(byte a) { + return (byte)Math.asin((double)a); + } + + static byte scalar_acos(byte a) { + return (byte)Math.acos((double)a); + } + + static byte scalar_atan(byte a) { + return (byte)Math.atan((double)a); + } + + static byte scalar_cbrt(byte a) { + return (byte)Math.cbrt((double)a); + } + + static byte scalar_sqrt(byte a) { + return (byte)Math.sqrt((double)a); + } + + static byte scalar_hypot(byte a, byte b) { + return (byte)Math.hypot((double)a, (double)b); + } + + static byte scalar_pow(byte a, byte b) { + return (byte)Math.pow((double)a, (double)b); + } + + static byte scalar_atan2(byte a, byte b) { + return (byte)Math.atan2((double)a, (double)b); + } + + static byte strict_scalar_sin(byte a) { + return (byte)StrictMath.sin((double)a); + } + + static byte strict_scalar_exp(byte a) { + return (byte)StrictMath.exp((double)a); + } + + static byte strict_scalar_log1p(byte a) { + return (byte)StrictMath.log1p((double)a); + } + + static byte strict_scalar_log(byte a) { + return (byte)StrictMath.log((double)a); + } + + static byte strict_scalar_log10(byte a) { + return (byte)StrictMath.log10((double)a); + } + + static byte strict_scalar_expm1(byte a) { + return (byte)StrictMath.expm1((double)a); + } + + static byte strict_scalar_cos(byte a) { + return (byte)StrictMath.cos((double)a); + } + + static byte strict_scalar_tan(byte a) { + return (byte)StrictMath.tan((double)a); + } + + static byte strict_scalar_sinh(byte a) { + return (byte)StrictMath.sinh((double)a); + } + + static byte strict_scalar_cosh(byte a) { + return (byte)StrictMath.cosh((double)a); + } + + static byte strict_scalar_tanh(byte a) { + return (byte)StrictMath.tanh((double)a); + } + + static byte strict_scalar_asin(byte a) { + return (byte)StrictMath.asin((double)a); + } + + static byte strict_scalar_acos(byte a) { + return (byte)StrictMath.acos((double)a); + } + + static byte strict_scalar_atan(byte a) { + return (byte)StrictMath.atan((double)a); + } + + static byte strict_scalar_cbrt(byte a) { + return (byte)StrictMath.cbrt((double)a); + } + + static byte strict_scalar_sqrt(byte a) { + return (byte)StrictMath.sqrt((double)a); + } + + static byte strict_scalar_hypot(byte a, byte b) { + return (byte)StrictMath.hypot((double)a, (double)b); + } + + static byte strict_scalar_pow(byte a, byte b) { + return (byte)StrictMath.pow((double)a, (double)b); + } + + static byte strict_scalar_atan2(byte a, byte b) { + return (byte)StrictMath.atan2((double)a, (double)b); + } + static byte additiveIdentity() { + return (byte)0; + } + + static boolean ult(byte a, byte b) { return Byte.compareUnsigned(a, b) < 0; } @@ -1548,10 +1760,19 @@ static boolean uge(byte a, byte b) { return Byte.compareUnsigned(a, b) >= 0; } - static byte firstNonZero(byte a, byte b) { - return Byte.compare(a, (byte) 0) != 0 ? a : b; + static byte zeroValue() { + return (short) 0; + } + + static byte maxValue() { + return Byte.MAX_VALUE; + } + + static byte minValue() { + return Byte.MIN_VALUE; } + @Test static void smokeTest1() { ByteVector three = ByteVector.broadcast(SPECIES, (byte)-3); @@ -1659,7 +1880,7 @@ static void bitwiseDivByZeroSmokeTest() { } static byte ADD(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1680,7 +1901,7 @@ static void ADDByteMaxVectorTests(IntFunction fa, IntFunction fb } static byte add(byte a, byte b) { - return (byte)(a + b); + return (byte)(scalar_add(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1737,7 +1958,7 @@ static void addByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte sub(byte a, byte b) { - return (byte)(a - b); + return (byte)(scalar_sub(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1815,7 +2036,7 @@ static void subByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static byte mul(byte a, byte b) { - return (byte)(a * b); + return (byte)(scalar_mul(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -1983,7 +2204,7 @@ static void divByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static byte MIN(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3206,7 +3427,7 @@ static void MINByteMaxVectorTests(IntFunction fa, IntFunction fb } static byte min(byte a, byte b) { - return (byte)(Math.min(a, b)); + return (byte)(scalar_min(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3225,7 +3446,7 @@ static void minByteMaxVectorTests(IntFunction fa, IntFunction fb } static byte MAX(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3246,7 +3467,7 @@ static void MAXByteMaxVectorTests(IntFunction fa, IntFunction fb } static byte max(byte a, byte b) { - return (byte)(Math.max(a, b)); + return (byte)(scalar_max(a, b)); } @Test(dataProvider = "byteBinaryOpProvider") @@ -3614,7 +3835,7 @@ static void SUADDAssocByteMaxVectorTestsMasked(IntFunction fa, IntFuncti static byte ANDReduce(byte[] a, int idx) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3623,7 +3844,7 @@ static byte ANDReduce(byte[] a, int idx) { static byte ANDReduceAll(byte[] a) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3646,7 +3867,7 @@ static void ANDReduceByteMaxVectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3658,7 +3879,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3667,7 +3888,7 @@ static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ANDReduceAllMasked(byte[] a, boolean[] mask) { byte res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3692,7 +3913,7 @@ static void ANDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3703,7 +3924,7 @@ static void ANDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio static byte ORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3712,7 +3933,7 @@ static byte ORReduce(byte[] a, int idx) { static byte ORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3735,7 +3956,7 @@ static void ORReduceByteMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3747,7 +3968,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3756,7 +3977,7 @@ static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte ORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3781,7 +4002,7 @@ static void ORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3792,7 +4013,7 @@ static void ORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunction static byte XORReduce(byte[] a, int idx) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3801,7 +4022,7 @@ static byte XORReduce(byte[] a, int idx) { static byte XORReduceAll(byte[] a) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3824,7 +4045,7 @@ static void XORReduceByteMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3836,7 +4057,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { byte res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3845,7 +4066,7 @@ static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) { static byte XORReduceAllMasked(byte[] a, boolean[] mask) { byte res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3870,7 +4091,7 @@ static void XORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3879,18 +4100,18 @@ static void XORReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } static byte ADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAll(byte[] a) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3900,7 +4121,7 @@ static byte ADDReduceAll(byte[] a) { static void ADDReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3910,10 +4131,10 @@ static void ADDReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3922,19 +4143,19 @@ static void ADDReduceByteMaxVectorTests(IntFunction fa) { } static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static byte ADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3946,7 +4167,7 @@ static void ADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3956,10 +4177,10 @@ static void ADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3968,18 +4189,18 @@ static void ADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } static byte MULReduce(byte[] a, int idx) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAll(byte[] a) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3989,7 +4210,7 @@ static byte MULReduceAll(byte[] a) { static void MULReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3999,10 +4220,10 @@ static void MULReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4011,19 +4232,19 @@ static void MULReduceByteMaxVectorTests(IntFunction fa) { } static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static byte MULReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 1; + byte res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4035,7 +4256,7 @@ static void MULReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 1; + byte ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4045,10 +4266,10 @@ static void MULReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4057,18 +4278,18 @@ static void MULReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } static byte MINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4078,7 +4299,7 @@ static byte MINReduceAll(byte[] a) { static void MINReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4088,10 +4309,10 @@ static void MINReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4100,19 +4321,19 @@ static void MINReduceByteMaxVectorTests(IntFunction fa) { } static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static byte MINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4124,7 +4345,7 @@ static void MINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4134,10 +4355,10 @@ static void MINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4146,18 +4367,18 @@ static void MINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } static byte MAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4167,7 +4388,7 @@ static byte MAXReduceAll(byte[] a) { static void MAXReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4177,10 +4398,10 @@ static void MAXReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4189,19 +4410,19 @@ static void MAXReduceByteMaxVectorTests(IntFunction fa) { } static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (byte) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static byte MAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (byte) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4213,7 +4434,7 @@ static void MAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4223,10 +4444,10 @@ static void MAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4235,7 +4456,7 @@ static void MAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunctio } static byte UMINReduce(byte[] a, int idx) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.minUnsigned(res, a[i]); } @@ -4244,7 +4465,7 @@ static byte UMINReduce(byte[] a, int idx) { } static byte UMINReduceAll(byte[] a) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4256,7 +4477,7 @@ static byte UMINReduceAll(byte[] a) { static void UMINReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4266,7 +4487,7 @@ static void UMINReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4278,7 +4499,7 @@ static void UMINReduceByteMaxVectorTests(IntFunction fa) { } static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.minUnsigned(res, a[i]); @@ -4288,7 +4509,7 @@ static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMINReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MAX_VALUE; + byte res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4302,7 +4523,7 @@ static void UMINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MAX_VALUE; + byte ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4312,7 +4533,7 @@ static void UMINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4324,7 +4545,7 @@ static void UMINReduceByteMaxVectorTestsMasked(IntFunction fa, IntFuncti } static byte UMAXReduce(byte[] a, int idx) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.maxUnsigned(res, a[i]); } @@ -4333,7 +4554,7 @@ static byte UMAXReduce(byte[] a, int idx) { } static byte UMAXReduceAll(byte[] a) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4345,7 +4566,7 @@ static byte UMAXReduceAll(byte[] a) { static void UMAXReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4355,7 +4576,7 @@ static void UMAXReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4367,7 +4588,7 @@ static void UMAXReduceByteMaxVectorTests(IntFunction fa) { } static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.maxUnsigned(res, a[i]); @@ -4377,7 +4598,7 @@ static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) { - byte res = Byte.MIN_VALUE; + byte res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4391,7 +4612,7 @@ static void UMAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFuncti byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = Byte.MIN_VALUE; + byte ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4401,7 +4622,7 @@ static void UMAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Byte.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4413,7 +4634,7 @@ static void UMAXReduceByteMaxVectorTestsMasked(IntFunction fa, IntFuncti } static byte FIRST_NONZEROReduce(byte[] a, int idx) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4422,7 +4643,7 @@ static byte FIRST_NONZEROReduce(byte[] a, int idx) { } static byte FIRST_NONZEROReduceAll(byte[] a) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4434,7 +4655,7 @@ static byte FIRST_NONZEROReduceAll(byte[] a) { static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4444,7 +4665,7 @@ static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4456,7 +4677,7 @@ static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction fa) { } static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4466,7 +4687,7 @@ static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) { - byte res = (byte) 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4480,7 +4701,7 @@ static void FIRST_NONZEROReduceByteMaxVectorTestsMasked(IntFunction fa, byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = (byte) 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4490,7 +4711,7 @@ static void FIRST_NONZEROReduceByteMaxVectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (byte) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4550,7 +4771,7 @@ static void allTrueByteMaxVectorTests(IntFunction fm) { } static byte SUADDReduce(byte[] a, int idx) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4559,7 +4780,7 @@ static byte SUADDReduce(byte[] a, int idx) { } static byte SUADDReduceAll(byte[] a) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4571,7 +4792,7 @@ static byte SUADDReduceAll(byte[] a) { static void SUADDReduceByteMaxVectorTests(IntFunction fa) { byte[] a = fa.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4581,7 +4802,7 @@ static void SUADDReduceByteMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4593,7 +4814,7 @@ static void SUADDReduceByteMaxVectorTests(IntFunction fa) { } static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (byte) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4603,7 +4824,7 @@ static byte SUADDReduceMasked(byte[] a, int idx, boolean[] mask) { } static byte SUADDReduceAllMasked(byte[] a, boolean[] mask) { - byte res = 0; + byte res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (byte) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4616,7 +4837,7 @@ static void SUADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunct byte[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - byte ra = 0; + byte ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4626,7 +4847,7 @@ static void SUADDReduceByteMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ra = (byte) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4671,7 +4892,7 @@ static void IS_DEFAULTByteMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4691,7 +4912,7 @@ static void IS_DEFAULTMaskedByteMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4712,7 +4933,7 @@ static void IS_NEGATIVEByteMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4732,7 +4953,7 @@ static void IS_NEGATIVEMaskedByteMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4751,7 +4972,7 @@ static void LTByteMaxVectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4770,7 +4991,7 @@ static void ltByteMaxVectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4793,7 +5014,7 @@ static void LTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4835,7 +5056,7 @@ static void GTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4873,7 +5094,7 @@ static void eqByteMaxVectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4896,7 +5117,7 @@ static void EQByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4938,7 +5159,7 @@ static void NEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4980,7 +5201,7 @@ static void LEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5022,7 +5243,7 @@ static void GEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5064,7 +5285,7 @@ static void ULTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5106,7 +5327,7 @@ static void UGTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5148,7 +5369,7 @@ static void ULEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5190,7 +5411,7 @@ static void UGEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5227,7 +5448,7 @@ static void LTByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5243,7 +5464,7 @@ static void LTByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (byte)((long)b[i]))); } } } @@ -5263,7 +5484,7 @@ static void LTByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(byte)((long)b[i])))); } } } @@ -5279,7 +5500,7 @@ static void EQByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5299,7 +5520,7 @@ static void EQByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5315,7 +5536,7 @@ static void EQByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (byte)((long)b[i]))); } } } @@ -5335,7 +5556,7 @@ static void EQByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(byte)((long)b[i])))); } } } @@ -5616,7 +5837,7 @@ static void ZeroByteMaxVectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static byte[] sliceUnary(byte[] a, int origin, int idx) { @@ -6047,11 +6268,11 @@ static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static byte NEG(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } static byte neg(byte a) { - return (byte)(-((byte)a)); + return (byte)(scalar_neg((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6103,11 +6324,11 @@ static void NEGMaskedByteMaxVectorTests(IntFunction fa, } static byte ABS(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } static byte abs(byte a) { - return (byte)(Math.abs((byte)a)); + return (byte)(scalar_abs((byte)a)); } @Test(dataProvider = "byteUnaryOpProvider") @@ -6447,7 +6668,7 @@ static void ltByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6463,7 +6684,7 @@ static void eqByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6714,7 +6935,7 @@ static void shuffleMiscellaneousByteMaxVectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Double128VectorTests.java b/test/jdk/jdk/incubator/vector/Double128VectorTests.java index 4b096db34bfcf..aa2fc2c106489 100644 --- a/test/jdk/jdk/incubator/vector/Double128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double128VectorTests.java @@ -1120,19 +1120,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[intCornerCaseValue(i)]", (int s) -> { + withToString("Double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)intCornerCaseValue(i)); }) @@ -1169,19 +1169,19 @@ static double genValue(long i) { } static final List> LONG_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[cornerCaseValue(i)]", (int s) -> { + withToString("Double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)longCornerCaseValue(i)); }) @@ -1204,15 +1204,15 @@ static long bits(double e) { } static final List> DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1546,6 +1546,225 @@ static double firstNonZero(double a, double b) { return Double.compare(a, (double) 0) != 0 ? a : b; } + static double multiplicativeIdentity() { + return (double)1; + } + + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + static double additiveIdentity() { + return (double)0; + } + + + static double zeroValue() { + return (short) 0; + } + + static double maxValue() { + return Double.POSITIVE_INFINITY; + } + + static double minValue() { + return Double.NEGATIVE_INFINITY; + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1639,7 +1858,7 @@ void viewAsFloatingLanesTest() { } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1660,7 +1879,7 @@ static void ADDDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1738,7 +1957,7 @@ static void SUBDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1816,7 +2035,7 @@ static void MULDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1894,7 +2113,7 @@ static void DIVDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2241,7 +2460,7 @@ static void MAXDouble128VectorTestsMaskedWithMemOp(IntFunction fa, Int } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2262,7 +2481,7 @@ static void MINDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, } static double ADDReduce(double[] a, int idx) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAll(double[] a) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2398,7 +2617,7 @@ static double ADDReduceAll(double[] a) { static void ADDReduceDouble128VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2408,10 +2627,10 @@ static void ADDReduceDouble128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2420,19 +2639,19 @@ static void ADDReduceDouble128VectorTests(IntFunction fa) { } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAllMasked(double[] a, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2444,7 +2663,7 @@ static void ADDReduceDouble128VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2454,10 +2673,10 @@ static void ADDReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2466,18 +2685,18 @@ static void ADDReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } static double MULReduce(double[] a, int idx) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAll(double[] a) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2487,7 +2706,7 @@ static double MULReduceAll(double[] a) { static void MULReduceDouble128VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2497,10 +2716,10 @@ static void MULReduceDouble128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2509,19 +2728,19 @@ static void MULReduceDouble128VectorTests(IntFunction fa) { } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAllMasked(double[] a, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2533,7 +2752,7 @@ static void MULReduceDouble128VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2543,10 +2762,10 @@ static void MULReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2555,18 +2774,18 @@ static void MULReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } static double MINReduce(double[] a, int idx) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAll(double[] a) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2576,7 +2795,7 @@ static double MINReduceAll(double[] a) { static void MINReduceDouble128VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2586,10 +2805,10 @@ static void MINReduceDouble128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2598,19 +2817,19 @@ static void MINReduceDouble128VectorTests(IntFunction fa) { } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2622,7 +2841,7 @@ static void MINReduceDouble128VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2632,10 +2851,10 @@ static void MINReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2644,18 +2863,18 @@ static void MINReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } static double MAXReduce(double[] a, int idx) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAll(double[] a) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2665,7 +2884,7 @@ static double MAXReduceAll(double[] a) { static void MAXReduceDouble128VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2675,10 +2894,10 @@ static void MAXReduceDouble128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2687,19 +2906,19 @@ static void MAXReduceDouble128VectorTests(IntFunction fa) { } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2711,7 +2930,7 @@ static void MAXReduceDouble128VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2721,10 +2940,10 @@ static void MAXReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2733,7 +2952,7 @@ static void MAXReduceDouble128VectorTestsMasked(IntFunction fa, IntFun } static double FIRST_NONZEROReduce(double[] a, int idx) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2742,7 +2961,7 @@ static double FIRST_NONZEROReduce(double[] a, int idx) { } static double FIRST_NONZEROReduceAll(double[] a) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2754,7 +2973,7 @@ static double FIRST_NONZEROReduceAll(double[] a) { static void FIRST_NONZEROReduceDouble128VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2764,7 +2983,7 @@ static void FIRST_NONZEROReduceDouble128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2776,7 +2995,7 @@ static void FIRST_NONZEROReduceDouble128VectorTests(IntFunction fa) { } static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2786,7 +3005,7 @@ static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { } static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2800,7 +3019,7 @@ static void FIRST_NONZEROReduceDouble128VectorTestsMasked(IntFunction double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2810,7 +3029,7 @@ static void FIRST_NONZEROReduceDouble128VectorTestsMasked(IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2855,7 +3074,7 @@ static void IS_DEFAULTDouble128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2875,7 +3094,7 @@ static void IS_DEFAULTMaskedDouble128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2896,7 +3115,7 @@ static void IS_NEGATIVEDouble128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2916,14 +3135,14 @@ static void IS_NEGATIVEMaskedDouble128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2937,7 +3156,7 @@ static void IS_FINITEDouble128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2957,14 +3176,14 @@ static void IS_FINITEMaskedDouble128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2978,7 +3197,7 @@ static void IS_NANDouble128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -2998,14 +3217,14 @@ static void IS_NANMaskedDouble128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -3019,7 +3238,7 @@ static void IS_INFINITEDouble128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3039,7 +3258,7 @@ static void IS_INFINITEMaskedDouble128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3058,7 +3277,7 @@ static void LTDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3366,7 +3585,7 @@ static void LTDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3382,7 +3601,7 @@ static void LTDouble128VectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @@ -3402,7 +3621,7 @@ static void LTDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3438,7 +3657,7 @@ static void EQDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3454,7 +3673,7 @@ static void EQDouble128VectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @@ -3474,7 +3693,7 @@ static void EQDouble128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static double[] sliceUnary(double[] a, int origin, int idx) { @@ -3974,11 +4193,11 @@ static void unsliceDouble128VectorTestsMasked(IntFunction fa, IntFunct } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3997,11 +4216,11 @@ static void SINDouble128VectorTests(IntFunction fa) { } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4020,11 +4239,11 @@ static void EXPDouble128VectorTests(IntFunction fa) { } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4043,11 +4262,11 @@ static void LOG1PDouble128VectorTests(IntFunction fa) { } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4066,11 +4285,11 @@ static void LOGDouble128VectorTests(IntFunction fa) { } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4089,11 +4308,11 @@ static void LOG10Double128VectorTests(IntFunction fa) { } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4112,11 +4331,11 @@ static void EXPM1Double128VectorTests(IntFunction fa) { } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4135,11 +4354,11 @@ static void COSDouble128VectorTests(IntFunction fa) { } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4158,11 +4377,11 @@ static void TANDouble128VectorTests(IntFunction fa) { } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4181,11 +4400,11 @@ static void SINHDouble128VectorTests(IntFunction fa) { } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4204,11 +4423,11 @@ static void COSHDouble128VectorTests(IntFunction fa) { } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4227,11 +4446,11 @@ static void TANHDouble128VectorTests(IntFunction fa) { } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4250,11 +4469,11 @@ static void ASINDouble128VectorTests(IntFunction fa) { } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4273,11 +4492,11 @@ static void ACOSDouble128VectorTests(IntFunction fa) { } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4296,11 +4515,11 @@ static void ATANDouble128VectorTests(IntFunction fa) { } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4319,11 +4538,11 @@ static void CBRTDouble128VectorTests(IntFunction fa) { } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4345,11 +4564,11 @@ static void HYPOTDouble128VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4677,11 +4896,11 @@ static void FMADouble128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4789,11 +5008,11 @@ static void ABSMaskedDouble128VectorTests(IntFunction fa, } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4855,7 +5074,7 @@ static void ltDouble128VectorTestsBroadcastSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4871,7 +5090,7 @@ static void eqDouble128VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5101,7 +5320,7 @@ static void shuffleMiscellaneousDouble128VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Double256VectorTests.java b/test/jdk/jdk/incubator/vector/Double256VectorTests.java index 9cedfba15f1bd..85a44136be18a 100644 --- a/test/jdk/jdk/incubator/vector/Double256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double256VectorTests.java @@ -1120,19 +1120,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[intCornerCaseValue(i)]", (int s) -> { + withToString("Double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)intCornerCaseValue(i)); }) @@ -1169,19 +1169,19 @@ static double genValue(long i) { } static final List> LONG_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[cornerCaseValue(i)]", (int s) -> { + withToString("Double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)longCornerCaseValue(i)); }) @@ -1204,15 +1204,15 @@ static long bits(double e) { } static final List> DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1546,6 +1546,225 @@ static double firstNonZero(double a, double b) { return Double.compare(a, (double) 0) != 0 ? a : b; } + static double multiplicativeIdentity() { + return (double)1; + } + + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + static double additiveIdentity() { + return (double)0; + } + + + static double zeroValue() { + return (short) 0; + } + + static double maxValue() { + return Double.POSITIVE_INFINITY; + } + + static double minValue() { + return Double.NEGATIVE_INFINITY; + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1639,7 +1858,7 @@ void viewAsFloatingLanesTest() { } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1660,7 +1879,7 @@ static void ADDDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1738,7 +1957,7 @@ static void SUBDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1816,7 +2035,7 @@ static void MULDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1894,7 +2113,7 @@ static void DIVDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2241,7 +2460,7 @@ static void MAXDouble256VectorTestsMaskedWithMemOp(IntFunction fa, Int } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2262,7 +2481,7 @@ static void MINDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, } static double ADDReduce(double[] a, int idx) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAll(double[] a) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2398,7 +2617,7 @@ static double ADDReduceAll(double[] a) { static void ADDReduceDouble256VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2408,10 +2627,10 @@ static void ADDReduceDouble256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2420,19 +2639,19 @@ static void ADDReduceDouble256VectorTests(IntFunction fa) { } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAllMasked(double[] a, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2444,7 +2663,7 @@ static void ADDReduceDouble256VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2454,10 +2673,10 @@ static void ADDReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2466,18 +2685,18 @@ static void ADDReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } static double MULReduce(double[] a, int idx) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAll(double[] a) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2487,7 +2706,7 @@ static double MULReduceAll(double[] a) { static void MULReduceDouble256VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2497,10 +2716,10 @@ static void MULReduceDouble256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2509,19 +2728,19 @@ static void MULReduceDouble256VectorTests(IntFunction fa) { } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAllMasked(double[] a, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2533,7 +2752,7 @@ static void MULReduceDouble256VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2543,10 +2762,10 @@ static void MULReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2555,18 +2774,18 @@ static void MULReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } static double MINReduce(double[] a, int idx) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAll(double[] a) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2576,7 +2795,7 @@ static double MINReduceAll(double[] a) { static void MINReduceDouble256VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2586,10 +2805,10 @@ static void MINReduceDouble256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2598,19 +2817,19 @@ static void MINReduceDouble256VectorTests(IntFunction fa) { } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2622,7 +2841,7 @@ static void MINReduceDouble256VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2632,10 +2851,10 @@ static void MINReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2644,18 +2863,18 @@ static void MINReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } static double MAXReduce(double[] a, int idx) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAll(double[] a) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2665,7 +2884,7 @@ static double MAXReduceAll(double[] a) { static void MAXReduceDouble256VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2675,10 +2894,10 @@ static void MAXReduceDouble256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2687,19 +2906,19 @@ static void MAXReduceDouble256VectorTests(IntFunction fa) { } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2711,7 +2930,7 @@ static void MAXReduceDouble256VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2721,10 +2940,10 @@ static void MAXReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2733,7 +2952,7 @@ static void MAXReduceDouble256VectorTestsMasked(IntFunction fa, IntFun } static double FIRST_NONZEROReduce(double[] a, int idx) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2742,7 +2961,7 @@ static double FIRST_NONZEROReduce(double[] a, int idx) { } static double FIRST_NONZEROReduceAll(double[] a) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2754,7 +2973,7 @@ static double FIRST_NONZEROReduceAll(double[] a) { static void FIRST_NONZEROReduceDouble256VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2764,7 +2983,7 @@ static void FIRST_NONZEROReduceDouble256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2776,7 +2995,7 @@ static void FIRST_NONZEROReduceDouble256VectorTests(IntFunction fa) { } static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2786,7 +3005,7 @@ static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { } static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2800,7 +3019,7 @@ static void FIRST_NONZEROReduceDouble256VectorTestsMasked(IntFunction double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2810,7 +3029,7 @@ static void FIRST_NONZEROReduceDouble256VectorTestsMasked(IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2855,7 +3074,7 @@ static void IS_DEFAULTDouble256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2875,7 +3094,7 @@ static void IS_DEFAULTMaskedDouble256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2896,7 +3115,7 @@ static void IS_NEGATIVEDouble256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2916,14 +3135,14 @@ static void IS_NEGATIVEMaskedDouble256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2937,7 +3156,7 @@ static void IS_FINITEDouble256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2957,14 +3176,14 @@ static void IS_FINITEMaskedDouble256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2978,7 +3197,7 @@ static void IS_NANDouble256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -2998,14 +3217,14 @@ static void IS_NANMaskedDouble256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -3019,7 +3238,7 @@ static void IS_INFINITEDouble256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3039,7 +3258,7 @@ static void IS_INFINITEMaskedDouble256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3058,7 +3277,7 @@ static void LTDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3366,7 +3585,7 @@ static void LTDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3382,7 +3601,7 @@ static void LTDouble256VectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @@ -3402,7 +3621,7 @@ static void LTDouble256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3438,7 +3657,7 @@ static void EQDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3454,7 +3673,7 @@ static void EQDouble256VectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @@ -3474,7 +3693,7 @@ static void EQDouble256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static double[] sliceUnary(double[] a, int origin, int idx) { @@ -3974,11 +4193,11 @@ static void unsliceDouble256VectorTestsMasked(IntFunction fa, IntFunct } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3997,11 +4216,11 @@ static void SINDouble256VectorTests(IntFunction fa) { } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4020,11 +4239,11 @@ static void EXPDouble256VectorTests(IntFunction fa) { } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4043,11 +4262,11 @@ static void LOG1PDouble256VectorTests(IntFunction fa) { } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4066,11 +4285,11 @@ static void LOGDouble256VectorTests(IntFunction fa) { } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4089,11 +4308,11 @@ static void LOG10Double256VectorTests(IntFunction fa) { } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4112,11 +4331,11 @@ static void EXPM1Double256VectorTests(IntFunction fa) { } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4135,11 +4354,11 @@ static void COSDouble256VectorTests(IntFunction fa) { } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4158,11 +4377,11 @@ static void TANDouble256VectorTests(IntFunction fa) { } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4181,11 +4400,11 @@ static void SINHDouble256VectorTests(IntFunction fa) { } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4204,11 +4423,11 @@ static void COSHDouble256VectorTests(IntFunction fa) { } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4227,11 +4446,11 @@ static void TANHDouble256VectorTests(IntFunction fa) { } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4250,11 +4469,11 @@ static void ASINDouble256VectorTests(IntFunction fa) { } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4273,11 +4492,11 @@ static void ACOSDouble256VectorTests(IntFunction fa) { } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4296,11 +4515,11 @@ static void ATANDouble256VectorTests(IntFunction fa) { } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4319,11 +4538,11 @@ static void CBRTDouble256VectorTests(IntFunction fa) { } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4345,11 +4564,11 @@ static void HYPOTDouble256VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4677,11 +4896,11 @@ static void FMADouble256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4789,11 +5008,11 @@ static void ABSMaskedDouble256VectorTests(IntFunction fa, } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4855,7 +5074,7 @@ static void ltDouble256VectorTestsBroadcastSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4871,7 +5090,7 @@ static void eqDouble256VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5101,7 +5320,7 @@ static void shuffleMiscellaneousDouble256VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Double512VectorTests.java b/test/jdk/jdk/incubator/vector/Double512VectorTests.java index c0f2460ba19ad..4c452d60b132c 100644 --- a/test/jdk/jdk/incubator/vector/Double512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double512VectorTests.java @@ -1120,19 +1120,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[intCornerCaseValue(i)]", (int s) -> { + withToString("Double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)intCornerCaseValue(i)); }) @@ -1169,19 +1169,19 @@ static double genValue(long i) { } static final List> LONG_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[cornerCaseValue(i)]", (int s) -> { + withToString("Double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)longCornerCaseValue(i)); }) @@ -1204,15 +1204,15 @@ static long bits(double e) { } static final List> DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1546,6 +1546,225 @@ static double firstNonZero(double a, double b) { return Double.compare(a, (double) 0) != 0 ? a : b; } + static double multiplicativeIdentity() { + return (double)1; + } + + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + static double additiveIdentity() { + return (double)0; + } + + + static double zeroValue() { + return (short) 0; + } + + static double maxValue() { + return Double.POSITIVE_INFINITY; + } + + static double minValue() { + return Double.NEGATIVE_INFINITY; + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1639,7 +1858,7 @@ void viewAsFloatingLanesTest() { } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1660,7 +1879,7 @@ static void ADDDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1738,7 +1957,7 @@ static void SUBDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1816,7 +2035,7 @@ static void MULDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1894,7 +2113,7 @@ static void DIVDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2241,7 +2460,7 @@ static void MAXDouble512VectorTestsMaskedWithMemOp(IntFunction fa, Int } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2262,7 +2481,7 @@ static void MINDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, } static double ADDReduce(double[] a, int idx) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAll(double[] a) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2398,7 +2617,7 @@ static double ADDReduceAll(double[] a) { static void ADDReduceDouble512VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2408,10 +2627,10 @@ static void ADDReduceDouble512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2420,19 +2639,19 @@ static void ADDReduceDouble512VectorTests(IntFunction fa) { } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAllMasked(double[] a, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2444,7 +2663,7 @@ static void ADDReduceDouble512VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2454,10 +2673,10 @@ static void ADDReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2466,18 +2685,18 @@ static void ADDReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } static double MULReduce(double[] a, int idx) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAll(double[] a) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2487,7 +2706,7 @@ static double MULReduceAll(double[] a) { static void MULReduceDouble512VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2497,10 +2716,10 @@ static void MULReduceDouble512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2509,19 +2728,19 @@ static void MULReduceDouble512VectorTests(IntFunction fa) { } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAllMasked(double[] a, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2533,7 +2752,7 @@ static void MULReduceDouble512VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2543,10 +2762,10 @@ static void MULReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2555,18 +2774,18 @@ static void MULReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } static double MINReduce(double[] a, int idx) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAll(double[] a) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2576,7 +2795,7 @@ static double MINReduceAll(double[] a) { static void MINReduceDouble512VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2586,10 +2805,10 @@ static void MINReduceDouble512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2598,19 +2817,19 @@ static void MINReduceDouble512VectorTests(IntFunction fa) { } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2622,7 +2841,7 @@ static void MINReduceDouble512VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2632,10 +2851,10 @@ static void MINReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2644,18 +2863,18 @@ static void MINReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } static double MAXReduce(double[] a, int idx) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAll(double[] a) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2665,7 +2884,7 @@ static double MAXReduceAll(double[] a) { static void MAXReduceDouble512VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2675,10 +2894,10 @@ static void MAXReduceDouble512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2687,19 +2906,19 @@ static void MAXReduceDouble512VectorTests(IntFunction fa) { } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2711,7 +2930,7 @@ static void MAXReduceDouble512VectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2721,10 +2940,10 @@ static void MAXReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2733,7 +2952,7 @@ static void MAXReduceDouble512VectorTestsMasked(IntFunction fa, IntFun } static double FIRST_NONZEROReduce(double[] a, int idx) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2742,7 +2961,7 @@ static double FIRST_NONZEROReduce(double[] a, int idx) { } static double FIRST_NONZEROReduceAll(double[] a) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2754,7 +2973,7 @@ static double FIRST_NONZEROReduceAll(double[] a) { static void FIRST_NONZEROReduceDouble512VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2764,7 +2983,7 @@ static void FIRST_NONZEROReduceDouble512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2776,7 +2995,7 @@ static void FIRST_NONZEROReduceDouble512VectorTests(IntFunction fa) { } static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2786,7 +3005,7 @@ static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { } static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2800,7 +3019,7 @@ static void FIRST_NONZEROReduceDouble512VectorTestsMasked(IntFunction double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2810,7 +3029,7 @@ static void FIRST_NONZEROReduceDouble512VectorTestsMasked(IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2855,7 +3074,7 @@ static void IS_DEFAULTDouble512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2875,7 +3094,7 @@ static void IS_DEFAULTMaskedDouble512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2896,7 +3115,7 @@ static void IS_NEGATIVEDouble512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2916,14 +3135,14 @@ static void IS_NEGATIVEMaskedDouble512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2937,7 +3156,7 @@ static void IS_FINITEDouble512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2957,14 +3176,14 @@ static void IS_FINITEMaskedDouble512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2978,7 +3197,7 @@ static void IS_NANDouble512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -2998,14 +3217,14 @@ static void IS_NANMaskedDouble512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -3019,7 +3238,7 @@ static void IS_INFINITEDouble512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3039,7 +3258,7 @@ static void IS_INFINITEMaskedDouble512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3058,7 +3277,7 @@ static void LTDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3366,7 +3585,7 @@ static void LTDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3382,7 +3601,7 @@ static void LTDouble512VectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @@ -3402,7 +3621,7 @@ static void LTDouble512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3438,7 +3657,7 @@ static void EQDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3454,7 +3673,7 @@ static void EQDouble512VectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @@ -3474,7 +3693,7 @@ static void EQDouble512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static double[] sliceUnary(double[] a, int origin, int idx) { @@ -3974,11 +4193,11 @@ static void unsliceDouble512VectorTestsMasked(IntFunction fa, IntFunct } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3997,11 +4216,11 @@ static void SINDouble512VectorTests(IntFunction fa) { } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4020,11 +4239,11 @@ static void EXPDouble512VectorTests(IntFunction fa) { } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4043,11 +4262,11 @@ static void LOG1PDouble512VectorTests(IntFunction fa) { } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4066,11 +4285,11 @@ static void LOGDouble512VectorTests(IntFunction fa) { } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4089,11 +4308,11 @@ static void LOG10Double512VectorTests(IntFunction fa) { } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4112,11 +4331,11 @@ static void EXPM1Double512VectorTests(IntFunction fa) { } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4135,11 +4354,11 @@ static void COSDouble512VectorTests(IntFunction fa) { } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4158,11 +4377,11 @@ static void TANDouble512VectorTests(IntFunction fa) { } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4181,11 +4400,11 @@ static void SINHDouble512VectorTests(IntFunction fa) { } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4204,11 +4423,11 @@ static void COSHDouble512VectorTests(IntFunction fa) { } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4227,11 +4446,11 @@ static void TANHDouble512VectorTests(IntFunction fa) { } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4250,11 +4469,11 @@ static void ASINDouble512VectorTests(IntFunction fa) { } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4273,11 +4492,11 @@ static void ACOSDouble512VectorTests(IntFunction fa) { } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4296,11 +4515,11 @@ static void ATANDouble512VectorTests(IntFunction fa) { } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4319,11 +4538,11 @@ static void CBRTDouble512VectorTests(IntFunction fa) { } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4345,11 +4564,11 @@ static void HYPOTDouble512VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4677,11 +4896,11 @@ static void FMADouble512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4789,11 +5008,11 @@ static void ABSMaskedDouble512VectorTests(IntFunction fa, } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4855,7 +5074,7 @@ static void ltDouble512VectorTestsBroadcastSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4871,7 +5090,7 @@ static void eqDouble512VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5101,7 +5320,7 @@ static void shuffleMiscellaneousDouble512VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Double64VectorTests.java b/test/jdk/jdk/incubator/vector/Double64VectorTests.java index bcce613c3d666..b39b96e01b7db 100644 --- a/test/jdk/jdk/incubator/vector/Double64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Double64VectorTests.java @@ -1120,19 +1120,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[intCornerCaseValue(i)]", (int s) -> { + withToString("Double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)intCornerCaseValue(i)); }) @@ -1169,19 +1169,19 @@ static double genValue(long i) { } static final List> LONG_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[cornerCaseValue(i)]", (int s) -> { + withToString("Double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)longCornerCaseValue(i)); }) @@ -1204,15 +1204,15 @@ static long bits(double e) { } static final List> DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1546,6 +1546,225 @@ static double firstNonZero(double a, double b) { return Double.compare(a, (double) 0) != 0 ? a : b; } + static double multiplicativeIdentity() { + return (double)1; + } + + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + static double additiveIdentity() { + return (double)0; + } + + + static double zeroValue() { + return (short) 0; + } + + static double maxValue() { + return Double.POSITIVE_INFINITY; + } + + static double minValue() { + return Double.NEGATIVE_INFINITY; + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1639,7 +1858,7 @@ void viewAsFloatingLanesTest() { } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1660,7 +1879,7 @@ static void ADDDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntF } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2262,7 +2481,7 @@ static void MINDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I } static double ADDReduce(double[] a, int idx) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAll(double[] a) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2398,7 +2617,7 @@ static double ADDReduceAll(double[] a) { static void ADDReduceDouble64VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2408,10 +2627,10 @@ static void ADDReduceDouble64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2420,19 +2639,19 @@ static void ADDReduceDouble64VectorTests(IntFunction fa) { } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAllMasked(double[] a, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2444,7 +2663,7 @@ static void ADDReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2454,10 +2673,10 @@ static void ADDReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2466,18 +2685,18 @@ static void ADDReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } static double MULReduce(double[] a, int idx) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAll(double[] a) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2487,7 +2706,7 @@ static double MULReduceAll(double[] a) { static void MULReduceDouble64VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2497,10 +2716,10 @@ static void MULReduceDouble64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2509,19 +2728,19 @@ static void MULReduceDouble64VectorTests(IntFunction fa) { } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAllMasked(double[] a, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2533,7 +2752,7 @@ static void MULReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2543,10 +2762,10 @@ static void MULReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2555,18 +2774,18 @@ static void MULReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } static double MINReduce(double[] a, int idx) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAll(double[] a) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2576,7 +2795,7 @@ static double MINReduceAll(double[] a) { static void MINReduceDouble64VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2586,10 +2805,10 @@ static void MINReduceDouble64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2598,19 +2817,19 @@ static void MINReduceDouble64VectorTests(IntFunction fa) { } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2622,7 +2841,7 @@ static void MINReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2632,10 +2851,10 @@ static void MINReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2644,18 +2863,18 @@ static void MINReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } static double MAXReduce(double[] a, int idx) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAll(double[] a) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2665,7 +2884,7 @@ static double MAXReduceAll(double[] a) { static void MAXReduceDouble64VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2675,10 +2894,10 @@ static void MAXReduceDouble64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2687,19 +2906,19 @@ static void MAXReduceDouble64VectorTests(IntFunction fa) { } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2711,7 +2930,7 @@ static void MAXReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2721,10 +2940,10 @@ static void MAXReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2733,7 +2952,7 @@ static void MAXReduceDouble64VectorTestsMasked(IntFunction fa, IntFunc } static double FIRST_NONZEROReduce(double[] a, int idx) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2742,7 +2961,7 @@ static double FIRST_NONZEROReduce(double[] a, int idx) { } static double FIRST_NONZEROReduceAll(double[] a) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2754,7 +2973,7 @@ static double FIRST_NONZEROReduceAll(double[] a) { static void FIRST_NONZEROReduceDouble64VectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2764,7 +2983,7 @@ static void FIRST_NONZEROReduceDouble64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2776,7 +2995,7 @@ static void FIRST_NONZEROReduceDouble64VectorTests(IntFunction fa) { } static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2786,7 +3005,7 @@ static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { } static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2800,7 +3019,7 @@ static void FIRST_NONZEROReduceDouble64VectorTestsMasked(IntFunction f double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2810,7 +3029,7 @@ static void FIRST_NONZEROReduceDouble64VectorTestsMasked(IntFunction f } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2855,7 +3074,7 @@ static void IS_DEFAULTDouble64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2875,7 +3094,7 @@ static void IS_DEFAULTMaskedDouble64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2896,7 +3115,7 @@ static void IS_NEGATIVEDouble64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2916,14 +3135,14 @@ static void IS_NEGATIVEMaskedDouble64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2937,7 +3156,7 @@ static void IS_FINITEDouble64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2957,14 +3176,14 @@ static void IS_FINITEMaskedDouble64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2978,7 +3197,7 @@ static void IS_NANDouble64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -2998,14 +3217,14 @@ static void IS_NANMaskedDouble64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -3019,7 +3238,7 @@ static void IS_INFINITEDouble64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3039,7 +3258,7 @@ static void IS_INFINITEMaskedDouble64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3058,7 +3277,7 @@ static void LTDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, In // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3366,7 +3585,7 @@ static void LTDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3382,7 +3601,7 @@ static void LTDouble64VectorTestsBroadcastLongSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @@ -3402,7 +3621,7 @@ static void LTDouble64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, In // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3438,7 +3657,7 @@ static void EQDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3454,7 +3673,7 @@ static void EQDouble64VectorTestsBroadcastLongSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @@ -3474,7 +3693,7 @@ static void EQDouble64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static double[] sliceUnary(double[] a, int origin, int idx) { @@ -3974,11 +4193,11 @@ static void unsliceDouble64VectorTestsMasked(IntFunction fa, IntFuncti } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -3997,11 +4216,11 @@ static void SINDouble64VectorTests(IntFunction fa) { } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4020,11 +4239,11 @@ static void EXPDouble64VectorTests(IntFunction fa) { } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4043,11 +4262,11 @@ static void LOG1PDouble64VectorTests(IntFunction fa) { } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4066,11 +4285,11 @@ static void LOGDouble64VectorTests(IntFunction fa) { } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4089,11 +4308,11 @@ static void LOG10Double64VectorTests(IntFunction fa) { } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4112,11 +4331,11 @@ static void EXPM1Double64VectorTests(IntFunction fa) { } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4135,11 +4354,11 @@ static void COSDouble64VectorTests(IntFunction fa) { } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4158,11 +4377,11 @@ static void TANDouble64VectorTests(IntFunction fa) { } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4181,11 +4400,11 @@ static void SINHDouble64VectorTests(IntFunction fa) { } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4204,11 +4423,11 @@ static void COSHDouble64VectorTests(IntFunction fa) { } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4227,11 +4446,11 @@ static void TANHDouble64VectorTests(IntFunction fa) { } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4250,11 +4469,11 @@ static void ASINDouble64VectorTests(IntFunction fa) { } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4273,11 +4492,11 @@ static void ACOSDouble64VectorTests(IntFunction fa) { } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4296,11 +4515,11 @@ static void ATANDouble64VectorTests(IntFunction fa) { } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4319,11 +4538,11 @@ static void CBRTDouble64VectorTests(IntFunction fa) { } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4345,11 +4564,11 @@ static void HYPOTDouble64VectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4677,11 +4896,11 @@ static void FMADouble64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4789,11 +5008,11 @@ static void ABSMaskedDouble64VectorTests(IntFunction fa, } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4855,7 +5074,7 @@ static void ltDouble64VectorTestsBroadcastSmokeTest(IntFunction fa, In // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4871,7 +5090,7 @@ static void eqDouble64VectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5101,7 +5320,7 @@ static void shuffleMiscellaneousDouble64VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java index 213b9edf6cf09..0fd176dfd84b5 100644 --- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorTests.java @@ -1125,19 +1125,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[intCornerCaseValue(i)]", (int s) -> { + withToString("Double[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)intCornerCaseValue(i)); }) @@ -1174,19 +1174,19 @@ static double genValue(long i) { } static final List> LONG_DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("double[cornerCaseValue(i)]", (int s) -> { + withToString("Double[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (double)longCornerCaseValue(i)); }) @@ -1209,15 +1209,15 @@ static long bits(double e) { } static final List> DOUBLE_GENERATORS = List.of( - withToString("double[-i * 5]", (int s) -> { + withToString("Double[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("double[i * 5]", (int s) -> { + withToString("Double[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("double[i + 1]", (int s) -> { + withToString("Double[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((double)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1551,6 +1551,225 @@ static double firstNonZero(double a, double b) { return Double.compare(a, (double) 0) != 0 ? a : b; } + static double multiplicativeIdentity() { + return (double)1; + } + + + static double scalar_add(double a, double b) { + return (double)(a + b); + } + + static double scalar_sub(double a, double b) { + return (double)(a - b); + } + + static double scalar_mul(double a, double b) { + return (double)(a * b); + } + + static double scalar_min(double a, double b) { + return (double)(Math.min(a, b)); + } + + static double scalar_max(double a, double b) { + return (double)(Math.max(a, b)); + } + + static double scalar_div(double a, double b) { + return (double)(a / b); + } + + static double scalar_fma(double a, double b, double c) { + return (double)(Math.fma(a, b, c)); + } + + static double scalar_abs(double a) { + return (double)(Math.abs(a)); + } + + static double scalar_neg(double a) { + return ((double)-a); + } + + static double scalar_sin(double a) { + return (double)Math.sin((double)a); + } + + static double scalar_exp(double a) { + return (double)Math.exp((double)a); + } + + static double scalar_log1p(double a) { + return (double)Math.log1p((double)a); + } + + static double scalar_log(double a) { + return (double)Math.log((double)a); + } + + static double scalar_log10(double a) { + return (double)Math.log10((double)a); + } + + static double scalar_expm1(double a) { + return (double)Math.expm1((double)a); + } + + static double scalar_cos(double a) { + return (double)Math.cos((double)a); + } + + static double scalar_tan(double a) { + return (double)Math.tan((double)a); + } + + static double scalar_sinh(double a) { + return (double)Math.sinh((double)a); + } + + static double scalar_cosh(double a) { + return (double)Math.cosh((double)a); + } + + static double scalar_tanh(double a) { + return (double)Math.tanh((double)a); + } + + static double scalar_asin(double a) { + return (double)Math.asin((double)a); + } + + static double scalar_acos(double a) { + return (double)Math.acos((double)a); + } + + static double scalar_atan(double a) { + return (double)Math.atan((double)a); + } + + static double scalar_cbrt(double a) { + return (double)Math.cbrt((double)a); + } + + static double scalar_sqrt(double a) { + return (double)Math.sqrt((double)a); + } + + static double scalar_hypot(double a, double b) { + return (double)Math.hypot((double)a, (double)b); + } + + static double scalar_pow(double a, double b) { + return (double)Math.pow((double)a, (double)b); + } + + static double scalar_atan2(double a, double b) { + return (double)Math.atan2((double)a, (double)b); + } + + static double strict_scalar_sin(double a) { + return (double)StrictMath.sin((double)a); + } + + static double strict_scalar_exp(double a) { + return (double)StrictMath.exp((double)a); + } + + static double strict_scalar_log1p(double a) { + return (double)StrictMath.log1p((double)a); + } + + static double strict_scalar_log(double a) { + return (double)StrictMath.log((double)a); + } + + static double strict_scalar_log10(double a) { + return (double)StrictMath.log10((double)a); + } + + static double strict_scalar_expm1(double a) { + return (double)StrictMath.expm1((double)a); + } + + static double strict_scalar_cos(double a) { + return (double)StrictMath.cos((double)a); + } + + static double strict_scalar_tan(double a) { + return (double)StrictMath.tan((double)a); + } + + static double strict_scalar_sinh(double a) { + return (double)StrictMath.sinh((double)a); + } + + static double strict_scalar_cosh(double a) { + return (double)StrictMath.cosh((double)a); + } + + static double strict_scalar_tanh(double a) { + return (double)StrictMath.tanh((double)a); + } + + static double strict_scalar_asin(double a) { + return (double)StrictMath.asin((double)a); + } + + static double strict_scalar_acos(double a) { + return (double)StrictMath.acos((double)a); + } + + static double strict_scalar_atan(double a) { + return (double)StrictMath.atan((double)a); + } + + static double strict_scalar_cbrt(double a) { + return (double)StrictMath.cbrt((double)a); + } + + static double strict_scalar_sqrt(double a) { + return (double)StrictMath.sqrt((double)a); + } + + static double strict_scalar_hypot(double a, double b) { + return (double)StrictMath.hypot((double)a, (double)b); + } + + static double strict_scalar_pow(double a, double b) { + return (double)StrictMath.pow((double)a, (double)b); + } + + static double strict_scalar_atan2(double a, double b) { + return (double)StrictMath.atan2((double)a, (double)b); + } + static double additiveIdentity() { + return (double)0; + } + + + static double zeroValue() { + return (short) 0; + } + + static double maxValue() { + return Double.POSITIVE_INFINITY; + } + + static double minValue() { + return Double.NEGATIVE_INFINITY; + } + + static boolean isNaN(double a) { + return Double.isNaN(a); + } + static boolean isFinite(double a) { + return Double.isFinite(a); + } + static boolean isInfinite(double a) { + return Double.isInfinite(a); + } + @Test static void smokeTest1() { DoubleVector three = DoubleVector.broadcast(SPECIES, (byte)-3); @@ -1644,7 +1863,7 @@ void viewAsFloatingLanesTest() { } static double ADD(double a, double b) { - return (double)(a + b); + return (double)(scalar_add(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1665,7 +1884,7 @@ static void ADDDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double SUB(double a, double b) { - return (double)(a - b); + return (double)(scalar_sub(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1743,7 +1962,7 @@ static void SUBDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double MUL(double a, double b) { - return (double)(a * b); + return (double)(scalar_mul(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1821,7 +2040,7 @@ static void MULDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double DIV(double a, double b) { - return (double)(a / b); + return (double)(scalar_div(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -1899,7 +2118,7 @@ static void DIVDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction< } static double FIRST_NONZERO(double a, double b) { - return (double)(Double.doubleToLongBits(a)!=0?a:b); + return (double)(firstNonZero(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2246,7 +2465,7 @@ static void MAXDoubleMaxVectorTestsMaskedWithMemOp(IntFunction fa, Int } static double MIN(double a, double b) { - return (double)(Math.min(a, b)); + return (double)(scalar_min(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -2267,7 +2486,7 @@ static void MINDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, } static double ADDReduce(double[] a, int idx) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAll(double[] a) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2403,7 +2622,7 @@ static double ADDReduceAll(double[] a) { static void ADDReduceDoubleMaxVectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2413,10 +2632,10 @@ static void ADDReduceDoubleMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2425,19 +2644,19 @@ static void ADDReduceDoubleMaxVectorTests(IntFunction fa) { } static double ADDReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static double ADDReduceAllMasked(double[] a, boolean[] mask) { - double res = 0; + double res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2449,7 +2668,7 @@ static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 0; + double ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2459,10 +2678,10 @@ static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2471,18 +2690,18 @@ static void ADDReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } static double MULReduce(double[] a, int idx) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAll(double[] a) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2492,7 +2711,7 @@ static double MULReduceAll(double[] a) { static void MULReduceDoubleMaxVectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2502,10 +2721,10 @@ static void MULReduceDoubleMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2514,19 +2733,19 @@ static void MULReduceDoubleMaxVectorTests(IntFunction fa) { } static double MULReduceMasked(double[] a, int idx, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static double MULReduceAllMasked(double[] a, boolean[] mask) { - double res = 1; + double res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2538,7 +2757,7 @@ static void MULReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = 1; + double ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2548,10 +2767,10 @@ static void MULReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2560,18 +2779,18 @@ static void MULReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } static double MINReduce(double[] a, int idx) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAll(double[] a) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2581,7 +2800,7 @@ static double MINReduceAll(double[] a) { static void MINReduceDoubleMaxVectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2591,10 +2810,10 @@ static void MINReduceDoubleMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2603,19 +2822,19 @@ static void MINReduceDoubleMaxVectorTests(IntFunction fa) { } static double MINReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static double MINReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.POSITIVE_INFINITY; + double res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2627,7 +2846,7 @@ static void MINReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.POSITIVE_INFINITY; + double ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2637,10 +2856,10 @@ static void MINReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2649,18 +2868,18 @@ static void MINReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } static double MAXReduce(double[] a, int idx) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAll(double[] a) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2670,7 +2889,7 @@ static double MAXReduceAll(double[] a) { static void MAXReduceDoubleMaxVectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2680,10 +2899,10 @@ static void MAXReduceDoubleMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2692,19 +2911,19 @@ static void MAXReduceDoubleMaxVectorTests(IntFunction fa) { } static double MAXReduceMasked(double[] a, int idx, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (double) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static double MAXReduceAllMasked(double[] a, boolean[] mask) { - double res = Double.NEGATIVE_INFINITY; + double res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (double) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2716,7 +2935,7 @@ static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = Double.NEGATIVE_INFINITY; + double ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2726,10 +2945,10 @@ static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Double.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - ra = (double) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2738,7 +2957,7 @@ static void MAXReduceDoubleMaxVectorTestsMasked(IntFunction fa, IntFun } static double FIRST_NONZEROReduce(double[] a, int idx) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2747,7 +2966,7 @@ static double FIRST_NONZEROReduce(double[] a, int idx) { } static double FIRST_NONZEROReduceAll(double[] a) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2759,7 +2978,7 @@ static double FIRST_NONZEROReduceAll(double[] a) { static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction fa) { double[] a = fa.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2769,7 +2988,7 @@ static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2781,7 +3000,7 @@ static void FIRST_NONZEROReduceDoubleMaxVectorTests(IntFunction fa) { } static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2791,7 +3010,7 @@ static double FIRST_NONZEROReduceMasked(double[] a, int idx, boolean[] mask) { } static double FIRST_NONZEROReduceAllMasked(double[] a, boolean[] mask) { - double res = (double) 0; + double res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2805,7 +3024,7 @@ static void FIRST_NONZEROReduceDoubleMaxVectorTestsMasked(IntFunction double[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - double ra = (double) 0; + double ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2815,7 +3034,7 @@ static void FIRST_NONZEROReduceDoubleMaxVectorTestsMasked(IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (double) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2860,7 +3079,7 @@ static void IS_DEFAULTDoubleMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2880,7 +3099,7 @@ static void IS_DEFAULTMaskedDoubleMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2901,7 +3120,7 @@ static void IS_NEGATIVEDoubleMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2921,14 +3140,14 @@ static void IS_NEGATIVEMaskedDoubleMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(double a) { - return Double.isFinite(a); + return isFinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2942,7 +3161,7 @@ static void IS_FINITEDoubleMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2962,14 +3181,14 @@ static void IS_FINITEMaskedDoubleMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(double a) { - return Double.isNaN(a); + return isNaN(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -2983,7 +3202,7 @@ static void IS_NANDoubleMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -3003,14 +3222,14 @@ static void IS_NANMaskedDoubleMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(double a) { - return Double.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "doubleTestOpProvider") @@ -3024,7 +3243,7 @@ static void IS_INFINITEDoubleMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3044,7 +3263,7 @@ static void IS_INFINITEMaskedDoubleMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3063,7 +3282,7 @@ static void LTDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3371,7 +3590,7 @@ static void LTDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3387,7 +3606,7 @@ static void LTDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (double)((long)b[i]))); } } } @@ -3407,7 +3626,7 @@ static void LTDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3443,7 +3662,7 @@ static void EQDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3459,7 +3678,7 @@ static void EQDoubleMaxVectorTestsBroadcastLongSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (double)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (double)((long)b[i]))); } } } @@ -3479,7 +3698,7 @@ static void EQDoubleMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static double[] sliceUnary(double[] a, int origin, int idx) { @@ -3979,11 +4198,11 @@ static void unsliceDoubleMaxVectorTestsMasked(IntFunction fa, IntFunct } static double SIN(double a) { - return (double)(Math.sin((double)a)); + return (double)(scalar_sin(a)); } static double strictSIN(double a) { - return (double)(StrictMath.sin((double)a)); + return (double)(strict_scalar_sin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4002,11 +4221,11 @@ static void SINDoubleMaxVectorTests(IntFunction fa) { } static double EXP(double a) { - return (double)(Math.exp((double)a)); + return (double)(scalar_exp(a)); } static double strictEXP(double a) { - return (double)(StrictMath.exp((double)a)); + return (double)(strict_scalar_exp(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4025,11 +4244,11 @@ static void EXPDoubleMaxVectorTests(IntFunction fa) { } static double LOG1P(double a) { - return (double)(Math.log1p((double)a)); + return (double)(scalar_log1p(a)); } static double strictLOG1P(double a) { - return (double)(StrictMath.log1p((double)a)); + return (double)(strict_scalar_log1p(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4048,11 +4267,11 @@ static void LOG1PDoubleMaxVectorTests(IntFunction fa) { } static double LOG(double a) { - return (double)(Math.log((double)a)); + return (double)(scalar_log(a)); } static double strictLOG(double a) { - return (double)(StrictMath.log((double)a)); + return (double)(strict_scalar_log(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4071,11 +4290,11 @@ static void LOGDoubleMaxVectorTests(IntFunction fa) { } static double LOG10(double a) { - return (double)(Math.log10((double)a)); + return (double)(scalar_log10(a)); } static double strictLOG10(double a) { - return (double)(StrictMath.log10((double)a)); + return (double)(strict_scalar_log10(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4094,11 +4313,11 @@ static void LOG10DoubleMaxVectorTests(IntFunction fa) { } static double EXPM1(double a) { - return (double)(Math.expm1((double)a)); + return (double)(scalar_expm1(a)); } static double strictEXPM1(double a) { - return (double)(StrictMath.expm1((double)a)); + return (double)(strict_scalar_expm1(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4117,11 +4336,11 @@ static void EXPM1DoubleMaxVectorTests(IntFunction fa) { } static double COS(double a) { - return (double)(Math.cos((double)a)); + return (double)(scalar_cos(a)); } static double strictCOS(double a) { - return (double)(StrictMath.cos((double)a)); + return (double)(strict_scalar_cos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4140,11 +4359,11 @@ static void COSDoubleMaxVectorTests(IntFunction fa) { } static double TAN(double a) { - return (double)(Math.tan((double)a)); + return (double)(scalar_tan(a)); } static double strictTAN(double a) { - return (double)(StrictMath.tan((double)a)); + return (double)(strict_scalar_tan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4163,11 +4382,11 @@ static void TANDoubleMaxVectorTests(IntFunction fa) { } static double SINH(double a) { - return (double)(Math.sinh((double)a)); + return (double)(scalar_sinh(a)); } static double strictSINH(double a) { - return (double)(StrictMath.sinh((double)a)); + return (double)(strict_scalar_sinh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4186,11 +4405,11 @@ static void SINHDoubleMaxVectorTests(IntFunction fa) { } static double COSH(double a) { - return (double)(Math.cosh((double)a)); + return (double)(scalar_cosh(a)); } static double strictCOSH(double a) { - return (double)(StrictMath.cosh((double)a)); + return (double)(strict_scalar_cosh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4209,11 +4428,11 @@ static void COSHDoubleMaxVectorTests(IntFunction fa) { } static double TANH(double a) { - return (double)(Math.tanh((double)a)); + return (double)(scalar_tanh(a)); } static double strictTANH(double a) { - return (double)(StrictMath.tanh((double)a)); + return (double)(strict_scalar_tanh(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4232,11 +4451,11 @@ static void TANHDoubleMaxVectorTests(IntFunction fa) { } static double ASIN(double a) { - return (double)(Math.asin((double)a)); + return (double)(scalar_asin(a)); } static double strictASIN(double a) { - return (double)(StrictMath.asin((double)a)); + return (double)(strict_scalar_asin(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4255,11 +4474,11 @@ static void ASINDoubleMaxVectorTests(IntFunction fa) { } static double ACOS(double a) { - return (double)(Math.acos((double)a)); + return (double)(scalar_acos(a)); } static double strictACOS(double a) { - return (double)(StrictMath.acos((double)a)); + return (double)(strict_scalar_acos(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4278,11 +4497,11 @@ static void ACOSDoubleMaxVectorTests(IntFunction fa) { } static double ATAN(double a) { - return (double)(Math.atan((double)a)); + return (double)(scalar_atan(a)); } static double strictATAN(double a) { - return (double)(StrictMath.atan((double)a)); + return (double)(strict_scalar_atan(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4301,11 +4520,11 @@ static void ATANDoubleMaxVectorTests(IntFunction fa) { } static double CBRT(double a) { - return (double)(Math.cbrt((double)a)); + return (double)(scalar_cbrt(a)); } static double strictCBRT(double a) { - return (double)(StrictMath.cbrt((double)a)); + return (double)(strict_scalar_cbrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4324,11 +4543,11 @@ static void CBRTDoubleMaxVectorTests(IntFunction fa) { } static double HYPOT(double a, double b) { - return (double)(Math.hypot((double)a, (double)b)); + return (double)(scalar_hypot(a, b)); } static double strictHYPOT(double a, double b) { - return (double)(StrictMath.hypot((double)a, (double)b)); + return (double)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "doubleBinaryOpProvider") @@ -4350,11 +4569,11 @@ static void HYPOTDoubleMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fa, IntFunction fa, static double FMA(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } static double fma(double a, double b, double c) { - return (double)(Math.fma(a, b, c)); + return (double)(scalar_fma(a, b, c)); } @Test(dataProvider = "doubleTernaryOpProvider") @@ -4682,11 +4901,11 @@ static void FMADoubleMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static double ABS(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } static double abs(double a) { - return (double)(Math.abs((double)a)); + return (double)(scalar_abs((double)a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4794,11 +5013,11 @@ static void ABSMaskedDoubleMaxVectorTests(IntFunction fa, } static double SQRT(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } static double sqrt(double a) { - return (double)(Math.sqrt((double)a)); + return (double)(scalar_sqrt(a)); } @Test(dataProvider = "doubleUnaryOpProvider") @@ -4860,7 +5079,7 @@ static void ltDoubleMaxVectorTestsBroadcastSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4876,7 +5095,7 @@ static void eqDoubleMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5106,7 +5325,7 @@ static void shuffleMiscellaneousDoubleMaxVectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Float128VectorTests.java b/test/jdk/jdk/incubator/vector/Float128VectorTests.java index 8140ad6ba11fd..eaed7a5a80711 100644 --- a/test/jdk/jdk/incubator/vector/Float128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float128VectorTests.java @@ -1126,19 +1126,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[intCornerCaseValue(i)]", (int s) -> { + withToString("Float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)intCornerCaseValue(i)); }) @@ -1175,19 +1175,19 @@ static float genValue(long i) { } static final List> LONG_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[cornerCaseValue(i)]", (int s) -> { + withToString("Float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)longCornerCaseValue(i)); }) @@ -1221,15 +1221,15 @@ static int bits(float e) { } static final List> FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1563,6 +1563,225 @@ static float firstNonZero(float a, float b) { return Float.compare(a, (float) 0) != 0 ? a : b; } + static float multiplicativeIdentity() { + return (float)1; + } + + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + static float additiveIdentity() { + return (float)0; + } + + + static float zeroValue() { + return (short) 0; + } + + static float maxValue() { + return Float.POSITIVE_INFINITY; + } + + static float minValue() { + return Float.NEGATIVE_INFINITY; + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1656,7 +1875,7 @@ void viewAsFloatingLanesTest() { } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1677,7 +1896,7 @@ static void ADDFloat128VectorTests(IntFunction fa, IntFunction } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1734,7 +1953,7 @@ static void addFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1812,7 +2031,7 @@ static void subFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1890,7 +2109,7 @@ static void mulFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1968,7 +2187,7 @@ static void divFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2279,7 +2498,7 @@ static void MINFloat128VectorTests(IntFunction fa, IntFunction } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2298,7 +2517,7 @@ static void minFloat128VectorTests(IntFunction fa, IntFunction } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2319,7 +2538,7 @@ static void MAXFloat128VectorTests(IntFunction fa, IntFunction } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2394,18 +2613,18 @@ static void maxFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In } static float ADDReduce(float[] a, int idx) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAll(float[] a) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2415,7 +2634,7 @@ static float ADDReduceAll(float[] a) { static void ADDReduceFloat128VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2425,10 +2644,10 @@ static void ADDReduceFloat128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2437,19 +2656,19 @@ static void ADDReduceFloat128VectorTests(IntFunction fa) { } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAllMasked(float[] a, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2461,7 +2680,7 @@ static void ADDReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2471,10 +2690,10 @@ static void ADDReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2483,18 +2702,18 @@ static void ADDReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } static float MULReduce(float[] a, int idx) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAll(float[] a) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2504,7 +2723,7 @@ static float MULReduceAll(float[] a) { static void MULReduceFloat128VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2514,10 +2733,10 @@ static void MULReduceFloat128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2526,19 +2745,19 @@ static void MULReduceFloat128VectorTests(IntFunction fa) { } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAllMasked(float[] a, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2550,7 +2769,7 @@ static void MULReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2560,10 +2779,10 @@ static void MULReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2572,18 +2791,18 @@ static void MULReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } static float MINReduce(float[] a, int idx) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAll(float[] a) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2593,7 +2812,7 @@ static float MINReduceAll(float[] a) { static void MINReduceFloat128VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2603,10 +2822,10 @@ static void MINReduceFloat128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2615,19 +2834,19 @@ static void MINReduceFloat128VectorTests(IntFunction fa) { } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2639,7 +2858,7 @@ static void MINReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2649,10 +2868,10 @@ static void MINReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2661,18 +2880,18 @@ static void MINReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } static float MAXReduce(float[] a, int idx) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAll(float[] a) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2682,7 +2901,7 @@ static float MAXReduceAll(float[] a) { static void MAXReduceFloat128VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2692,10 +2911,10 @@ static void MAXReduceFloat128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2704,19 +2923,19 @@ static void MAXReduceFloat128VectorTests(IntFunction fa) { } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2728,7 +2947,7 @@ static void MAXReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2738,10 +2957,10 @@ static void MAXReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2750,7 +2969,7 @@ static void MAXReduceFloat128VectorTestsMasked(IntFunction fa, IntFunct } static float FIRST_NONZEROReduce(float[] a, int idx) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2759,7 +2978,7 @@ static float FIRST_NONZEROReduce(float[] a, int idx) { } static float FIRST_NONZEROReduceAll(float[] a) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2771,7 +2990,7 @@ static float FIRST_NONZEROReduceAll(float[] a) { static void FIRST_NONZEROReduceFloat128VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2781,7 +3000,7 @@ static void FIRST_NONZEROReduceFloat128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2793,7 +3012,7 @@ static void FIRST_NONZEROReduceFloat128VectorTests(IntFunction fa) { } static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2803,7 +3022,7 @@ static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { } static float FIRST_NONZEROReduceAllMasked(float[] a, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2817,7 +3036,7 @@ static void FIRST_NONZEROReduceFloat128VectorTestsMasked(IntFunction fa float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2827,7 +3046,7 @@ static void FIRST_NONZEROReduceFloat128VectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2872,7 +3091,7 @@ static void IS_DEFAULTFloat128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2892,7 +3111,7 @@ static void IS_DEFAULTMaskedFloat128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2913,7 +3132,7 @@ static void IS_NEGATIVEFloat128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2933,14 +3152,14 @@ static void IS_NEGATIVEMaskedFloat128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2954,7 +3173,7 @@ static void IS_FINITEFloat128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2974,14 +3193,14 @@ static void IS_FINITEMaskedFloat128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2995,7 +3214,7 @@ static void IS_NANFloat128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -3015,14 +3234,14 @@ static void IS_NANMaskedFloat128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -3036,7 +3255,7 @@ static void IS_INFINITEFloat128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3056,7 +3275,7 @@ static void IS_INFINITEMaskedFloat128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3075,7 +3294,7 @@ static void LTFloat128VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3094,7 +3313,7 @@ static void ltFloat128VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3117,7 +3336,7 @@ static void LTFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -3159,7 +3378,7 @@ static void GTFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3197,7 +3416,7 @@ static void eqFloat128VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3220,7 +3439,7 @@ static void EQFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -3262,7 +3481,7 @@ static void NEFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -3304,7 +3523,7 @@ static void LEFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -3346,7 +3565,7 @@ static void GEFloat128VectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3383,7 +3602,7 @@ static void LTFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3399,7 +3618,7 @@ static void LTFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @@ -3419,7 +3638,7 @@ static void LTFloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3455,7 +3674,7 @@ static void EQFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3471,7 +3690,7 @@ static void EQFloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @@ -3491,7 +3710,7 @@ static void EQFloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static float[] sliceUnary(float[] a, int origin, int idx) { @@ -3991,11 +4210,11 @@ static void unsliceFloat128VectorTestsMasked(IntFunction fa, IntFunctio } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4014,11 +4233,11 @@ static void SINFloat128VectorTests(IntFunction fa) { } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4037,11 +4256,11 @@ static void EXPFloat128VectorTests(IntFunction fa) { } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4060,11 +4279,11 @@ static void LOG1PFloat128VectorTests(IntFunction fa) { } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4083,11 +4302,11 @@ static void LOGFloat128VectorTests(IntFunction fa) { } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4106,11 +4325,11 @@ static void LOG10Float128VectorTests(IntFunction fa) { } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4129,11 +4348,11 @@ static void EXPM1Float128VectorTests(IntFunction fa) { } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4152,11 +4371,11 @@ static void COSFloat128VectorTests(IntFunction fa) { } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4175,11 +4394,11 @@ static void TANFloat128VectorTests(IntFunction fa) { } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4198,11 +4417,11 @@ static void SINHFloat128VectorTests(IntFunction fa) { } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4221,11 +4440,11 @@ static void COSHFloat128VectorTests(IntFunction fa) { } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4244,11 +4463,11 @@ static void TANHFloat128VectorTests(IntFunction fa) { } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4267,11 +4486,11 @@ static void ASINFloat128VectorTests(IntFunction fa) { } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4290,11 +4509,11 @@ static void ACOSFloat128VectorTests(IntFunction fa) { } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4313,11 +4532,11 @@ static void ATANFloat128VectorTests(IntFunction fa) { } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,11 +4555,11 @@ static void CBRTFloat128VectorTests(IntFunction fa) { } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4362,11 +4581,11 @@ static void HYPOTFloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4414,11 +4633,11 @@ static void powFloat128VectorTests(IntFunction fa, IntFunction static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4470,11 +4689,11 @@ static void powFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, In static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4652,11 +4871,11 @@ static void FMAFloat128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4764,11 +4983,11 @@ static void ABSMaskedFloat128VectorTests(IntFunction fa, } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4830,7 +5049,7 @@ static void ltFloat128VectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4846,7 +5065,7 @@ static void eqFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5086,7 +5305,7 @@ static void shuffleMiscellaneousFloat128VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Float256VectorTests.java b/test/jdk/jdk/incubator/vector/Float256VectorTests.java index b9068673dc217..4e879e105eb18 100644 --- a/test/jdk/jdk/incubator/vector/Float256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float256VectorTests.java @@ -1126,19 +1126,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[intCornerCaseValue(i)]", (int s) -> { + withToString("Float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)intCornerCaseValue(i)); }) @@ -1175,19 +1175,19 @@ static float genValue(long i) { } static final List> LONG_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[cornerCaseValue(i)]", (int s) -> { + withToString("Float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)longCornerCaseValue(i)); }) @@ -1221,15 +1221,15 @@ static int bits(float e) { } static final List> FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1563,6 +1563,225 @@ static float firstNonZero(float a, float b) { return Float.compare(a, (float) 0) != 0 ? a : b; } + static float multiplicativeIdentity() { + return (float)1; + } + + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + static float additiveIdentity() { + return (float)0; + } + + + static float zeroValue() { + return (short) 0; + } + + static float maxValue() { + return Float.POSITIVE_INFINITY; + } + + static float minValue() { + return Float.NEGATIVE_INFINITY; + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1656,7 +1875,7 @@ void viewAsFloatingLanesTest() { } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1677,7 +1896,7 @@ static void ADDFloat256VectorTests(IntFunction fa, IntFunction } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1734,7 +1953,7 @@ static void addFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1812,7 +2031,7 @@ static void subFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1890,7 +2109,7 @@ static void mulFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1968,7 +2187,7 @@ static void divFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2279,7 +2498,7 @@ static void MINFloat256VectorTests(IntFunction fa, IntFunction } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2298,7 +2517,7 @@ static void minFloat256VectorTests(IntFunction fa, IntFunction } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2319,7 +2538,7 @@ static void MAXFloat256VectorTests(IntFunction fa, IntFunction } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2394,18 +2613,18 @@ static void maxFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In } static float ADDReduce(float[] a, int idx) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAll(float[] a) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2415,7 +2634,7 @@ static float ADDReduceAll(float[] a) { static void ADDReduceFloat256VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2425,10 +2644,10 @@ static void ADDReduceFloat256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2437,19 +2656,19 @@ static void ADDReduceFloat256VectorTests(IntFunction fa) { } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAllMasked(float[] a, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2461,7 +2680,7 @@ static void ADDReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2471,10 +2690,10 @@ static void ADDReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2483,18 +2702,18 @@ static void ADDReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } static float MULReduce(float[] a, int idx) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAll(float[] a) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2504,7 +2723,7 @@ static float MULReduceAll(float[] a) { static void MULReduceFloat256VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2514,10 +2733,10 @@ static void MULReduceFloat256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2526,19 +2745,19 @@ static void MULReduceFloat256VectorTests(IntFunction fa) { } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAllMasked(float[] a, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2550,7 +2769,7 @@ static void MULReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2560,10 +2779,10 @@ static void MULReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2572,18 +2791,18 @@ static void MULReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } static float MINReduce(float[] a, int idx) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAll(float[] a) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2593,7 +2812,7 @@ static float MINReduceAll(float[] a) { static void MINReduceFloat256VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2603,10 +2822,10 @@ static void MINReduceFloat256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2615,19 +2834,19 @@ static void MINReduceFloat256VectorTests(IntFunction fa) { } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2639,7 +2858,7 @@ static void MINReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2649,10 +2868,10 @@ static void MINReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2661,18 +2880,18 @@ static void MINReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } static float MAXReduce(float[] a, int idx) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAll(float[] a) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2682,7 +2901,7 @@ static float MAXReduceAll(float[] a) { static void MAXReduceFloat256VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2692,10 +2911,10 @@ static void MAXReduceFloat256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2704,19 +2923,19 @@ static void MAXReduceFloat256VectorTests(IntFunction fa) { } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2728,7 +2947,7 @@ static void MAXReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2738,10 +2957,10 @@ static void MAXReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2750,7 +2969,7 @@ static void MAXReduceFloat256VectorTestsMasked(IntFunction fa, IntFunct } static float FIRST_NONZEROReduce(float[] a, int idx) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2759,7 +2978,7 @@ static float FIRST_NONZEROReduce(float[] a, int idx) { } static float FIRST_NONZEROReduceAll(float[] a) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2771,7 +2990,7 @@ static float FIRST_NONZEROReduceAll(float[] a) { static void FIRST_NONZEROReduceFloat256VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2781,7 +3000,7 @@ static void FIRST_NONZEROReduceFloat256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2793,7 +3012,7 @@ static void FIRST_NONZEROReduceFloat256VectorTests(IntFunction fa) { } static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2803,7 +3022,7 @@ static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { } static float FIRST_NONZEROReduceAllMasked(float[] a, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2817,7 +3036,7 @@ static void FIRST_NONZEROReduceFloat256VectorTestsMasked(IntFunction fa float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2827,7 +3046,7 @@ static void FIRST_NONZEROReduceFloat256VectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2872,7 +3091,7 @@ static void IS_DEFAULTFloat256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2892,7 +3111,7 @@ static void IS_DEFAULTMaskedFloat256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2913,7 +3132,7 @@ static void IS_NEGATIVEFloat256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2933,14 +3152,14 @@ static void IS_NEGATIVEMaskedFloat256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2954,7 +3173,7 @@ static void IS_FINITEFloat256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2974,14 +3193,14 @@ static void IS_FINITEMaskedFloat256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2995,7 +3214,7 @@ static void IS_NANFloat256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -3015,14 +3234,14 @@ static void IS_NANMaskedFloat256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -3036,7 +3255,7 @@ static void IS_INFINITEFloat256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3056,7 +3275,7 @@ static void IS_INFINITEMaskedFloat256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3075,7 +3294,7 @@ static void LTFloat256VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3094,7 +3313,7 @@ static void ltFloat256VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3117,7 +3336,7 @@ static void LTFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -3159,7 +3378,7 @@ static void GTFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3197,7 +3416,7 @@ static void eqFloat256VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3220,7 +3439,7 @@ static void EQFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -3262,7 +3481,7 @@ static void NEFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -3304,7 +3523,7 @@ static void LEFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -3346,7 +3565,7 @@ static void GEFloat256VectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3383,7 +3602,7 @@ static void LTFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3399,7 +3618,7 @@ static void LTFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @@ -3419,7 +3638,7 @@ static void LTFloat256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3455,7 +3674,7 @@ static void EQFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3471,7 +3690,7 @@ static void EQFloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @@ -3491,7 +3710,7 @@ static void EQFloat256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static float[] sliceUnary(float[] a, int origin, int idx) { @@ -3991,11 +4210,11 @@ static void unsliceFloat256VectorTestsMasked(IntFunction fa, IntFunctio } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4014,11 +4233,11 @@ static void SINFloat256VectorTests(IntFunction fa) { } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4037,11 +4256,11 @@ static void EXPFloat256VectorTests(IntFunction fa) { } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4060,11 +4279,11 @@ static void LOG1PFloat256VectorTests(IntFunction fa) { } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4083,11 +4302,11 @@ static void LOGFloat256VectorTests(IntFunction fa) { } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4106,11 +4325,11 @@ static void LOG10Float256VectorTests(IntFunction fa) { } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4129,11 +4348,11 @@ static void EXPM1Float256VectorTests(IntFunction fa) { } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4152,11 +4371,11 @@ static void COSFloat256VectorTests(IntFunction fa) { } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4175,11 +4394,11 @@ static void TANFloat256VectorTests(IntFunction fa) { } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4198,11 +4417,11 @@ static void SINHFloat256VectorTests(IntFunction fa) { } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4221,11 +4440,11 @@ static void COSHFloat256VectorTests(IntFunction fa) { } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4244,11 +4463,11 @@ static void TANHFloat256VectorTests(IntFunction fa) { } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4267,11 +4486,11 @@ static void ASINFloat256VectorTests(IntFunction fa) { } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4290,11 +4509,11 @@ static void ACOSFloat256VectorTests(IntFunction fa) { } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4313,11 +4532,11 @@ static void ATANFloat256VectorTests(IntFunction fa) { } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,11 +4555,11 @@ static void CBRTFloat256VectorTests(IntFunction fa) { } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4362,11 +4581,11 @@ static void HYPOTFloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4414,11 +4633,11 @@ static void powFloat256VectorTests(IntFunction fa, IntFunction static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4470,11 +4689,11 @@ static void powFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, In static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4652,11 +4871,11 @@ static void FMAFloat256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4764,11 +4983,11 @@ static void ABSMaskedFloat256VectorTests(IntFunction fa, } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4830,7 +5049,7 @@ static void ltFloat256VectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4846,7 +5065,7 @@ static void eqFloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5086,7 +5305,7 @@ static void shuffleMiscellaneousFloat256VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Float512VectorTests.java b/test/jdk/jdk/incubator/vector/Float512VectorTests.java index 78726c99443f2..679ad3f2934eb 100644 --- a/test/jdk/jdk/incubator/vector/Float512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float512VectorTests.java @@ -1126,19 +1126,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[intCornerCaseValue(i)]", (int s) -> { + withToString("Float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)intCornerCaseValue(i)); }) @@ -1175,19 +1175,19 @@ static float genValue(long i) { } static final List> LONG_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[cornerCaseValue(i)]", (int s) -> { + withToString("Float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)longCornerCaseValue(i)); }) @@ -1221,15 +1221,15 @@ static int bits(float e) { } static final List> FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1563,6 +1563,225 @@ static float firstNonZero(float a, float b) { return Float.compare(a, (float) 0) != 0 ? a : b; } + static float multiplicativeIdentity() { + return (float)1; + } + + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + static float additiveIdentity() { + return (float)0; + } + + + static float zeroValue() { + return (short) 0; + } + + static float maxValue() { + return Float.POSITIVE_INFINITY; + } + + static float minValue() { + return Float.NEGATIVE_INFINITY; + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1656,7 +1875,7 @@ void viewAsFloatingLanesTest() { } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1677,7 +1896,7 @@ static void ADDFloat512VectorTests(IntFunction fa, IntFunction } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1734,7 +1953,7 @@ static void addFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1812,7 +2031,7 @@ static void subFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1890,7 +2109,7 @@ static void mulFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1968,7 +2187,7 @@ static void divFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2279,7 +2498,7 @@ static void MINFloat512VectorTests(IntFunction fa, IntFunction } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2298,7 +2517,7 @@ static void minFloat512VectorTests(IntFunction fa, IntFunction } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2319,7 +2538,7 @@ static void MAXFloat512VectorTests(IntFunction fa, IntFunction } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2394,18 +2613,18 @@ static void maxFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In } static float ADDReduce(float[] a, int idx) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAll(float[] a) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2415,7 +2634,7 @@ static float ADDReduceAll(float[] a) { static void ADDReduceFloat512VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2425,10 +2644,10 @@ static void ADDReduceFloat512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2437,19 +2656,19 @@ static void ADDReduceFloat512VectorTests(IntFunction fa) { } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAllMasked(float[] a, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2461,7 +2680,7 @@ static void ADDReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2471,10 +2690,10 @@ static void ADDReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2483,18 +2702,18 @@ static void ADDReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } static float MULReduce(float[] a, int idx) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAll(float[] a) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2504,7 +2723,7 @@ static float MULReduceAll(float[] a) { static void MULReduceFloat512VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2514,10 +2733,10 @@ static void MULReduceFloat512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2526,19 +2745,19 @@ static void MULReduceFloat512VectorTests(IntFunction fa) { } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAllMasked(float[] a, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2550,7 +2769,7 @@ static void MULReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2560,10 +2779,10 @@ static void MULReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2572,18 +2791,18 @@ static void MULReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } static float MINReduce(float[] a, int idx) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAll(float[] a) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2593,7 +2812,7 @@ static float MINReduceAll(float[] a) { static void MINReduceFloat512VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2603,10 +2822,10 @@ static void MINReduceFloat512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2615,19 +2834,19 @@ static void MINReduceFloat512VectorTests(IntFunction fa) { } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2639,7 +2858,7 @@ static void MINReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2649,10 +2868,10 @@ static void MINReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2661,18 +2880,18 @@ static void MINReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } static float MAXReduce(float[] a, int idx) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAll(float[] a) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2682,7 +2901,7 @@ static float MAXReduceAll(float[] a) { static void MAXReduceFloat512VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2692,10 +2911,10 @@ static void MAXReduceFloat512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2704,19 +2923,19 @@ static void MAXReduceFloat512VectorTests(IntFunction fa) { } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2728,7 +2947,7 @@ static void MAXReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2738,10 +2957,10 @@ static void MAXReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2750,7 +2969,7 @@ static void MAXReduceFloat512VectorTestsMasked(IntFunction fa, IntFunct } static float FIRST_NONZEROReduce(float[] a, int idx) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2759,7 +2978,7 @@ static float FIRST_NONZEROReduce(float[] a, int idx) { } static float FIRST_NONZEROReduceAll(float[] a) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2771,7 +2990,7 @@ static float FIRST_NONZEROReduceAll(float[] a) { static void FIRST_NONZEROReduceFloat512VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2781,7 +3000,7 @@ static void FIRST_NONZEROReduceFloat512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2793,7 +3012,7 @@ static void FIRST_NONZEROReduceFloat512VectorTests(IntFunction fa) { } static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2803,7 +3022,7 @@ static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { } static float FIRST_NONZEROReduceAllMasked(float[] a, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2817,7 +3036,7 @@ static void FIRST_NONZEROReduceFloat512VectorTestsMasked(IntFunction fa float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2827,7 +3046,7 @@ static void FIRST_NONZEROReduceFloat512VectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2872,7 +3091,7 @@ static void IS_DEFAULTFloat512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2892,7 +3111,7 @@ static void IS_DEFAULTMaskedFloat512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2913,7 +3132,7 @@ static void IS_NEGATIVEFloat512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2933,14 +3152,14 @@ static void IS_NEGATIVEMaskedFloat512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2954,7 +3173,7 @@ static void IS_FINITEFloat512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2974,14 +3193,14 @@ static void IS_FINITEMaskedFloat512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2995,7 +3214,7 @@ static void IS_NANFloat512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -3015,14 +3234,14 @@ static void IS_NANMaskedFloat512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -3036,7 +3255,7 @@ static void IS_INFINITEFloat512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3056,7 +3275,7 @@ static void IS_INFINITEMaskedFloat512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3075,7 +3294,7 @@ static void LTFloat512VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3094,7 +3313,7 @@ static void ltFloat512VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3117,7 +3336,7 @@ static void LTFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -3159,7 +3378,7 @@ static void GTFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3197,7 +3416,7 @@ static void eqFloat512VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3220,7 +3439,7 @@ static void EQFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -3262,7 +3481,7 @@ static void NEFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -3304,7 +3523,7 @@ static void LEFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -3346,7 +3565,7 @@ static void GEFloat512VectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3383,7 +3602,7 @@ static void LTFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3399,7 +3618,7 @@ static void LTFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @@ -3419,7 +3638,7 @@ static void LTFloat512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3455,7 +3674,7 @@ static void EQFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3471,7 +3690,7 @@ static void EQFloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @@ -3491,7 +3710,7 @@ static void EQFloat512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static float[] sliceUnary(float[] a, int origin, int idx) { @@ -3991,11 +4210,11 @@ static void unsliceFloat512VectorTestsMasked(IntFunction fa, IntFunctio } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4014,11 +4233,11 @@ static void SINFloat512VectorTests(IntFunction fa) { } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4037,11 +4256,11 @@ static void EXPFloat512VectorTests(IntFunction fa) { } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4060,11 +4279,11 @@ static void LOG1PFloat512VectorTests(IntFunction fa) { } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4083,11 +4302,11 @@ static void LOGFloat512VectorTests(IntFunction fa) { } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4106,11 +4325,11 @@ static void LOG10Float512VectorTests(IntFunction fa) { } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4129,11 +4348,11 @@ static void EXPM1Float512VectorTests(IntFunction fa) { } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4152,11 +4371,11 @@ static void COSFloat512VectorTests(IntFunction fa) { } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4175,11 +4394,11 @@ static void TANFloat512VectorTests(IntFunction fa) { } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4198,11 +4417,11 @@ static void SINHFloat512VectorTests(IntFunction fa) { } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4221,11 +4440,11 @@ static void COSHFloat512VectorTests(IntFunction fa) { } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4244,11 +4463,11 @@ static void TANHFloat512VectorTests(IntFunction fa) { } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4267,11 +4486,11 @@ static void ASINFloat512VectorTests(IntFunction fa) { } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4290,11 +4509,11 @@ static void ACOSFloat512VectorTests(IntFunction fa) { } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4313,11 +4532,11 @@ static void ATANFloat512VectorTests(IntFunction fa) { } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,11 +4555,11 @@ static void CBRTFloat512VectorTests(IntFunction fa) { } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4362,11 +4581,11 @@ static void HYPOTFloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4414,11 +4633,11 @@ static void powFloat512VectorTests(IntFunction fa, IntFunction static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4470,11 +4689,11 @@ static void powFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, In static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4652,11 +4871,11 @@ static void FMAFloat512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4764,11 +4983,11 @@ static void ABSMaskedFloat512VectorTests(IntFunction fa, } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4830,7 +5049,7 @@ static void ltFloat512VectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4846,7 +5065,7 @@ static void eqFloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5086,7 +5305,7 @@ static void shuffleMiscellaneousFloat512VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Float64VectorTests.java b/test/jdk/jdk/incubator/vector/Float64VectorTests.java index 93d08f7f95810..5de9c5ed1070a 100644 --- a/test/jdk/jdk/incubator/vector/Float64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Float64VectorTests.java @@ -1126,19 +1126,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[intCornerCaseValue(i)]", (int s) -> { + withToString("Float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)intCornerCaseValue(i)); }) @@ -1175,19 +1175,19 @@ static float genValue(long i) { } static final List> LONG_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[cornerCaseValue(i)]", (int s) -> { + withToString("Float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)longCornerCaseValue(i)); }) @@ -1221,15 +1221,15 @@ static int bits(float e) { } static final List> FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1563,6 +1563,225 @@ static float firstNonZero(float a, float b) { return Float.compare(a, (float) 0) != 0 ? a : b; } + static float multiplicativeIdentity() { + return (float)1; + } + + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + static float additiveIdentity() { + return (float)0; + } + + + static float zeroValue() { + return (short) 0; + } + + static float maxValue() { + return Float.POSITIVE_INFINITY; + } + + static float minValue() { + return Float.NEGATIVE_INFINITY; + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1656,7 +1875,7 @@ void viewAsFloatingLanesTest() { } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1677,7 +1896,7 @@ static void ADDFloat64VectorTests(IntFunction fa, IntFunction } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1734,7 +1953,7 @@ static void addFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1812,7 +2031,7 @@ static void subFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1890,7 +2109,7 @@ static void mulFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1968,7 +2187,7 @@ static void divFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFun } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2279,7 +2498,7 @@ static void MINFloat64VectorTests(IntFunction fa, IntFunction } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2298,7 +2517,7 @@ static void minFloat64VectorTests(IntFunction fa, IntFunction } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2319,7 +2538,7 @@ static void MAXFloat64VectorTests(IntFunction fa, IntFunction } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2394,18 +2613,18 @@ static void maxFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int } static float ADDReduce(float[] a, int idx) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAll(float[] a) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2415,7 +2634,7 @@ static float ADDReduceAll(float[] a) { static void ADDReduceFloat64VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2425,10 +2644,10 @@ static void ADDReduceFloat64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2437,19 +2656,19 @@ static void ADDReduceFloat64VectorTests(IntFunction fa) { } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAllMasked(float[] a, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2461,7 +2680,7 @@ static void ADDReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2471,10 +2690,10 @@ static void ADDReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2483,18 +2702,18 @@ static void ADDReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } static float MULReduce(float[] a, int idx) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAll(float[] a) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2504,7 +2723,7 @@ static float MULReduceAll(float[] a) { static void MULReduceFloat64VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2514,10 +2733,10 @@ static void MULReduceFloat64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2526,19 +2745,19 @@ static void MULReduceFloat64VectorTests(IntFunction fa) { } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAllMasked(float[] a, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2550,7 +2769,7 @@ static void MULReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2560,10 +2779,10 @@ static void MULReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2572,18 +2791,18 @@ static void MULReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } static float MINReduce(float[] a, int idx) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAll(float[] a) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2593,7 +2812,7 @@ static float MINReduceAll(float[] a) { static void MINReduceFloat64VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2603,10 +2822,10 @@ static void MINReduceFloat64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2615,19 +2834,19 @@ static void MINReduceFloat64VectorTests(IntFunction fa) { } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2639,7 +2858,7 @@ static void MINReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2649,10 +2868,10 @@ static void MINReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2661,18 +2880,18 @@ static void MINReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } static float MAXReduce(float[] a, int idx) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAll(float[] a) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2682,7 +2901,7 @@ static float MAXReduceAll(float[] a) { static void MAXReduceFloat64VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2692,10 +2911,10 @@ static void MAXReduceFloat64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2704,19 +2923,19 @@ static void MAXReduceFloat64VectorTests(IntFunction fa) { } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2728,7 +2947,7 @@ static void MAXReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2738,10 +2957,10 @@ static void MAXReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2750,7 +2969,7 @@ static void MAXReduceFloat64VectorTestsMasked(IntFunction fa, IntFuncti } static float FIRST_NONZEROReduce(float[] a, int idx) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2759,7 +2978,7 @@ static float FIRST_NONZEROReduce(float[] a, int idx) { } static float FIRST_NONZEROReduceAll(float[] a) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2771,7 +2990,7 @@ static float FIRST_NONZEROReduceAll(float[] a) { static void FIRST_NONZEROReduceFloat64VectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2781,7 +3000,7 @@ static void FIRST_NONZEROReduceFloat64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2793,7 +3012,7 @@ static void FIRST_NONZEROReduceFloat64VectorTests(IntFunction fa) { } static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2803,7 +3022,7 @@ static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { } static float FIRST_NONZEROReduceAllMasked(float[] a, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2817,7 +3036,7 @@ static void FIRST_NONZEROReduceFloat64VectorTestsMasked(IntFunction fa, float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2827,7 +3046,7 @@ static void FIRST_NONZEROReduceFloat64VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2872,7 +3091,7 @@ static void IS_DEFAULTFloat64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2892,7 +3111,7 @@ static void IS_DEFAULTMaskedFloat64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2913,7 +3132,7 @@ static void IS_NEGATIVEFloat64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2933,14 +3152,14 @@ static void IS_NEGATIVEMaskedFloat64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2954,7 +3173,7 @@ static void IS_FINITEFloat64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2974,14 +3193,14 @@ static void IS_FINITEMaskedFloat64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2995,7 +3214,7 @@ static void IS_NANFloat64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -3015,14 +3234,14 @@ static void IS_NANMaskedFloat64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -3036,7 +3255,7 @@ static void IS_INFINITEFloat64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3056,7 +3275,7 @@ static void IS_INFINITEMaskedFloat64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3075,7 +3294,7 @@ static void LTFloat64VectorTests(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3094,7 +3313,7 @@ static void ltFloat64VectorTests(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3117,7 +3336,7 @@ static void LTFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -3159,7 +3378,7 @@ static void GTFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3197,7 +3416,7 @@ static void eqFloat64VectorTests(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3220,7 +3439,7 @@ static void EQFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -3262,7 +3481,7 @@ static void NEFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -3304,7 +3523,7 @@ static void LEFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -3346,7 +3565,7 @@ static void GEFloat64VectorTestsMasked(IntFunction fa, IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3383,7 +3602,7 @@ static void LTFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3399,7 +3618,7 @@ static void LTFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @@ -3419,7 +3638,7 @@ static void LTFloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3455,7 +3674,7 @@ static void EQFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3471,7 +3690,7 @@ static void EQFloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @@ -3491,7 +3710,7 @@ static void EQFloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static float[] sliceUnary(float[] a, int origin, int idx) { @@ -3991,11 +4210,11 @@ static void unsliceFloat64VectorTestsMasked(IntFunction fa, IntFunction } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4014,11 +4233,11 @@ static void SINFloat64VectorTests(IntFunction fa) { } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4037,11 +4256,11 @@ static void EXPFloat64VectorTests(IntFunction fa) { } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4060,11 +4279,11 @@ static void LOG1PFloat64VectorTests(IntFunction fa) { } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4083,11 +4302,11 @@ static void LOGFloat64VectorTests(IntFunction fa) { } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4106,11 +4325,11 @@ static void LOG10Float64VectorTests(IntFunction fa) { } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4129,11 +4348,11 @@ static void EXPM1Float64VectorTests(IntFunction fa) { } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4152,11 +4371,11 @@ static void COSFloat64VectorTests(IntFunction fa) { } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4175,11 +4394,11 @@ static void TANFloat64VectorTests(IntFunction fa) { } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4198,11 +4417,11 @@ static void SINHFloat64VectorTests(IntFunction fa) { } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4221,11 +4440,11 @@ static void COSHFloat64VectorTests(IntFunction fa) { } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4244,11 +4463,11 @@ static void TANHFloat64VectorTests(IntFunction fa) { } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4267,11 +4486,11 @@ static void ASINFloat64VectorTests(IntFunction fa) { } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4290,11 +4509,11 @@ static void ACOSFloat64VectorTests(IntFunction fa) { } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4313,11 +4532,11 @@ static void ATANFloat64VectorTests(IntFunction fa) { } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4336,11 +4555,11 @@ static void CBRTFloat64VectorTests(IntFunction fa) { } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4362,11 +4581,11 @@ static void HYPOTFloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4414,11 +4633,11 @@ static void powFloat64VectorTests(IntFunction fa, IntFunction static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4470,11 +4689,11 @@ static void powFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, Int static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4652,11 +4871,11 @@ static void FMAFloat64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4764,11 +4983,11 @@ static void ABSMaskedFloat64VectorTests(IntFunction fa, } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4830,7 +5049,7 @@ static void ltFloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4846,7 +5065,7 @@ static void eqFloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5086,7 +5305,7 @@ static void shuffleMiscellaneousFloat64VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java index e0d806dddf6f5..8f147d00050a7 100644 --- a/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java @@ -1131,19 +1131,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[intCornerCaseValue(i)]", (int s) -> { + withToString("Float[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)intCornerCaseValue(i)); }) @@ -1180,19 +1180,19 @@ static float genValue(long i) { } static final List> LONG_FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("float[cornerCaseValue(i)]", (int s) -> { + withToString("Float[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (float)longCornerCaseValue(i)); }) @@ -1226,15 +1226,15 @@ static int bits(float e) { } static final List> FLOAT_GENERATORS = List.of( - withToString("float[-i * 5]", (int s) -> { + withToString("Float[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("float[i * 5]", (int s) -> { + withToString("Float[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("float[i + 1]", (int s) -> { + withToString("Float[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((float)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1568,6 +1568,225 @@ static float firstNonZero(float a, float b) { return Float.compare(a, (float) 0) != 0 ? a : b; } + static float multiplicativeIdentity() { + return (float)1; + } + + + static float scalar_add(float a, float b) { + return (float)(a + b); + } + + static float scalar_sub(float a, float b) { + return (float)(a - b); + } + + static float scalar_mul(float a, float b) { + return (float)(a * b); + } + + static float scalar_min(float a, float b) { + return (float)(Math.min(a, b)); + } + + static float scalar_max(float a, float b) { + return (float)(Math.max(a, b)); + } + + static float scalar_div(float a, float b) { + return (float)(a / b); + } + + static float scalar_fma(float a, float b, float c) { + return (float)(Math.fma(a, b, c)); + } + + static float scalar_abs(float a) { + return (float)(Math.abs(a)); + } + + static float scalar_neg(float a) { + return ((float)-a); + } + + static float scalar_sin(float a) { + return (float)Math.sin((double)a); + } + + static float scalar_exp(float a) { + return (float)Math.exp((double)a); + } + + static float scalar_log1p(float a) { + return (float)Math.log1p((double)a); + } + + static float scalar_log(float a) { + return (float)Math.log((double)a); + } + + static float scalar_log10(float a) { + return (float)Math.log10((double)a); + } + + static float scalar_expm1(float a) { + return (float)Math.expm1((double)a); + } + + static float scalar_cos(float a) { + return (float)Math.cos((double)a); + } + + static float scalar_tan(float a) { + return (float)Math.tan((double)a); + } + + static float scalar_sinh(float a) { + return (float)Math.sinh((double)a); + } + + static float scalar_cosh(float a) { + return (float)Math.cosh((double)a); + } + + static float scalar_tanh(float a) { + return (float)Math.tanh((double)a); + } + + static float scalar_asin(float a) { + return (float)Math.asin((double)a); + } + + static float scalar_acos(float a) { + return (float)Math.acos((double)a); + } + + static float scalar_atan(float a) { + return (float)Math.atan((double)a); + } + + static float scalar_cbrt(float a) { + return (float)Math.cbrt((double)a); + } + + static float scalar_sqrt(float a) { + return (float)Math.sqrt((double)a); + } + + static float scalar_hypot(float a, float b) { + return (float)Math.hypot((double)a, (double)b); + } + + static float scalar_pow(float a, float b) { + return (float)Math.pow((double)a, (double)b); + } + + static float scalar_atan2(float a, float b) { + return (float)Math.atan2((double)a, (double)b); + } + + static float strict_scalar_sin(float a) { + return (float)StrictMath.sin((double)a); + } + + static float strict_scalar_exp(float a) { + return (float)StrictMath.exp((double)a); + } + + static float strict_scalar_log1p(float a) { + return (float)StrictMath.log1p((double)a); + } + + static float strict_scalar_log(float a) { + return (float)StrictMath.log((double)a); + } + + static float strict_scalar_log10(float a) { + return (float)StrictMath.log10((double)a); + } + + static float strict_scalar_expm1(float a) { + return (float)StrictMath.expm1((double)a); + } + + static float strict_scalar_cos(float a) { + return (float)StrictMath.cos((double)a); + } + + static float strict_scalar_tan(float a) { + return (float)StrictMath.tan((double)a); + } + + static float strict_scalar_sinh(float a) { + return (float)StrictMath.sinh((double)a); + } + + static float strict_scalar_cosh(float a) { + return (float)StrictMath.cosh((double)a); + } + + static float strict_scalar_tanh(float a) { + return (float)StrictMath.tanh((double)a); + } + + static float strict_scalar_asin(float a) { + return (float)StrictMath.asin((double)a); + } + + static float strict_scalar_acos(float a) { + return (float)StrictMath.acos((double)a); + } + + static float strict_scalar_atan(float a) { + return (float)StrictMath.atan((double)a); + } + + static float strict_scalar_cbrt(float a) { + return (float)StrictMath.cbrt((double)a); + } + + static float strict_scalar_sqrt(float a) { + return (float)StrictMath.sqrt((double)a); + } + + static float strict_scalar_hypot(float a, float b) { + return (float)StrictMath.hypot((double)a, (double)b); + } + + static float strict_scalar_pow(float a, float b) { + return (float)StrictMath.pow((double)a, (double)b); + } + + static float strict_scalar_atan2(float a, float b) { + return (float)StrictMath.atan2((double)a, (double)b); + } + static float additiveIdentity() { + return (float)0; + } + + + static float zeroValue() { + return (short) 0; + } + + static float maxValue() { + return Float.POSITIVE_INFINITY; + } + + static float minValue() { + return Float.NEGATIVE_INFINITY; + } + + static boolean isNaN(float a) { + return Float.isNaN(a); + } + static boolean isFinite(float a) { + return Float.isFinite(a); + } + static boolean isInfinite(float a) { + return Float.isInfinite(a); + } + @Test static void smokeTest1() { FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3); @@ -1661,7 +1880,7 @@ void viewAsFloatingLanesTest() { } static float ADD(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1682,7 +1901,7 @@ static void ADDFloatMaxVectorTests(IntFunction fa, IntFunction } static float add(float a, float b) { - return (float)(a + b); + return (float)(scalar_add(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1739,7 +1958,7 @@ static void addFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float sub(float a, float b) { - return (float)(a - b); + return (float)(scalar_sub(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1817,7 +2036,7 @@ static void subFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float mul(float a, float b) { - return (float)(a * b); + return (float)(scalar_mul(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1895,7 +2114,7 @@ static void mulFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static float div(float a, float b) { - return (float)(a / b); + return (float)(scalar_div(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -1973,7 +2192,7 @@ static void divFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static float MIN(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2284,7 +2503,7 @@ static void MINFloatMaxVectorTests(IntFunction fa, IntFunction } static float min(float a, float b) { - return (float)(Math.min(a, b)); + return (float)(scalar_min(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2303,7 +2522,7 @@ static void minFloatMaxVectorTests(IntFunction fa, IntFunction } static float MAX(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2324,7 +2543,7 @@ static void MAXFloatMaxVectorTests(IntFunction fa, IntFunction } static float max(float a, float b) { - return (float)(Math.max(a, b)); + return (float)(scalar_max(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -2399,18 +2618,18 @@ static void maxFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In } static float ADDReduce(float[] a, int idx) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAll(float[] a) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -2420,7 +2639,7 @@ static float ADDReduceAll(float[] a) { static void ADDReduceFloatMaxVectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2430,10 +2649,10 @@ static void ADDReduceFloatMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -2442,19 +2661,19 @@ static void ADDReduceFloatMaxVectorTests(IntFunction fa) { } static float ADDReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static float ADDReduceAllMasked(float[] a, boolean[] mask) { - float res = 0; + float res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -2466,7 +2685,7 @@ static void ADDReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 0; + float ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2476,10 +2695,10 @@ static void ADDReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -2488,18 +2707,18 @@ static void ADDReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } static float MULReduce(float[] a, int idx) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAll(float[] a) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -2509,7 +2728,7 @@ static float MULReduceAll(float[] a) { static void MULReduceFloatMaxVectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2519,10 +2738,10 @@ static void MULReduceFloatMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -2531,19 +2750,19 @@ static void MULReduceFloatMaxVectorTests(IntFunction fa) { } static float MULReduceMasked(float[] a, int idx, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static float MULReduceAllMasked(float[] a, boolean[] mask) { - float res = 1; + float res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -2555,7 +2774,7 @@ static void MULReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = 1; + float ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2565,10 +2784,10 @@ static void MULReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -2577,18 +2796,18 @@ static void MULReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } static float MINReduce(float[] a, int idx) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAll(float[] a) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -2598,7 +2817,7 @@ static float MINReduceAll(float[] a) { static void MINReduceFloatMaxVectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2608,10 +2827,10 @@ static void MINReduceFloatMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -2620,19 +2839,19 @@ static void MINReduceFloatMaxVectorTests(IntFunction fa) { } static float MINReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static float MINReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.POSITIVE_INFINITY; + float res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -2644,7 +2863,7 @@ static void MINReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.POSITIVE_INFINITY; + float ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2654,10 +2873,10 @@ static void MINReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.POSITIVE_INFINITY; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -2666,18 +2885,18 @@ static void MINReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } static float MAXReduce(float[] a, int idx) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAll(float[] a) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -2687,7 +2906,7 @@ static float MAXReduceAll(float[] a) { static void MAXReduceFloatMaxVectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2697,10 +2916,10 @@ static void MAXReduceFloatMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -2709,19 +2928,19 @@ static void MAXReduceFloatMaxVectorTests(IntFunction fa) { } static float MAXReduceMasked(float[] a, int idx, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (float) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static float MAXReduceAllMasked(float[] a, boolean[] mask) { - float res = Float.NEGATIVE_INFINITY; + float res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (float) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -2733,7 +2952,7 @@ static void MAXReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = Float.NEGATIVE_INFINITY; + float ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2743,10 +2962,10 @@ static void MAXReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Float.NEGATIVE_INFINITY; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - ra = (float) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -2755,7 +2974,7 @@ static void MAXReduceFloatMaxVectorTestsMasked(IntFunction fa, IntFunct } static float FIRST_NONZEROReduce(float[] a, int idx) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -2764,7 +2983,7 @@ static float FIRST_NONZEROReduce(float[] a, int idx) { } static float FIRST_NONZEROReduceAll(float[] a) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -2776,7 +2995,7 @@ static float FIRST_NONZEROReduceAll(float[] a) { static void FIRST_NONZEROReduceFloatMaxVectorTests(IntFunction fa) { float[] a = fa.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2786,7 +3005,7 @@ static void FIRST_NONZEROReduceFloatMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -2798,7 +3017,7 @@ static void FIRST_NONZEROReduceFloatMaxVectorTests(IntFunction fa) { } static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -2808,7 +3027,7 @@ static float FIRST_NONZEROReduceMasked(float[] a, int idx, boolean[] mask) { } static float FIRST_NONZEROReduceAllMasked(float[] a, boolean[] mask) { - float res = (float) 0; + float res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -2822,7 +3041,7 @@ static void FIRST_NONZEROReduceFloatMaxVectorTestsMasked(IntFunction fa float[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - float ra = (float) 0; + float ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -2832,7 +3051,7 @@ static void FIRST_NONZEROReduceFloatMaxVectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (float) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -2877,7 +3096,7 @@ static void IS_DEFAULTFloatMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -2897,7 +3116,7 @@ static void IS_DEFAULTMaskedFloatMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -2918,7 +3137,7 @@ static void IS_NEGATIVEFloatMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -2938,14 +3157,14 @@ static void IS_NEGATIVEMaskedFloatMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } } static boolean testIS_FINITE(float a) { - return Float.isFinite(a); + return isFinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -2959,7 +3178,7 @@ static void IS_FINITEFloatMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); } } } @@ -2979,14 +3198,14 @@ static void IS_FINITEMaskedFloatMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); } } } } static boolean testIS_NAN(float a) { - return Float.isNaN(a); + return isNaN(a); } @Test(dataProvider = "floatTestOpProvider") @@ -3000,7 +3219,7 @@ static void IS_NANFloatMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); } } } @@ -3020,14 +3239,14 @@ static void IS_NANMaskedFloatMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); } } } } static boolean testIS_INFINITE(float a) { - return Float.isInfinite(a); + return isInfinite(a); } @Test(dataProvider = "floatTestOpProvider") @@ -3041,7 +3260,7 @@ static void IS_INFINITEFloatMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); } } } @@ -3061,7 +3280,7 @@ static void IS_INFINITEMaskedFloatMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); } } } @@ -3080,7 +3299,7 @@ static void LTFloatMaxVectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3099,7 +3318,7 @@ static void ltFloatMaxVectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -3122,7 +3341,7 @@ static void LTFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -3164,7 +3383,7 @@ static void GTFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3202,7 +3421,7 @@ static void eqFloatMaxVectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -3225,7 +3444,7 @@ static void EQFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -3267,7 +3486,7 @@ static void NEFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -3309,7 +3528,7 @@ static void LEFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -3351,7 +3570,7 @@ static void GEFloatMaxVectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -3388,7 +3607,7 @@ static void LTFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -3404,7 +3623,7 @@ static void LTFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (float)((long)b[i]))); } } } @@ -3424,7 +3643,7 @@ static void LTFloatMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -3460,7 +3679,7 @@ static void EQFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -3476,7 +3695,7 @@ static void EQFloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (float)((long)b[i]))); } } } @@ -3496,7 +3715,7 @@ static void EQFloatMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static float[] sliceUnary(float[] a, int origin, int idx) { @@ -3996,11 +4215,11 @@ static void unsliceFloatMaxVectorTestsMasked(IntFunction fa, IntFunctio } static float SIN(float a) { - return (float)(Math.sin((double)a)); + return (float)(scalar_sin(a)); } static float strictSIN(float a) { - return (float)(StrictMath.sin((double)a)); + return (float)(strict_scalar_sin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4019,11 +4238,11 @@ static void SINFloatMaxVectorTests(IntFunction fa) { } static float EXP(float a) { - return (float)(Math.exp((double)a)); + return (float)(scalar_exp(a)); } static float strictEXP(float a) { - return (float)(StrictMath.exp((double)a)); + return (float)(strict_scalar_exp(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4042,11 +4261,11 @@ static void EXPFloatMaxVectorTests(IntFunction fa) { } static float LOG1P(float a) { - return (float)(Math.log1p((double)a)); + return (float)(scalar_log1p(a)); } static float strictLOG1P(float a) { - return (float)(StrictMath.log1p((double)a)); + return (float)(strict_scalar_log1p(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4065,11 +4284,11 @@ static void LOG1PFloatMaxVectorTests(IntFunction fa) { } static float LOG(float a) { - return (float)(Math.log((double)a)); + return (float)(scalar_log(a)); } static float strictLOG(float a) { - return (float)(StrictMath.log((double)a)); + return (float)(strict_scalar_log(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4088,11 +4307,11 @@ static void LOGFloatMaxVectorTests(IntFunction fa) { } static float LOG10(float a) { - return (float)(Math.log10((double)a)); + return (float)(scalar_log10(a)); } static float strictLOG10(float a) { - return (float)(StrictMath.log10((double)a)); + return (float)(strict_scalar_log10(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4111,11 +4330,11 @@ static void LOG10FloatMaxVectorTests(IntFunction fa) { } static float EXPM1(float a) { - return (float)(Math.expm1((double)a)); + return (float)(scalar_expm1(a)); } static float strictEXPM1(float a) { - return (float)(StrictMath.expm1((double)a)); + return (float)(strict_scalar_expm1(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4134,11 +4353,11 @@ static void EXPM1FloatMaxVectorTests(IntFunction fa) { } static float COS(float a) { - return (float)(Math.cos((double)a)); + return (float)(scalar_cos(a)); } static float strictCOS(float a) { - return (float)(StrictMath.cos((double)a)); + return (float)(strict_scalar_cos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4157,11 +4376,11 @@ static void COSFloatMaxVectorTests(IntFunction fa) { } static float TAN(float a) { - return (float)(Math.tan((double)a)); + return (float)(scalar_tan(a)); } static float strictTAN(float a) { - return (float)(StrictMath.tan((double)a)); + return (float)(strict_scalar_tan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4180,11 +4399,11 @@ static void TANFloatMaxVectorTests(IntFunction fa) { } static float SINH(float a) { - return (float)(Math.sinh((double)a)); + return (float)(scalar_sinh(a)); } static float strictSINH(float a) { - return (float)(StrictMath.sinh((double)a)); + return (float)(strict_scalar_sinh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4203,11 +4422,11 @@ static void SINHFloatMaxVectorTests(IntFunction fa) { } static float COSH(float a) { - return (float)(Math.cosh((double)a)); + return (float)(scalar_cosh(a)); } static float strictCOSH(float a) { - return (float)(StrictMath.cosh((double)a)); + return (float)(strict_scalar_cosh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4226,11 +4445,11 @@ static void COSHFloatMaxVectorTests(IntFunction fa) { } static float TANH(float a) { - return (float)(Math.tanh((double)a)); + return (float)(scalar_tanh(a)); } static float strictTANH(float a) { - return (float)(StrictMath.tanh((double)a)); + return (float)(strict_scalar_tanh(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4249,11 +4468,11 @@ static void TANHFloatMaxVectorTests(IntFunction fa) { } static float ASIN(float a) { - return (float)(Math.asin((double)a)); + return (float)(scalar_asin(a)); } static float strictASIN(float a) { - return (float)(StrictMath.asin((double)a)); + return (float)(strict_scalar_asin(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4272,11 +4491,11 @@ static void ASINFloatMaxVectorTests(IntFunction fa) { } static float ACOS(float a) { - return (float)(Math.acos((double)a)); + return (float)(scalar_acos(a)); } static float strictACOS(float a) { - return (float)(StrictMath.acos((double)a)); + return (float)(strict_scalar_acos(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4295,11 +4514,11 @@ static void ACOSFloatMaxVectorTests(IntFunction fa) { } static float ATAN(float a) { - return (float)(Math.atan((double)a)); + return (float)(scalar_atan(a)); } static float strictATAN(float a) { - return (float)(StrictMath.atan((double)a)); + return (float)(strict_scalar_atan(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4318,11 +4537,11 @@ static void ATANFloatMaxVectorTests(IntFunction fa) { } static float CBRT(float a) { - return (float)(Math.cbrt((double)a)); + return (float)(scalar_cbrt(a)); } static float strictCBRT(float a) { - return (float)(StrictMath.cbrt((double)a)); + return (float)(strict_scalar_cbrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4341,11 +4560,11 @@ static void CBRTFloatMaxVectorTests(IntFunction fa) { } static float HYPOT(float a, float b) { - return (float)(Math.hypot((double)a, (double)b)); + return (float)(scalar_hypot(a, b)); } static float strictHYPOT(float a, float b) { - return (float)(StrictMath.hypot((double)a, (double)b)); + return (float)(strict_scalar_hypot(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4367,11 +4586,11 @@ static void HYPOTFloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction static float pow(float a, float b) { - return (float)(Math.pow((double)a, (double)b)); + return (float)(scalar_pow(a, b)); } static float strictpow(float a, float b) { - return (float)(StrictMath.pow((double)a, (double)b)); + return (float)(strict_scalar_pow(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4419,11 +4638,11 @@ static void powFloatMaxVectorTests(IntFunction fa, IntFunction static float ATAN2(float a, float b) { - return (float)(Math.atan2((double)a, (double)b)); + return (float)(scalar_atan2(a, b)); } static float strictATAN2(float a, float b) { - return (float)(StrictMath.atan2((double)a, (double)b)); + return (float)(strict_scalar_atan2(a, b)); } @Test(dataProvider = "floatBinaryOpProvider") @@ -4475,11 +4694,11 @@ static void powFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, In static float FMA(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } static float fma(float a, float b, float c) { - return (float)(Math.fma(a, b, c)); + return (float)(scalar_fma(a, b, c)); } @Test(dataProvider = "floatTernaryOpProvider") @@ -4657,11 +4876,11 @@ static void FMAFloatMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, } static float ABS(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } static float abs(float a) { - return (float)(Math.abs((float)a)); + return (float)(scalar_abs((float)a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4769,11 +4988,11 @@ static void ABSMaskedFloatMaxVectorTests(IntFunction fa, } static float SQRT(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } static float sqrt(float a) { - return (float)(Math.sqrt((double)a)); + return (float)(scalar_sqrt(a)); } @Test(dataProvider = "floatUnaryOpProvider") @@ -4835,7 +5054,7 @@ static void ltFloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -4851,7 +5070,7 @@ static void eqFloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -5091,7 +5310,7 @@ static void shuffleMiscellaneousFloatMaxVectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java index 592a7d13702d0..a89f89f0d1b4b 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat128VectorTests.java @@ -40,6 +40,7 @@ import jdk.incubator.vector.Vector; import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; import jdk.incubator.vector.HalffloatVector; import org.testng.Assert; @@ -197,13 +198,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -225,13 +226,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -380,7 +381,7 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + wrapped_index = Math.floorMod(shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -397,7 +398,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); AssertEquals(r[i+j], a[i+wrapped_index]); } @@ -433,7 +434,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) AssertEquals(r[i+j], a[i+wrapped_index]); @@ -858,8 +859,8 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s static boolean isWithin1Ulp(short actual, short expected) { - Float16 act = Float16.shortBitsToFloat16(actual); - Float16 exp = Float16.shortBitsToFloat16(expected); + Float16 act = shortBitsToFloat16(actual); + Float16 exp = shortBitsToFloat16(expected); if (Float16.isNaN(exp) && !Float16.isNaN(act)) { return false; } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { @@ -885,11 +886,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FU try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -899,11 +900,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBin try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -914,14 +915,14 @@ static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[ try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1116,7 +1117,7 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } static short genValue(int i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static int intCornerCaseValue(int i) { @@ -1180,7 +1181,7 @@ static long longCornerCaseValue(int i) { } static short genValue(long i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static final List> LONG_HALFFLOAT_GENERATORS = List.of( @@ -1518,12 +1519,12 @@ static short[] fill(short[] a, ToHalffloatF f) { static short cornerCaseValue(int i) { return switch(i % 8) { - case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); - case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); - case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); - case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); - case 4 -> Float16.float16ToRawShortBits(Float16.NaN); - case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 0 -> float16ToShortBits(Float16.MAX_VALUE); + case 1 -> float16ToShortBits(Float16.MIN_VALUE); + case 2 -> float16ToShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> float16ToShortBits(Float16.POSITIVE_INFINITY); + case 4 -> float16ToShortBits(Float16.NaN); + case 5 -> float16ToShortBits(shortBitsToFloat16((short)0x7FFA)); case 6 -> ((short)0.0); default -> ((short)-0.0); }; @@ -1545,57 +1546,301 @@ static short cornerCaseValue(int i) { }; static boolean eq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() == bt.floatValue(); } static boolean neq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() != bt.floatValue(); } static boolean lt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() < bt.floatValue(); } static boolean le(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() <= bt.floatValue(); } static boolean gt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() > bt.floatValue(); } static boolean ge(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() >= bt.floatValue(); } static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 zero = shortBitsToFloat16((short)0); + return Float16.compare(at, zero) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)float16ToShortBits(Float16.valueOf(1.0f)); + } + + static short scalar_add(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.add(at, bt)); + } + + static short scalar_sub(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.subtract(at, bt)); + } + + static short scalar_mul(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.multiply(at, bt)); + + } + static short scalar_max(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.max(at, bt)); + } + + static short scalar_min(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.min(at, bt)); + } + + static short scalar_div(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.divide(at, bt)); + } + + static short scalar_fma(short a, short b, short c) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 ct = shortBitsToFloat16(c); + return float16ToShortBits(Float16.fma(at, bt, ct)); + } + + static short scalar_abs(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.abs(at)); + } + + static short scalar_neg(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.valueOf(-at.floatValue())); + } + + static short scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + static short additiveIdentity() { + return (short)0; + } + + + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return float16ToShortBits(Float16.POSITIVE_INFINITY); + } + + static short minValue() { + return float16ToShortBits(Float16.NEGATIVE_INFINITY); + } + + static boolean isNaN(short a) { + return Float16.isNaN(shortBitsToFloat16(a)); + } + static boolean isFinite(short a) { + return Float16.isFinite(shortBitsToFloat16(a)); + } + static boolean isInfinite(short a) { + return Float16.isInfinite(shortBitsToFloat16(a)); } @Test static void smokeTest1() { - HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); - HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three = HalffloatVector.broadcast(SPECIES, float16ToShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three2).allTrue()); - HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three3 = three2.broadcast(float16ToShortBits(Float16.valueOf(1))).broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three3).allTrue()); int scale = 2; HalffloatVector higher = three.addIndex(scale); VectorMask m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); - m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + m = higher.min((float16ToShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); m = higher.test(VectorOperators.IS_FINITE); assert(m.allTrue()); @@ -1672,7 +1917,7 @@ void viewAsFloatingLanesTest() { } static short ADD(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1692,6 +1937,25 @@ static void ADDHalffloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::add); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void ADDHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1712,8 +1976,26 @@ static void ADDHalffloat128VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::ADD); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::add); + } + static short SUB(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1733,6 +2015,25 @@ static void SUBHalffloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::sub); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void SUBHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1753,8 +2054,26 @@ static void SUBHalffloat128VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::SUB); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::sub); + } + static short MUL(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1774,6 +2093,25 @@ static void MULHalffloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::mul); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void MULHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1794,8 +2132,26 @@ static void MULHalffloat128VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::MUL); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::mul); + } + static short DIV(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + return (short)(scalar_div(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1815,6 +2171,25 @@ static void DIVHalffloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::div); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void DIVHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1835,12 +2210,30 @@ static void DIVHalffloat128VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::DIV); } - static short MAX(short a, short b) { - return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::div); + } + + static short FIRST_NONZERO(short a, short b) { + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROHalffloat128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1849,15 +2242,15 @@ static void MAXHalffloat128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void FIRST_NONZEROHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1869,36 +2262,29 @@ static void MAXHalffloat128VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::MAX); - } - - static short MIN(short a, short b) { - return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + static void addHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, Halffloat128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MINHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1906,236 +2292,170 @@ static void MINHalffloat128VectorTestsMasked(IntFunction fa, IntFunctio boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat128VectorTests::add); } - static short ABS(short a) { - return (short)(Math.abs(a)); - } + @Test(dataProvider = "shortBinaryOpProvider") + static void subHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short abs(short a) { - return (short)(Math.abs(a)); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void ABSHalffloat128VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS).intoArray(r, i); - } - } - - assertArraysEquals(r, a, Halffloat128VectorTests::ABS); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void absHalffloat128VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.abs().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat128VectorTests::abs); + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedHalffloat128VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat128VectorTests::ABS); - } - - static short NEG(short a) { - return (short)(-a); - } - - static short neg(short a) { - return (short)(-a); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat128VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpProvider") - static void NEGHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void mulHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat128VectorTests::NEG); + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpProvider") - static void negHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.neg().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat128VectorTests::neg); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat128VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedHalffloat128VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpProvider") + static void divHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - boolean[] mask = fm.apply(SPECIES.length()); - VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat128VectorTests::NEG); - } - - static short FMA(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); - } - - static short fma(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void FMAHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat128VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat128VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void fmaHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.fma(bv, cv).intoArray(r, i); + av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat128VectorTests::fma); + assertBroadcastLongArraysEquals(r, a, b, Halffloat128VectorTests::ADD); } - @Test(dataProvider = "shortTernaryOpMaskProvider") - static void FMAHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, - IntFunction fc, IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, mask, Halffloat128VectorTests::FMA); - } - - static short SQRT(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); - } - - static short sqrt(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat128VectorTests::ADD); } @Test(dataProvider = "shortUnaryOpProvider") - static void SQRTHalffloat128VectorTests(IntFunction fa) { + static void MINHalffloat128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat128VectorTests::SQRT); + assertArraysEquals(r, a, (short)10, Halffloat128VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void sqrtHalffloat128VectorTests(IntFunction fa) { + static void minHalffloat128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.sqrt().intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat128VectorTests::sqrt); + assertArraysEquals(r, a, (short)10, Halffloat128VectorTests::min); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void SQRTMaskedHalffloat128VectorTests(IntFunction fa, - IntFunction fm) { + static void MINHalffloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2144,510 +2464,2620 @@ static void SQRTMaskedHalffloat128VectorTests(IntFunction fa, for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, mask, Halffloat128VectorTests::SQRT); - } - - static short SIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); - } - - static short strictSIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat128VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHalffloat128VectorTests(IntFunction fa) { + static void MAXHalffloat128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SIN).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::SIN, Halffloat128VectorTests::strictSIN); - } - - static short EXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); - } - - static short strictEXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat128VectorTests::MAX); } @Test(dataProvider = "shortUnaryOpProvider") - static void EXPHalffloat128VectorTests(IntFunction fa) { + static void maxHalffloat128VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXP).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::EXP, Halffloat128VectorTests::strictEXP); - } - - static short LOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); - } - - static short strictLOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat128VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG1PHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXHalffloat128VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG1P, Halffloat128VectorTests::strictLOG1P); - } - - static short LOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat128VectorTests::MAX); } - static short strictLOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + static short MIN(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOGHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG, Halffloat128VectorTests::strictLOG); - } - - static short LOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat128VectorTests::MIN); } - static short strictLOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + static short min(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG10Halffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG10).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.min(bv).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG10, Halffloat128VectorTests::strictLOG10); - } - - static short EXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat128VectorTests::min); } - static short strictEXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + static short MAX(short a, short b) { + return (short)(scalar_max(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void EXPM1Halffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::EXPM1, Halffloat128VectorTests::strictEXPM1); + assertArraysEquals(r, a, b, Halffloat128VectorTests::MAX); } - static short COS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + static short max(short a, short b) { + return (short)(scalar_max(a, b)); } - static short strictCOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.max(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat128VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COS).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::COS, Halffloat128VectorTests::strictCOS); + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::MIN); } - static short TAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::min); } - static short strictTAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::MAX); } - @Test(dataProvider = "shortUnaryOpProvider") - static void TANHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TAN).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::TAN, Halffloat128VectorTests::strictTAN); + assertBroadcastArraysEquals(r, a, b, Halffloat128VectorTests::max); } - static short SINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + static short ADDReduce(short[] a, int idx) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_add(res, a[i]); + } + + return res; } - static short strictSINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + static short ADDReduceAll(short[] a) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHHalffloat128VectorTests(IntFunction fa) { + static void ADDReduceHalffloat128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SINH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::SINH, Halffloat128VectorTests::strictSINH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat128VectorTests::ADDReduce, Halffloat128VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short COSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_add(res, a[i]); + } + + return res; } - static short strictCOSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + static short ADDReduceAllMasked(short[] a, boolean[] mask) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COSH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::COSH, Halffloat128VectorTests::strictCOSH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat128VectorTests::ADDReduceMasked, Halffloat128VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short TANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + static short MULReduce(short[] a, int idx) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictTANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + static short MULReduceAll(short[] a) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void TANHHalffloat128VectorTests(IntFunction fa) { + static void MULReduceHalffloat128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TANH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::TANH, Halffloat128VectorTests::strictTANH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat128VectorTests::MULReduce, Halffloat128VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + static short MULReduceMasked(short[] a, int idx, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + static short MULReduceAllMasked(short[] a, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ASINHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MULReduceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ASIN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ASIN, Halffloat128VectorTests::strictASIN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat128VectorTests::MULReduceMasked, Halffloat128VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + static short MINReduce(short[] a, int idx) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_min(res, a[i]); + } + + return res; } - static short strictACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + static short MINReduceAll(short[] a) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ACOSHalffloat128VectorTests(IntFunction fa) { + static void MINReduceHalffloat128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ACOS).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ACOS, Halffloat128VectorTests::strictACOS); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat128VectorTests::MINReduce, Halffloat128VectorTests::MINReduceAll); } - static short ATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + static short MINReduceMasked(short[] a, int idx, boolean[] mask) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_min(res, a[i]); + } + + return res; } - static short strictATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + static short MINReduceAllMasked(short[] a, boolean[] mask) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ATANHalffloat128VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MINReduceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ATAN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ATAN, Halffloat128VectorTests::strictATAN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat128VectorTests::MINReduceMasked, Halffloat128VectorTests::MINReduceAllMasked); } - static short CBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + static short MAXReduce(short[] a, int idx) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_max(res, a[i]); + } + + return res; } - static short strictCBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + static short MAXReduceAll(short[] a) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void CBRTHalffloat128VectorTests(IntFunction fa) { + static void MAXReduceHalffloat128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.CBRT).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::CBRT, Halffloat128VectorTests::strictCBRT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat128VectorTests::MAXReduce, Halffloat128VectorTests::MAXReduceAll); } - static short HYPOT(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_max(res, a[i]); + } + + return res; } - static short strictHYPOT(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short MAXReduceAllMasked(short[] a, boolean[] mask) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void HYPOTHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXReduceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::HYPOT, Halffloat128VectorTests::strictHYPOT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat128VectorTests::MAXReduceMasked, Halffloat128VectorTests::MAXReduceAllMasked); } - static short POW(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduce(short[] a, int idx) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictPOW(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAll(short[] a) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpProvider") + static void FIRST_NONZEROReduceHalffloat128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::POW, Halffloat128VectorTests::strictPOW); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat128VectorTests::FIRST_NONZEROReduce, Halffloat128VectorTests::FIRST_NONZEROReduceAll); } - static short pow(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictpow(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void FIRST_NONZEROReduceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.pow(bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::pow, Halffloat128VectorTests::strictpow); - } - - static short ATAN2(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); - } + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); + } + } - static short strictATAN2(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat128VectorTests::FIRST_NONZEROReduceMasked, Halffloat128VectorTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void ATAN2Halffloat128VectorTests(IntFunction fa, IntFunction fb) { + static void withHalffloat128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); + } + } + + + assertArraysStrictlyEquals(r, a); + } + + static boolean testIS_DEFAULT(short a) { + return bits(a)==0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_DEFAULTHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_DEFAULTMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + } + } + } + } + + static boolean testIS_NEGATIVE(short a) { + return bits(a)<0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NEGATIVEHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NEGATIVEMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + } + } + } + } + + static boolean testIS_FINITE(short a) { + return isFinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_FINITEHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_FINITEMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + } + } + } + } + + static boolean testIS_NAN(short a) { + return isNaN(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NANHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NANMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + } + } + } + } + + static boolean testIS_INFINITE(short a) { + return isInfinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_INFINITEHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_INFINITEMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.lt(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GTHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GTHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.eq(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void NEHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void NEHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LEHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LEHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GEHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GEHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(short)((long)b[i])))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat128VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(short)((long)b[i])))); + } + } + } + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat128VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::blend); + } + + @Test(dataProvider = "shortUnaryOpShuffleProvider") + static void RearrangeHalffloat128VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); + } + } + + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") + static void RearrangeHalffloat128VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); + } + + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void compressHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.compress(vmask).intoArray(r, i); + } + } + + assertcompressArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void expandHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.expand(vmask).intoArray(r, i); + } + } + + assertexpandArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void getHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int num_lanes = SPECIES.length(); + // Manually unroll because full unroll happens after intrinsification. + // Unroll is needed because get intrinsic requires for index to be a known constant. + if (num_lanes == 1) { + r[i]=av.lane(0); + } else if (num_lanes == 2) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + } else if (num_lanes == 4) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + } else if (num_lanes == 8) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + } else if (num_lanes == 16) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + } else if (num_lanes == 32) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + } else if (num_lanes == 64) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + r[i+32]=av.lane(32); + r[i+33]=av.lane(33); + r[i+34]=av.lane(34); + r[i+35]=av.lane(35); + r[i+36]=av.lane(36); + r[i+37]=av.lane(37); + r[i+38]=av.lane(38); + r[i+39]=av.lane(39); + r[i+40]=av.lane(40); + r[i+41]=av.lane(41); + r[i+42]=av.lane(42); + r[i+43]=av.lane(43); + r[i+44]=av.lane(44); + r[i+45]=av.lane(45); + r[i+46]=av.lane(46); + r[i+47]=av.lane(47); + r[i+48]=av.lane(48); + r[i+49]=av.lane(49); + r[i+50]=av.lane(50); + r[i+51]=av.lane(51); + r[i+52]=av.lane(52); + r[i+53]=av.lane(53); + r[i+54]=av.lane(54); + r[i+55]=av.lane(55); + r[i+56]=av.lane(56); + r[i+57]=av.lane(57); + r[i+58]=av.lane(58); + r[i+59]=av.lane(59); + r[i+60]=av.lane(60); + r[i+61]=av.lane(61); + r[i+62]=av.lane(62); + r[i+63]=av.lane(63); + } else { + for (int j = 0; j < SPECIES.length(); j++) { + r[i+j]=av.lane(j); + } + } + } + } + + assertArraysStrictlyEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void BroadcastHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, a[i]).intoArray(r, i); + } + } + + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ZeroHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.zero(SPECIES).intoArray(a, i); + } + } + + AssertEquals(a, r); + } + + static short[] sliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else + res[i] = (short)0; + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sliceUnaryHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.slice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat128VectorTests::sliceUnary); + } + + static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void sliceBinaryHalffloat128VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, Halffloat128VectorTests::sliceBinary); + } + + static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = mask[i] ? a[idx+i+origin] : (short)0; + else { + res[i] = mask[i] ? b[idx+j] : (short)0; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void sliceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, mask, Halffloat128VectorTests::slice); + } + + static short[] unsliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i < origin) + res[i] = (short)0; + else { + res[i] = a[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void unsliceUnaryHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.unslice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat128VectorTests::unsliceUnary); + } + + static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (part == 0) { + if (i < origin) + res[i] = b[idx+i]; + else { + res[i] = a[idx+j]; + j++; + } + } else if (part == 1) { + if (i < origin) + res[i] = a[idx+SPECIES.length()-origin+i]; + else { + res[i] = b[idx+origin+j]; + j++; + } + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void unsliceBinaryHalffloat128VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, Halffloat128VectorTests::unsliceBinary); + } + + static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = b[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + for (int i = 0; i < SPECIES.length(); i++){ + res[i] = mask[i] ? a[idx+i] : res[i]; + } + short[] res1 = new short[SPECIES.length()]; + if (part == 0) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = b[idx+i]; + else { + res1[i] = res[j]; + j++; + } + } + } else if (part == 1) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = res[SPECIES.length()-origin+i]; + else { + res1[i] = b[idx+origin+j]; + j++; + } + } + } + return res1; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void unsliceHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, mask, Halffloat128VectorTests::unslice); + } + + static short SIN(short a) { + return (short)(scalar_sin(a)); + } + + static short strictSIN(short a) { + return (short)(strict_scalar_sin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::SIN, Halffloat128VectorTests::strictSIN); + } + + static short EXP(short a) { + return (short)(scalar_exp(a)); + } + + static short strictEXP(short a) { + return (short)(strict_scalar_exp(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::EXP, Halffloat128VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return (short)(scalar_log1p(a)); + } + + static short strictLOG1P(short a) { + return (short)(strict_scalar_log1p(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG1P, Halffloat128VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return (short)(scalar_log(a)); + } + + static short strictLOG(short a) { + return (short)(strict_scalar_log(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG, Halffloat128VectorTests::strictLOG); + } + + static short LOG10(short a) { + return (short)(scalar_log10(a)); + } + + static short strictLOG10(short a) { + return (short)(strict_scalar_log10(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::LOG10, Halffloat128VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return (short)(scalar_expm1(a)); + } + + static short strictEXPM1(short a) { + return (short)(strict_scalar_expm1(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::EXPM1, Halffloat128VectorTests::strictEXPM1); + } + + static short COS(short a) { + return (short)(scalar_cos(a)); + } + + static short strictCOS(short a) { + return (short)(strict_scalar_cos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::COS, Halffloat128VectorTests::strictCOS); + } + + static short TAN(short a) { + return (short)(scalar_tan(a)); + } + + static short strictTAN(short a) { + return (short)(strict_scalar_tan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::TAN, Halffloat128VectorTests::strictTAN); + } + + static short SINH(short a) { + return (short)(scalar_sinh(a)); + } + + static short strictSINH(short a) { + return (short)(strict_scalar_sinh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::SINH, Halffloat128VectorTests::strictSINH); + } + + static short COSH(short a) { + return (short)(scalar_cosh(a)); + } + + static short strictCOSH(short a) { + return (short)(strict_scalar_cosh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::COSH, Halffloat128VectorTests::strictCOSH); + } + + static short TANH(short a) { + return (short)(scalar_tanh(a)); + } + + static short strictTANH(short a) { + return (short)(strict_scalar_tanh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::TANH, Halffloat128VectorTests::strictTANH); + } + + static short ASIN(short a) { + return (short)(scalar_asin(a)); + } + + static short strictASIN(short a) { + return (short)(strict_scalar_asin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ASIN, Halffloat128VectorTests::strictASIN); + } + + static short ACOS(short a) { + return (short)(scalar_acos(a)); + } + + static short strictACOS(short a) { + return (short)(strict_scalar_acos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ACOS, Halffloat128VectorTests::strictACOS); + } + + static short ATAN(short a) { + return (short)(scalar_atan(a)); + } + + static short strictATAN(short a) { + return (short)(strict_scalar_atan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::ATAN, Halffloat128VectorTests::strictATAN); + } + + static short CBRT(short a) { + return (short)(scalar_cbrt(a)); + } + + static short strictCBRT(short a) { + return (short)(strict_scalar_cbrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat128VectorTests::CBRT, Halffloat128VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return (short)(scalar_hypot(a, b)); + } + + static short strictHYPOT(short a, short b) { + return (short)(strict_scalar_hypot(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::HYPOT, Halffloat128VectorTests::strictHYPOT); + } + + + static short POW(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictPOW(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::POW, Halffloat128VectorTests::strictPOW); + } + + + static short pow(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictpow(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::pow, Halffloat128VectorTests::strictpow); + } + + + static short ATAN2(short a, short b) { + return (short)(scalar_atan2(a, b)); + } + + static short strictATAN2(short a, short b) { + return (short)(strict_scalar_atan2(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::ATAN2, Halffloat128VectorTests::strictATAN2); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::POW, Halffloat128VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::pow, Halffloat128VectorTests::strictpow); + } + + + static short FMA(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + static short fma(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat128VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat128VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat128VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::ATAN2, Halffloat128VectorTests::strictATAN2); + assertArraysEquals(r, a, b, c, mask, Halffloat128VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } + assertBroadcastArraysEquals(r, a, b, c, Halffloat128VectorTests::FMA); + } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::POW, Halffloat128VectorTests::strictPOW); + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat128VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); + } + assertAltBroadcastArraysEquals(r, a, b, c, Halffloat128VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, c, mask, Halffloat128VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.pow(b[i]).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat128VectorTests::pow, Halffloat128VectorTests::strictpow); + assertAltBroadcastArraysEquals(r, a, b, c, mask, Halffloat128VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short blend(short a, short b, boolean mask) { - return mask ? b : a; + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat128VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendHalffloat128VectorTests(IntFunction fa, IntFunction fb, - IntFunction fm) { + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.fma(b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat128VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Halffloat128VectorTests::FMA); + } + + static short NEG(short a) { + return (short)(scalar_neg((short)a)); + } + + static short neg(short a) { + return (short)(scalar_neg((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.blend(bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat128VectorTests::blend); + assertArraysEquals(r, a, Halffloat128VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat128VectorTests::NEG); + } + + static short ABS(short a) { + return (short)(scalar_abs((short)a)); + } + + static short abs(short a) { + return (short)(scalar_abs((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat128VectorTests::ABS); + } + + static short SQRT(short a) { + return (short)(scalar_sqrt(a)); + } + + static short sqrt(short a) { + return (short)(scalar_sqrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat128VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat128VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat128VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat128VectorTests::SQRT); } @Test(dataProvider = "shortCompareOpProvider") @@ -2661,7 +5091,7 @@ static void ltHalffloat128VectorTestsBroadcastSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -2677,7 +5107,7 @@ static void eqHalffloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java index d0e29d46b606f..7c53cd98bbea5 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat256VectorTests.java @@ -40,6 +40,7 @@ import jdk.incubator.vector.Vector; import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; import jdk.incubator.vector.HalffloatVector; import org.testng.Assert; @@ -197,13 +198,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -225,13 +226,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -380,7 +381,7 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + wrapped_index = Math.floorMod(shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -397,7 +398,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); AssertEquals(r[i+j], a[i+wrapped_index]); } @@ -433,7 +434,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) AssertEquals(r[i+j], a[i+wrapped_index]); @@ -858,8 +859,8 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s static boolean isWithin1Ulp(short actual, short expected) { - Float16 act = Float16.shortBitsToFloat16(actual); - Float16 exp = Float16.shortBitsToFloat16(expected); + Float16 act = shortBitsToFloat16(actual); + Float16 exp = shortBitsToFloat16(expected); if (Float16.isNaN(exp) && !Float16.isNaN(act)) { return false; } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { @@ -885,11 +886,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FU try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -899,11 +900,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBin try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -914,14 +915,14 @@ static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[ try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1116,7 +1117,7 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } static short genValue(int i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static int intCornerCaseValue(int i) { @@ -1180,7 +1181,7 @@ static long longCornerCaseValue(int i) { } static short genValue(long i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static final List> LONG_HALFFLOAT_GENERATORS = List.of( @@ -1518,12 +1519,12 @@ static short[] fill(short[] a, ToHalffloatF f) { static short cornerCaseValue(int i) { return switch(i % 8) { - case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); - case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); - case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); - case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); - case 4 -> Float16.float16ToRawShortBits(Float16.NaN); - case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 0 -> float16ToShortBits(Float16.MAX_VALUE); + case 1 -> float16ToShortBits(Float16.MIN_VALUE); + case 2 -> float16ToShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> float16ToShortBits(Float16.POSITIVE_INFINITY); + case 4 -> float16ToShortBits(Float16.NaN); + case 5 -> float16ToShortBits(shortBitsToFloat16((short)0x7FFA)); case 6 -> ((short)0.0); default -> ((short)-0.0); }; @@ -1545,57 +1546,301 @@ static short cornerCaseValue(int i) { }; static boolean eq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() == bt.floatValue(); } static boolean neq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() != bt.floatValue(); } static boolean lt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() < bt.floatValue(); } static boolean le(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() <= bt.floatValue(); } static boolean gt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() > bt.floatValue(); } static boolean ge(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() >= bt.floatValue(); } static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 zero = shortBitsToFloat16((short)0); + return Float16.compare(at, zero) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)float16ToShortBits(Float16.valueOf(1.0f)); + } + + static short scalar_add(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.add(at, bt)); + } + + static short scalar_sub(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.subtract(at, bt)); + } + + static short scalar_mul(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.multiply(at, bt)); + + } + static short scalar_max(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.max(at, bt)); + } + + static short scalar_min(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.min(at, bt)); + } + + static short scalar_div(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.divide(at, bt)); + } + + static short scalar_fma(short a, short b, short c) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 ct = shortBitsToFloat16(c); + return float16ToShortBits(Float16.fma(at, bt, ct)); + } + + static short scalar_abs(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.abs(at)); + } + + static short scalar_neg(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.valueOf(-at.floatValue())); + } + + static short scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + static short additiveIdentity() { + return (short)0; + } + + + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return float16ToShortBits(Float16.POSITIVE_INFINITY); + } + + static short minValue() { + return float16ToShortBits(Float16.NEGATIVE_INFINITY); + } + + static boolean isNaN(short a) { + return Float16.isNaN(shortBitsToFloat16(a)); + } + static boolean isFinite(short a) { + return Float16.isFinite(shortBitsToFloat16(a)); + } + static boolean isInfinite(short a) { + return Float16.isInfinite(shortBitsToFloat16(a)); } @Test static void smokeTest1() { - HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); - HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three = HalffloatVector.broadcast(SPECIES, float16ToShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three2).allTrue()); - HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three3 = three2.broadcast(float16ToShortBits(Float16.valueOf(1))).broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three3).allTrue()); int scale = 2; HalffloatVector higher = three.addIndex(scale); VectorMask m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); - m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + m = higher.min((float16ToShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); m = higher.test(VectorOperators.IS_FINITE); assert(m.allTrue()); @@ -1672,7 +1917,7 @@ void viewAsFloatingLanesTest() { } static short ADD(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1692,6 +1937,25 @@ static void ADDHalffloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::add); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void ADDHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1712,8 +1976,26 @@ static void ADDHalffloat256VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::ADD); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::add); + } + static short SUB(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1733,6 +2015,25 @@ static void SUBHalffloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::sub); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void SUBHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1753,8 +2054,26 @@ static void SUBHalffloat256VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::SUB); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::sub); + } + static short MUL(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1774,6 +2093,25 @@ static void MULHalffloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::mul); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void MULHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1794,8 +2132,26 @@ static void MULHalffloat256VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::MUL); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::mul); + } + static short DIV(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + return (short)(scalar_div(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1815,6 +2171,25 @@ static void DIVHalffloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::div); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void DIVHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1835,12 +2210,30 @@ static void DIVHalffloat256VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::DIV); } - static short MAX(short a, short b) { - return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::div); + } + + static short FIRST_NONZERO(short a, short b) { + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROHalffloat256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1849,15 +2242,15 @@ static void MAXHalffloat256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void FIRST_NONZEROHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1869,36 +2262,29 @@ static void MAXHalffloat256VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::MAX); - } - - static short MIN(short a, short b) { - return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + static void addHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, Halffloat256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MINHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1906,236 +2292,170 @@ static void MINHalffloat256VectorTestsMasked(IntFunction fa, IntFunctio boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat256VectorTests::add); } - static short ABS(short a) { - return (short)(Math.abs(a)); - } + @Test(dataProvider = "shortBinaryOpProvider") + static void subHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short abs(short a) { - return (short)(Math.abs(a)); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void ABSHalffloat256VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS).intoArray(r, i); - } - } - - assertArraysEquals(r, a, Halffloat256VectorTests::ABS); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void absHalffloat256VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.abs().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat256VectorTests::abs); + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedHalffloat256VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat256VectorTests::ABS); - } - - static short NEG(short a) { - return (short)(-a); - } - - static short neg(short a) { - return (short)(-a); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat256VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpProvider") - static void NEGHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void mulHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat256VectorTests::NEG); + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpProvider") - static void negHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.neg().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat256VectorTests::neg); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat256VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedHalffloat256VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpProvider") + static void divHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - boolean[] mask = fm.apply(SPECIES.length()); - VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat256VectorTests::NEG); - } - - static short FMA(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); - } - - static short fma(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void FMAHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat256VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat256VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void fmaHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.fma(bv, cv).intoArray(r, i); + av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat256VectorTests::fma); + assertBroadcastLongArraysEquals(r, a, b, Halffloat256VectorTests::ADD); } - @Test(dataProvider = "shortTernaryOpMaskProvider") - static void FMAHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, - IntFunction fc, IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, mask, Halffloat256VectorTests::FMA); - } - - static short SQRT(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); - } - - static short sqrt(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat256VectorTests::ADD); } @Test(dataProvider = "shortUnaryOpProvider") - static void SQRTHalffloat256VectorTests(IntFunction fa) { + static void MINHalffloat256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat256VectorTests::SQRT); + assertArraysEquals(r, a, (short)10, Halffloat256VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void sqrtHalffloat256VectorTests(IntFunction fa) { + static void minHalffloat256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.sqrt().intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat256VectorTests::sqrt); + assertArraysEquals(r, a, (short)10, Halffloat256VectorTests::min); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void SQRTMaskedHalffloat256VectorTests(IntFunction fa, - IntFunction fm) { + static void MINHalffloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2144,510 +2464,2620 @@ static void SQRTMaskedHalffloat256VectorTests(IntFunction fa, for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, mask, Halffloat256VectorTests::SQRT); - } - - static short SIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); - } - - static short strictSIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat256VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHalffloat256VectorTests(IntFunction fa) { + static void MAXHalffloat256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SIN).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::SIN, Halffloat256VectorTests::strictSIN); - } - - static short EXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); - } - - static short strictEXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat256VectorTests::MAX); } @Test(dataProvider = "shortUnaryOpProvider") - static void EXPHalffloat256VectorTests(IntFunction fa) { + static void maxHalffloat256VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXP).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::EXP, Halffloat256VectorTests::strictEXP); - } - - static short LOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); - } - - static short strictLOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat256VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG1PHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXHalffloat256VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG1P, Halffloat256VectorTests::strictLOG1P); - } - - static short LOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat256VectorTests::MAX); } - static short strictLOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + static short MIN(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOGHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG, Halffloat256VectorTests::strictLOG); - } - - static short LOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat256VectorTests::MIN); } - static short strictLOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + static short min(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG10Halffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG10).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.min(bv).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG10, Halffloat256VectorTests::strictLOG10); - } - - static short EXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat256VectorTests::min); } - static short strictEXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + static short MAX(short a, short b) { + return (short)(scalar_max(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void EXPM1Halffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::EXPM1, Halffloat256VectorTests::strictEXPM1); + assertArraysEquals(r, a, b, Halffloat256VectorTests::MAX); } - static short COS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + static short max(short a, short b) { + return (short)(scalar_max(a, b)); } - static short strictCOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.max(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat256VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COS).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::COS, Halffloat256VectorTests::strictCOS); + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::MIN); } - static short TAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::min); } - static short strictTAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::MAX); } - @Test(dataProvider = "shortUnaryOpProvider") - static void TANHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TAN).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::TAN, Halffloat256VectorTests::strictTAN); + assertBroadcastArraysEquals(r, a, b, Halffloat256VectorTests::max); } - static short SINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + static short ADDReduce(short[] a, int idx) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_add(res, a[i]); + } + + return res; } - static short strictSINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + static short ADDReduceAll(short[] a) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHHalffloat256VectorTests(IntFunction fa) { + static void ADDReduceHalffloat256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SINH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::SINH, Halffloat256VectorTests::strictSINH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat256VectorTests::ADDReduce, Halffloat256VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short COSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_add(res, a[i]); + } + + return res; } - static short strictCOSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + static short ADDReduceAllMasked(short[] a, boolean[] mask) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COSH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::COSH, Halffloat256VectorTests::strictCOSH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat256VectorTests::ADDReduceMasked, Halffloat256VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short TANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + static short MULReduce(short[] a, int idx) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictTANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + static short MULReduceAll(short[] a) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void TANHHalffloat256VectorTests(IntFunction fa) { + static void MULReduceHalffloat256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TANH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::TANH, Halffloat256VectorTests::strictTANH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat256VectorTests::MULReduce, Halffloat256VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + static short MULReduceMasked(short[] a, int idx, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + static short MULReduceAllMasked(short[] a, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ASINHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MULReduceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ASIN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ASIN, Halffloat256VectorTests::strictASIN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat256VectorTests::MULReduceMasked, Halffloat256VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + static short MINReduce(short[] a, int idx) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_min(res, a[i]); + } + + return res; } - static short strictACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + static short MINReduceAll(short[] a) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ACOSHalffloat256VectorTests(IntFunction fa) { + static void MINReduceHalffloat256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ACOS).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ACOS, Halffloat256VectorTests::strictACOS); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat256VectorTests::MINReduce, Halffloat256VectorTests::MINReduceAll); } - static short ATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + static short MINReduceMasked(short[] a, int idx, boolean[] mask) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_min(res, a[i]); + } + + return res; } - static short strictATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + static short MINReduceAllMasked(short[] a, boolean[] mask) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ATANHalffloat256VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MINReduceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ATAN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ATAN, Halffloat256VectorTests::strictATAN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat256VectorTests::MINReduceMasked, Halffloat256VectorTests::MINReduceAllMasked); } - static short CBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + static short MAXReduce(short[] a, int idx) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_max(res, a[i]); + } + + return res; } - static short strictCBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + static short MAXReduceAll(short[] a) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void CBRTHalffloat256VectorTests(IntFunction fa) { + static void MAXReduceHalffloat256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.CBRT).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::CBRT, Halffloat256VectorTests::strictCBRT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat256VectorTests::MAXReduce, Halffloat256VectorTests::MAXReduceAll); } - static short HYPOT(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_max(res, a[i]); + } + + return res; } - static short strictHYPOT(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short MAXReduceAllMasked(short[] a, boolean[] mask) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void HYPOTHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXReduceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::HYPOT, Halffloat256VectorTests::strictHYPOT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat256VectorTests::MAXReduceMasked, Halffloat256VectorTests::MAXReduceAllMasked); } - static short POW(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduce(short[] a, int idx) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictPOW(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAll(short[] a) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpProvider") + static void FIRST_NONZEROReduceHalffloat256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::POW, Halffloat256VectorTests::strictPOW); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat256VectorTests::FIRST_NONZEROReduce, Halffloat256VectorTests::FIRST_NONZEROReduceAll); } - static short pow(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictpow(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void FIRST_NONZEROReduceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.pow(bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::pow, Halffloat256VectorTests::strictpow); - } - - static short ATAN2(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); - } + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); + } + } - static short strictATAN2(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat256VectorTests::FIRST_NONZEROReduceMasked, Halffloat256VectorTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void ATAN2Halffloat256VectorTests(IntFunction fa, IntFunction fb) { + static void withHalffloat256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); + } + } + + + assertArraysStrictlyEquals(r, a); + } + + static boolean testIS_DEFAULT(short a) { + return bits(a)==0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_DEFAULTHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_DEFAULTMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + } + } + } + } + + static boolean testIS_NEGATIVE(short a) { + return bits(a)<0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NEGATIVEHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NEGATIVEMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + } + } + } + } + + static boolean testIS_FINITE(short a) { + return isFinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_FINITEHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_FINITEMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + } + } + } + } + + static boolean testIS_NAN(short a) { + return isNaN(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NANHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NANMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + } + } + } + } + + static boolean testIS_INFINITE(short a) { + return isInfinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_INFINITEHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_INFINITEMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.lt(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GTHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GTHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.eq(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void NEHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void NEHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LEHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LEHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GEHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GEHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(short)((long)b[i])))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat256VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(short)((long)b[i])))); + } + } + } + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat256VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::blend); + } + + @Test(dataProvider = "shortUnaryOpShuffleProvider") + static void RearrangeHalffloat256VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); + } + } + + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") + static void RearrangeHalffloat256VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); + } + + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void compressHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.compress(vmask).intoArray(r, i); + } + } + + assertcompressArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void expandHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.expand(vmask).intoArray(r, i); + } + } + + assertexpandArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void getHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int num_lanes = SPECIES.length(); + // Manually unroll because full unroll happens after intrinsification. + // Unroll is needed because get intrinsic requires for index to be a known constant. + if (num_lanes == 1) { + r[i]=av.lane(0); + } else if (num_lanes == 2) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + } else if (num_lanes == 4) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + } else if (num_lanes == 8) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + } else if (num_lanes == 16) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + } else if (num_lanes == 32) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + } else if (num_lanes == 64) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + r[i+32]=av.lane(32); + r[i+33]=av.lane(33); + r[i+34]=av.lane(34); + r[i+35]=av.lane(35); + r[i+36]=av.lane(36); + r[i+37]=av.lane(37); + r[i+38]=av.lane(38); + r[i+39]=av.lane(39); + r[i+40]=av.lane(40); + r[i+41]=av.lane(41); + r[i+42]=av.lane(42); + r[i+43]=av.lane(43); + r[i+44]=av.lane(44); + r[i+45]=av.lane(45); + r[i+46]=av.lane(46); + r[i+47]=av.lane(47); + r[i+48]=av.lane(48); + r[i+49]=av.lane(49); + r[i+50]=av.lane(50); + r[i+51]=av.lane(51); + r[i+52]=av.lane(52); + r[i+53]=av.lane(53); + r[i+54]=av.lane(54); + r[i+55]=av.lane(55); + r[i+56]=av.lane(56); + r[i+57]=av.lane(57); + r[i+58]=av.lane(58); + r[i+59]=av.lane(59); + r[i+60]=av.lane(60); + r[i+61]=av.lane(61); + r[i+62]=av.lane(62); + r[i+63]=av.lane(63); + } else { + for (int j = 0; j < SPECIES.length(); j++) { + r[i+j]=av.lane(j); + } + } + } + } + + assertArraysStrictlyEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void BroadcastHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, a[i]).intoArray(r, i); + } + } + + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ZeroHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.zero(SPECIES).intoArray(a, i); + } + } + + AssertEquals(a, r); + } + + static short[] sliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else + res[i] = (short)0; + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sliceUnaryHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.slice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat256VectorTests::sliceUnary); + } + + static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void sliceBinaryHalffloat256VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, Halffloat256VectorTests::sliceBinary); + } + + static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = mask[i] ? a[idx+i+origin] : (short)0; + else { + res[i] = mask[i] ? b[idx+j] : (short)0; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void sliceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, mask, Halffloat256VectorTests::slice); + } + + static short[] unsliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i < origin) + res[i] = (short)0; + else { + res[i] = a[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void unsliceUnaryHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.unslice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat256VectorTests::unsliceUnary); + } + + static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (part == 0) { + if (i < origin) + res[i] = b[idx+i]; + else { + res[i] = a[idx+j]; + j++; + } + } else if (part == 1) { + if (i < origin) + res[i] = a[idx+SPECIES.length()-origin+i]; + else { + res[i] = b[idx+origin+j]; + j++; + } + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void unsliceBinaryHalffloat256VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, Halffloat256VectorTests::unsliceBinary); + } + + static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = b[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + for (int i = 0; i < SPECIES.length(); i++){ + res[i] = mask[i] ? a[idx+i] : res[i]; + } + short[] res1 = new short[SPECIES.length()]; + if (part == 0) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = b[idx+i]; + else { + res1[i] = res[j]; + j++; + } + } + } else if (part == 1) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = res[SPECIES.length()-origin+i]; + else { + res1[i] = b[idx+origin+j]; + j++; + } + } + } + return res1; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void unsliceHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, mask, Halffloat256VectorTests::unslice); + } + + static short SIN(short a) { + return (short)(scalar_sin(a)); + } + + static short strictSIN(short a) { + return (short)(strict_scalar_sin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::SIN, Halffloat256VectorTests::strictSIN); + } + + static short EXP(short a) { + return (short)(scalar_exp(a)); + } + + static short strictEXP(short a) { + return (short)(strict_scalar_exp(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::EXP, Halffloat256VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return (short)(scalar_log1p(a)); + } + + static short strictLOG1P(short a) { + return (short)(strict_scalar_log1p(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG1P, Halffloat256VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return (short)(scalar_log(a)); + } + + static short strictLOG(short a) { + return (short)(strict_scalar_log(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG, Halffloat256VectorTests::strictLOG); + } + + static short LOG10(short a) { + return (short)(scalar_log10(a)); + } + + static short strictLOG10(short a) { + return (short)(strict_scalar_log10(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::LOG10, Halffloat256VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return (short)(scalar_expm1(a)); + } + + static short strictEXPM1(short a) { + return (short)(strict_scalar_expm1(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::EXPM1, Halffloat256VectorTests::strictEXPM1); + } + + static short COS(short a) { + return (short)(scalar_cos(a)); + } + + static short strictCOS(short a) { + return (short)(strict_scalar_cos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::COS, Halffloat256VectorTests::strictCOS); + } + + static short TAN(short a) { + return (short)(scalar_tan(a)); + } + + static short strictTAN(short a) { + return (short)(strict_scalar_tan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::TAN, Halffloat256VectorTests::strictTAN); + } + + static short SINH(short a) { + return (short)(scalar_sinh(a)); + } + + static short strictSINH(short a) { + return (short)(strict_scalar_sinh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::SINH, Halffloat256VectorTests::strictSINH); + } + + static short COSH(short a) { + return (short)(scalar_cosh(a)); + } + + static short strictCOSH(short a) { + return (short)(strict_scalar_cosh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::COSH, Halffloat256VectorTests::strictCOSH); + } + + static short TANH(short a) { + return (short)(scalar_tanh(a)); + } + + static short strictTANH(short a) { + return (short)(strict_scalar_tanh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::TANH, Halffloat256VectorTests::strictTANH); + } + + static short ASIN(short a) { + return (short)(scalar_asin(a)); + } + + static short strictASIN(short a) { + return (short)(strict_scalar_asin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ASIN, Halffloat256VectorTests::strictASIN); + } + + static short ACOS(short a) { + return (short)(scalar_acos(a)); + } + + static short strictACOS(short a) { + return (short)(strict_scalar_acos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ACOS, Halffloat256VectorTests::strictACOS); + } + + static short ATAN(short a) { + return (short)(scalar_atan(a)); + } + + static short strictATAN(short a) { + return (short)(strict_scalar_atan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::ATAN, Halffloat256VectorTests::strictATAN); + } + + static short CBRT(short a) { + return (short)(scalar_cbrt(a)); + } + + static short strictCBRT(short a) { + return (short)(strict_scalar_cbrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat256VectorTests::CBRT, Halffloat256VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return (short)(scalar_hypot(a, b)); + } + + static short strictHYPOT(short a, short b) { + return (short)(strict_scalar_hypot(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::HYPOT, Halffloat256VectorTests::strictHYPOT); + } + + + static short POW(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictPOW(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::POW, Halffloat256VectorTests::strictPOW); + } + + + static short pow(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictpow(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::pow, Halffloat256VectorTests::strictpow); + } + + + static short ATAN2(short a, short b) { + return (short)(scalar_atan2(a, b)); + } + + static short strictATAN2(short a, short b) { + return (short)(strict_scalar_atan2(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::ATAN2, Halffloat256VectorTests::strictATAN2); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::POW, Halffloat256VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::pow, Halffloat256VectorTests::strictpow); + } + + + static short FMA(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + static short fma(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat256VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat256VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat256VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::ATAN2, Halffloat256VectorTests::strictATAN2); + assertArraysEquals(r, a, b, c, mask, Halffloat256VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } + assertBroadcastArraysEquals(r, a, b, c, Halffloat256VectorTests::FMA); + } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::POW, Halffloat256VectorTests::strictPOW); + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat256VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); + } + assertAltBroadcastArraysEquals(r, a, b, c, Halffloat256VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, c, mask, Halffloat256VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.pow(b[i]).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat256VectorTests::pow, Halffloat256VectorTests::strictpow); + assertAltBroadcastArraysEquals(r, a, b, c, mask, Halffloat256VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short blend(short a, short b, boolean mask) { - return mask ? b : a; + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat256VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendHalffloat256VectorTests(IntFunction fa, IntFunction fb, - IntFunction fm) { + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat256VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.fma(b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat256VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Halffloat256VectorTests::FMA); + } + + static short NEG(short a) { + return (short)(scalar_neg((short)a)); + } + + static short neg(short a) { + return (short)(scalar_neg((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.blend(bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat256VectorTests::blend); + assertArraysEquals(r, a, Halffloat256VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat256VectorTests::NEG); + } + + static short ABS(short a) { + return (short)(scalar_abs((short)a)); + } + + static short abs(short a) { + return (short)(scalar_abs((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat256VectorTests::ABS); + } + + static short SQRT(short a) { + return (short)(scalar_sqrt(a)); + } + + static short sqrt(short a) { + return (short)(scalar_sqrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat256VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat256VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat256VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat256VectorTests::SQRT); } @Test(dataProvider = "shortCompareOpProvider") @@ -2661,7 +5091,7 @@ static void ltHalffloat256VectorTestsBroadcastSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -2677,7 +5107,7 @@ static void eqHalffloat256VectorTestsBroadcastMaskedSmokeTest(IntFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java index 82546dc8ca237..8e793bab3aecc 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat512VectorTests.java @@ -40,6 +40,7 @@ import jdk.incubator.vector.Vector; import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; import jdk.incubator.vector.HalffloatVector; import org.testng.Assert; @@ -197,13 +198,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -225,13 +226,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -380,7 +381,7 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + wrapped_index = Math.floorMod(shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -397,7 +398,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); AssertEquals(r[i+j], a[i+wrapped_index]); } @@ -433,7 +434,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) AssertEquals(r[i+j], a[i+wrapped_index]); @@ -858,8 +859,8 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s static boolean isWithin1Ulp(short actual, short expected) { - Float16 act = Float16.shortBitsToFloat16(actual); - Float16 exp = Float16.shortBitsToFloat16(expected); + Float16 act = shortBitsToFloat16(actual); + Float16 exp = shortBitsToFloat16(expected); if (Float16.isNaN(exp) && !Float16.isNaN(act)) { return false; } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { @@ -885,11 +886,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FU try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -899,11 +900,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBin try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -914,14 +915,14 @@ static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[ try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1116,7 +1117,7 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } static short genValue(int i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static int intCornerCaseValue(int i) { @@ -1180,7 +1181,7 @@ static long longCornerCaseValue(int i) { } static short genValue(long i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static final List> LONG_HALFFLOAT_GENERATORS = List.of( @@ -1518,12 +1519,12 @@ static short[] fill(short[] a, ToHalffloatF f) { static short cornerCaseValue(int i) { return switch(i % 8) { - case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); - case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); - case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); - case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); - case 4 -> Float16.float16ToRawShortBits(Float16.NaN); - case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 0 -> float16ToShortBits(Float16.MAX_VALUE); + case 1 -> float16ToShortBits(Float16.MIN_VALUE); + case 2 -> float16ToShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> float16ToShortBits(Float16.POSITIVE_INFINITY); + case 4 -> float16ToShortBits(Float16.NaN); + case 5 -> float16ToShortBits(shortBitsToFloat16((short)0x7FFA)); case 6 -> ((short)0.0); default -> ((short)-0.0); }; @@ -1545,57 +1546,301 @@ static short cornerCaseValue(int i) { }; static boolean eq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() == bt.floatValue(); } static boolean neq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() != bt.floatValue(); } static boolean lt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() < bt.floatValue(); } static boolean le(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() <= bt.floatValue(); } static boolean gt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() > bt.floatValue(); } static boolean ge(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() >= bt.floatValue(); } static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 zero = shortBitsToFloat16((short)0); + return Float16.compare(at, zero) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)float16ToShortBits(Float16.valueOf(1.0f)); + } + + static short scalar_add(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.add(at, bt)); + } + + static short scalar_sub(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.subtract(at, bt)); + } + + static short scalar_mul(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.multiply(at, bt)); + + } + static short scalar_max(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.max(at, bt)); + } + + static short scalar_min(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.min(at, bt)); + } + + static short scalar_div(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.divide(at, bt)); + } + + static short scalar_fma(short a, short b, short c) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 ct = shortBitsToFloat16(c); + return float16ToShortBits(Float16.fma(at, bt, ct)); + } + + static short scalar_abs(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.abs(at)); + } + + static short scalar_neg(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.valueOf(-at.floatValue())); + } + + static short scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + static short additiveIdentity() { + return (short)0; + } + + + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return float16ToShortBits(Float16.POSITIVE_INFINITY); + } + + static short minValue() { + return float16ToShortBits(Float16.NEGATIVE_INFINITY); + } + + static boolean isNaN(short a) { + return Float16.isNaN(shortBitsToFloat16(a)); + } + static boolean isFinite(short a) { + return Float16.isFinite(shortBitsToFloat16(a)); + } + static boolean isInfinite(short a) { + return Float16.isInfinite(shortBitsToFloat16(a)); } @Test static void smokeTest1() { - HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); - HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three = HalffloatVector.broadcast(SPECIES, float16ToShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three2).allTrue()); - HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three3 = three2.broadcast(float16ToShortBits(Float16.valueOf(1))).broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three3).allTrue()); int scale = 2; HalffloatVector higher = three.addIndex(scale); VectorMask m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); - m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + m = higher.min((float16ToShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); m = higher.test(VectorOperators.IS_FINITE); assert(m.allTrue()); @@ -1672,7 +1917,7 @@ void viewAsFloatingLanesTest() { } static short ADD(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1692,6 +1937,25 @@ static void ADDHalffloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::add); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void ADDHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1712,8 +1976,26 @@ static void ADDHalffloat512VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::ADD); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::add); + } + static short SUB(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1733,6 +2015,25 @@ static void SUBHalffloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::sub); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void SUBHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1753,8 +2054,26 @@ static void SUBHalffloat512VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::SUB); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::sub); + } + static short MUL(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1774,6 +2093,25 @@ static void MULHalffloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::mul); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void MULHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1794,8 +2132,26 @@ static void MULHalffloat512VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::MUL); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::mul); + } + static short DIV(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + return (short)(scalar_div(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1815,6 +2171,25 @@ static void DIVHalffloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::div); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void DIVHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1835,12 +2210,30 @@ static void DIVHalffloat512VectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::DIV); } - static short MAX(short a, short b) { - return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::div); + } + + static short FIRST_NONZERO(short a, short b) { + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROHalffloat512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1849,15 +2242,15 @@ static void MAXHalffloat512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void FIRST_NONZEROHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1869,36 +2262,29 @@ static void MAXHalffloat512VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::MAX); - } - - static short MIN(short a, short b) { - return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + static void addHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, Halffloat512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MINHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1906,236 +2292,170 @@ static void MINHalffloat512VectorTestsMasked(IntFunction fa, IntFunctio boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat512VectorTests::add); } - static short ABS(short a) { - return (short)(Math.abs(a)); - } + @Test(dataProvider = "shortBinaryOpProvider") + static void subHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short abs(short a) { - return (short)(Math.abs(a)); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void ABSHalffloat512VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS).intoArray(r, i); - } - } - - assertArraysEquals(r, a, Halffloat512VectorTests::ABS); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void absHalffloat512VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.abs().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat512VectorTests::abs); + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedHalffloat512VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat512VectorTests::ABS); - } - - static short NEG(short a) { - return (short)(-a); - } - - static short neg(short a) { - return (short)(-a); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat512VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpProvider") - static void NEGHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void mulHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat512VectorTests::NEG); + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpProvider") - static void negHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.neg().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat512VectorTests::neg); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat512VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedHalffloat512VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpProvider") + static void divHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - boolean[] mask = fm.apply(SPECIES.length()); - VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat512VectorTests::NEG); - } - - static short FMA(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); - } - - static short fma(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void FMAHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat512VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat512VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void fmaHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.fma(bv, cv).intoArray(r, i); + av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat512VectorTests::fma); + assertBroadcastLongArraysEquals(r, a, b, Halffloat512VectorTests::ADD); } - @Test(dataProvider = "shortTernaryOpMaskProvider") - static void FMAHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, - IntFunction fc, IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat512VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, mask, Halffloat512VectorTests::FMA); - } - - static short SQRT(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); - } - - static short sqrt(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat512VectorTests::ADD); } @Test(dataProvider = "shortUnaryOpProvider") - static void SQRTHalffloat512VectorTests(IntFunction fa) { + static void MINHalffloat512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat512VectorTests::SQRT); + assertArraysEquals(r, a, (short)10, Halffloat512VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void sqrtHalffloat512VectorTests(IntFunction fa) { + static void minHalffloat512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.sqrt().intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat512VectorTests::sqrt); + assertArraysEquals(r, a, (short)10, Halffloat512VectorTests::min); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void SQRTMaskedHalffloat512VectorTests(IntFunction fa, - IntFunction fm) { + static void MINHalffloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2144,510 +2464,2620 @@ static void SQRTMaskedHalffloat512VectorTests(IntFunction fa, for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, mask, Halffloat512VectorTests::SQRT); - } - - static short SIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); - } - - static short strictSIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat512VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHalffloat512VectorTests(IntFunction fa) { + static void MAXHalffloat512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SIN).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::SIN, Halffloat512VectorTests::strictSIN); - } - - static short EXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); - } - - static short strictEXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat512VectorTests::MAX); } @Test(dataProvider = "shortUnaryOpProvider") - static void EXPHalffloat512VectorTests(IntFunction fa) { + static void maxHalffloat512VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXP).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::EXP, Halffloat512VectorTests::strictEXP); - } - - static short LOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); - } - - static short strictLOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat512VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG1PHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXHalffloat512VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG1P, Halffloat512VectorTests::strictLOG1P); - } - - static short LOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat512VectorTests::MAX); } - static short strictLOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + static short MIN(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOGHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG, Halffloat512VectorTests::strictLOG); - } - - static short LOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat512VectorTests::MIN); } - static short strictLOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + static short min(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG10Halffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG10).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.min(bv).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG10, Halffloat512VectorTests::strictLOG10); - } - - static short EXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat512VectorTests::min); } - static short strictEXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + static short MAX(short a, short b) { + return (short)(scalar_max(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void EXPM1Halffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::EXPM1, Halffloat512VectorTests::strictEXPM1); + assertArraysEquals(r, a, b, Halffloat512VectorTests::MAX); } - static short COS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + static short max(short a, short b) { + return (short)(scalar_max(a, b)); } - static short strictCOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.max(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat512VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COS).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::COS, Halffloat512VectorTests::strictCOS); + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::MIN); } - static short TAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::min); } - static short strictTAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::MAX); } - @Test(dataProvider = "shortUnaryOpProvider") - static void TANHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TAN).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::TAN, Halffloat512VectorTests::strictTAN); + assertBroadcastArraysEquals(r, a, b, Halffloat512VectorTests::max); } - static short SINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + static short ADDReduce(short[] a, int idx) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_add(res, a[i]); + } + + return res; } - static short strictSINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + static short ADDReduceAll(short[] a) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHHalffloat512VectorTests(IntFunction fa) { + static void ADDReduceHalffloat512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SINH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::SINH, Halffloat512VectorTests::strictSINH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat512VectorTests::ADDReduce, Halffloat512VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short COSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_add(res, a[i]); + } + + return res; } - static short strictCOSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + static short ADDReduceAllMasked(short[] a, boolean[] mask) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COSH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::COSH, Halffloat512VectorTests::strictCOSH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat512VectorTests::ADDReduceMasked, Halffloat512VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short TANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + static short MULReduce(short[] a, int idx) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictTANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + static short MULReduceAll(short[] a) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void TANHHalffloat512VectorTests(IntFunction fa) { + static void MULReduceHalffloat512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TANH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::TANH, Halffloat512VectorTests::strictTANH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat512VectorTests::MULReduce, Halffloat512VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + static short MULReduceMasked(short[] a, int idx, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + static short MULReduceAllMasked(short[] a, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ASINHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MULReduceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ASIN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ASIN, Halffloat512VectorTests::strictASIN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat512VectorTests::MULReduceMasked, Halffloat512VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + static short MINReduce(short[] a, int idx) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_min(res, a[i]); + } + + return res; } - static short strictACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + static short MINReduceAll(short[] a) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ACOSHalffloat512VectorTests(IntFunction fa) { + static void MINReduceHalffloat512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ACOS).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ACOS, Halffloat512VectorTests::strictACOS); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat512VectorTests::MINReduce, Halffloat512VectorTests::MINReduceAll); } - static short ATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + static short MINReduceMasked(short[] a, int idx, boolean[] mask) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_min(res, a[i]); + } + + return res; } - static short strictATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + static short MINReduceAllMasked(short[] a, boolean[] mask) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ATANHalffloat512VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MINReduceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ATAN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ATAN, Halffloat512VectorTests::strictATAN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat512VectorTests::MINReduceMasked, Halffloat512VectorTests::MINReduceAllMasked); } - static short CBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + static short MAXReduce(short[] a, int idx) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_max(res, a[i]); + } + + return res; } - static short strictCBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + static short MAXReduceAll(short[] a) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void CBRTHalffloat512VectorTests(IntFunction fa) { + static void MAXReduceHalffloat512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.CBRT).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::CBRT, Halffloat512VectorTests::strictCBRT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat512VectorTests::MAXReduce, Halffloat512VectorTests::MAXReduceAll); } - static short HYPOT(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_max(res, a[i]); + } + + return res; } - static short strictHYPOT(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short MAXReduceAllMasked(short[] a, boolean[] mask) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void HYPOTHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXReduceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::HYPOT, Halffloat512VectorTests::strictHYPOT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat512VectorTests::MAXReduceMasked, Halffloat512VectorTests::MAXReduceAllMasked); } - static short POW(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduce(short[] a, int idx) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictPOW(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAll(short[] a) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpProvider") + static void FIRST_NONZEROReduceHalffloat512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::POW, Halffloat512VectorTests::strictPOW); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat512VectorTests::FIRST_NONZEROReduce, Halffloat512VectorTests::FIRST_NONZEROReduceAll); } - static short pow(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictpow(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void FIRST_NONZEROReduceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.pow(bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::pow, Halffloat512VectorTests::strictpow); - } - - static short ATAN2(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); - } + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); + } + } - static short strictATAN2(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat512VectorTests::FIRST_NONZEROReduceMasked, Halffloat512VectorTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void ATAN2Halffloat512VectorTests(IntFunction fa, IntFunction fb) { + static void withHalffloat512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); + } + } + + + assertArraysStrictlyEquals(r, a); + } + + static boolean testIS_DEFAULT(short a) { + return bits(a)==0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_DEFAULTHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_DEFAULTMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + } + } + } + } + + static boolean testIS_NEGATIVE(short a) { + return bits(a)<0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NEGATIVEHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NEGATIVEMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + } + } + } + } + + static boolean testIS_FINITE(short a) { + return isFinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_FINITEHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_FINITEMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + } + } + } + } + + static boolean testIS_NAN(short a) { + return isNaN(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NANHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NANMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + } + } + } + } + + static boolean testIS_INFINITE(short a) { + return isInfinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_INFINITEHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_INFINITEMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.lt(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GTHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GTHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.eq(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void NEHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void NEHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LEHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LEHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GEHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GEHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(short)((long)b[i])))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat512VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(short)((long)b[i])))); + } + } + } + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat512VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::blend); + } + + @Test(dataProvider = "shortUnaryOpShuffleProvider") + static void RearrangeHalffloat512VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); + } + } + + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") + static void RearrangeHalffloat512VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); + } + + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void compressHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.compress(vmask).intoArray(r, i); + } + } + + assertcompressArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void expandHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.expand(vmask).intoArray(r, i); + } + } + + assertexpandArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void getHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int num_lanes = SPECIES.length(); + // Manually unroll because full unroll happens after intrinsification. + // Unroll is needed because get intrinsic requires for index to be a known constant. + if (num_lanes == 1) { + r[i]=av.lane(0); + } else if (num_lanes == 2) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + } else if (num_lanes == 4) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + } else if (num_lanes == 8) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + } else if (num_lanes == 16) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + } else if (num_lanes == 32) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + } else if (num_lanes == 64) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + r[i+32]=av.lane(32); + r[i+33]=av.lane(33); + r[i+34]=av.lane(34); + r[i+35]=av.lane(35); + r[i+36]=av.lane(36); + r[i+37]=av.lane(37); + r[i+38]=av.lane(38); + r[i+39]=av.lane(39); + r[i+40]=av.lane(40); + r[i+41]=av.lane(41); + r[i+42]=av.lane(42); + r[i+43]=av.lane(43); + r[i+44]=av.lane(44); + r[i+45]=av.lane(45); + r[i+46]=av.lane(46); + r[i+47]=av.lane(47); + r[i+48]=av.lane(48); + r[i+49]=av.lane(49); + r[i+50]=av.lane(50); + r[i+51]=av.lane(51); + r[i+52]=av.lane(52); + r[i+53]=av.lane(53); + r[i+54]=av.lane(54); + r[i+55]=av.lane(55); + r[i+56]=av.lane(56); + r[i+57]=av.lane(57); + r[i+58]=av.lane(58); + r[i+59]=av.lane(59); + r[i+60]=av.lane(60); + r[i+61]=av.lane(61); + r[i+62]=av.lane(62); + r[i+63]=av.lane(63); + } else { + for (int j = 0; j < SPECIES.length(); j++) { + r[i+j]=av.lane(j); + } + } + } + } + + assertArraysStrictlyEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void BroadcastHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, a[i]).intoArray(r, i); + } + } + + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ZeroHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.zero(SPECIES).intoArray(a, i); + } + } + + AssertEquals(a, r); + } + + static short[] sliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else + res[i] = (short)0; + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sliceUnaryHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.slice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat512VectorTests::sliceUnary); + } + + static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void sliceBinaryHalffloat512VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, Halffloat512VectorTests::sliceBinary); + } + + static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = mask[i] ? a[idx+i+origin] : (short)0; + else { + res[i] = mask[i] ? b[idx+j] : (short)0; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void sliceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, mask, Halffloat512VectorTests::slice); + } + + static short[] unsliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i < origin) + res[i] = (short)0; + else { + res[i] = a[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void unsliceUnaryHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.unslice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat512VectorTests::unsliceUnary); + } + + static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (part == 0) { + if (i < origin) + res[i] = b[idx+i]; + else { + res[i] = a[idx+j]; + j++; + } + } else if (part == 1) { + if (i < origin) + res[i] = a[idx+SPECIES.length()-origin+i]; + else { + res[i] = b[idx+origin+j]; + j++; + } + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void unsliceBinaryHalffloat512VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, Halffloat512VectorTests::unsliceBinary); + } + + static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = b[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + for (int i = 0; i < SPECIES.length(); i++){ + res[i] = mask[i] ? a[idx+i] : res[i]; + } + short[] res1 = new short[SPECIES.length()]; + if (part == 0) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = b[idx+i]; + else { + res1[i] = res[j]; + j++; + } + } + } else if (part == 1) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = res[SPECIES.length()-origin+i]; + else { + res1[i] = b[idx+origin+j]; + j++; + } + } + } + return res1; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void unsliceHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, mask, Halffloat512VectorTests::unslice); + } + + static short SIN(short a) { + return (short)(scalar_sin(a)); + } + + static short strictSIN(short a) { + return (short)(strict_scalar_sin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::SIN, Halffloat512VectorTests::strictSIN); + } + + static short EXP(short a) { + return (short)(scalar_exp(a)); + } + + static short strictEXP(short a) { + return (short)(strict_scalar_exp(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::EXP, Halffloat512VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return (short)(scalar_log1p(a)); + } + + static short strictLOG1P(short a) { + return (short)(strict_scalar_log1p(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG1P, Halffloat512VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return (short)(scalar_log(a)); + } + + static short strictLOG(short a) { + return (short)(strict_scalar_log(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG, Halffloat512VectorTests::strictLOG); + } + + static short LOG10(short a) { + return (short)(scalar_log10(a)); + } + + static short strictLOG10(short a) { + return (short)(strict_scalar_log10(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::LOG10, Halffloat512VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return (short)(scalar_expm1(a)); + } + + static short strictEXPM1(short a) { + return (short)(strict_scalar_expm1(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::EXPM1, Halffloat512VectorTests::strictEXPM1); + } + + static short COS(short a) { + return (short)(scalar_cos(a)); + } + + static short strictCOS(short a) { + return (short)(strict_scalar_cos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::COS, Halffloat512VectorTests::strictCOS); + } + + static short TAN(short a) { + return (short)(scalar_tan(a)); + } + + static short strictTAN(short a) { + return (short)(strict_scalar_tan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::TAN, Halffloat512VectorTests::strictTAN); + } + + static short SINH(short a) { + return (short)(scalar_sinh(a)); + } + + static short strictSINH(short a) { + return (short)(strict_scalar_sinh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::SINH, Halffloat512VectorTests::strictSINH); + } + + static short COSH(short a) { + return (short)(scalar_cosh(a)); + } + + static short strictCOSH(short a) { + return (short)(strict_scalar_cosh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::COSH, Halffloat512VectorTests::strictCOSH); + } + + static short TANH(short a) { + return (short)(scalar_tanh(a)); + } + + static short strictTANH(short a) { + return (short)(strict_scalar_tanh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::TANH, Halffloat512VectorTests::strictTANH); + } + + static short ASIN(short a) { + return (short)(scalar_asin(a)); + } + + static short strictASIN(short a) { + return (short)(strict_scalar_asin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ASIN, Halffloat512VectorTests::strictASIN); + } + + static short ACOS(short a) { + return (short)(scalar_acos(a)); + } + + static short strictACOS(short a) { + return (short)(strict_scalar_acos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ACOS, Halffloat512VectorTests::strictACOS); + } + + static short ATAN(short a) { + return (short)(scalar_atan(a)); + } + + static short strictATAN(short a) { + return (short)(strict_scalar_atan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::ATAN, Halffloat512VectorTests::strictATAN); + } + + static short CBRT(short a) { + return (short)(scalar_cbrt(a)); + } + + static short strictCBRT(short a) { + return (short)(strict_scalar_cbrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat512VectorTests::CBRT, Halffloat512VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return (short)(scalar_hypot(a, b)); + } + + static short strictHYPOT(short a, short b) { + return (short)(strict_scalar_hypot(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::HYPOT, Halffloat512VectorTests::strictHYPOT); + } + + + static short POW(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictPOW(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::POW, Halffloat512VectorTests::strictPOW); + } + + + static short pow(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictpow(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::pow, Halffloat512VectorTests::strictpow); + } + + + static short ATAN2(short a, short b) { + return (short)(scalar_atan2(a, b)); + } + + static short strictATAN2(short a, short b) { + return (short)(strict_scalar_atan2(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::ATAN2, Halffloat512VectorTests::strictATAN2); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::POW, Halffloat512VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::pow, Halffloat512VectorTests::strictpow); + } + + + static short FMA(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + static short fma(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat512VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat512VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat512VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::ATAN2, Halffloat512VectorTests::strictATAN2); + assertArraysEquals(r, a, b, c, mask, Halffloat512VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } + assertBroadcastArraysEquals(r, a, b, c, Halffloat512VectorTests::FMA); + } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::POW, Halffloat512VectorTests::strictPOW); + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat512VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); + } + assertAltBroadcastArraysEquals(r, a, b, c, Halffloat512VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, c, mask, Halffloat512VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat512VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.pow(b[i]).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat512VectorTests::pow, Halffloat512VectorTests::strictpow); + assertAltBroadcastArraysEquals(r, a, b, c, mask, Halffloat512VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short blend(short a, short b, boolean mask) { - return mask ? b : a; + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat512VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendHalffloat512VectorTests(IntFunction fa, IntFunction fb, - IntFunction fm) { + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat512VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.fma(b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat512VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Halffloat512VectorTests::FMA); + } + + static short NEG(short a) { + return (short)(scalar_neg((short)a)); + } + + static short neg(short a) { + return (short)(scalar_neg((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.blend(bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat512VectorTests::blend); + assertArraysEquals(r, a, Halffloat512VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat512VectorTests::NEG); + } + + static short ABS(short a) { + return (short)(scalar_abs((short)a)); + } + + static short abs(short a) { + return (short)(scalar_abs((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat512VectorTests::ABS); + } + + static short SQRT(short a) { + return (short)(scalar_sqrt(a)); + } + + static short sqrt(short a) { + return (short)(scalar_sqrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat512VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat512VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat512VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat512VectorTests::SQRT); } @Test(dataProvider = "shortCompareOpProvider") @@ -2661,7 +5091,7 @@ static void ltHalffloat512VectorTestsBroadcastSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -2677,7 +5107,7 @@ static void eqHalffloat512VectorTestsBroadcastMaskedSmokeTest(IntFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java b/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java index 4e4b36ac82c61..06b616dcabc7f 100644 --- a/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Halffloat64VectorTests.java @@ -40,6 +40,7 @@ import jdk.incubator.vector.Vector; import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; import jdk.incubator.vector.HalffloatVector; import org.testng.Assert; @@ -197,13 +198,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -225,13 +226,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -380,7 +381,7 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + wrapped_index = Math.floorMod(shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -397,7 +398,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); AssertEquals(r[i+j], a[i+wrapped_index]); } @@ -433,7 +434,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) AssertEquals(r[i+j], a[i+wrapped_index]); @@ -858,8 +859,8 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s static boolean isWithin1Ulp(short actual, short expected) { - Float16 act = Float16.shortBitsToFloat16(actual); - Float16 exp = Float16.shortBitsToFloat16(expected); + Float16 act = shortBitsToFloat16(actual); + Float16 exp = shortBitsToFloat16(expected); if (Float16.isNaN(exp) && !Float16.isNaN(act)) { return false; } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { @@ -885,11 +886,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FU try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -899,11 +900,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBin try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -914,14 +915,14 @@ static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[ try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1116,7 +1117,7 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } static short genValue(int i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static int intCornerCaseValue(int i) { @@ -1180,7 +1181,7 @@ static long longCornerCaseValue(int i) { } static short genValue(long i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static final List> LONG_HALFFLOAT_GENERATORS = List.of( @@ -1518,12 +1519,12 @@ static short[] fill(short[] a, ToHalffloatF f) { static short cornerCaseValue(int i) { return switch(i % 8) { - case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); - case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); - case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); - case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); - case 4 -> Float16.float16ToRawShortBits(Float16.NaN); - case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 0 -> float16ToShortBits(Float16.MAX_VALUE); + case 1 -> float16ToShortBits(Float16.MIN_VALUE); + case 2 -> float16ToShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> float16ToShortBits(Float16.POSITIVE_INFINITY); + case 4 -> float16ToShortBits(Float16.NaN); + case 5 -> float16ToShortBits(shortBitsToFloat16((short)0x7FFA)); case 6 -> ((short)0.0); default -> ((short)-0.0); }; @@ -1545,57 +1546,301 @@ static short cornerCaseValue(int i) { }; static boolean eq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() == bt.floatValue(); } static boolean neq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() != bt.floatValue(); } static boolean lt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() < bt.floatValue(); } static boolean le(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() <= bt.floatValue(); } static boolean gt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() > bt.floatValue(); } static boolean ge(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() >= bt.floatValue(); } static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 zero = shortBitsToFloat16((short)0); + return Float16.compare(at, zero) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)float16ToShortBits(Float16.valueOf(1.0f)); + } + + static short scalar_add(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.add(at, bt)); + } + + static short scalar_sub(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.subtract(at, bt)); + } + + static short scalar_mul(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.multiply(at, bt)); + + } + static short scalar_max(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.max(at, bt)); + } + + static short scalar_min(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.min(at, bt)); + } + + static short scalar_div(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.divide(at, bt)); + } + + static short scalar_fma(short a, short b, short c) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 ct = shortBitsToFloat16(c); + return float16ToShortBits(Float16.fma(at, bt, ct)); + } + + static short scalar_abs(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.abs(at)); + } + + static short scalar_neg(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.valueOf(-at.floatValue())); + } + + static short scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + static short additiveIdentity() { + return (short)0; + } + + + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return float16ToShortBits(Float16.POSITIVE_INFINITY); + } + + static short minValue() { + return float16ToShortBits(Float16.NEGATIVE_INFINITY); + } + + static boolean isNaN(short a) { + return Float16.isNaN(shortBitsToFloat16(a)); + } + static boolean isFinite(short a) { + return Float16.isFinite(shortBitsToFloat16(a)); + } + static boolean isInfinite(short a) { + return Float16.isInfinite(shortBitsToFloat16(a)); } @Test static void smokeTest1() { - HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); - HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three = HalffloatVector.broadcast(SPECIES, float16ToShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three2).allTrue()); - HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three3 = three2.broadcast(float16ToShortBits(Float16.valueOf(1))).broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three3).allTrue()); int scale = 2; HalffloatVector higher = three.addIndex(scale); VectorMask m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); - m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + m = higher.min((float16ToShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); m = higher.test(VectorOperators.IS_FINITE); assert(m.allTrue()); @@ -1672,7 +1917,7 @@ void viewAsFloatingLanesTest() { } static short ADD(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1692,6 +1937,25 @@ static void ADDHalffloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::add); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void ADDHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1712,8 +1976,26 @@ static void ADDHalffloat64VectorTestsMasked(IntFunction fa, IntFunction assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::ADD); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::add); + } + static short SUB(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1733,6 +2015,25 @@ static void SUBHalffloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::sub); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void SUBHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1753,8 +2054,26 @@ static void SUBHalffloat64VectorTestsMasked(IntFunction fa, IntFunction assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::SUB); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::sub); + } + static short MUL(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1774,6 +2093,25 @@ static void MULHalffloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::mul); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void MULHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1794,8 +2132,26 @@ static void MULHalffloat64VectorTestsMasked(IntFunction fa, IntFunction assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::MUL); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::mul); + } + static short DIV(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + return (short)(scalar_div(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1815,6 +2171,25 @@ static void DIVHalffloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::div); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void DIVHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1835,12 +2210,30 @@ static void DIVHalffloat64VectorTestsMasked(IntFunction fa, IntFunction assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::DIV); } - static short MAX(short a, short b) { - return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::div); + } + + static short FIRST_NONZERO(short a, short b) { + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROHalffloat64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1849,15 +2242,15 @@ static void MAXHalffloat64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void FIRST_NONZEROHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1869,36 +2262,29 @@ static void MAXHalffloat64VectorTestsMasked(IntFunction fa, IntFunction for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::MAX); - } - - static short MIN(short a, short b) { - return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + static void addHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, Halffloat64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MINHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + static void addHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1906,236 +2292,170 @@ static void MINHalffloat64VectorTestsMasked(IntFunction fa, IntFunction boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat64VectorTests::add); } - static short ABS(short a) { - return (short)(Math.abs(a)); - } + @Test(dataProvider = "shortBinaryOpProvider") + static void subHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short abs(short a) { - return (short)(Math.abs(a)); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void ABSHalffloat64VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS).intoArray(r, i); - } - } - - assertArraysEquals(r, a, Halffloat64VectorTests::ABS); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void absHalffloat64VectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.abs().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat64VectorTests::abs); + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedHalffloat64VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat64VectorTests::ABS); - } - - static short NEG(short a) { - return (short)(-a); - } - - static short neg(short a) { - return (short)(-a); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat64VectorTests::sub); } - @Test(dataProvider = "shortUnaryOpProvider") - static void NEGHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void mulHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat64VectorTests::NEG); + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpProvider") - static void negHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.neg().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, Halffloat64VectorTests::neg); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat64VectorTests::mul); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedHalffloat64VectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpProvider") + static void divHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - boolean[] mask = fm.apply(SPECIES.length()); - VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, mask, Halffloat64VectorTests::NEG); - } - - static short FMA(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); - } - - static short fma(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void FMAHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat64VectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, mask, Halffloat64VectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void fmaHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.fma(bv, cv).intoArray(r, i); + av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, c, Halffloat64VectorTests::fma); + assertBroadcastLongArraysEquals(r, a, b, Halffloat64VectorTests::ADD); } - @Test(dataProvider = "shortTernaryOpMaskProvider") - static void FMAHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, - IntFunction fc, IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloat64VectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, mask, Halffloat64VectorTests::FMA); - } - - static short SQRT(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); - } - - static short sqrt(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + assertBroadcastLongArraysEquals(r, a, b, mask, Halffloat64VectorTests::ADD); } @Test(dataProvider = "shortUnaryOpProvider") - static void SQRTHalffloat64VectorTests(IntFunction fa) { + static void MINHalffloat64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat64VectorTests::SQRT); + assertArraysEquals(r, a, (short)10, Halffloat64VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void sqrtHalffloat64VectorTests(IntFunction fa) { + static void minHalffloat64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.sqrt().intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, Halffloat64VectorTests::sqrt); + assertArraysEquals(r, a, (short)10, Halffloat64VectorTests::min); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void SQRTMaskedHalffloat64VectorTests(IntFunction fa, - IntFunction fm) { + static void MINHalffloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2144,510 +2464,2620 @@ static void SQRTMaskedHalffloat64VectorTests(IntFunction fa, for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, mask, Halffloat64VectorTests::SQRT); - } - - static short SIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); - } - - static short strictSIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat64VectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHalffloat64VectorTests(IntFunction fa) { + static void MAXHalffloat64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SIN).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::SIN, Halffloat64VectorTests::strictSIN); - } - - static short EXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); - } - - static short strictEXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat64VectorTests::MAX); } @Test(dataProvider = "shortUnaryOpProvider") - static void EXPHalffloat64VectorTests(IntFunction fa) { + static void maxHalffloat64VectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXP).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::EXP, Halffloat64VectorTests::strictEXP); - } - - static short LOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); - } - - static short strictLOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, Halffloat64VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG1PHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXHalffloat64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG1P, Halffloat64VectorTests::strictLOG1P); - } - - static short LOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, Halffloat64VectorTests::MAX); } - static short strictLOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + static short MIN(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOGHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG, Halffloat64VectorTests::strictLOG); - } - - static short LOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat64VectorTests::MIN); } - static short strictLOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + static short min(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG10Halffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG10).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.min(bv).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG10, Halffloat64VectorTests::strictLOG10); - } - - static short EXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, Halffloat64VectorTests::min); } - static short strictEXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + static short MAX(short a, short b) { + return (short)(scalar_max(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void EXPM1Halffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::EXPM1, Halffloat64VectorTests::strictEXPM1); + assertArraysEquals(r, a, b, Halffloat64VectorTests::MAX); } - static short COS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + static short max(short a, short b) { + return (short)(scalar_max(a, b)); } - static short strictCOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.max(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, Halffloat64VectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COS).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::COS, Halffloat64VectorTests::strictCOS); + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::MIN); } - static short TAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::min); } - static short strictTAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::MAX); } - @Test(dataProvider = "shortUnaryOpProvider") - static void TANHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TAN).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::TAN, Halffloat64VectorTests::strictTAN); + assertBroadcastArraysEquals(r, a, b, Halffloat64VectorTests::max); } - static short SINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + static short ADDReduce(short[] a, int idx) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_add(res, a[i]); + } + + return res; } - static short strictSINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + static short ADDReduceAll(short[] a) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHHalffloat64VectorTests(IntFunction fa) { + static void ADDReduceHalffloat64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SINH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::SINH, Halffloat64VectorTests::strictSINH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat64VectorTests::ADDReduce, Halffloat64VectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short COSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_add(res, a[i]); + } + + return res; } - static short strictCOSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + static short ADDReduceAllMasked(short[] a, boolean[] mask) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COSH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::COSH, Halffloat64VectorTests::strictCOSH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat64VectorTests::ADDReduceMasked, Halffloat64VectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short TANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + static short MULReduce(short[] a, int idx) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictTANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + static short MULReduceAll(short[] a) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void TANHHalffloat64VectorTests(IntFunction fa) { + static void MULReduceHalffloat64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TANH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::TANH, Halffloat64VectorTests::strictTANH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat64VectorTests::MULReduce, Halffloat64VectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + static short MULReduceMasked(short[] a, int idx, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + static short MULReduceAllMasked(short[] a, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ASINHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MULReduceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ASIN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ASIN, Halffloat64VectorTests::strictASIN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat64VectorTests::MULReduceMasked, Halffloat64VectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + static short MINReduce(short[] a, int idx) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_min(res, a[i]); + } + + return res; } - static short strictACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + static short MINReduceAll(short[] a) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ACOSHalffloat64VectorTests(IntFunction fa) { + static void MINReduceHalffloat64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ACOS).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ACOS, Halffloat64VectorTests::strictACOS); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat64VectorTests::MINReduce, Halffloat64VectorTests::MINReduceAll); } - static short ATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + static short MINReduceMasked(short[] a, int idx, boolean[] mask) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_min(res, a[i]); + } + + return res; } - static short strictATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + static short MINReduceAllMasked(short[] a, boolean[] mask) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ATANHalffloat64VectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MINReduceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ATAN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ATAN, Halffloat64VectorTests::strictATAN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat64VectorTests::MINReduceMasked, Halffloat64VectorTests::MINReduceAllMasked); } - static short CBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + static short MAXReduce(short[] a, int idx) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_max(res, a[i]); + } + + return res; } - static short strictCBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + static short MAXReduceAll(short[] a) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void CBRTHalffloat64VectorTests(IntFunction fa) { + static void MAXReduceHalffloat64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.CBRT).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX); } } - assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::CBRT, Halffloat64VectorTests::strictCBRT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat64VectorTests::MAXReduce, Halffloat64VectorTests::MAXReduceAll); } - static short HYPOT(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_max(res, a[i]); + } + + return res; } - static short strictHYPOT(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short MAXReduceAllMasked(short[] a, boolean[] mask) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void HYPOTHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXReduceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::HYPOT, Halffloat64VectorTests::strictHYPOT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat64VectorTests::MAXReduceMasked, Halffloat64VectorTests::MAXReduceAllMasked); } - static short POW(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduce(short[] a, int idx) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictPOW(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAll(short[] a) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpProvider") + static void FIRST_NONZEROReduceHalffloat64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::POW, Halffloat64VectorTests::strictPOW); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); + } + } + + assertReductionArraysEquals(r, ra, a, + Halffloat64VectorTests::FIRST_NONZEROReduce, Halffloat64VectorTests::FIRST_NONZEROReduceAll); } - static short pow(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictpow(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void FIRST_NONZEROReduceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.pow(bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::pow, Halffloat64VectorTests::strictpow); - } - - static short ATAN2(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); - } + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); + } + } - static short strictATAN2(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertReductionArraysEqualsMasked(r, ra, a, mask, + Halffloat64VectorTests::FIRST_NONZEROReduceMasked, Halffloat64VectorTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void ATAN2Halffloat64VectorTests(IntFunction fa, IntFunction fb) { + static void withHalffloat64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); + } + } + + + assertArraysStrictlyEquals(r, a); + } + + static boolean testIS_DEFAULT(short a) { + return bits(a)==0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_DEFAULTHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_DEFAULTMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + } + } + } + } + + static boolean testIS_NEGATIVE(short a) { + return bits(a)<0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NEGATIVEHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NEGATIVEMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + } + } + } + } + + static boolean testIS_FINITE(short a) { + return isFinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_FINITEHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_FINITEMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + } + } + } + } + + static boolean testIS_NAN(short a) { + return isNaN(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NANHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NANMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + } + } + } + } + + static boolean testIS_INFINITE(short a) { + return isInfinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_INFINITEHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_INFINITEMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.lt(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GTHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GTHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.eq(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void NEHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void NEHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LEHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LEHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GEHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GEHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(short)((long)b[i])))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloat64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloat64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(short)((long)b[i])))); + } + } + } + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloat64VectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::blend); + } + + @Test(dataProvider = "shortUnaryOpShuffleProvider") + static void RearrangeHalffloat64VectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); + } + } + + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") + static void RearrangeHalffloat64VectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); + } + + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void compressHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.compress(vmask).intoArray(r, i); + } + } + + assertcompressArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void expandHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.expand(vmask).intoArray(r, i); + } + } + + assertexpandArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void getHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int num_lanes = SPECIES.length(); + // Manually unroll because full unroll happens after intrinsification. + // Unroll is needed because get intrinsic requires for index to be a known constant. + if (num_lanes == 1) { + r[i]=av.lane(0); + } else if (num_lanes == 2) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + } else if (num_lanes == 4) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + } else if (num_lanes == 8) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + } else if (num_lanes == 16) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + } else if (num_lanes == 32) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + } else if (num_lanes == 64) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + r[i+32]=av.lane(32); + r[i+33]=av.lane(33); + r[i+34]=av.lane(34); + r[i+35]=av.lane(35); + r[i+36]=av.lane(36); + r[i+37]=av.lane(37); + r[i+38]=av.lane(38); + r[i+39]=av.lane(39); + r[i+40]=av.lane(40); + r[i+41]=av.lane(41); + r[i+42]=av.lane(42); + r[i+43]=av.lane(43); + r[i+44]=av.lane(44); + r[i+45]=av.lane(45); + r[i+46]=av.lane(46); + r[i+47]=av.lane(47); + r[i+48]=av.lane(48); + r[i+49]=av.lane(49); + r[i+50]=av.lane(50); + r[i+51]=av.lane(51); + r[i+52]=av.lane(52); + r[i+53]=av.lane(53); + r[i+54]=av.lane(54); + r[i+55]=av.lane(55); + r[i+56]=av.lane(56); + r[i+57]=av.lane(57); + r[i+58]=av.lane(58); + r[i+59]=av.lane(59); + r[i+60]=av.lane(60); + r[i+61]=av.lane(61); + r[i+62]=av.lane(62); + r[i+63]=av.lane(63); + } else { + for (int j = 0; j < SPECIES.length(); j++) { + r[i+j]=av.lane(j); + } + } + } + } + + assertArraysStrictlyEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void BroadcastHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, a[i]).intoArray(r, i); + } + } + + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ZeroHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.zero(SPECIES).intoArray(a, i); + } + } + + AssertEquals(a, r); + } + + static short[] sliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else + res[i] = (short)0; + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sliceUnaryHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.slice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat64VectorTests::sliceUnary); + } + + static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void sliceBinaryHalffloat64VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, Halffloat64VectorTests::sliceBinary); + } + + static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = mask[i] ? a[idx+i+origin] : (short)0; + else { + res[i] = mask[i] ? b[idx+j] : (short)0; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void sliceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, mask, Halffloat64VectorTests::slice); + } + + static short[] unsliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i < origin) + res[i] = (short)0; + else { + res[i] = a[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void unsliceUnaryHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.unslice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, Halffloat64VectorTests::unsliceUnary); + } + + static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (part == 0) { + if (i < origin) + res[i] = b[idx+i]; + else { + res[i] = a[idx+j]; + j++; + } + } else if (part == 1) { + if (i < origin) + res[i] = a[idx+SPECIES.length()-origin+i]; + else { + res[i] = b[idx+origin+j]; + j++; + } + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void unsliceBinaryHalffloat64VectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, Halffloat64VectorTests::unsliceBinary); + } + + static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = b[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + for (int i = 0; i < SPECIES.length(); i++){ + res[i] = mask[i] ? a[idx+i] : res[i]; + } + short[] res1 = new short[SPECIES.length()]; + if (part == 0) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = b[idx+i]; + else { + res1[i] = res[j]; + j++; + } + } + } else if (part == 1) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = res[SPECIES.length()-origin+i]; + else { + res1[i] = b[idx+origin+j]; + j++; + } + } + } + return res1; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void unsliceHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, mask, Halffloat64VectorTests::unslice); + } + + static short SIN(short a) { + return (short)(scalar_sin(a)); + } + + static short strictSIN(short a) { + return (short)(strict_scalar_sin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::SIN, Halffloat64VectorTests::strictSIN); + } + + static short EXP(short a) { + return (short)(scalar_exp(a)); + } + + static short strictEXP(short a) { + return (short)(strict_scalar_exp(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::EXP, Halffloat64VectorTests::strictEXP); + } + + static short LOG1P(short a) { + return (short)(scalar_log1p(a)); + } + + static short strictLOG1P(short a) { + return (short)(strict_scalar_log1p(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG1P, Halffloat64VectorTests::strictLOG1P); + } + + static short LOG(short a) { + return (short)(scalar_log(a)); + } + + static short strictLOG(short a) { + return (short)(strict_scalar_log(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG, Halffloat64VectorTests::strictLOG); + } + + static short LOG10(short a) { + return (short)(scalar_log10(a)); + } + + static short strictLOG10(short a) { + return (short)(strict_scalar_log10(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10Halffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::LOG10, Halffloat64VectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return (short)(scalar_expm1(a)); + } + + static short strictEXPM1(short a) { + return (short)(strict_scalar_expm1(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1Halffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::EXPM1, Halffloat64VectorTests::strictEXPM1); + } + + static short COS(short a) { + return (short)(scalar_cos(a)); + } + + static short strictCOS(short a) { + return (short)(strict_scalar_cos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::COS, Halffloat64VectorTests::strictCOS); + } + + static short TAN(short a) { + return (short)(scalar_tan(a)); + } + + static short strictTAN(short a) { + return (short)(strict_scalar_tan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::TAN, Halffloat64VectorTests::strictTAN); + } + + static short SINH(short a) { + return (short)(scalar_sinh(a)); + } + + static short strictSINH(short a) { + return (short)(strict_scalar_sinh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::SINH, Halffloat64VectorTests::strictSINH); + } + + static short COSH(short a) { + return (short)(scalar_cosh(a)); + } + + static short strictCOSH(short a) { + return (short)(strict_scalar_cosh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::COSH, Halffloat64VectorTests::strictCOSH); + } + + static short TANH(short a) { + return (short)(scalar_tanh(a)); + } + + static short strictTANH(short a) { + return (short)(strict_scalar_tanh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::TANH, Halffloat64VectorTests::strictTANH); + } + + static short ASIN(short a) { + return (short)(scalar_asin(a)); + } + + static short strictASIN(short a) { + return (short)(strict_scalar_asin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ASIN, Halffloat64VectorTests::strictASIN); + } + + static short ACOS(short a) { + return (short)(scalar_acos(a)); + } + + static short strictACOS(short a) { + return (short)(strict_scalar_acos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ACOS, Halffloat64VectorTests::strictACOS); + } + + static short ATAN(short a) { + return (short)(scalar_atan(a)); + } + + static short strictATAN(short a) { + return (short)(strict_scalar_atan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::ATAN, Halffloat64VectorTests::strictATAN); + } + + static short CBRT(short a) { + return (short)(scalar_cbrt(a)); + } + + static short strictCBRT(short a) { + return (short)(strict_scalar_cbrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, Halffloat64VectorTests::CBRT, Halffloat64VectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return (short)(scalar_hypot(a, b)); + } + + static short strictHYPOT(short a, short b) { + return (short)(strict_scalar_hypot(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::HYPOT, Halffloat64VectorTests::strictHYPOT); + } + + + static short POW(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictPOW(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::POW, Halffloat64VectorTests::strictPOW); + } + + + static short pow(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictpow(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::pow, Halffloat64VectorTests::strictpow); + } + + + static short ATAN2(short a, short b) { + return (short)(scalar_atan2(a, b)); + } + + static short strictATAN2(short a, short b) { + return (short)(strict_scalar_atan2(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2Halffloat64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::ATAN2, Halffloat64VectorTests::strictATAN2); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::POW, Halffloat64VectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::pow, Halffloat64VectorTests::strictpow); + } + + + static short FMA(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + static short fma(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, Halffloat64VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat64VectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, Halffloat64VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::ATAN2, Halffloat64VectorTests::strictATAN2); + assertArraysEquals(r, a, b, c, mask, Halffloat64VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } + assertBroadcastArraysEquals(r, a, b, c, Halffloat64VectorTests::FMA); + } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::POW, Halffloat64VectorTests::strictPOW); + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat64VectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); + } + assertAltBroadcastArraysEquals(r, a, b, c, Halffloat64VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, c, mask, Halffloat64VectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat64VectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.pow(b[i]).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Halffloat64VectorTests::pow, Halffloat64VectorTests::strictpow); + assertAltBroadcastArraysEquals(r, a, b, c, mask, Halffloat64VectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short blend(short a, short b, boolean mask) { - return mask ? b : a; + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat64VectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendHalffloat64VectorTests(IntFunction fa, IntFunction fb, - IntFunction fm) { + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloat64VectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.fma(b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, Halffloat64VectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloat64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Halffloat64VectorTests::FMA); + } + + static short NEG(short a) { + return (short)(scalar_neg((short)a)); + } + + static short neg(short a) { + return (short)(scalar_neg((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.blend(bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, Halffloat64VectorTests::blend); + assertArraysEquals(r, a, Halffloat64VectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat64VectorTests::NEG); + } + + static short ABS(short a) { + return (short)(scalar_abs((short)a)); + } + + static short abs(short a) { + return (short)(scalar_abs((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat64VectorTests::ABS); + } + + static short SQRT(short a) { + return (short)(scalar_sqrt(a)); + } + + static short sqrt(short a) { + return (short)(scalar_sqrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloat64VectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, Halffloat64VectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloat64VectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, Halffloat64VectorTests::SQRT); } @Test(dataProvider = "shortCompareOpProvider") @@ -2661,7 +5091,7 @@ static void ltHalffloat64VectorTestsBroadcastSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -2677,7 +5107,7 @@ static void eqHalffloat64VectorTestsBroadcastMaskedSmokeTest(IntFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java index 3655ccbab8800..a2feb83f1a552 100644 --- a/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/HalffloatMaxVectorTests.java @@ -40,6 +40,7 @@ import jdk.incubator.vector.Vector; import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; import jdk.incubator.vector.HalffloatVector; import org.testng.Assert; @@ -202,13 +203,13 @@ static void assertReductionArraysEquals(short[] r, short rc, short[] a, short relativeErrorFactor) { int i = 0; try { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor)))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor)))); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor)))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i), Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); + AssertEquals(rc, fa.apply(a), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))), "at index #" + i); } } @@ -230,13 +231,13 @@ static void assertReductionArraysEqualsMasked(short[] r, short rc, short[] a, bo short relativeError) { int i = 0; try { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError))))); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError))))); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError))))); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i, mask), Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))), "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))), "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))), "at index #" + i); } } @@ -385,7 +386,7 @@ static void assertSelectFromTwoVectorEquals(short[] r, short[] order, short[] a, for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod(Float16.shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); + wrapped_index = Math.floorMod(shortBitsToFloat16(order[idx]).intValue(), 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -402,7 +403,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, in try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); AssertEquals(r[i+j], a[i+wrapped_index]); } @@ -438,7 +439,7 @@ static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, bo try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = Float16.shortBitsToFloat16(order[i+j]).intValue(); + idx = shortBitsToFloat16(order[i+j]).intValue(); wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) AssertEquals(r[i+j], a[i+wrapped_index]); @@ -863,8 +864,8 @@ static void assertDoubleBroadcastArraysEquals(short[] r, short[] a, short[] b, s static boolean isWithin1Ulp(short actual, short expected) { - Float16 act = Float16.shortBitsToFloat16(actual); - Float16 exp = Float16.shortBitsToFloat16(expected); + Float16 act = shortBitsToFloat16(actual); + Float16 exp = shortBitsToFloat16(expected); if (Float16.isNaN(exp) && !Float16.isNaN(act)) { return false; } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { @@ -890,11 +891,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, FUnOp mathf, FU try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -904,11 +905,11 @@ static void assertArraysEqualsWithinOneUlp(short[] r, short[] a, short[] b, FBin try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), shortBitsToFloat16(mathf.apply(a[i], b[i]))) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -919,14 +920,14 @@ static void assertBroadcastArraysEqualsWithinOneUlp(short[] r, short[] a, short[ try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue(Float16.compare(Float16.shortBitsToFloat16(r[i]), - Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, + Assert.assertTrue(Float16.compare(shortBitsToFloat16(r[i]), + shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1121,7 +1122,7 @@ static void assertArraysEquals(short[] r, short[] a, short[] b, int origin, int } static short genValue(int i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static int intCornerCaseValue(int i) { @@ -1185,7 +1186,7 @@ static long longCornerCaseValue(int i) { } static short genValue(long i) { - return Float16.float16ToRawShortBits(Float16.valueOf(i)); + return float16ToShortBits(Float16.valueOf(i)); } static final List> LONG_HALFFLOAT_GENERATORS = List.of( @@ -1523,12 +1524,12 @@ static short[] fill(short[] a, ToHalffloatF f) { static short cornerCaseValue(int i) { return switch(i % 8) { - case 0 -> Float16.float16ToRawShortBits(Float16.MAX_VALUE); - case 1 -> Float16.float16ToRawShortBits(Float16.MIN_VALUE); - case 2 -> Float16.float16ToRawShortBits(Float16.NEGATIVE_INFINITY); - case 3 -> Float16.float16ToRawShortBits(Float16.POSITIVE_INFINITY); - case 4 -> Float16.float16ToRawShortBits(Float16.NaN); - case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 0 -> float16ToShortBits(Float16.MAX_VALUE); + case 1 -> float16ToShortBits(Float16.MIN_VALUE); + case 2 -> float16ToShortBits(Float16.NEGATIVE_INFINITY); + case 3 -> float16ToShortBits(Float16.POSITIVE_INFINITY); + case 4 -> float16ToShortBits(Float16.NaN); + case 5 -> float16ToShortBits(shortBitsToFloat16((short)0x7FFA)); case 6 -> ((short)0.0); default -> ((short)-0.0); }; @@ -1550,57 +1551,301 @@ static short cornerCaseValue(int i) { }; static boolean eq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() == bt.floatValue(); } static boolean neq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() != bt.floatValue(); } static boolean lt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() < bt.floatValue(); } static boolean le(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() <= bt.floatValue(); } static boolean gt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() > bt.floatValue(); } static boolean ge(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() >= bt.floatValue(); } static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 zero = shortBitsToFloat16((short)0); + return Float16.compare(at, zero) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)float16ToShortBits(Float16.valueOf(1.0f)); + } + + static short scalar_add(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.add(at, bt)); + } + + static short scalar_sub(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.subtract(at, bt)); + } + + static short scalar_mul(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.multiply(at, bt)); + + } + static short scalar_max(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.max(at, bt)); + } + + static short scalar_min(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.min(at, bt)); + } + + static short scalar_div(short a, short b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.divide(at, bt)); + } + + static short scalar_fma(short a, short b, short c) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 ct = shortBitsToFloat16(c); + return float16ToShortBits(Float16.fma(at, bt, ct)); + } + + static short scalar_abs(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.abs(at)); + } + + static short scalar_neg(short a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.valueOf(-at.floatValue())); + } + + static short scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_sin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_exp(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log1p(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_log10(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_expm1(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sinh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cosh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_tanh(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_asin(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_acos(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_atan(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_cbrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_sqrt(short a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static short strict_scalar_hypot(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_pow(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static short strict_scalar_atan2(short a, short b) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + static short additiveIdentity() { + return (short)0; + } + + + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return float16ToShortBits(Float16.POSITIVE_INFINITY); + } + + static short minValue() { + return float16ToShortBits(Float16.NEGATIVE_INFINITY); + } + + static boolean isNaN(short a) { + return Float16.isNaN(shortBitsToFloat16(a)); + } + static boolean isFinite(short a) { + return Float16.isFinite(shortBitsToFloat16(a)); + } + static boolean isInfinite(short a) { + return Float16.isInfinite(shortBitsToFloat16(a)); } @Test static void smokeTest1() { - HalffloatVector three = HalffloatVector.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); - HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three = HalffloatVector.broadcast(SPECIES, float16ToShortBits(Float16.valueOf(-3))); + HalffloatVector three2 = (HalffloatVector) SPECIES.broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three2).allTrue()); - HalffloatVector three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + HalffloatVector three3 = three2.broadcast(float16ToShortBits(Float16.valueOf(1))).broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three3).allTrue()); int scale = 2; HalffloatVector higher = three.addIndex(scale); VectorMask m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); - m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + m = higher.min((float16ToShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); m = higher.test(VectorOperators.IS_FINITE); assert(m.allTrue()); @@ -1677,7 +1922,7 @@ void viewAsFloatingLanesTest() { } static short ADD(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1697,6 +1942,25 @@ static void ADDHalffloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::add); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void ADDHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1717,8 +1981,26 @@ static void ADDHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::ADD); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void addHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.add(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::add); + } + static short SUB(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1738,6 +2020,25 @@ static void SUBHalffloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::sub); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void SUBHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1758,8 +2059,26 @@ static void SUBHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::SUB); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.sub(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::sub); + } + static short MUL(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) * Float.float16ToFloat(b))); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1779,6 +2098,25 @@ static void MULHalffloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::mul); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void MULHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1799,8 +2137,26 @@ static void MULHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::MUL); } + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.mul(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::mul); + } + static short DIV(short a, short b) { - return (short)(Float.floatToFloat16(Float.float16ToFloat(a) / Float.float16ToFloat(b))); + return (short)(scalar_div(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1820,6 +2176,25 @@ static void DIVHalffloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::div); + } + @Test(dataProvider = "shortBinaryOpMaskProvider") static void DIVHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { @@ -1840,12 +2215,30 @@ static void DIVHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunctio assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::DIV); } - static short MAX(short a, short b) { - return (short)(Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.div(bv, vmask).intoArray(r, i); + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::div); + } + + static short FIRST_NONZERO(short a, short b) { + return (short)(firstNonZero(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") - static void MAXHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void FIRST_NONZEROHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); @@ -1854,15 +2247,15 @@ static void MAXHalffloatMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void FIRST_NONZEROHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1874,36 +2267,29 @@ static void MAXHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MAX, bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::MAX); - } - - static short MIN(short a, short b) { - return (short)(Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::FIRST_NONZERO); } @Test(dataProvider = "shortBinaryOpProvider") - static void MINHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void addHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, HalffloatMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::add); } @Test(dataProvider = "shortBinaryOpMaskProvider") - static void MINHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void addHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -1911,236 +2297,170 @@ static void MINHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunctio boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.MIN, bv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.add(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::MIN); + assertBroadcastArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::add); } - static short ABS(short a) { - return (short)(Math.abs(a)); - } + @Test(dataProvider = "shortBinaryOpProvider") + static void subHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short abs(short a) { - return (short)(Math.abs(a)); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void ABSHalffloatMaxVectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS).intoArray(r, i); - } - } - - assertArraysEquals(r, a, HalffloatMaxVectorTests::ABS); - } - - @Test(dataProvider = "shortUnaryOpProvider") - static void absHalffloatMaxVectorTests(IntFunction fa) { - short[] a = fa.apply(SPECIES.length()); - short[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.abs().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, HalffloatMaxVectorTests::abs); + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::sub); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void ABSMaskedHalffloatMaxVectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void subHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sub(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::ABS); - } - - static short NEG(short a) { - return (short)(-a); - } - - static short neg(short a) { - return (short)(-a); + assertBroadcastArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::sub); } - @Test(dataProvider = "shortUnaryOpProvider") - static void NEGHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void mulHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, HalffloatMaxVectorTests::NEG); + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::mul); } - @Test(dataProvider = "shortUnaryOpProvider") - static void negHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void mulHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.neg().intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.mul(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, HalffloatMaxVectorTests::neg); + assertBroadcastArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::mul); } - @Test(dataProvider = "shortUnaryOpMaskProvider") - static void NEGMaskedHalffloatMaxVectorTests(IntFunction fa, - IntFunction fm) { + @Test(dataProvider = "shortBinaryOpProvider") + static void divHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - boolean[] mask = fm.apply(SPECIES.length()); - VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i]).intoArray(r, i); } - assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::NEG); - } - - static short FMA(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); - } - - static short fma(short a, short b, short c) { - return (short)(Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))); + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void FMAHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void divHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.div(b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, HalffloatMaxVectorTests::FMA); + assertBroadcastArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::div); } - @Test(dataProvider = "shortTernaryOpProvider") - static void fmaHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + @Test(dataProvider = "shortBinaryOpProvider") + static void ADDHalffloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.fma(bv, cv).intoArray(r, i); + av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i); } - assertArraysEquals(r, a, b, c, HalffloatMaxVectorTests::fma); + assertBroadcastLongArraysEquals(r, a, b, HalffloatMaxVectorTests::ADD); } - @Test(dataProvider = "shortTernaryOpMaskProvider") - static void FMAHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, - IntFunction fc, IntFunction fm) { + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void ADDHalffloatMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); - short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); - av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i); } - assertArraysEquals(r, a, b, c, mask, HalffloatMaxVectorTests::FMA); - } - - static short SQRT(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); - } - - static short sqrt(short a) { - return (short)(Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))); + assertBroadcastLongArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::ADD); } @Test(dataProvider = "shortUnaryOpProvider") - static void SQRTHalffloatMaxVectorTests(IntFunction fa) { + static void MINHalffloatMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, HalffloatMaxVectorTests::SQRT); + assertArraysEquals(r, a, (short)10, HalffloatMaxVectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void sqrtHalffloatMaxVectorTests(IntFunction fa) { + static void minHalffloatMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.sqrt().intoArray(r, i); + av.min(bcast_vec).intoArray(r, i); } } - assertArraysEquals(r, a, HalffloatMaxVectorTests::sqrt); + assertArraysEquals(r, a, (short)10, HalffloatMaxVectorTests::min); } @Test(dataProvider = "shortUnaryOpMaskProvider") - static void SQRTMaskedHalffloatMaxVectorTests(IntFunction fa, - IntFunction fm) { + static void MINHalffloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); @@ -2149,510 +2469,2620 @@ static void SQRTMaskedHalffloatMaxVectorTests(IntFunction fa, for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + av.lanewise(VectorOperators.MIN, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::SQRT); - } - - static short SIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sin(Float.float16ToFloat(a)))); - } - - static short strictSIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sin(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, HalffloatMaxVectorTests::MIN); } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHalffloatMaxVectorTests(IntFunction fa) { + static void MAXHalffloatMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SIN).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::SIN, HalffloatMaxVectorTests::strictSIN); - } - - static short EXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.exp(Float.float16ToFloat(a)))); - } - - static short strictEXP(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.exp(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, HalffloatMaxVectorTests::MAX); } @Test(dataProvider = "shortUnaryOpProvider") - static void EXPHalffloatMaxVectorTests(IntFunction fa) { + static void maxHalffloatMaxVectorTestsWithMemOp(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXP).intoArray(r, i); + av.max(bcast_vec).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::EXP, HalffloatMaxVectorTests::strictEXP); - } - - static short LOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log1p(Float.float16ToFloat(a)))); - } - - static short strictLOG1P(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log1p(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, HalffloatMaxVectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG1PHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXHalffloatMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + av.lanewise(VectorOperators.MAX, bcast_vec, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG1P, HalffloatMaxVectorTests::strictLOG1P); - } - - static short LOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, (short)10, mask, HalffloatMaxVectorTests::MAX); } - static short strictLOG(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log(Float.float16ToFloat(a)))); + static short MIN(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOGHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MIN, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG, HalffloatMaxVectorTests::strictLOG); - } - - static short LOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.log10(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::MIN); } - static short strictLOG10(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.log10(Float.float16ToFloat(a)))); + static short min(short a, short b) { + return (short)(scalar_min(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void LOG10HalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.LOG10).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.min(bv).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG10, HalffloatMaxVectorTests::strictLOG10); - } - - static short EXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.expm1(Float.float16ToFloat(a)))); + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::min); } - static short strictEXPM1(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.expm1(Float.float16ToFloat(a)))); + static short MAX(short a, short b) { + return (short)(scalar_max(a, b)); } - @Test(dataProvider = "shortUnaryOpProvider") - static void EXPM1HalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.MAX, bv).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::EXPM1, HalffloatMaxVectorTests::strictEXPM1); + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::MAX); } - static short COS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cos(Float.float16ToFloat(a)))); + static short max(short a, short b) { + return (short)(scalar_max(a, b)); } - static short strictCOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cos(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.max(bv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, HalffloatMaxVectorTests::max); } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void MINHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COS).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::COS, HalffloatMaxVectorTests::strictCOS); + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::MIN); } - static short TAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void minHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.min(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::min); } - static short strictTAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tan(Float.float16ToFloat(a)))); + @Test(dataProvider = "shortBinaryOpProvider") + static void MAXHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::MAX); } - @Test(dataProvider = "shortUnaryOpProvider") - static void TANHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortBinaryOpProvider") + static void maxHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TAN).intoArray(r, i); - } + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.max(b[i]).intoArray(r, i); } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::TAN, HalffloatMaxVectorTests::strictTAN); + assertBroadcastArraysEquals(r, a, b, HalffloatMaxVectorTests::max); } - static short SINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.sinh(Float.float16ToFloat(a)))); + static short ADDReduce(short[] a, int idx) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_add(res, a[i]); + } + + return res; } - static short strictSINH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.sinh(Float.float16ToFloat(a)))); + static short ADDReduceAll(short[] a) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void SINHHalffloatMaxVectorTests(IntFunction fa) { + static void ADDReduceHalffloatMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.SINH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::SINH, HalffloatMaxVectorTests::strictSINH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); + } + } + + assertReductionArraysEquals(r, ra, a, + HalffloatMaxVectorTests::ADDReduce, HalffloatMaxVectorTests::ADDReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short COSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cosh(Float.float16ToFloat(a)))); + static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { + short res = additiveIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_add(res, a[i]); + } + + return res; } - static short strictCOSH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cosh(Float.float16ToFloat(a)))); + static short ADDReduceAllMasked(short[] a, boolean[] mask) { + short res = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_add(res, ADDReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void COSHHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ADDReduceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.COSH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.ADD, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::COSH, HalffloatMaxVectorTests::strictCOSH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = additiveIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + HalffloatMaxVectorTests::ADDReduceMasked, HalffloatMaxVectorTests::ADDReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_ADD); } - static short TANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.tanh(Float.float16ToFloat(a)))); + static short MULReduce(short[] a, int idx) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictTANH(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.tanh(Float.float16ToFloat(a)))); + static short MULReduceAll(short[] a) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void TANHHalffloatMaxVectorTests(IntFunction fa) { + static void MULReduceHalffloatMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.TANH).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::TANH, HalffloatMaxVectorTests::strictTANH); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); + } + } + + assertReductionArraysEquals(r, ra, a, + HalffloatMaxVectorTests::MULReduce, HalffloatMaxVectorTests::MULReduceAll, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.asin(Float.float16ToFloat(a)))); + static short MULReduceMasked(short[] a, int idx, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_mul(res, a[i]); + } + + return res; } - static short strictASIN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.asin(Float.float16ToFloat(a)))); + static short MULReduceAllMasked(short[] a, boolean[] mask) { + short res = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_mul(res, MULReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ASINHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MULReduceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ASIN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MUL, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ASIN, HalffloatMaxVectorTests::strictASIN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = multiplicativeIdentity(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + HalffloatMaxVectorTests::MULReduceMasked, HalffloatMaxVectorTests::MULReduceAllMasked, RELATIVE_ROUNDING_ERROR_FACTOR_MUL); } - static short ACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.acos(Float.float16ToFloat(a)))); + static short MINReduce(short[] a, int idx) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_min(res, a[i]); + } + + return res; } - static short strictACOS(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.acos(Float.float16ToFloat(a)))); + static short MINReduceAll(short[] a) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void ACOSHalffloatMaxVectorTests(IntFunction fa) { + static void MINReduceHalffloatMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ACOS).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ACOS, HalffloatMaxVectorTests::strictACOS); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); + } + } + + assertReductionArraysEquals(r, ra, a, + HalffloatMaxVectorTests::MINReduce, HalffloatMaxVectorTests::MINReduceAll); } - static short ATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.atan(Float.float16ToFloat(a)))); + static short MINReduceMasked(short[] a, int idx, boolean[] mask) { + short res = maxValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_min(res, a[i]); + } + + return res; } - static short strictATAN(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan(Float.float16ToFloat(a)))); + static short MINReduceAllMasked(short[] a, boolean[] mask) { + short res = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_min(res, MINReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortUnaryOpProvider") - static void ATANHalffloatMaxVectorTests(IntFunction fa) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MINReduceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.ATAN).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MIN, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ATAN, HalffloatMaxVectorTests::strictATAN); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = maxValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + HalffloatMaxVectorTests::MINReduceMasked, HalffloatMaxVectorTests::MINReduceAllMasked); } - static short CBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Math.cbrt(Float.float16ToFloat(a)))); + static short MAXReduce(short[] a, int idx) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = scalar_max(res, a[i]); + } + + return res; } - static short strictCBRT(short a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.cbrt(Float.float16ToFloat(a)))); + static short MAXReduceAll(short[] a) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduce(a, i)); + } + + return res; } @Test(dataProvider = "shortUnaryOpProvider") - static void CBRTHalffloatMaxVectorTests(IntFunction fa) { + static void MAXReduceHalffloatMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.CBRT).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX); } } - assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::CBRT, HalffloatMaxVectorTests::strictCBRT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); + } + } + + assertReductionArraysEquals(r, ra, a, + HalffloatMaxVectorTests::MAXReduce, HalffloatMaxVectorTests::MAXReduceAll); } - static short HYPOT(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { + short res = minValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = scalar_max(res, a[i]); + } + + return res; } - static short strictHYPOT(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short MAXReduceAllMasked(short[] a, boolean[] mask) { + short res = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = scalar_max(res, MAXReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void HYPOTHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void MAXReduceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.MAX, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::HYPOT, HalffloatMaxVectorTests::strictHYPOT); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = minValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + } + } + + assertReductionArraysEqualsMasked(r, ra, a, mask, + HalffloatMaxVectorTests::MAXReduceMasked, HalffloatMaxVectorTests::MAXReduceAllMasked); } - static short POW(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduce(short[] a, int idx) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictPOW(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAll(short[] a) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpProvider") + static void FIRST_NONZEROReduceHalffloatMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO); } } - assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::POW, HalffloatMaxVectorTests::strictPOW); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); + } + } + + assertReductionArraysEquals(r, ra, a, + HalffloatMaxVectorTests::FIRST_NONZEROReduce, HalffloatMaxVectorTests::FIRST_NONZEROReduceAll); } - static short pow(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))))); + static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { + short res = zeroValue(); + for (int i = idx; i < (idx + SPECIES.length()); i++) { + if (mask[i % SPECIES.length()]) + res = firstNonZero(res, a[i]); + } + + return res; } - static short strictpow(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.pow(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { + short res = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); + } + + return res; } - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void FIRST_NONZEROReduceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); - short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.pow(bv).intoArray(r, i); + r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask); } } - assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::pow, HalffloatMaxVectorTests::strictpow); - } - - static short ATAN2(short a, short b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))))); - } + for (int ic = 0; ic < INVOC_COUNT; ic++) { + ra = zeroValue(); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); + } + } - static short strictATAN2(short a, short b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) StrictMath.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b)))); + assertReductionArraysEqualsMasked(r, ra, a, mask, + HalffloatMaxVectorTests::FIRST_NONZEROReduceMasked, HalffloatMaxVectorTests::FIRST_NONZEROReduceAllMasked); } @Test(dataProvider = "shortBinaryOpProvider") - static void ATAN2HalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + static void withHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { + for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); + } + } + + + assertArraysStrictlyEquals(r, a); + } + + static boolean testIS_DEFAULT(short a) { + return bits(a)==0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_DEFAULTHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_DEFAULTMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_DEFAULT, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + } + } + } + } + + static boolean testIS_NEGATIVE(short a) { + return bits(a)<0; + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NEGATIVEHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NEGATIVEMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NEGATIVE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + } + } + } + } + + static boolean testIS_FINITE(short a) { + return isFinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_FINITEHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_FINITEMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_FINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j])); + } + } + } + } + + static boolean testIS_NAN(short a) { + return isNaN(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_NANHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_NANMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_NAN, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j])); + } + } + } + } + + static boolean testIS_INFINITE(short a) { + return isInfinite(a); + } + + @Test(dataProvider = "shortTestOpProvider") + static void IS_INFINITEHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortTestOpMaskProvider") + static void IS_INFINITEMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.test(VectorOperators.IS_INFINITE, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void ltHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.lt(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GTHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GTHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GT, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void eqHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.eq(bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.EQ, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void NEHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void NEHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.NE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LEHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LEHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.LE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void GEHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void GEHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + VectorMask mv = av.compare(VectorOperators.GE, bv, vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + } + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void LTHalffloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void LTHalffloatMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.LT, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(short)((long)b[i])))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpProvider") + static void EQHalffloatMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i]); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); + } + } + } + + @Test(dataProvider = "shortCompareOpMaskProvider") + static void EQHalffloatMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, + IntFunction fb, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + VectorMask mv = av.compare(VectorOperators.EQ, (long)b[i], vmask); + + // Check results as part of computation. + for (int j = 0; j < SPECIES.length(); j++) { + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(short)((long)b[i])))); + } + } + } + + static short blend(short a, short b, boolean mask) { + return mask ? b : a; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void blendHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.blend(bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::blend); + } + + @Test(dataProvider = "shortUnaryOpShuffleProvider") + static void RearrangeHalffloatMaxVectorTests(IntFunction fa, + BiFunction fs) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i); + } + } + + assertRearrangeArraysEquals(r, a, order, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpShuffleMaskProvider") + static void RearrangeHalffloatMaxVectorTestsMaskedSmokeTest(IntFunction fa, + BiFunction fs, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + int[] order = fs.apply(a.length, SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i); + } + + assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void compressHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.compress(vmask).intoArray(r, i); + } + } + + assertcompressArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void expandHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.expand(vmask).intoArray(r, i); + } + } + + assertexpandArraysEquals(r, a, mask, SPECIES.length()); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void getHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + int num_lanes = SPECIES.length(); + // Manually unroll because full unroll happens after intrinsification. + // Unroll is needed because get intrinsic requires for index to be a known constant. + if (num_lanes == 1) { + r[i]=av.lane(0); + } else if (num_lanes == 2) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + } else if (num_lanes == 4) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + } else if (num_lanes == 8) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + } else if (num_lanes == 16) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + } else if (num_lanes == 32) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + } else if (num_lanes == 64) { + r[i]=av.lane(0); + r[i+1]=av.lane(1); + r[i+2]=av.lane(2); + r[i+3]=av.lane(3); + r[i+4]=av.lane(4); + r[i+5]=av.lane(5); + r[i+6]=av.lane(6); + r[i+7]=av.lane(7); + r[i+8]=av.lane(8); + r[i+9]=av.lane(9); + r[i+10]=av.lane(10); + r[i+11]=av.lane(11); + r[i+12]=av.lane(12); + r[i+13]=av.lane(13); + r[i+14]=av.lane(14); + r[i+15]=av.lane(15); + r[i+16]=av.lane(16); + r[i+17]=av.lane(17); + r[i+18]=av.lane(18); + r[i+19]=av.lane(19); + r[i+20]=av.lane(20); + r[i+21]=av.lane(21); + r[i+22]=av.lane(22); + r[i+23]=av.lane(23); + r[i+24]=av.lane(24); + r[i+25]=av.lane(25); + r[i+26]=av.lane(26); + r[i+27]=av.lane(27); + r[i+28]=av.lane(28); + r[i+29]=av.lane(29); + r[i+30]=av.lane(30); + r[i+31]=av.lane(31); + r[i+32]=av.lane(32); + r[i+33]=av.lane(33); + r[i+34]=av.lane(34); + r[i+35]=av.lane(35); + r[i+36]=av.lane(36); + r[i+37]=av.lane(37); + r[i+38]=av.lane(38); + r[i+39]=av.lane(39); + r[i+40]=av.lane(40); + r[i+41]=av.lane(41); + r[i+42]=av.lane(42); + r[i+43]=av.lane(43); + r[i+44]=av.lane(44); + r[i+45]=av.lane(45); + r[i+46]=av.lane(46); + r[i+47]=av.lane(47); + r[i+48]=av.lane(48); + r[i+49]=av.lane(49); + r[i+50]=av.lane(50); + r[i+51]=av.lane(51); + r[i+52]=av.lane(52); + r[i+53]=av.lane(53); + r[i+54]=av.lane(54); + r[i+55]=av.lane(55); + r[i+56]=av.lane(56); + r[i+57]=av.lane(57); + r[i+58]=av.lane(58); + r[i+59]=av.lane(59); + r[i+60]=av.lane(60); + r[i+61]=av.lane(61); + r[i+62]=av.lane(62); + r[i+63]=av.lane(63); + } else { + for (int j = 0; j < SPECIES.length(); j++) { + r[i+j]=av.lane(j); + } + } + } + } + + assertArraysStrictlyEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void BroadcastHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.broadcast(SPECIES, a[i]).intoArray(r, i); + } + } + + assertBroadcastArraysEquals(r, a); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ZeroHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector.zero(SPECIES).intoArray(a, i); + } + } + + AssertEquals(a, r); + } + + static short[] sliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else + res[i] = (short)0; + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sliceUnaryHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.slice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, HalffloatMaxVectorTests::sliceUnary); + } + + static short[] sliceBinary(short[] a, short[] b, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = a[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void sliceBinaryHalffloatMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, HalffloatMaxVectorTests::sliceBinary); + } + + static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = mask[i] ? a[idx+i+origin] : (short)0; + else { + res[i] = mask[i] ? b[idx+j] : (short)0; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void sliceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.slice(origin, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, mask, HalffloatMaxVectorTests::slice); + } + + static short[] unsliceUnary(short[] a, int origin, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i < origin) + res[i] = (short)0; + else { + res[i] = a[idx+j]; + j++; + } + } + return res; + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void unsliceUnaryHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.unslice(origin).intoArray(r, i); + } + } + + assertArraysEquals(r, a, origin, HalffloatMaxVectorTests::unsliceUnary); + } + + static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (part == 0) { + if (i < origin) + res[i] = b[idx+i]; + else { + res[i] = a[idx+j]; + j++; + } + } else if (part == 1) { + if (i < origin) + res[i] = a[idx+SPECIES.length()-origin+i]; + else { + res[i] = b[idx+origin+j]; + j++; + } + } + } + return res; + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void unsliceBinaryHalffloatMaxVectorTestsBinary(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, HalffloatMaxVectorTests::unsliceBinary); + } + + static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) { + short[] res = new short[SPECIES.length()]; + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if(i+origin < SPECIES.length()) + res[i] = b[idx+i+origin]; + else { + res[i] = b[idx+j]; + j++; + } + } + for (int i = 0; i < SPECIES.length(); i++){ + res[i] = mask[i] ? a[idx+i] : res[i]; + } + short[] res1 = new short[SPECIES.length()]; + if (part == 0) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = b[idx+i]; + else { + res1[i] = res[j]; + j++; + } + } + } else if (part == 1) { + for (int i = 0, j = 0; i < SPECIES.length(); i++){ + if (i < origin) + res1[i] = res[SPECIES.length()-origin+i]; + else { + res1[i] = b[idx+origin+j]; + j++; + } + } + } + return res1; + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void unsliceHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + short[] r = new short[a.length]; + int origin = RAND.nextInt(SPECIES.length()); + int part = RAND.nextInt(2); + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.unslice(origin, bv, part, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, origin, part, mask, HalffloatMaxVectorTests::unslice); + } + + static short SIN(short a) { + return (short)(scalar_sin(a)); + } + + static short strictSIN(short a) { + return (short)(strict_scalar_sin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::SIN, HalffloatMaxVectorTests::strictSIN); + } + + static short EXP(short a) { + return (short)(scalar_exp(a)); + } + + static short strictEXP(short a) { + return (short)(strict_scalar_exp(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXP).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::EXP, HalffloatMaxVectorTests::strictEXP); + } + + static short LOG1P(short a) { + return (short)(scalar_log1p(a)); + } + + static short strictLOG1P(short a) { + return (short)(strict_scalar_log1p(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG1PHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG1P).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG1P, HalffloatMaxVectorTests::strictLOG1P); + } + + static short LOG(short a) { + return (short)(scalar_log(a)); + } + + static short strictLOG(short a) { + return (short)(strict_scalar_log(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOGHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG, HalffloatMaxVectorTests::strictLOG); + } + + static short LOG10(short a) { + return (short)(scalar_log10(a)); + } + + static short strictLOG10(short a) { + return (short)(strict_scalar_log10(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void LOG10HalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.LOG10).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::LOG10, HalffloatMaxVectorTests::strictLOG10); + } + + static short EXPM1(short a) { + return (short)(scalar_expm1(a)); + } + + static short strictEXPM1(short a) { + return (short)(strict_scalar_expm1(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void EXPM1HalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.EXPM1).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::EXPM1, HalffloatMaxVectorTests::strictEXPM1); + } + + static short COS(short a) { + return (short)(scalar_cos(a)); + } + + static short strictCOS(short a) { + return (short)(strict_scalar_cos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::COS, HalffloatMaxVectorTests::strictCOS); + } + + static short TAN(short a) { + return (short)(scalar_tan(a)); + } + + static short strictTAN(short a) { + return (short)(strict_scalar_tan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::TAN, HalffloatMaxVectorTests::strictTAN); + } + + static short SINH(short a) { + return (short)(scalar_sinh(a)); + } + + static short strictSINH(short a) { + return (short)(strict_scalar_sinh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SINHHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SINH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::SINH, HalffloatMaxVectorTests::strictSINH); + } + + static short COSH(short a) { + return (short)(scalar_cosh(a)); + } + + static short strictCOSH(short a) { + return (short)(strict_scalar_cosh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void COSHHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.COSH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::COSH, HalffloatMaxVectorTests::strictCOSH); + } + + static short TANH(short a) { + return (short)(scalar_tanh(a)); + } + + static short strictTANH(short a) { + return (short)(strict_scalar_tanh(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void TANHHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.TANH).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::TANH, HalffloatMaxVectorTests::strictTANH); + } + + static short ASIN(short a) { + return (short)(scalar_asin(a)); + } + + static short strictASIN(short a) { + return (short)(strict_scalar_asin(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ASINHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ASIN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ASIN, HalffloatMaxVectorTests::strictASIN); + } + + static short ACOS(short a) { + return (short)(scalar_acos(a)); + } + + static short strictACOS(short a) { + return (short)(strict_scalar_acos(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ACOSHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ACOS).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ACOS, HalffloatMaxVectorTests::strictACOS); + } + + static short ATAN(short a) { + return (short)(scalar_atan(a)); + } + + static short strictATAN(short a) { + return (short)(strict_scalar_atan(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ATANHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ATAN).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::ATAN, HalffloatMaxVectorTests::strictATAN); + } + + static short CBRT(short a) { + return (short)(scalar_cbrt(a)); + } + + static short strictCBRT(short a) { + return (short)(strict_scalar_cbrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void CBRTHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.CBRT).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, HalffloatMaxVectorTests::CBRT, HalffloatMaxVectorTests::strictCBRT); + } + + static short HYPOT(short a, short b) { + return (short)(scalar_hypot(a, b)); + } + + static short strictHYPOT(short a, short b) { + return (short)(strict_scalar_hypot(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void HYPOTHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::HYPOT, HalffloatMaxVectorTests::strictHYPOT); + } + + + static short POW(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictPOW(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.POW, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::POW, HalffloatMaxVectorTests::strictPOW); + } + + + static short pow(short a, short b) { + return (short)(scalar_pow(a, b)); + } + + static short strictpow(short a, short b) { + return (short)(strict_scalar_pow(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.pow(bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::pow, HalffloatMaxVectorTests::strictpow); + } + + + static short ATAN2(short a, short b) { + return (short)(scalar_atan2(a, b)); + } + + static short strictATAN2(short a, short b) { + return (short)(strict_scalar_atan2(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void ATAN2HalffloatMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + } + } + + assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::ATAN2, HalffloatMaxVectorTests::strictATAN2); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void POWHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::POW, HalffloatMaxVectorTests::strictPOW); + } + + + @Test(dataProvider = "shortBinaryOpProvider") + static void powHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.pow(b[i]).intoArray(r, i); + } + + assertBroadcastArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::pow, HalffloatMaxVectorTests::strictpow); + } + + + static short FMA(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + static short fma(short a, short b, short c) { + return (short)(scalar_fma(a, b, c)); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, c, HalffloatMaxVectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.fma(bv, cv).intoArray(r, i); + } + + assertArraysEquals(r, a, b, c, HalffloatMaxVectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloatMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i); } } - assertArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::ATAN2, HalffloatMaxVectorTests::strictATAN2); + assertArraysEquals(r, a, b, c, mask, HalffloatMaxVectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpProvider") - static void POWHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i); } + assertBroadcastArraysEquals(r, a, b, c, HalffloatMaxVectorTests::FMA); + } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::POW, HalffloatMaxVectorTests::strictPOW); + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloatMaxVectorTestsAltBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i); + } + assertAltBroadcastArraysEquals(r, a, b, c, HalffloatMaxVectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - @Test(dataProvider = "shortBinaryOpProvider") - static void powHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i); + } + + assertBroadcastArraysEquals(r, a, b, c, mask, HalffloatMaxVectorTests::FMA); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloatMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - av.pow(b[i]).intoArray(r, i); + HalffloatVector cv = HalffloatVector.fromArray(SPECIES, c, i); + av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i); } - assertBroadcastArraysEqualsWithinOneUlp(r, a, b, HalffloatMaxVectorTests::pow, HalffloatMaxVectorTests::strictpow); + assertAltBroadcastArraysEquals(r, a, b, c, mask, HalffloatMaxVectorTests::FMA); } + @Test(dataProvider = "shortTernaryOpProvider") + static void FMAHalffloatMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); - static short blend(short a, short b, boolean mask) { - return mask ? b : a; + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, HalffloatMaxVectorTests::FMA); } - @Test(dataProvider = "shortBinaryOpMaskProvider") - static void blendHalffloatMaxVectorTests(IntFunction fa, IntFunction fb, - IntFunction fm) { + @Test(dataProvider = "shortTernaryOpProvider") + static void fmaHalffloatMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction fa, IntFunction fb, IntFunction fc) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.fma(b[i], c[i]).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, HalffloatMaxVectorTests::fma); + } + + @Test(dataProvider = "shortTernaryOpMaskProvider") + static void FMAHalffloatMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction fa, IntFunction fb, + IntFunction fc, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); + short[] c = fc.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i); + } + + assertDoubleBroadcastArraysEquals(r, a, b, c, mask, HalffloatMaxVectorTests::FMA); + } + + static short NEG(short a) { + return (short)(scalar_neg((short)a)); + } + + static short neg(short a) { + return (short)(scalar_neg((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void NEGHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); - HalffloatVector bv = HalffloatVector.fromArray(SPECIES, b, i); - av.blend(bv, vmask).intoArray(r, i); + av.lanewise(VectorOperators.NEG).intoArray(r, i); } } - assertArraysEquals(r, a, b, mask, HalffloatMaxVectorTests::blend); + assertArraysEquals(r, a, HalffloatMaxVectorTests::NEG); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void negHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.neg().intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::neg); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void NEGMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::NEG); + } + + static short ABS(short a) { + return (short)(scalar_abs((short)a)); + } + + static short abs(short a) { + return (short)(scalar_abs((short)a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void ABSHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS).intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::ABS); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void absHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.abs().intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::abs); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void ABSMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::ABS); + } + + static short SQRT(short a) { + return (short)(scalar_sqrt(a)); + } + + static short sqrt(short a) { + return (short)(scalar_sqrt(a)); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void SQRTHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT).intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::SQRT); + } + + @Test(dataProvider = "shortUnaryOpProvider") + static void sqrtHalffloatMaxVectorTests(IntFunction fa) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.sqrt().intoArray(r, i); + } + } + + assertArraysEquals(r, a, HalffloatMaxVectorTests::sqrt); + } + + @Test(dataProvider = "shortUnaryOpMaskProvider") + static void SQRTMaskedHalffloatMaxVectorTests(IntFunction fa, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + HalffloatVector av = HalffloatVector.fromArray(SPECIES, a, i); + av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, mask, HalffloatMaxVectorTests::SQRT); } @Test(dataProvider = "shortCompareOpProvider") @@ -2666,7 +5096,7 @@ static void ltHalffloatMaxVectorTestsBroadcastSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -2682,7 +5112,7 @@ static void eqHalffloatMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index 19454bb8555bd..b32161028aee7 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -1060,15 +1060,15 @@ static int bits(int e) { } static final List> INT_GENERATORS = List.of( - withToString("int[-i * 5]", (int s) -> { + withToString("Integer[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("int[i * 5]", (int s) -> { + withToString("Integer[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("int[i + 1]", (int s) -> { + withToString("Integer[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1484,6 +1484,218 @@ static boolean ge(int a, int b) { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int multiplicativeIdentity() { + return (int)1; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static int scalar_sin(int a) { + return (int)Math.sin((double)a); + } + + static int scalar_exp(int a) { + return (int)Math.exp((double)a); + } + + static int scalar_log1p(int a) { + return (int)Math.log1p((double)a); + } + + static int scalar_log(int a) { + return (int)Math.log((double)a); + } + + static int scalar_log10(int a) { + return (int)Math.log10((double)a); + } + + static int scalar_expm1(int a) { + return (int)Math.expm1((double)a); + } + + static int scalar_cos(int a) { + return (int)Math.cos((double)a); + } + + static int scalar_tan(int a) { + return (int)Math.tan((double)a); + } + + static int scalar_sinh(int a) { + return (int)Math.sinh((double)a); + } + + static int scalar_cosh(int a) { + return (int)Math.cosh((double)a); + } + + static int scalar_tanh(int a) { + return (int)Math.tanh((double)a); + } + + static int scalar_asin(int a) { + return (int)Math.asin((double)a); + } + + static int scalar_acos(int a) { + return (int)Math.acos((double)a); + } + + static int scalar_atan(int a) { + return (int)Math.atan((double)a); + } + + static int scalar_cbrt(int a) { + return (int)Math.cbrt((double)a); + } + + static int scalar_sqrt(int a) { + return (int)Math.sqrt((double)a); + } + + static int scalar_hypot(int a, int b) { + return (int)Math.hypot((double)a, (double)b); + } + + static int scalar_pow(int a, int b) { + return (int)Math.pow((double)a, (double)b); + } + + static int scalar_atan2(int a, int b) { + return (int)Math.atan2((double)a, (double)b); + } + + static int strict_scalar_sin(int a) { + return (int)StrictMath.sin((double)a); + } + + static int strict_scalar_exp(int a) { + return (int)StrictMath.exp((double)a); + } + + static int strict_scalar_log1p(int a) { + return (int)StrictMath.log1p((double)a); + } + + static int strict_scalar_log(int a) { + return (int)StrictMath.log((double)a); + } + + static int strict_scalar_log10(int a) { + return (int)StrictMath.log10((double)a); + } + + static int strict_scalar_expm1(int a) { + return (int)StrictMath.expm1((double)a); + } + + static int strict_scalar_cos(int a) { + return (int)StrictMath.cos((double)a); + } + + static int strict_scalar_tan(int a) { + return (int)StrictMath.tan((double)a); + } + + static int strict_scalar_sinh(int a) { + return (int)StrictMath.sinh((double)a); + } + + static int strict_scalar_cosh(int a) { + return (int)StrictMath.cosh((double)a); + } + + static int strict_scalar_tanh(int a) { + return (int)StrictMath.tanh((double)a); + } + + static int strict_scalar_asin(int a) { + return (int)StrictMath.asin((double)a); + } + + static int strict_scalar_acos(int a) { + return (int)StrictMath.acos((double)a); + } + + static int strict_scalar_atan(int a) { + return (int)StrictMath.atan((double)a); + } + + static int strict_scalar_cbrt(int a) { + return (int)StrictMath.cbrt((double)a); + } + + static int strict_scalar_sqrt(int a) { + return (int)StrictMath.sqrt((double)a); + } + + static int strict_scalar_hypot(int a, int b) { + return (int)StrictMath.hypot((double)a, (double)b); + } + + static int strict_scalar_pow(int a, int b) { + return (int)StrictMath.pow((double)a, (double)b); + } + + static int strict_scalar_atan2(int a, int b) { + return (int)StrictMath.atan2((double)a, (double)b); + } + static int additiveIdentity() { + return (int)0; + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1500,10 +1712,19 @@ static boolean uge(int a, int b) { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; + static int zeroValue() { + return (short) 0; + } + + static int maxValue() { + return Integer.MAX_VALUE; + } + + static int minValue() { + return Integer.MIN_VALUE; } + @Test static void smokeTest1() { IntVector three = IntVector.broadcast(SPECIES, (byte)-3); @@ -1616,7 +1837,7 @@ static void bitwiseDivByZeroSmokeTest() { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1637,7 +1858,7 @@ static void ADDInt128VectorTests(IntFunction fa, IntFunction fb) { } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1694,7 +1915,7 @@ static void addInt128VectorTestsMasked(IntFunction fa, IntFunction } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1715,7 +1936,7 @@ static void SUBInt128VectorTests(IntFunction fa, IntFunction fb) { } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1772,7 +1993,7 @@ static void subInt128VectorTestsMasked(IntFunction fa, IntFunction } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1793,7 +2014,7 @@ static void MULInt128VectorTests(IntFunction fa, IntFunction fb) { } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1940,7 +2161,7 @@ static void divInt128VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3224,7 +3445,7 @@ static void MAXInt128VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3245,7 +3466,7 @@ static void MINInt128VectorTests(IntFunction fa, IntFunction fb) { } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3264,7 +3485,7 @@ static void minInt128VectorTests(IntFunction fa, IntFunction fb) { } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3285,7 +3506,7 @@ static void MAXInt128VectorTests(IntFunction fa, IntFunction fb) { } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3653,7 +3874,7 @@ static void SUADDAssocInt128VectorTestsMasked(IntFunction fa, IntFunction static int ANDReduce(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static int ANDReduce(int[] a, int idx) { static int ANDReduceAll(int[] a) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3685,7 +3906,7 @@ static void ANDReduceInt128VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3697,7 +3918,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3706,7 +3927,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3731,7 +3952,7 @@ static void ANDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3742,7 +3963,7 @@ static void ANDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< static int ORReduce(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static int ORReduce(int[] a, int idx) { static int ORReduceAll(int[] a) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3774,7 +3995,7 @@ static void ORReduceInt128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3786,7 +4007,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3795,7 +4016,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3820,7 +4041,7 @@ static void ORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3875,7 +4096,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3884,7 +4105,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3909,7 +4130,7 @@ static void XORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3918,18 +4139,18 @@ static void XORReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } static int ADDReduce(int[] a, int idx) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAll(int[] a) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3939,7 +4160,7 @@ static int ADDReduceAll(int[] a) { static void ADDReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3949,10 +4170,10 @@ static void ADDReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3961,19 +4182,19 @@ static void ADDReduceInt128VectorTests(IntFunction fa) { } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3985,7 +4206,7 @@ static void ADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3995,10 +4216,10 @@ static void ADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4007,18 +4228,18 @@ static void ADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } static int MULReduce(int[] a, int idx) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAll(int[] a) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4028,7 +4249,7 @@ static int MULReduceAll(int[] a) { static void MULReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4038,10 +4259,10 @@ static void MULReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4050,19 +4271,19 @@ static void MULReduceInt128VectorTests(IntFunction fa) { } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAllMasked(int[] a, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4074,7 +4295,7 @@ static void MULReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4084,10 +4305,10 @@ static void MULReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4096,18 +4317,18 @@ static void MULReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } static int MINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4117,7 +4338,7 @@ static int MINReduceAll(int[] a) { static void MINReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4127,10 +4348,10 @@ static void MINReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4139,19 +4360,19 @@ static void MINReduceInt128VectorTests(IntFunction fa) { } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4163,7 +4384,7 @@ static void MINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4173,10 +4394,10 @@ static void MINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4185,18 +4406,18 @@ static void MINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } static int MAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4206,7 +4427,7 @@ static int MAXReduceAll(int[] a) { static void MAXReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4216,10 +4437,10 @@ static void MAXReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4228,19 +4449,19 @@ static void MAXReduceInt128VectorTests(IntFunction fa) { } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4252,7 +4473,7 @@ static void MAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4262,10 +4483,10 @@ static void MAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4274,7 +4495,7 @@ static void MAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction< } static int UMINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.minUnsigned(res, a[i]); } @@ -4283,7 +4504,7 @@ static int UMINReduce(int[] a, int idx) { } static int UMINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4295,7 +4516,7 @@ static int UMINReduceAll(int[] a) { static void UMINReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4305,7 +4526,7 @@ static void UMINReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4317,7 +4538,7 @@ static void UMINReduceInt128VectorTests(IntFunction fa) { } static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.minUnsigned(res, a[i]); @@ -4327,7 +4548,7 @@ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4341,7 +4562,7 @@ static void UMINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4351,7 +4572,7 @@ static void UMINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4363,7 +4584,7 @@ static void UMINReduceInt128VectorTestsMasked(IntFunction fa, IntFunction } static int UMAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.maxUnsigned(res, a[i]); } @@ -4372,7 +4593,7 @@ static int UMAXReduce(int[] a, int idx) { } static int UMAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4384,7 +4605,7 @@ static int UMAXReduceAll(int[] a) { static void UMAXReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4394,7 +4615,7 @@ static void UMAXReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4406,7 +4627,7 @@ static void UMAXReduceInt128VectorTests(IntFunction fa) { } static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.maxUnsigned(res, a[i]); @@ -4416,7 +4637,7 @@ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4430,7 +4651,7 @@ static void UMAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4440,7 +4661,7 @@ static void UMAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4452,7 +4673,7 @@ static void UMAXReduceInt128VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZEROReduce(int[] a, int idx) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4461,7 +4682,7 @@ static int FIRST_NONZEROReduce(int[] a, int idx) { } static int FIRST_NONZEROReduceAll(int[] a) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4473,7 +4694,7 @@ static int FIRST_NONZEROReduceAll(int[] a) { static void FIRST_NONZEROReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4483,7 +4704,7 @@ static void FIRST_NONZEROReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4495,7 +4716,7 @@ static void FIRST_NONZEROReduceInt128VectorTests(IntFunction fa) { } static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4505,7 +4726,7 @@ static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { } static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4519,7 +4740,7 @@ static void FIRST_NONZEROReduceInt128VectorTestsMasked(IntFunction fa, In int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4529,7 +4750,7 @@ static void FIRST_NONZEROReduceInt128VectorTestsMasked(IntFunction fa, In } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4589,7 +4810,7 @@ static void allTrueInt128VectorTests(IntFunction fm) { } static int SUADDReduce(int[] a, int idx) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4598,7 +4819,7 @@ static int SUADDReduce(int[] a, int idx) { } static int SUADDReduceAll(int[] a) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4610,7 +4831,7 @@ static int SUADDReduceAll(int[] a) { static void SUADDReduceInt128VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4620,7 +4841,7 @@ static void SUADDReduceInt128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4632,7 +4853,7 @@ static void SUADDReduceInt128VectorTests(IntFunction fa) { } static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4642,7 +4863,7 @@ static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { } static int SUADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4655,7 +4876,7 @@ static void SUADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunctio int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4665,7 +4886,7 @@ static void SUADDReduceInt128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4710,7 +4931,7 @@ static void IS_DEFAULTInt128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4730,7 +4951,7 @@ static void IS_DEFAULTMaskedInt128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4751,7 +4972,7 @@ static void IS_NEGATIVEInt128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4771,7 +4992,7 @@ static void IS_NEGATIVEMaskedInt128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4790,7 +5011,7 @@ static void LTInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4809,7 +5030,7 @@ static void ltInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4832,7 +5053,7 @@ static void LTInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); } } } @@ -4851,7 +5072,7 @@ static void GTInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4874,7 +5095,7 @@ static void GTInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); } } } @@ -4893,7 +5114,7 @@ static void EQInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4912,7 +5133,7 @@ static void eqInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4935,7 +5156,7 @@ static void EQInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); } } } @@ -4954,7 +5175,7 @@ static void NEInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4977,7 +5198,7 @@ static void NEInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); } } } @@ -4996,7 +5217,7 @@ static void LEInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5019,7 +5240,7 @@ static void LEInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); } } } @@ -5038,7 +5259,7 @@ static void GEInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5061,7 +5282,7 @@ static void GEInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); } } } @@ -5080,7 +5301,7 @@ static void ULTInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5103,7 +5324,7 @@ static void ULTInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); } } } @@ -5122,7 +5343,7 @@ static void UGTInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5145,7 +5366,7 @@ static void UGTInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); } } } @@ -5164,7 +5385,7 @@ static void ULEInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5187,7 +5408,7 @@ static void ULEInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); } } } @@ -5206,7 +5427,7 @@ static void UGEInt128VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5229,7 +5450,7 @@ static void UGEInt128VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); } } } @@ -5246,7 +5467,7 @@ static void LTInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5266,7 +5487,7 @@ static void LTInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5282,7 +5503,7 @@ static void LTInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @@ -5302,7 +5523,7 @@ static void LTInt128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(int)((long)b[i])))); } } } @@ -5318,7 +5539,7 @@ static void EQInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5338,7 +5559,7 @@ static void EQInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5354,7 +5575,7 @@ static void EQInt128VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @@ -5374,7 +5595,7 @@ static void EQInt128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(int)((long)b[i])))); } } } @@ -5655,7 +5876,7 @@ static void ZeroInt128VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static int[] sliceUnary(int[] a, int origin, int idx) { @@ -6086,11 +6307,11 @@ static void BITWISE_BLENDInt128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunc } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6142,11 +6363,11 @@ static void NEGMaskedInt128VectorTests(IntFunction fa, } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6486,7 +6707,7 @@ static void ltInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6502,7 +6723,7 @@ static void eqInt128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6742,7 +6963,7 @@ static void shuffleMiscellaneousInt128VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index 6bd7b67938f13..6eb31f5f298d1 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -1060,15 +1060,15 @@ static int bits(int e) { } static final List> INT_GENERATORS = List.of( - withToString("int[-i * 5]", (int s) -> { + withToString("Integer[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("int[i * 5]", (int s) -> { + withToString("Integer[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("int[i + 1]", (int s) -> { + withToString("Integer[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1484,6 +1484,218 @@ static boolean ge(int a, int b) { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int multiplicativeIdentity() { + return (int)1; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static int scalar_sin(int a) { + return (int)Math.sin((double)a); + } + + static int scalar_exp(int a) { + return (int)Math.exp((double)a); + } + + static int scalar_log1p(int a) { + return (int)Math.log1p((double)a); + } + + static int scalar_log(int a) { + return (int)Math.log((double)a); + } + + static int scalar_log10(int a) { + return (int)Math.log10((double)a); + } + + static int scalar_expm1(int a) { + return (int)Math.expm1((double)a); + } + + static int scalar_cos(int a) { + return (int)Math.cos((double)a); + } + + static int scalar_tan(int a) { + return (int)Math.tan((double)a); + } + + static int scalar_sinh(int a) { + return (int)Math.sinh((double)a); + } + + static int scalar_cosh(int a) { + return (int)Math.cosh((double)a); + } + + static int scalar_tanh(int a) { + return (int)Math.tanh((double)a); + } + + static int scalar_asin(int a) { + return (int)Math.asin((double)a); + } + + static int scalar_acos(int a) { + return (int)Math.acos((double)a); + } + + static int scalar_atan(int a) { + return (int)Math.atan((double)a); + } + + static int scalar_cbrt(int a) { + return (int)Math.cbrt((double)a); + } + + static int scalar_sqrt(int a) { + return (int)Math.sqrt((double)a); + } + + static int scalar_hypot(int a, int b) { + return (int)Math.hypot((double)a, (double)b); + } + + static int scalar_pow(int a, int b) { + return (int)Math.pow((double)a, (double)b); + } + + static int scalar_atan2(int a, int b) { + return (int)Math.atan2((double)a, (double)b); + } + + static int strict_scalar_sin(int a) { + return (int)StrictMath.sin((double)a); + } + + static int strict_scalar_exp(int a) { + return (int)StrictMath.exp((double)a); + } + + static int strict_scalar_log1p(int a) { + return (int)StrictMath.log1p((double)a); + } + + static int strict_scalar_log(int a) { + return (int)StrictMath.log((double)a); + } + + static int strict_scalar_log10(int a) { + return (int)StrictMath.log10((double)a); + } + + static int strict_scalar_expm1(int a) { + return (int)StrictMath.expm1((double)a); + } + + static int strict_scalar_cos(int a) { + return (int)StrictMath.cos((double)a); + } + + static int strict_scalar_tan(int a) { + return (int)StrictMath.tan((double)a); + } + + static int strict_scalar_sinh(int a) { + return (int)StrictMath.sinh((double)a); + } + + static int strict_scalar_cosh(int a) { + return (int)StrictMath.cosh((double)a); + } + + static int strict_scalar_tanh(int a) { + return (int)StrictMath.tanh((double)a); + } + + static int strict_scalar_asin(int a) { + return (int)StrictMath.asin((double)a); + } + + static int strict_scalar_acos(int a) { + return (int)StrictMath.acos((double)a); + } + + static int strict_scalar_atan(int a) { + return (int)StrictMath.atan((double)a); + } + + static int strict_scalar_cbrt(int a) { + return (int)StrictMath.cbrt((double)a); + } + + static int strict_scalar_sqrt(int a) { + return (int)StrictMath.sqrt((double)a); + } + + static int strict_scalar_hypot(int a, int b) { + return (int)StrictMath.hypot((double)a, (double)b); + } + + static int strict_scalar_pow(int a, int b) { + return (int)StrictMath.pow((double)a, (double)b); + } + + static int strict_scalar_atan2(int a, int b) { + return (int)StrictMath.atan2((double)a, (double)b); + } + static int additiveIdentity() { + return (int)0; + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1500,10 +1712,19 @@ static boolean uge(int a, int b) { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; + static int zeroValue() { + return (short) 0; + } + + static int maxValue() { + return Integer.MAX_VALUE; + } + + static int minValue() { + return Integer.MIN_VALUE; } + @Test static void smokeTest1() { IntVector three = IntVector.broadcast(SPECIES, (byte)-3); @@ -1616,7 +1837,7 @@ static void bitwiseDivByZeroSmokeTest() { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1637,7 +1858,7 @@ static void ADDInt256VectorTests(IntFunction fa, IntFunction fb) { } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1694,7 +1915,7 @@ static void addInt256VectorTestsMasked(IntFunction fa, IntFunction } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1715,7 +1936,7 @@ static void SUBInt256VectorTests(IntFunction fa, IntFunction fb) { } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1772,7 +1993,7 @@ static void subInt256VectorTestsMasked(IntFunction fa, IntFunction } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1793,7 +2014,7 @@ static void MULInt256VectorTests(IntFunction fa, IntFunction fb) { } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1940,7 +2161,7 @@ static void divInt256VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3224,7 +3445,7 @@ static void MAXInt256VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3245,7 +3466,7 @@ static void MINInt256VectorTests(IntFunction fa, IntFunction fb) { } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3264,7 +3485,7 @@ static void minInt256VectorTests(IntFunction fa, IntFunction fb) { } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3285,7 +3506,7 @@ static void MAXInt256VectorTests(IntFunction fa, IntFunction fb) { } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3653,7 +3874,7 @@ static void SUADDAssocInt256VectorTestsMasked(IntFunction fa, IntFunction static int ANDReduce(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static int ANDReduce(int[] a, int idx) { static int ANDReduceAll(int[] a) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3685,7 +3906,7 @@ static void ANDReduceInt256VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3697,7 +3918,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3706,7 +3927,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3731,7 +3952,7 @@ static void ANDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3742,7 +3963,7 @@ static void ANDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< static int ORReduce(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static int ORReduce(int[] a, int idx) { static int ORReduceAll(int[] a) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3774,7 +3995,7 @@ static void ORReduceInt256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3786,7 +4007,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3795,7 +4016,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3820,7 +4041,7 @@ static void ORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3875,7 +4096,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3884,7 +4105,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3909,7 +4130,7 @@ static void XORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3918,18 +4139,18 @@ static void XORReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } static int ADDReduce(int[] a, int idx) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAll(int[] a) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3939,7 +4160,7 @@ static int ADDReduceAll(int[] a) { static void ADDReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3949,10 +4170,10 @@ static void ADDReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3961,19 +4182,19 @@ static void ADDReduceInt256VectorTests(IntFunction fa) { } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3985,7 +4206,7 @@ static void ADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3995,10 +4216,10 @@ static void ADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4007,18 +4228,18 @@ static void ADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } static int MULReduce(int[] a, int idx) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAll(int[] a) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4028,7 +4249,7 @@ static int MULReduceAll(int[] a) { static void MULReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4038,10 +4259,10 @@ static void MULReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4050,19 +4271,19 @@ static void MULReduceInt256VectorTests(IntFunction fa) { } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAllMasked(int[] a, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4074,7 +4295,7 @@ static void MULReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4084,10 +4305,10 @@ static void MULReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4096,18 +4317,18 @@ static void MULReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } static int MINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4117,7 +4338,7 @@ static int MINReduceAll(int[] a) { static void MINReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4127,10 +4348,10 @@ static void MINReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4139,19 +4360,19 @@ static void MINReduceInt256VectorTests(IntFunction fa) { } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4163,7 +4384,7 @@ static void MINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4173,10 +4394,10 @@ static void MINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4185,18 +4406,18 @@ static void MINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } static int MAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4206,7 +4427,7 @@ static int MAXReduceAll(int[] a) { static void MAXReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4216,10 +4437,10 @@ static void MAXReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4228,19 +4449,19 @@ static void MAXReduceInt256VectorTests(IntFunction fa) { } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4252,7 +4473,7 @@ static void MAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4262,10 +4483,10 @@ static void MAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4274,7 +4495,7 @@ static void MAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction< } static int UMINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.minUnsigned(res, a[i]); } @@ -4283,7 +4504,7 @@ static int UMINReduce(int[] a, int idx) { } static int UMINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4295,7 +4516,7 @@ static int UMINReduceAll(int[] a) { static void UMINReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4305,7 +4526,7 @@ static void UMINReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4317,7 +4538,7 @@ static void UMINReduceInt256VectorTests(IntFunction fa) { } static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.minUnsigned(res, a[i]); @@ -4327,7 +4548,7 @@ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4341,7 +4562,7 @@ static void UMINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4351,7 +4572,7 @@ static void UMINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4363,7 +4584,7 @@ static void UMINReduceInt256VectorTestsMasked(IntFunction fa, IntFunction } static int UMAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.maxUnsigned(res, a[i]); } @@ -4372,7 +4593,7 @@ static int UMAXReduce(int[] a, int idx) { } static int UMAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4384,7 +4605,7 @@ static int UMAXReduceAll(int[] a) { static void UMAXReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4394,7 +4615,7 @@ static void UMAXReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4406,7 +4627,7 @@ static void UMAXReduceInt256VectorTests(IntFunction fa) { } static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.maxUnsigned(res, a[i]); @@ -4416,7 +4637,7 @@ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4430,7 +4651,7 @@ static void UMAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4440,7 +4661,7 @@ static void UMAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4452,7 +4673,7 @@ static void UMAXReduceInt256VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZEROReduce(int[] a, int idx) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4461,7 +4682,7 @@ static int FIRST_NONZEROReduce(int[] a, int idx) { } static int FIRST_NONZEROReduceAll(int[] a) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4473,7 +4694,7 @@ static int FIRST_NONZEROReduceAll(int[] a) { static void FIRST_NONZEROReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4483,7 +4704,7 @@ static void FIRST_NONZEROReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4495,7 +4716,7 @@ static void FIRST_NONZEROReduceInt256VectorTests(IntFunction fa) { } static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4505,7 +4726,7 @@ static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { } static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4519,7 +4740,7 @@ static void FIRST_NONZEROReduceInt256VectorTestsMasked(IntFunction fa, In int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4529,7 +4750,7 @@ static void FIRST_NONZEROReduceInt256VectorTestsMasked(IntFunction fa, In } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4589,7 +4810,7 @@ static void allTrueInt256VectorTests(IntFunction fm) { } static int SUADDReduce(int[] a, int idx) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4598,7 +4819,7 @@ static int SUADDReduce(int[] a, int idx) { } static int SUADDReduceAll(int[] a) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4610,7 +4831,7 @@ static int SUADDReduceAll(int[] a) { static void SUADDReduceInt256VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4620,7 +4841,7 @@ static void SUADDReduceInt256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4632,7 +4853,7 @@ static void SUADDReduceInt256VectorTests(IntFunction fa) { } static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4642,7 +4863,7 @@ static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { } static int SUADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4655,7 +4876,7 @@ static void SUADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunctio int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4665,7 +4886,7 @@ static void SUADDReduceInt256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4710,7 +4931,7 @@ static void IS_DEFAULTInt256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4730,7 +4951,7 @@ static void IS_DEFAULTMaskedInt256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4751,7 +4972,7 @@ static void IS_NEGATIVEInt256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4771,7 +4992,7 @@ static void IS_NEGATIVEMaskedInt256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4790,7 +5011,7 @@ static void LTInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4809,7 +5030,7 @@ static void ltInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4832,7 +5053,7 @@ static void LTInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); } } } @@ -4851,7 +5072,7 @@ static void GTInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4874,7 +5095,7 @@ static void GTInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); } } } @@ -4893,7 +5114,7 @@ static void EQInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4912,7 +5133,7 @@ static void eqInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4935,7 +5156,7 @@ static void EQInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); } } } @@ -4954,7 +5175,7 @@ static void NEInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4977,7 +5198,7 @@ static void NEInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); } } } @@ -4996,7 +5217,7 @@ static void LEInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5019,7 +5240,7 @@ static void LEInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); } } } @@ -5038,7 +5259,7 @@ static void GEInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5061,7 +5282,7 @@ static void GEInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); } } } @@ -5080,7 +5301,7 @@ static void ULTInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5103,7 +5324,7 @@ static void ULTInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); } } } @@ -5122,7 +5343,7 @@ static void UGTInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5145,7 +5366,7 @@ static void UGTInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); } } } @@ -5164,7 +5385,7 @@ static void ULEInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5187,7 +5408,7 @@ static void ULEInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); } } } @@ -5206,7 +5427,7 @@ static void UGEInt256VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5229,7 +5450,7 @@ static void UGEInt256VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); } } } @@ -5246,7 +5467,7 @@ static void LTInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5266,7 +5487,7 @@ static void LTInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5282,7 +5503,7 @@ static void LTInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @@ -5302,7 +5523,7 @@ static void LTInt256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(int)((long)b[i])))); } } } @@ -5318,7 +5539,7 @@ static void EQInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5338,7 +5559,7 @@ static void EQInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5354,7 +5575,7 @@ static void EQInt256VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @@ -5374,7 +5595,7 @@ static void EQInt256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(int)((long)b[i])))); } } } @@ -5655,7 +5876,7 @@ static void ZeroInt256VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static int[] sliceUnary(int[] a, int origin, int idx) { @@ -6086,11 +6307,11 @@ static void BITWISE_BLENDInt256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunc } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6142,11 +6363,11 @@ static void NEGMaskedInt256VectorTests(IntFunction fa, } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6486,7 +6707,7 @@ static void ltInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6502,7 +6723,7 @@ static void eqInt256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6742,7 +6963,7 @@ static void shuffleMiscellaneousInt256VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index 9dfa034eb8982..cd734d565ca0b 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -1060,15 +1060,15 @@ static int bits(int e) { } static final List> INT_GENERATORS = List.of( - withToString("int[-i * 5]", (int s) -> { + withToString("Integer[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("int[i * 5]", (int s) -> { + withToString("Integer[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("int[i + 1]", (int s) -> { + withToString("Integer[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1484,6 +1484,218 @@ static boolean ge(int a, int b) { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int multiplicativeIdentity() { + return (int)1; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static int scalar_sin(int a) { + return (int)Math.sin((double)a); + } + + static int scalar_exp(int a) { + return (int)Math.exp((double)a); + } + + static int scalar_log1p(int a) { + return (int)Math.log1p((double)a); + } + + static int scalar_log(int a) { + return (int)Math.log((double)a); + } + + static int scalar_log10(int a) { + return (int)Math.log10((double)a); + } + + static int scalar_expm1(int a) { + return (int)Math.expm1((double)a); + } + + static int scalar_cos(int a) { + return (int)Math.cos((double)a); + } + + static int scalar_tan(int a) { + return (int)Math.tan((double)a); + } + + static int scalar_sinh(int a) { + return (int)Math.sinh((double)a); + } + + static int scalar_cosh(int a) { + return (int)Math.cosh((double)a); + } + + static int scalar_tanh(int a) { + return (int)Math.tanh((double)a); + } + + static int scalar_asin(int a) { + return (int)Math.asin((double)a); + } + + static int scalar_acos(int a) { + return (int)Math.acos((double)a); + } + + static int scalar_atan(int a) { + return (int)Math.atan((double)a); + } + + static int scalar_cbrt(int a) { + return (int)Math.cbrt((double)a); + } + + static int scalar_sqrt(int a) { + return (int)Math.sqrt((double)a); + } + + static int scalar_hypot(int a, int b) { + return (int)Math.hypot((double)a, (double)b); + } + + static int scalar_pow(int a, int b) { + return (int)Math.pow((double)a, (double)b); + } + + static int scalar_atan2(int a, int b) { + return (int)Math.atan2((double)a, (double)b); + } + + static int strict_scalar_sin(int a) { + return (int)StrictMath.sin((double)a); + } + + static int strict_scalar_exp(int a) { + return (int)StrictMath.exp((double)a); + } + + static int strict_scalar_log1p(int a) { + return (int)StrictMath.log1p((double)a); + } + + static int strict_scalar_log(int a) { + return (int)StrictMath.log((double)a); + } + + static int strict_scalar_log10(int a) { + return (int)StrictMath.log10((double)a); + } + + static int strict_scalar_expm1(int a) { + return (int)StrictMath.expm1((double)a); + } + + static int strict_scalar_cos(int a) { + return (int)StrictMath.cos((double)a); + } + + static int strict_scalar_tan(int a) { + return (int)StrictMath.tan((double)a); + } + + static int strict_scalar_sinh(int a) { + return (int)StrictMath.sinh((double)a); + } + + static int strict_scalar_cosh(int a) { + return (int)StrictMath.cosh((double)a); + } + + static int strict_scalar_tanh(int a) { + return (int)StrictMath.tanh((double)a); + } + + static int strict_scalar_asin(int a) { + return (int)StrictMath.asin((double)a); + } + + static int strict_scalar_acos(int a) { + return (int)StrictMath.acos((double)a); + } + + static int strict_scalar_atan(int a) { + return (int)StrictMath.atan((double)a); + } + + static int strict_scalar_cbrt(int a) { + return (int)StrictMath.cbrt((double)a); + } + + static int strict_scalar_sqrt(int a) { + return (int)StrictMath.sqrt((double)a); + } + + static int strict_scalar_hypot(int a, int b) { + return (int)StrictMath.hypot((double)a, (double)b); + } + + static int strict_scalar_pow(int a, int b) { + return (int)StrictMath.pow((double)a, (double)b); + } + + static int strict_scalar_atan2(int a, int b) { + return (int)StrictMath.atan2((double)a, (double)b); + } + static int additiveIdentity() { + return (int)0; + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1500,10 +1712,19 @@ static boolean uge(int a, int b) { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; + static int zeroValue() { + return (short) 0; + } + + static int maxValue() { + return Integer.MAX_VALUE; + } + + static int minValue() { + return Integer.MIN_VALUE; } + @Test static void smokeTest1() { IntVector three = IntVector.broadcast(SPECIES, (byte)-3); @@ -1616,7 +1837,7 @@ static void bitwiseDivByZeroSmokeTest() { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1637,7 +1858,7 @@ static void ADDInt512VectorTests(IntFunction fa, IntFunction fb) { } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1694,7 +1915,7 @@ static void addInt512VectorTestsMasked(IntFunction fa, IntFunction } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1715,7 +1936,7 @@ static void SUBInt512VectorTests(IntFunction fa, IntFunction fb) { } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1772,7 +1993,7 @@ static void subInt512VectorTestsMasked(IntFunction fa, IntFunction } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1793,7 +2014,7 @@ static void MULInt512VectorTests(IntFunction fa, IntFunction fb) { } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1940,7 +2161,7 @@ static void divInt512VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3224,7 +3445,7 @@ static void MAXInt512VectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3245,7 +3466,7 @@ static void MINInt512VectorTests(IntFunction fa, IntFunction fb) { } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3264,7 +3485,7 @@ static void minInt512VectorTests(IntFunction fa, IntFunction fb) { } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3285,7 +3506,7 @@ static void MAXInt512VectorTests(IntFunction fa, IntFunction fb) { } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3653,7 +3874,7 @@ static void SUADDAssocInt512VectorTestsMasked(IntFunction fa, IntFunction static int ANDReduce(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static int ANDReduce(int[] a, int idx) { static int ANDReduceAll(int[] a) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3685,7 +3906,7 @@ static void ANDReduceInt512VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3697,7 +3918,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3706,7 +3927,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3731,7 +3952,7 @@ static void ANDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3742,7 +3963,7 @@ static void ANDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< static int ORReduce(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3751,7 +3972,7 @@ static int ORReduce(int[] a, int idx) { static int ORReduceAll(int[] a) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3774,7 +3995,7 @@ static void ORReduceInt512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3786,7 +4007,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3795,7 +4016,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3820,7 +4041,7 @@ static void ORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3875,7 +4096,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3884,7 +4105,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3909,7 +4130,7 @@ static void XORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3918,18 +4139,18 @@ static void XORReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } static int ADDReduce(int[] a, int idx) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAll(int[] a) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3939,7 +4160,7 @@ static int ADDReduceAll(int[] a) { static void ADDReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3949,10 +4170,10 @@ static void ADDReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3961,19 +4182,19 @@ static void ADDReduceInt512VectorTests(IntFunction fa) { } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3985,7 +4206,7 @@ static void ADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3995,10 +4216,10 @@ static void ADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4007,18 +4228,18 @@ static void ADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } static int MULReduce(int[] a, int idx) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAll(int[] a) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4028,7 +4249,7 @@ static int MULReduceAll(int[] a) { static void MULReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4038,10 +4259,10 @@ static void MULReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4050,19 +4271,19 @@ static void MULReduceInt512VectorTests(IntFunction fa) { } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAllMasked(int[] a, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4074,7 +4295,7 @@ static void MULReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4084,10 +4305,10 @@ static void MULReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4096,18 +4317,18 @@ static void MULReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } static int MINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4117,7 +4338,7 @@ static int MINReduceAll(int[] a) { static void MINReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4127,10 +4348,10 @@ static void MINReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4139,19 +4360,19 @@ static void MINReduceInt512VectorTests(IntFunction fa) { } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4163,7 +4384,7 @@ static void MINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4173,10 +4394,10 @@ static void MINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4185,18 +4406,18 @@ static void MINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } static int MAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4206,7 +4427,7 @@ static int MAXReduceAll(int[] a) { static void MAXReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4216,10 +4437,10 @@ static void MAXReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4228,19 +4449,19 @@ static void MAXReduceInt512VectorTests(IntFunction fa) { } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4252,7 +4473,7 @@ static void MAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4262,10 +4483,10 @@ static void MAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4274,7 +4495,7 @@ static void MAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction< } static int UMINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.minUnsigned(res, a[i]); } @@ -4283,7 +4504,7 @@ static int UMINReduce(int[] a, int idx) { } static int UMINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4295,7 +4516,7 @@ static int UMINReduceAll(int[] a) { static void UMINReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4305,7 +4526,7 @@ static void UMINReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4317,7 +4538,7 @@ static void UMINReduceInt512VectorTests(IntFunction fa) { } static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.minUnsigned(res, a[i]); @@ -4327,7 +4548,7 @@ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4341,7 +4562,7 @@ static void UMINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4351,7 +4572,7 @@ static void UMINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4363,7 +4584,7 @@ static void UMINReduceInt512VectorTestsMasked(IntFunction fa, IntFunction } static int UMAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.maxUnsigned(res, a[i]); } @@ -4372,7 +4593,7 @@ static int UMAXReduce(int[] a, int idx) { } static int UMAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4384,7 +4605,7 @@ static int UMAXReduceAll(int[] a) { static void UMAXReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4394,7 +4615,7 @@ static void UMAXReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4406,7 +4627,7 @@ static void UMAXReduceInt512VectorTests(IntFunction fa) { } static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.maxUnsigned(res, a[i]); @@ -4416,7 +4637,7 @@ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4430,7 +4651,7 @@ static void UMAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4440,7 +4661,7 @@ static void UMAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4452,7 +4673,7 @@ static void UMAXReduceInt512VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZEROReduce(int[] a, int idx) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4461,7 +4682,7 @@ static int FIRST_NONZEROReduce(int[] a, int idx) { } static int FIRST_NONZEROReduceAll(int[] a) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4473,7 +4694,7 @@ static int FIRST_NONZEROReduceAll(int[] a) { static void FIRST_NONZEROReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4483,7 +4704,7 @@ static void FIRST_NONZEROReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4495,7 +4716,7 @@ static void FIRST_NONZEROReduceInt512VectorTests(IntFunction fa) { } static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4505,7 +4726,7 @@ static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { } static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4519,7 +4740,7 @@ static void FIRST_NONZEROReduceInt512VectorTestsMasked(IntFunction fa, In int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4529,7 +4750,7 @@ static void FIRST_NONZEROReduceInt512VectorTestsMasked(IntFunction fa, In } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4589,7 +4810,7 @@ static void allTrueInt512VectorTests(IntFunction fm) { } static int SUADDReduce(int[] a, int idx) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4598,7 +4819,7 @@ static int SUADDReduce(int[] a, int idx) { } static int SUADDReduceAll(int[] a) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4610,7 +4831,7 @@ static int SUADDReduceAll(int[] a) { static void SUADDReduceInt512VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4620,7 +4841,7 @@ static void SUADDReduceInt512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4632,7 +4853,7 @@ static void SUADDReduceInt512VectorTests(IntFunction fa) { } static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4642,7 +4863,7 @@ static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { } static int SUADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4655,7 +4876,7 @@ static void SUADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunctio int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4665,7 +4886,7 @@ static void SUADDReduceInt512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4710,7 +4931,7 @@ static void IS_DEFAULTInt512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4730,7 +4951,7 @@ static void IS_DEFAULTMaskedInt512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4751,7 +4972,7 @@ static void IS_NEGATIVEInt512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4771,7 +4992,7 @@ static void IS_NEGATIVEMaskedInt512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4790,7 +5011,7 @@ static void LTInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4809,7 +5030,7 @@ static void ltInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4832,7 +5053,7 @@ static void LTInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); } } } @@ -4851,7 +5072,7 @@ static void GTInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4874,7 +5095,7 @@ static void GTInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); } } } @@ -4893,7 +5114,7 @@ static void EQInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4912,7 +5133,7 @@ static void eqInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4935,7 +5156,7 @@ static void EQInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); } } } @@ -4954,7 +5175,7 @@ static void NEInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4977,7 +5198,7 @@ static void NEInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); } } } @@ -4996,7 +5217,7 @@ static void LEInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5019,7 +5240,7 @@ static void LEInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); } } } @@ -5038,7 +5259,7 @@ static void GEInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5061,7 +5282,7 @@ static void GEInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); } } } @@ -5080,7 +5301,7 @@ static void ULTInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5103,7 +5324,7 @@ static void ULTInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); } } } @@ -5122,7 +5343,7 @@ static void UGTInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5145,7 +5366,7 @@ static void UGTInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); } } } @@ -5164,7 +5385,7 @@ static void ULEInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5187,7 +5408,7 @@ static void ULEInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); } } } @@ -5206,7 +5427,7 @@ static void UGEInt512VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5229,7 +5450,7 @@ static void UGEInt512VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); } } } @@ -5246,7 +5467,7 @@ static void LTInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5266,7 +5487,7 @@ static void LTInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5282,7 +5503,7 @@ static void LTInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @@ -5302,7 +5523,7 @@ static void LTInt512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(int)((long)b[i])))); } } } @@ -5318,7 +5539,7 @@ static void EQInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5338,7 +5559,7 @@ static void EQInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5354,7 +5575,7 @@ static void EQInt512VectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @@ -5374,7 +5595,7 @@ static void EQInt512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(int)((long)b[i])))); } } } @@ -5655,7 +5876,7 @@ static void ZeroInt512VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static int[] sliceUnary(int[] a, int origin, int idx) { @@ -6086,11 +6307,11 @@ static void BITWISE_BLENDInt512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunc } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6142,11 +6363,11 @@ static void NEGMaskedInt512VectorTests(IntFunction fa, } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6486,7 +6707,7 @@ static void ltInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6502,7 +6723,7 @@ static void eqInt512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6742,7 +6963,7 @@ static void shuffleMiscellaneousInt512VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index ccffe8c5e067e..ec001f70319f6 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -1060,15 +1060,15 @@ static int bits(int e) { } static final List> INT_GENERATORS = List.of( - withToString("int[-i * 5]", (int s) -> { + withToString("Integer[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("int[i * 5]", (int s) -> { + withToString("Integer[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("int[i + 1]", (int s) -> { + withToString("Integer[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1484,6 +1484,218 @@ static boolean ge(int a, int b) { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int multiplicativeIdentity() { + return (int)1; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static int scalar_sin(int a) { + return (int)Math.sin((double)a); + } + + static int scalar_exp(int a) { + return (int)Math.exp((double)a); + } + + static int scalar_log1p(int a) { + return (int)Math.log1p((double)a); + } + + static int scalar_log(int a) { + return (int)Math.log((double)a); + } + + static int scalar_log10(int a) { + return (int)Math.log10((double)a); + } + + static int scalar_expm1(int a) { + return (int)Math.expm1((double)a); + } + + static int scalar_cos(int a) { + return (int)Math.cos((double)a); + } + + static int scalar_tan(int a) { + return (int)Math.tan((double)a); + } + + static int scalar_sinh(int a) { + return (int)Math.sinh((double)a); + } + + static int scalar_cosh(int a) { + return (int)Math.cosh((double)a); + } + + static int scalar_tanh(int a) { + return (int)Math.tanh((double)a); + } + + static int scalar_asin(int a) { + return (int)Math.asin((double)a); + } + + static int scalar_acos(int a) { + return (int)Math.acos((double)a); + } + + static int scalar_atan(int a) { + return (int)Math.atan((double)a); + } + + static int scalar_cbrt(int a) { + return (int)Math.cbrt((double)a); + } + + static int scalar_sqrt(int a) { + return (int)Math.sqrt((double)a); + } + + static int scalar_hypot(int a, int b) { + return (int)Math.hypot((double)a, (double)b); + } + + static int scalar_pow(int a, int b) { + return (int)Math.pow((double)a, (double)b); + } + + static int scalar_atan2(int a, int b) { + return (int)Math.atan2((double)a, (double)b); + } + + static int strict_scalar_sin(int a) { + return (int)StrictMath.sin((double)a); + } + + static int strict_scalar_exp(int a) { + return (int)StrictMath.exp((double)a); + } + + static int strict_scalar_log1p(int a) { + return (int)StrictMath.log1p((double)a); + } + + static int strict_scalar_log(int a) { + return (int)StrictMath.log((double)a); + } + + static int strict_scalar_log10(int a) { + return (int)StrictMath.log10((double)a); + } + + static int strict_scalar_expm1(int a) { + return (int)StrictMath.expm1((double)a); + } + + static int strict_scalar_cos(int a) { + return (int)StrictMath.cos((double)a); + } + + static int strict_scalar_tan(int a) { + return (int)StrictMath.tan((double)a); + } + + static int strict_scalar_sinh(int a) { + return (int)StrictMath.sinh((double)a); + } + + static int strict_scalar_cosh(int a) { + return (int)StrictMath.cosh((double)a); + } + + static int strict_scalar_tanh(int a) { + return (int)StrictMath.tanh((double)a); + } + + static int strict_scalar_asin(int a) { + return (int)StrictMath.asin((double)a); + } + + static int strict_scalar_acos(int a) { + return (int)StrictMath.acos((double)a); + } + + static int strict_scalar_atan(int a) { + return (int)StrictMath.atan((double)a); + } + + static int strict_scalar_cbrt(int a) { + return (int)StrictMath.cbrt((double)a); + } + + static int strict_scalar_sqrt(int a) { + return (int)StrictMath.sqrt((double)a); + } + + static int strict_scalar_hypot(int a, int b) { + return (int)StrictMath.hypot((double)a, (double)b); + } + + static int strict_scalar_pow(int a, int b) { + return (int)StrictMath.pow((double)a, (double)b); + } + + static int strict_scalar_atan2(int a, int b) { + return (int)StrictMath.atan2((double)a, (double)b); + } + static int additiveIdentity() { + return (int)0; + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1500,10 +1712,19 @@ static boolean uge(int a, int b) { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; + static int zeroValue() { + return (short) 0; + } + + static int maxValue() { + return Integer.MAX_VALUE; + } + + static int minValue() { + return Integer.MIN_VALUE; } + @Test static void smokeTest1() { IntVector three = IntVector.broadcast(SPECIES, (byte)-3); @@ -1616,7 +1837,7 @@ static void bitwiseDivByZeroSmokeTest() { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1637,7 +1858,7 @@ static void ADDInt64VectorTests(IntFunction fa, IntFunction fb) { } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1694,7 +1915,7 @@ static void addInt64VectorTestsMasked(IntFunction fa, IntFunction } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1715,7 +1936,7 @@ static void SUBInt64VectorTests(IntFunction fa, IntFunction fb) { } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1772,7 +1993,7 @@ static void subInt64VectorTestsMasked(IntFunction fa, IntFunction } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1793,7 +2014,7 @@ static void MULInt64VectorTests(IntFunction fa, IntFunction fb) { } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1940,7 +2161,7 @@ static void divInt64VectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3224,7 +3445,7 @@ static void MAXInt64VectorTestsMaskedWithMemOp(IntFunction fa, IntFunctio } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3245,7 +3466,7 @@ static void MINInt64VectorTests(IntFunction fa, IntFunction fb) { } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3264,7 +3485,7 @@ static void minInt64VectorTests(IntFunction fa, IntFunction fb) { } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3285,7 +3506,7 @@ static void MAXInt64VectorTests(IntFunction fa, IntFunction fb) { } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3653,7 +3874,7 @@ static void SUADDAssocInt64VectorTestsMasked(IntFunction fa, IntFunction< static int ANDReduce(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3662,7 +3883,7 @@ static int ANDReduce(int[] a, int idx) { static int ANDReduceAll(int[] a) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3685,7 +3906,7 @@ static void ANDReduceInt64VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3697,7 +3918,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3706,7 +3927,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3731,7 +3952,7 @@ static void ANDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3786,7 +4007,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3795,7 +4016,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3820,7 +4041,7 @@ static void ORReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3875,7 +4096,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3884,7 +4105,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3909,7 +4130,7 @@ static void XORReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3949,10 +4170,10 @@ static void ADDReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3961,19 +4182,19 @@ static void ADDReduceInt64VectorTests(IntFunction fa) { } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3985,7 +4206,7 @@ static void ADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3995,10 +4216,10 @@ static void ADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4038,10 +4259,10 @@ static void MULReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4050,19 +4271,19 @@ static void MULReduceInt64VectorTests(IntFunction fa) { } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAllMasked(int[] a, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4074,7 +4295,7 @@ static void MULReduceInt64VectorTestsMasked(IntFunction fa, IntFunction vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4084,10 +4305,10 @@ static void MULReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4127,10 +4348,10 @@ static void MINReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4139,19 +4360,19 @@ static void MINReduceInt64VectorTests(IntFunction fa) { } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4163,7 +4384,7 @@ static void MINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4173,10 +4394,10 @@ static void MINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4216,10 +4437,10 @@ static void MAXReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4228,19 +4449,19 @@ static void MAXReduceInt64VectorTests(IntFunction fa) { } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4252,7 +4473,7 @@ static void MAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4262,10 +4483,10 @@ static void MAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4305,7 +4526,7 @@ static void UMINReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4317,7 +4538,7 @@ static void UMINReduceInt64VectorTests(IntFunction fa) { } static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.minUnsigned(res, a[i]); @@ -4327,7 +4548,7 @@ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4341,7 +4562,7 @@ static void UMINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4351,7 +4572,7 @@ static void UMINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4363,7 +4584,7 @@ static void UMINReduceInt64VectorTestsMasked(IntFunction fa, IntFunction< } static int UMAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.maxUnsigned(res, a[i]); } @@ -4372,7 +4593,7 @@ static int UMAXReduce(int[] a, int idx) { } static int UMAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4384,7 +4605,7 @@ static int UMAXReduceAll(int[] a) { static void UMAXReduceInt64VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4394,7 +4615,7 @@ static void UMAXReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4406,7 +4627,7 @@ static void UMAXReduceInt64VectorTests(IntFunction fa) { } static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.maxUnsigned(res, a[i]); @@ -4416,7 +4637,7 @@ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4430,7 +4651,7 @@ static void UMAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4440,7 +4661,7 @@ static void UMAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4452,7 +4673,7 @@ static void UMAXReduceInt64VectorTestsMasked(IntFunction fa, IntFunction< } static int FIRST_NONZEROReduce(int[] a, int idx) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4461,7 +4682,7 @@ static int FIRST_NONZEROReduce(int[] a, int idx) { } static int FIRST_NONZEROReduceAll(int[] a) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4473,7 +4694,7 @@ static int FIRST_NONZEROReduceAll(int[] a) { static void FIRST_NONZEROReduceInt64VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4483,7 +4704,7 @@ static void FIRST_NONZEROReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4495,7 +4716,7 @@ static void FIRST_NONZEROReduceInt64VectorTests(IntFunction fa) { } static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4505,7 +4726,7 @@ static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { } static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4519,7 +4740,7 @@ static void FIRST_NONZEROReduceInt64VectorTestsMasked(IntFunction fa, Int int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4529,7 +4750,7 @@ static void FIRST_NONZEROReduceInt64VectorTestsMasked(IntFunction fa, Int } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4589,7 +4810,7 @@ static void allTrueInt64VectorTests(IntFunction fm) { } static int SUADDReduce(int[] a, int idx) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4598,7 +4819,7 @@ static int SUADDReduce(int[] a, int idx) { } static int SUADDReduceAll(int[] a) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4610,7 +4831,7 @@ static int SUADDReduceAll(int[] a) { static void SUADDReduceInt64VectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4620,7 +4841,7 @@ static void SUADDReduceInt64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4632,7 +4853,7 @@ static void SUADDReduceInt64VectorTests(IntFunction fa) { } static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4642,7 +4863,7 @@ static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { } static int SUADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4655,7 +4876,7 @@ static void SUADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4665,7 +4886,7 @@ static void SUADDReduceInt64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4710,7 +4931,7 @@ static void IS_DEFAULTInt64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4730,7 +4951,7 @@ static void IS_DEFAULTMaskedInt64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4751,7 +4972,7 @@ static void IS_NEGATIVEInt64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4771,7 +4992,7 @@ static void IS_NEGATIVEMaskedInt64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4790,7 +5011,7 @@ static void LTInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4809,7 +5030,7 @@ static void ltInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4832,7 +5053,7 @@ static void LTInt64VectorTestsMasked(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); } } } @@ -4851,7 +5072,7 @@ static void GTInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4874,7 +5095,7 @@ static void GTInt64VectorTestsMasked(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); } } } @@ -4893,7 +5114,7 @@ static void EQInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4912,7 +5133,7 @@ static void eqInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4935,7 +5156,7 @@ static void EQInt64VectorTestsMasked(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); } } } @@ -4954,7 +5175,7 @@ static void NEInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4977,7 +5198,7 @@ static void NEInt64VectorTestsMasked(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); } } } @@ -4996,7 +5217,7 @@ static void LEInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5019,7 +5240,7 @@ static void LEInt64VectorTestsMasked(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); } } } @@ -5038,7 +5259,7 @@ static void GEInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5061,7 +5282,7 @@ static void GEInt64VectorTestsMasked(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); } } } @@ -5080,7 +5301,7 @@ static void ULTInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5103,7 +5324,7 @@ static void ULTInt64VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); } } } @@ -5122,7 +5343,7 @@ static void UGTInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5145,7 +5366,7 @@ static void UGTInt64VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); } } } @@ -5164,7 +5385,7 @@ static void ULEInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5187,7 +5408,7 @@ static void ULEInt64VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); } } } @@ -5206,7 +5427,7 @@ static void UGEInt64VectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5229,7 +5450,7 @@ static void UGEInt64VectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); } } } @@ -5246,7 +5467,7 @@ static void LTInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunct // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5266,7 +5487,7 @@ static void LTInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5282,7 +5503,7 @@ static void LTInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @@ -5302,7 +5523,7 @@ static void LTInt64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(int)((long)b[i])))); } } } @@ -5318,7 +5539,7 @@ static void EQInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunct // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5338,7 +5559,7 @@ static void EQInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5354,7 +5575,7 @@ static void EQInt64VectorTestsBroadcastLongSmokeTest(IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @@ -5374,7 +5595,7 @@ static void EQInt64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(int)((long)b[i])))); } } } @@ -5655,7 +5876,7 @@ static void ZeroInt64VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static int[] sliceUnary(int[] a, int origin, int idx) { @@ -6086,11 +6307,11 @@ static void BITWISE_BLENDInt64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunct } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6142,11 +6363,11 @@ static void NEGMaskedInt64VectorTests(IntFunction fa, } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6486,7 +6707,7 @@ static void ltInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunct // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6502,7 +6723,7 @@ static void eqInt64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, In // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6742,7 +6963,7 @@ static void shuffleMiscellaneousInt64VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index fe2abe2450dea..9195a144eac0b 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -1065,15 +1065,15 @@ static int bits(int e) { } static final List> INT_GENERATORS = List.of( - withToString("int[-i * 5]", (int s) -> { + withToString("Integer[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("int[i * 5]", (int s) -> { + withToString("Integer[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("int[i + 1]", (int s) -> { + withToString("Integer[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((int)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1489,6 +1489,218 @@ static boolean ge(int a, int b) { return a >= b; } + static int firstNonZero(int a, int b) { + return Integer.compare(a, (int) 0) != 0 ? a : b; + } + + static int multiplicativeIdentity() { + return (int)1; + } + + static int scalar_or(int a, int b) { + return (int)(a | b); + } + + static int scalar_and(int a, int b) { + return (int)(a & b); + } + + static int scalar_xor(int a, int b) { + return (int)(a ^ b); + } + + static int scalar_add(int a, int b) { + return (int)(a + b); + } + + static int scalar_sub(int a, int b) { + return (int)(a - b); + } + + static int scalar_mul(int a, int b) { + return (int)(a * b); + } + + static int scalar_min(int a, int b) { + return (int)(Math.min(a, b)); + } + + static int scalar_max(int a, int b) { + return (int)(Math.max(a, b)); + } + + static int scalar_div(int a, int b) { + return (int)(a / b); + } + + static int scalar_fma(int a, int b, int c) { + return (int)(Math.fma(a, b, c)); + } + + static int scalar_abs(int a) { + return (int)(Math.abs(a)); + } + + static int scalar_neg(int a) { + return ((int)-a); + } + + static int scalar_sin(int a) { + return (int)Math.sin((double)a); + } + + static int scalar_exp(int a) { + return (int)Math.exp((double)a); + } + + static int scalar_log1p(int a) { + return (int)Math.log1p((double)a); + } + + static int scalar_log(int a) { + return (int)Math.log((double)a); + } + + static int scalar_log10(int a) { + return (int)Math.log10((double)a); + } + + static int scalar_expm1(int a) { + return (int)Math.expm1((double)a); + } + + static int scalar_cos(int a) { + return (int)Math.cos((double)a); + } + + static int scalar_tan(int a) { + return (int)Math.tan((double)a); + } + + static int scalar_sinh(int a) { + return (int)Math.sinh((double)a); + } + + static int scalar_cosh(int a) { + return (int)Math.cosh((double)a); + } + + static int scalar_tanh(int a) { + return (int)Math.tanh((double)a); + } + + static int scalar_asin(int a) { + return (int)Math.asin((double)a); + } + + static int scalar_acos(int a) { + return (int)Math.acos((double)a); + } + + static int scalar_atan(int a) { + return (int)Math.atan((double)a); + } + + static int scalar_cbrt(int a) { + return (int)Math.cbrt((double)a); + } + + static int scalar_sqrt(int a) { + return (int)Math.sqrt((double)a); + } + + static int scalar_hypot(int a, int b) { + return (int)Math.hypot((double)a, (double)b); + } + + static int scalar_pow(int a, int b) { + return (int)Math.pow((double)a, (double)b); + } + + static int scalar_atan2(int a, int b) { + return (int)Math.atan2((double)a, (double)b); + } + + static int strict_scalar_sin(int a) { + return (int)StrictMath.sin((double)a); + } + + static int strict_scalar_exp(int a) { + return (int)StrictMath.exp((double)a); + } + + static int strict_scalar_log1p(int a) { + return (int)StrictMath.log1p((double)a); + } + + static int strict_scalar_log(int a) { + return (int)StrictMath.log((double)a); + } + + static int strict_scalar_log10(int a) { + return (int)StrictMath.log10((double)a); + } + + static int strict_scalar_expm1(int a) { + return (int)StrictMath.expm1((double)a); + } + + static int strict_scalar_cos(int a) { + return (int)StrictMath.cos((double)a); + } + + static int strict_scalar_tan(int a) { + return (int)StrictMath.tan((double)a); + } + + static int strict_scalar_sinh(int a) { + return (int)StrictMath.sinh((double)a); + } + + static int strict_scalar_cosh(int a) { + return (int)StrictMath.cosh((double)a); + } + + static int strict_scalar_tanh(int a) { + return (int)StrictMath.tanh((double)a); + } + + static int strict_scalar_asin(int a) { + return (int)StrictMath.asin((double)a); + } + + static int strict_scalar_acos(int a) { + return (int)StrictMath.acos((double)a); + } + + static int strict_scalar_atan(int a) { + return (int)StrictMath.atan((double)a); + } + + static int strict_scalar_cbrt(int a) { + return (int)StrictMath.cbrt((double)a); + } + + static int strict_scalar_sqrt(int a) { + return (int)StrictMath.sqrt((double)a); + } + + static int strict_scalar_hypot(int a, int b) { + return (int)StrictMath.hypot((double)a, (double)b); + } + + static int strict_scalar_pow(int a, int b) { + return (int)StrictMath.pow((double)a, (double)b); + } + + static int strict_scalar_atan2(int a, int b) { + return (int)StrictMath.atan2((double)a, (double)b); + } + static int additiveIdentity() { + return (int)0; + } + + static boolean ult(int a, int b) { return Integer.compareUnsigned(a, b) < 0; } @@ -1505,10 +1717,19 @@ static boolean uge(int a, int b) { return Integer.compareUnsigned(a, b) >= 0; } - static int firstNonZero(int a, int b) { - return Integer.compare(a, (int) 0) != 0 ? a : b; + static int zeroValue() { + return (short) 0; + } + + static int maxValue() { + return Integer.MAX_VALUE; + } + + static int minValue() { + return Integer.MIN_VALUE; } + @Test static void smokeTest1() { IntVector three = IntVector.broadcast(SPECIES, (byte)-3); @@ -1621,7 +1842,7 @@ static void bitwiseDivByZeroSmokeTest() { } static int ADD(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1642,7 +1863,7 @@ static void ADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { } static int add(int a, int b) { - return (int)(a + b); + return (int)(scalar_add(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1699,7 +1920,7 @@ static void addIntMaxVectorTestsMasked(IntFunction fa, IntFunction } static int SUB(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1720,7 +1941,7 @@ static void SUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { } static int sub(int a, int b) { - return (int)(a - b); + return (int)(scalar_sub(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1777,7 +1998,7 @@ static void subIntMaxVectorTestsMasked(IntFunction fa, IntFunction } static int MUL(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1798,7 +2019,7 @@ static void MULIntMaxVectorTests(IntFunction fa, IntFunction fb) { } static int mul(int a, int b) { - return (int)(a * b); + return (int)(scalar_mul(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -1945,7 +2166,7 @@ static void divIntMaxVectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZERO(int a, int b) { - return (int)((a)!=0?a:b); + return (int)(firstNonZero(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3229,7 +3450,7 @@ static void MAXIntMaxVectorTestsMaskedWithMemOp(IntFunction fa, IntFuncti } static int MIN(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3250,7 +3471,7 @@ static void MINIntMaxVectorTests(IntFunction fa, IntFunction fb) { } static int min(int a, int b) { - return (int)(Math.min(a, b)); + return (int)(scalar_min(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3269,7 +3490,7 @@ static void minIntMaxVectorTests(IntFunction fa, IntFunction fb) { } static int MAX(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3290,7 +3511,7 @@ static void MAXIntMaxVectorTests(IntFunction fa, IntFunction fb) { } static int max(int a, int b) { - return (int)(Math.max(a, b)); + return (int)(scalar_max(a, b)); } @Test(dataProvider = "intBinaryOpProvider") @@ -3658,7 +3879,7 @@ static void SUADDAssocIntMaxVectorTestsMasked(IntFunction fa, IntFunction static int ANDReduce(int[] a, int idx) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3667,7 +3888,7 @@ static int ANDReduce(int[] a, int idx) { static int ANDReduceAll(int[] a) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3690,7 +3911,7 @@ static void ANDReduceIntMaxVectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3702,7 +3923,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { int res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3711,7 +3932,7 @@ static int ANDReduceMasked(int[] a, int idx, boolean[] mask) { static int ANDReduceAllMasked(int[] a, boolean[] mask) { int res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3736,7 +3957,7 @@ static void ANDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3747,7 +3968,7 @@ static void ANDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< static int ORReduce(int[] a, int idx) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3756,7 +3977,7 @@ static int ORReduce(int[] a, int idx) { static int ORReduceAll(int[] a) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3779,7 +4000,7 @@ static void ORReduceIntMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3791,7 +4012,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3800,7 +4021,7 @@ static int ORReduceMasked(int[] a, int idx, boolean[] mask) { static int ORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3825,7 +4046,7 @@ static void ORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3880,7 +4101,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { int res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3889,7 +4110,7 @@ static int XORReduceMasked(int[] a, int idx, boolean[] mask) { static int XORReduceAllMasked(int[] a, boolean[] mask) { int res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3914,7 +4135,7 @@ static void XORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3923,18 +4144,18 @@ static void XORReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } static int ADDReduce(int[] a, int idx) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAll(int[] a) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3944,7 +4165,7 @@ static int ADDReduceAll(int[] a) { static void ADDReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3954,10 +4175,10 @@ static void ADDReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3966,19 +4187,19 @@ static void ADDReduceIntMaxVectorTests(IntFunction fa) { } static int ADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static int ADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3990,7 +4211,7 @@ static void ADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4000,10 +4221,10 @@ static void ADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4012,18 +4233,18 @@ static void ADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } static int MULReduce(int[] a, int idx) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAll(int[] a) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4033,7 +4254,7 @@ static int MULReduceAll(int[] a) { static void MULReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4043,10 +4264,10 @@ static void MULReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4055,19 +4276,19 @@ static void MULReduceIntMaxVectorTests(IntFunction fa) { } static int MULReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static int MULReduceAllMasked(int[] a, boolean[] mask) { - int res = 1; + int res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4079,7 +4300,7 @@ static void MULReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 1; + int ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4089,10 +4310,10 @@ static void MULReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4101,18 +4322,18 @@ static void MULReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } static int MINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4122,7 +4343,7 @@ static int MINReduceAll(int[] a) { static void MINReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4132,10 +4353,10 @@ static void MINReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4144,19 +4365,19 @@ static void MINReduceIntMaxVectorTests(IntFunction fa) { } static int MINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static int MINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4168,7 +4389,7 @@ static void MINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4178,10 +4399,10 @@ static void MINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4190,18 +4411,18 @@ static void MINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } static int MAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4211,7 +4432,7 @@ static int MAXReduceAll(int[] a) { static void MAXReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4221,10 +4442,10 @@ static void MAXReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4233,19 +4454,19 @@ static void MAXReduceIntMaxVectorTests(IntFunction fa) { } static int MAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (int) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static int MAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (int) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4257,7 +4478,7 @@ static void MAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4267,10 +4488,10 @@ static void MAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4279,7 +4500,7 @@ static void MAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction< } static int UMINReduce(int[] a, int idx) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.minUnsigned(res, a[i]); } @@ -4288,7 +4509,7 @@ static int UMINReduce(int[] a, int idx) { } static int UMINReduceAll(int[] a) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4300,7 +4521,7 @@ static int UMINReduceAll(int[] a) { static void UMINReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4310,7 +4531,7 @@ static void UMINReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4322,7 +4543,7 @@ static void UMINReduceIntMaxVectorTests(IntFunction fa) { } static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.minUnsigned(res, a[i]); @@ -4332,7 +4553,7 @@ static int UMINReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMINReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MAX_VALUE; + int res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4346,7 +4567,7 @@ static void UMINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MAX_VALUE; + int ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4356,7 +4577,7 @@ static void UMINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4368,7 +4589,7 @@ static void UMINReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction } static int UMAXReduce(int[] a, int idx) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.maxUnsigned(res, a[i]); } @@ -4377,7 +4598,7 @@ static int UMAXReduce(int[] a, int idx) { } static int UMAXReduceAll(int[] a) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4389,7 +4610,7 @@ static int UMAXReduceAll(int[] a) { static void UMAXReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4399,7 +4620,7 @@ static void UMAXReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4411,7 +4632,7 @@ static void UMAXReduceIntMaxVectorTests(IntFunction fa) { } static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.maxUnsigned(res, a[i]); @@ -4421,7 +4642,7 @@ static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) { } static int UMAXReduceAllMasked(int[] a, boolean[] mask) { - int res = Integer.MIN_VALUE; + int res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4435,7 +4656,7 @@ static void UMAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = Integer.MIN_VALUE; + int ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4445,7 +4666,7 @@ static void UMAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Integer.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4457,7 +4678,7 @@ static void UMAXReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunction } static int FIRST_NONZEROReduce(int[] a, int idx) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4466,7 +4687,7 @@ static int FIRST_NONZEROReduce(int[] a, int idx) { } static int FIRST_NONZEROReduceAll(int[] a) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4478,7 +4699,7 @@ static int FIRST_NONZEROReduceAll(int[] a) { static void FIRST_NONZEROReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4488,7 +4709,7 @@ static void FIRST_NONZEROReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4500,7 +4721,7 @@ static void FIRST_NONZEROReduceIntMaxVectorTests(IntFunction fa) { } static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4510,7 +4731,7 @@ static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) { } static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) { - int res = (int) 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4524,7 +4745,7 @@ static void FIRST_NONZEROReduceIntMaxVectorTestsMasked(IntFunction fa, In int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = (int) 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4534,7 +4755,7 @@ static void FIRST_NONZEROReduceIntMaxVectorTestsMasked(IntFunction fa, In } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (int) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4594,7 +4815,7 @@ static void allTrueIntMaxVectorTests(IntFunction fm) { } static int SUADDReduce(int[] a, int idx) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4603,7 +4824,7 @@ static int SUADDReduce(int[] a, int idx) { } static int SUADDReduceAll(int[] a) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4615,7 +4836,7 @@ static int SUADDReduceAll(int[] a) { static void SUADDReduceIntMaxVectorTests(IntFunction fa) { int[] a = fa.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4625,7 +4846,7 @@ static void SUADDReduceIntMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4637,7 +4858,7 @@ static void SUADDReduceIntMaxVectorTests(IntFunction fa) { } static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (int) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4647,7 +4868,7 @@ static int SUADDReduceMasked(int[] a, int idx, boolean[] mask) { } static int SUADDReduceAllMasked(int[] a, boolean[] mask) { - int res = 0; + int res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (int) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4660,7 +4881,7 @@ static void SUADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunctio int[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - int ra = 0; + int ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4670,7 +4891,7 @@ static void SUADDReduceIntMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); ra = (int) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4715,7 +4936,7 @@ static void IS_DEFAULTIntMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4735,7 +4956,7 @@ static void IS_DEFAULTMaskedIntMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4756,7 +4977,7 @@ static void IS_NEGATIVEIntMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4776,7 +4997,7 @@ static void IS_NEGATIVEMaskedIntMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4795,7 +5016,7 @@ static void LTIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4814,7 +5035,7 @@ static void ltIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4837,7 +5058,7 @@ static void LTIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j])); } } } @@ -4856,7 +5077,7 @@ static void GTIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4879,7 +5100,7 @@ static void GTIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j])); } } } @@ -4898,7 +5119,7 @@ static void EQIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4917,7 +5138,7 @@ static void eqIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4940,7 +5161,7 @@ static void EQIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j])); } } } @@ -4959,7 +5180,7 @@ static void NEIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4982,7 +5203,7 @@ static void NEIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j])); } } } @@ -5001,7 +5222,7 @@ static void LEIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5024,7 +5245,7 @@ static void LEIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j])); } } } @@ -5043,7 +5264,7 @@ static void GEIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5066,7 +5287,7 @@ static void GEIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j])); } } } @@ -5085,7 +5306,7 @@ static void ULTIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5108,7 +5329,7 @@ static void ULTIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j])); } } } @@ -5127,7 +5348,7 @@ static void UGTIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5150,7 +5371,7 @@ static void UGTIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j])); } } } @@ -5169,7 +5390,7 @@ static void ULEIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5192,7 +5413,7 @@ static void ULEIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j])); } } } @@ -5211,7 +5432,7 @@ static void UGEIntMaxVectorTests(IntFunction fa, IntFunction fb) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5234,7 +5455,7 @@ static void UGEIntMaxVectorTestsMasked(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j])); } } } @@ -5251,7 +5472,7 @@ static void LTIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5271,7 +5492,7 @@ static void LTIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5287,7 +5508,7 @@ static void LTIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (int)((long)b[i]))); } } } @@ -5307,7 +5528,7 @@ static void LTIntMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j],(int)((long)b[i])))); } } } @@ -5323,7 +5544,7 @@ static void EQIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5343,7 +5564,7 @@ static void EQIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5359,7 +5580,7 @@ static void EQIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (int)((long)b[i]))); } } } @@ -5379,7 +5600,7 @@ static void EQIntMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j],(int)((long)b[i])))); } } } @@ -5660,7 +5881,7 @@ static void ZeroIntMaxVectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static int[] sliceUnary(int[] a, int origin, int idx) { @@ -6091,11 +6312,11 @@ static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunc } static int NEG(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } static int neg(int a) { - return (int)(-((int)a)); + return (int)(scalar_neg((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6147,11 +6368,11 @@ static void NEGMaskedIntMaxVectorTests(IntFunction fa, } static int ABS(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } static int abs(int a) { - return (int)(Math.abs((int)a)); + return (int)(scalar_abs((int)a)); } @Test(dataProvider = "intUnaryOpProvider") @@ -6491,7 +6712,7 @@ static void ltIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunc // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6507,7 +6728,7 @@ static void eqIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, I // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6747,7 +6968,7 @@ static void shuffleMiscellaneousIntMaxVectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index 054972cfd8447..4d87a6a0784c0 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -986,19 +986,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("long[intCornerCaseValue(i)]", (int s) -> { + withToString("Long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (long)intCornerCaseValue(i)); }) @@ -1044,15 +1044,15 @@ static long bits(long e) { } static final List> LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1500,6 +1500,218 @@ static boolean ge(long a, long b) { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long multiplicativeIdentity() { + return (long)1; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static long scalar_sin(long a) { + return (long)Math.sin((double)a); + } + + static long scalar_exp(long a) { + return (long)Math.exp((double)a); + } + + static long scalar_log1p(long a) { + return (long)Math.log1p((double)a); + } + + static long scalar_log(long a) { + return (long)Math.log((double)a); + } + + static long scalar_log10(long a) { + return (long)Math.log10((double)a); + } + + static long scalar_expm1(long a) { + return (long)Math.expm1((double)a); + } + + static long scalar_cos(long a) { + return (long)Math.cos((double)a); + } + + static long scalar_tan(long a) { + return (long)Math.tan((double)a); + } + + static long scalar_sinh(long a) { + return (long)Math.sinh((double)a); + } + + static long scalar_cosh(long a) { + return (long)Math.cosh((double)a); + } + + static long scalar_tanh(long a) { + return (long)Math.tanh((double)a); + } + + static long scalar_asin(long a) { + return (long)Math.asin((double)a); + } + + static long scalar_acos(long a) { + return (long)Math.acos((double)a); + } + + static long scalar_atan(long a) { + return (long)Math.atan((double)a); + } + + static long scalar_cbrt(long a) { + return (long)Math.cbrt((double)a); + } + + static long scalar_sqrt(long a) { + return (long)Math.sqrt((double)a); + } + + static long scalar_hypot(long a, long b) { + return (long)Math.hypot((double)a, (double)b); + } + + static long scalar_pow(long a, long b) { + return (long)Math.pow((double)a, (double)b); + } + + static long scalar_atan2(long a, long b) { + return (long)Math.atan2((double)a, (double)b); + } + + static long strict_scalar_sin(long a) { + return (long)StrictMath.sin((double)a); + } + + static long strict_scalar_exp(long a) { + return (long)StrictMath.exp((double)a); + } + + static long strict_scalar_log1p(long a) { + return (long)StrictMath.log1p((double)a); + } + + static long strict_scalar_log(long a) { + return (long)StrictMath.log((double)a); + } + + static long strict_scalar_log10(long a) { + return (long)StrictMath.log10((double)a); + } + + static long strict_scalar_expm1(long a) { + return (long)StrictMath.expm1((double)a); + } + + static long strict_scalar_cos(long a) { + return (long)StrictMath.cos((double)a); + } + + static long strict_scalar_tan(long a) { + return (long)StrictMath.tan((double)a); + } + + static long strict_scalar_sinh(long a) { + return (long)StrictMath.sinh((double)a); + } + + static long strict_scalar_cosh(long a) { + return (long)StrictMath.cosh((double)a); + } + + static long strict_scalar_tanh(long a) { + return (long)StrictMath.tanh((double)a); + } + + static long strict_scalar_asin(long a) { + return (long)StrictMath.asin((double)a); + } + + static long strict_scalar_acos(long a) { + return (long)StrictMath.acos((double)a); + } + + static long strict_scalar_atan(long a) { + return (long)StrictMath.atan((double)a); + } + + static long strict_scalar_cbrt(long a) { + return (long)StrictMath.cbrt((double)a); + } + + static long strict_scalar_sqrt(long a) { + return (long)StrictMath.sqrt((double)a); + } + + static long strict_scalar_hypot(long a, long b) { + return (long)StrictMath.hypot((double)a, (double)b); + } + + static long strict_scalar_pow(long a, long b) { + return (long)StrictMath.pow((double)a, (double)b); + } + + static long strict_scalar_atan2(long a, long b) { + return (long)StrictMath.atan2((double)a, (double)b); + } + static long additiveIdentity() { + return (long)0; + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1516,10 +1728,19 @@ static boolean uge(long a, long b) { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; + static long zeroValue() { + return (short) 0; + } + + static long maxValue() { + return Long.MAX_VALUE; + } + + static long minValue() { + return Long.MIN_VALUE; } + @Test static void smokeTest1() { LongVector three = LongVector.broadcast(SPECIES, (byte)-3); @@ -1632,7 +1853,7 @@ static void bitwiseDivByZeroSmokeTest() { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1653,7 +1874,7 @@ static void ADDLong128VectorTests(IntFunction fa, IntFunction fb } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1710,7 +1931,7 @@ static void addLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1788,7 +2009,7 @@ static void subLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1956,7 +2177,7 @@ static void divLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3261,7 +3482,7 @@ static void MINLong128VectorTests(IntFunction fa, IntFunction fb } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3280,7 +3501,7 @@ static void minLong128VectorTests(IntFunction fa, IntFunction fb } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3301,7 +3522,7 @@ static void MAXLong128VectorTests(IntFunction fa, IntFunction fb } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3669,7 +3890,7 @@ static void SUADDAssocLong128VectorTestsMasked(IntFunction fa, IntFuncti static long ANDReduce(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3678,7 +3899,7 @@ static long ANDReduce(long[] a, int idx) { static long ANDReduceAll(long[] a) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3701,7 +3922,7 @@ static void ANDReduceLong128VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3713,7 +3934,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3722,7 +3943,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3747,7 +3968,7 @@ static void ANDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3758,7 +3979,7 @@ static void ANDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio static long ORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3767,7 +3988,7 @@ static long ORReduce(long[] a, int idx) { static long ORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3790,7 +4011,7 @@ static void ORReduceLong128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3802,7 +4023,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3811,7 +4032,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3836,7 +4057,7 @@ static void ORReduceLong128VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3847,7 +4068,7 @@ static void ORReduceLong128VectorTestsMasked(IntFunction fa, IntFunction static long XORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3856,7 +4077,7 @@ static long XORReduce(long[] a, int idx) { static long XORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3879,7 +4100,7 @@ static void XORReduceLong128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3891,7 +4112,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3900,7 +4121,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3925,7 +4146,7 @@ static void XORReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3934,18 +4155,18 @@ static void XORReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } static long ADDReduce(long[] a, int idx) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAll(long[] a) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3955,7 +4176,7 @@ static long ADDReduceAll(long[] a) { static void ADDReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3965,10 +4186,10 @@ static void ADDReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3977,19 +4198,19 @@ static void ADDReduceLong128VectorTests(IntFunction fa) { } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -4001,7 +4222,7 @@ static void ADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4011,10 +4232,10 @@ static void ADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4023,18 +4244,18 @@ static void ADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } static long MULReduce(long[] a, int idx) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAll(long[] a) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4044,7 +4265,7 @@ static long MULReduceAll(long[] a) { static void MULReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4054,10 +4275,10 @@ static void MULReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4066,19 +4287,19 @@ static void MULReduceLong128VectorTests(IntFunction fa) { } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAllMasked(long[] a, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4090,7 +4311,7 @@ static void MULReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4100,10 +4321,10 @@ static void MULReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4112,18 +4333,18 @@ static void MULReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } static long MINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4133,7 +4354,7 @@ static long MINReduceAll(long[] a) { static void MINReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4143,10 +4364,10 @@ static void MINReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4155,19 +4376,19 @@ static void MINReduceLong128VectorTests(IntFunction fa) { } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4179,7 +4400,7 @@ static void MINReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4189,10 +4410,10 @@ static void MINReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4201,18 +4422,18 @@ static void MINReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } static long MAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4222,7 +4443,7 @@ static long MAXReduceAll(long[] a) { static void MAXReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4232,10 +4453,10 @@ static void MAXReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4244,19 +4465,19 @@ static void MAXReduceLong128VectorTests(IntFunction fa) { } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4268,7 +4489,7 @@ static void MAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4278,10 +4499,10 @@ static void MAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4290,7 +4511,7 @@ static void MAXReduceLong128VectorTestsMasked(IntFunction fa, IntFunctio } static long UMINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.minUnsigned(res, a[i]); } @@ -4299,7 +4520,7 @@ static long UMINReduce(long[] a, int idx) { } static long UMINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4311,7 +4532,7 @@ static long UMINReduceAll(long[] a) { static void UMINReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4321,7 +4542,7 @@ static void UMINReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4333,7 +4554,7 @@ static void UMINReduceLong128VectorTests(IntFunction fa) { } static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.minUnsigned(res, a[i]); @@ -4343,7 +4564,7 @@ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4357,7 +4578,7 @@ static void UMINReduceLong128VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4367,7 +4588,7 @@ static void UMINReduceLong128VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4379,7 +4600,7 @@ static void UMINReduceLong128VectorTestsMasked(IntFunction fa, IntFuncti } static long UMAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.maxUnsigned(res, a[i]); } @@ -4388,7 +4609,7 @@ static long UMAXReduce(long[] a, int idx) { } static long UMAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4400,7 +4621,7 @@ static long UMAXReduceAll(long[] a) { static void UMAXReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4410,7 +4631,7 @@ static void UMAXReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4422,7 +4643,7 @@ static void UMAXReduceLong128VectorTests(IntFunction fa) { } static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.maxUnsigned(res, a[i]); @@ -4432,7 +4653,7 @@ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4446,7 +4667,7 @@ static void UMAXReduceLong128VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4456,7 +4677,7 @@ static void UMAXReduceLong128VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4468,7 +4689,7 @@ static void UMAXReduceLong128VectorTestsMasked(IntFunction fa, IntFuncti } static long FIRST_NONZEROReduce(long[] a, int idx) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4477,7 +4698,7 @@ static long FIRST_NONZEROReduce(long[] a, int idx) { } static long FIRST_NONZEROReduceAll(long[] a) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4489,7 +4710,7 @@ static long FIRST_NONZEROReduceAll(long[] a) { static void FIRST_NONZEROReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4499,7 +4720,7 @@ static void FIRST_NONZEROReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4511,7 +4732,7 @@ static void FIRST_NONZEROReduceLong128VectorTests(IntFunction fa) { } static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4521,7 +4742,7 @@ static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { } static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4535,7 +4756,7 @@ static void FIRST_NONZEROReduceLong128VectorTestsMasked(IntFunction fa, long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4545,7 +4766,7 @@ static void FIRST_NONZEROReduceLong128VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4605,7 +4826,7 @@ static void allTrueLong128VectorTests(IntFunction fm) { } static long SUADDReduce(long[] a, int idx) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4614,7 +4835,7 @@ static long SUADDReduce(long[] a, int idx) { } static long SUADDReduceAll(long[] a) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4626,7 +4847,7 @@ static long SUADDReduceAll(long[] a) { static void SUADDReduceLong128VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4636,7 +4857,7 @@ static void SUADDReduceLong128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4648,7 +4869,7 @@ static void SUADDReduceLong128VectorTests(IntFunction fa) { } static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4658,7 +4879,7 @@ static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { } static long SUADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4671,7 +4892,7 @@ static void SUADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunct long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4681,7 +4902,7 @@ static void SUADDReduceLong128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4726,7 +4947,7 @@ static void IS_DEFAULTLong128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void IS_DEFAULTMaskedLong128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4767,7 +4988,7 @@ static void IS_NEGATIVELong128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4787,7 +5008,7 @@ static void IS_NEGATIVEMaskedLong128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4806,7 +5027,7 @@ static void LTLong128VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4825,7 +5046,7 @@ static void ltLong128VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4848,7 +5069,7 @@ static void LTLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4890,7 +5111,7 @@ static void GTLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4928,7 +5149,7 @@ static void eqLong128VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4951,7 +5172,7 @@ static void EQLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4993,7 +5214,7 @@ static void NELong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5035,7 +5256,7 @@ static void LELong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5077,7 +5298,7 @@ static void GELong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5119,7 +5340,7 @@ static void ULTLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5161,7 +5382,7 @@ static void UGTLong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5203,7 +5424,7 @@ static void ULELong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5245,7 +5466,7 @@ static void UGELong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5282,7 +5503,7 @@ static void LTLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5299,7 +5520,7 @@ static void EQLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5319,7 +5540,7 @@ static void EQLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5601,7 +5822,7 @@ static void ZeroLong128VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static long[] sliceUnary(long[] a, int origin, int idx) { @@ -6032,11 +6253,11 @@ static void BITWISE_BLENDLong128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6088,11 +6309,11 @@ static void NEGMaskedLong128VectorTests(IntFunction fa, } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6432,7 +6653,7 @@ static void ltLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6448,7 +6669,7 @@ static void eqLong128VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6622,7 +6843,7 @@ static void shuffleMiscellaneousLong128VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index 31e93fe9559a4..3de73024fab88 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -986,19 +986,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("long[intCornerCaseValue(i)]", (int s) -> { + withToString("Long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (long)intCornerCaseValue(i)); }) @@ -1044,15 +1044,15 @@ static long bits(long e) { } static final List> LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1500,6 +1500,218 @@ static boolean ge(long a, long b) { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long multiplicativeIdentity() { + return (long)1; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static long scalar_sin(long a) { + return (long)Math.sin((double)a); + } + + static long scalar_exp(long a) { + return (long)Math.exp((double)a); + } + + static long scalar_log1p(long a) { + return (long)Math.log1p((double)a); + } + + static long scalar_log(long a) { + return (long)Math.log((double)a); + } + + static long scalar_log10(long a) { + return (long)Math.log10((double)a); + } + + static long scalar_expm1(long a) { + return (long)Math.expm1((double)a); + } + + static long scalar_cos(long a) { + return (long)Math.cos((double)a); + } + + static long scalar_tan(long a) { + return (long)Math.tan((double)a); + } + + static long scalar_sinh(long a) { + return (long)Math.sinh((double)a); + } + + static long scalar_cosh(long a) { + return (long)Math.cosh((double)a); + } + + static long scalar_tanh(long a) { + return (long)Math.tanh((double)a); + } + + static long scalar_asin(long a) { + return (long)Math.asin((double)a); + } + + static long scalar_acos(long a) { + return (long)Math.acos((double)a); + } + + static long scalar_atan(long a) { + return (long)Math.atan((double)a); + } + + static long scalar_cbrt(long a) { + return (long)Math.cbrt((double)a); + } + + static long scalar_sqrt(long a) { + return (long)Math.sqrt((double)a); + } + + static long scalar_hypot(long a, long b) { + return (long)Math.hypot((double)a, (double)b); + } + + static long scalar_pow(long a, long b) { + return (long)Math.pow((double)a, (double)b); + } + + static long scalar_atan2(long a, long b) { + return (long)Math.atan2((double)a, (double)b); + } + + static long strict_scalar_sin(long a) { + return (long)StrictMath.sin((double)a); + } + + static long strict_scalar_exp(long a) { + return (long)StrictMath.exp((double)a); + } + + static long strict_scalar_log1p(long a) { + return (long)StrictMath.log1p((double)a); + } + + static long strict_scalar_log(long a) { + return (long)StrictMath.log((double)a); + } + + static long strict_scalar_log10(long a) { + return (long)StrictMath.log10((double)a); + } + + static long strict_scalar_expm1(long a) { + return (long)StrictMath.expm1((double)a); + } + + static long strict_scalar_cos(long a) { + return (long)StrictMath.cos((double)a); + } + + static long strict_scalar_tan(long a) { + return (long)StrictMath.tan((double)a); + } + + static long strict_scalar_sinh(long a) { + return (long)StrictMath.sinh((double)a); + } + + static long strict_scalar_cosh(long a) { + return (long)StrictMath.cosh((double)a); + } + + static long strict_scalar_tanh(long a) { + return (long)StrictMath.tanh((double)a); + } + + static long strict_scalar_asin(long a) { + return (long)StrictMath.asin((double)a); + } + + static long strict_scalar_acos(long a) { + return (long)StrictMath.acos((double)a); + } + + static long strict_scalar_atan(long a) { + return (long)StrictMath.atan((double)a); + } + + static long strict_scalar_cbrt(long a) { + return (long)StrictMath.cbrt((double)a); + } + + static long strict_scalar_sqrt(long a) { + return (long)StrictMath.sqrt((double)a); + } + + static long strict_scalar_hypot(long a, long b) { + return (long)StrictMath.hypot((double)a, (double)b); + } + + static long strict_scalar_pow(long a, long b) { + return (long)StrictMath.pow((double)a, (double)b); + } + + static long strict_scalar_atan2(long a, long b) { + return (long)StrictMath.atan2((double)a, (double)b); + } + static long additiveIdentity() { + return (long)0; + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1516,10 +1728,19 @@ static boolean uge(long a, long b) { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; + static long zeroValue() { + return (short) 0; + } + + static long maxValue() { + return Long.MAX_VALUE; + } + + static long minValue() { + return Long.MIN_VALUE; } + @Test static void smokeTest1() { LongVector three = LongVector.broadcast(SPECIES, (byte)-3); @@ -1632,7 +1853,7 @@ static void bitwiseDivByZeroSmokeTest() { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1653,7 +1874,7 @@ static void ADDLong256VectorTests(IntFunction fa, IntFunction fb } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1710,7 +1931,7 @@ static void addLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1788,7 +2009,7 @@ static void subLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1956,7 +2177,7 @@ static void divLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3261,7 +3482,7 @@ static void MINLong256VectorTests(IntFunction fa, IntFunction fb } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3280,7 +3501,7 @@ static void minLong256VectorTests(IntFunction fa, IntFunction fb } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3301,7 +3522,7 @@ static void MAXLong256VectorTests(IntFunction fa, IntFunction fb } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3669,7 +3890,7 @@ static void SUADDAssocLong256VectorTestsMasked(IntFunction fa, IntFuncti static long ANDReduce(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3678,7 +3899,7 @@ static long ANDReduce(long[] a, int idx) { static long ANDReduceAll(long[] a) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3701,7 +3922,7 @@ static void ANDReduceLong256VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3713,7 +3934,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3722,7 +3943,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3747,7 +3968,7 @@ static void ANDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3758,7 +3979,7 @@ static void ANDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio static long ORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3767,7 +3988,7 @@ static long ORReduce(long[] a, int idx) { static long ORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3790,7 +4011,7 @@ static void ORReduceLong256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3802,7 +4023,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3811,7 +4032,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3836,7 +4057,7 @@ static void ORReduceLong256VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3847,7 +4068,7 @@ static void ORReduceLong256VectorTestsMasked(IntFunction fa, IntFunction static long XORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3856,7 +4077,7 @@ static long XORReduce(long[] a, int idx) { static long XORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3879,7 +4100,7 @@ static void XORReduceLong256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3891,7 +4112,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3900,7 +4121,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3925,7 +4146,7 @@ static void XORReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3934,18 +4155,18 @@ static void XORReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } static long ADDReduce(long[] a, int idx) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAll(long[] a) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3955,7 +4176,7 @@ static long ADDReduceAll(long[] a) { static void ADDReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3965,10 +4186,10 @@ static void ADDReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3977,19 +4198,19 @@ static void ADDReduceLong256VectorTests(IntFunction fa) { } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -4001,7 +4222,7 @@ static void ADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4011,10 +4232,10 @@ static void ADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4023,18 +4244,18 @@ static void ADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } static long MULReduce(long[] a, int idx) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAll(long[] a) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4044,7 +4265,7 @@ static long MULReduceAll(long[] a) { static void MULReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4054,10 +4275,10 @@ static void MULReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4066,19 +4287,19 @@ static void MULReduceLong256VectorTests(IntFunction fa) { } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAllMasked(long[] a, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4090,7 +4311,7 @@ static void MULReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4100,10 +4321,10 @@ static void MULReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4112,18 +4333,18 @@ static void MULReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } static long MINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4133,7 +4354,7 @@ static long MINReduceAll(long[] a) { static void MINReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4143,10 +4364,10 @@ static void MINReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4155,19 +4376,19 @@ static void MINReduceLong256VectorTests(IntFunction fa) { } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4179,7 +4400,7 @@ static void MINReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4189,10 +4410,10 @@ static void MINReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4201,18 +4422,18 @@ static void MINReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } static long MAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4222,7 +4443,7 @@ static long MAXReduceAll(long[] a) { static void MAXReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4232,10 +4453,10 @@ static void MAXReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4244,19 +4465,19 @@ static void MAXReduceLong256VectorTests(IntFunction fa) { } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4268,7 +4489,7 @@ static void MAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4278,10 +4499,10 @@ static void MAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4290,7 +4511,7 @@ static void MAXReduceLong256VectorTestsMasked(IntFunction fa, IntFunctio } static long UMINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.minUnsigned(res, a[i]); } @@ -4299,7 +4520,7 @@ static long UMINReduce(long[] a, int idx) { } static long UMINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4311,7 +4532,7 @@ static long UMINReduceAll(long[] a) { static void UMINReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4321,7 +4542,7 @@ static void UMINReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4333,7 +4554,7 @@ static void UMINReduceLong256VectorTests(IntFunction fa) { } static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.minUnsigned(res, a[i]); @@ -4343,7 +4564,7 @@ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4357,7 +4578,7 @@ static void UMINReduceLong256VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4367,7 +4588,7 @@ static void UMINReduceLong256VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4379,7 +4600,7 @@ static void UMINReduceLong256VectorTestsMasked(IntFunction fa, IntFuncti } static long UMAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.maxUnsigned(res, a[i]); } @@ -4388,7 +4609,7 @@ static long UMAXReduce(long[] a, int idx) { } static long UMAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4400,7 +4621,7 @@ static long UMAXReduceAll(long[] a) { static void UMAXReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4410,7 +4631,7 @@ static void UMAXReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4422,7 +4643,7 @@ static void UMAXReduceLong256VectorTests(IntFunction fa) { } static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.maxUnsigned(res, a[i]); @@ -4432,7 +4653,7 @@ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4446,7 +4667,7 @@ static void UMAXReduceLong256VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4456,7 +4677,7 @@ static void UMAXReduceLong256VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4468,7 +4689,7 @@ static void UMAXReduceLong256VectorTestsMasked(IntFunction fa, IntFuncti } static long FIRST_NONZEROReduce(long[] a, int idx) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4477,7 +4698,7 @@ static long FIRST_NONZEROReduce(long[] a, int idx) { } static long FIRST_NONZEROReduceAll(long[] a) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4489,7 +4710,7 @@ static long FIRST_NONZEROReduceAll(long[] a) { static void FIRST_NONZEROReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4499,7 +4720,7 @@ static void FIRST_NONZEROReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4511,7 +4732,7 @@ static void FIRST_NONZEROReduceLong256VectorTests(IntFunction fa) { } static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4521,7 +4742,7 @@ static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { } static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4535,7 +4756,7 @@ static void FIRST_NONZEROReduceLong256VectorTestsMasked(IntFunction fa, long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4545,7 +4766,7 @@ static void FIRST_NONZEROReduceLong256VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4605,7 +4826,7 @@ static void allTrueLong256VectorTests(IntFunction fm) { } static long SUADDReduce(long[] a, int idx) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4614,7 +4835,7 @@ static long SUADDReduce(long[] a, int idx) { } static long SUADDReduceAll(long[] a) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4626,7 +4847,7 @@ static long SUADDReduceAll(long[] a) { static void SUADDReduceLong256VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4636,7 +4857,7 @@ static void SUADDReduceLong256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4648,7 +4869,7 @@ static void SUADDReduceLong256VectorTests(IntFunction fa) { } static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4658,7 +4879,7 @@ static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { } static long SUADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4671,7 +4892,7 @@ static void SUADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunct long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4681,7 +4902,7 @@ static void SUADDReduceLong256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4726,7 +4947,7 @@ static void IS_DEFAULTLong256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void IS_DEFAULTMaskedLong256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4767,7 +4988,7 @@ static void IS_NEGATIVELong256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4787,7 +5008,7 @@ static void IS_NEGATIVEMaskedLong256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4806,7 +5027,7 @@ static void LTLong256VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4825,7 +5046,7 @@ static void ltLong256VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4848,7 +5069,7 @@ static void LTLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4890,7 +5111,7 @@ static void GTLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4928,7 +5149,7 @@ static void eqLong256VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4951,7 +5172,7 @@ static void EQLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4993,7 +5214,7 @@ static void NELong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5035,7 +5256,7 @@ static void LELong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5077,7 +5298,7 @@ static void GELong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5119,7 +5340,7 @@ static void ULTLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5161,7 +5382,7 @@ static void UGTLong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5203,7 +5424,7 @@ static void ULELong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5245,7 +5466,7 @@ static void UGELong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5282,7 +5503,7 @@ static void LTLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5299,7 +5520,7 @@ static void EQLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5319,7 +5540,7 @@ static void EQLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5601,7 +5822,7 @@ static void ZeroLong256VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static long[] sliceUnary(long[] a, int origin, int idx) { @@ -6032,11 +6253,11 @@ static void BITWISE_BLENDLong256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6088,11 +6309,11 @@ static void NEGMaskedLong256VectorTests(IntFunction fa, } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6432,7 +6653,7 @@ static void ltLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6448,7 +6669,7 @@ static void eqLong256VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6622,7 +6843,7 @@ static void shuffleMiscellaneousLong256VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index 19e115bb7bc7e..eab01c2a353f5 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -986,19 +986,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("long[intCornerCaseValue(i)]", (int s) -> { + withToString("Long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (long)intCornerCaseValue(i)); }) @@ -1044,15 +1044,15 @@ static long bits(long e) { } static final List> LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1500,6 +1500,218 @@ static boolean ge(long a, long b) { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long multiplicativeIdentity() { + return (long)1; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static long scalar_sin(long a) { + return (long)Math.sin((double)a); + } + + static long scalar_exp(long a) { + return (long)Math.exp((double)a); + } + + static long scalar_log1p(long a) { + return (long)Math.log1p((double)a); + } + + static long scalar_log(long a) { + return (long)Math.log((double)a); + } + + static long scalar_log10(long a) { + return (long)Math.log10((double)a); + } + + static long scalar_expm1(long a) { + return (long)Math.expm1((double)a); + } + + static long scalar_cos(long a) { + return (long)Math.cos((double)a); + } + + static long scalar_tan(long a) { + return (long)Math.tan((double)a); + } + + static long scalar_sinh(long a) { + return (long)Math.sinh((double)a); + } + + static long scalar_cosh(long a) { + return (long)Math.cosh((double)a); + } + + static long scalar_tanh(long a) { + return (long)Math.tanh((double)a); + } + + static long scalar_asin(long a) { + return (long)Math.asin((double)a); + } + + static long scalar_acos(long a) { + return (long)Math.acos((double)a); + } + + static long scalar_atan(long a) { + return (long)Math.atan((double)a); + } + + static long scalar_cbrt(long a) { + return (long)Math.cbrt((double)a); + } + + static long scalar_sqrt(long a) { + return (long)Math.sqrt((double)a); + } + + static long scalar_hypot(long a, long b) { + return (long)Math.hypot((double)a, (double)b); + } + + static long scalar_pow(long a, long b) { + return (long)Math.pow((double)a, (double)b); + } + + static long scalar_atan2(long a, long b) { + return (long)Math.atan2((double)a, (double)b); + } + + static long strict_scalar_sin(long a) { + return (long)StrictMath.sin((double)a); + } + + static long strict_scalar_exp(long a) { + return (long)StrictMath.exp((double)a); + } + + static long strict_scalar_log1p(long a) { + return (long)StrictMath.log1p((double)a); + } + + static long strict_scalar_log(long a) { + return (long)StrictMath.log((double)a); + } + + static long strict_scalar_log10(long a) { + return (long)StrictMath.log10((double)a); + } + + static long strict_scalar_expm1(long a) { + return (long)StrictMath.expm1((double)a); + } + + static long strict_scalar_cos(long a) { + return (long)StrictMath.cos((double)a); + } + + static long strict_scalar_tan(long a) { + return (long)StrictMath.tan((double)a); + } + + static long strict_scalar_sinh(long a) { + return (long)StrictMath.sinh((double)a); + } + + static long strict_scalar_cosh(long a) { + return (long)StrictMath.cosh((double)a); + } + + static long strict_scalar_tanh(long a) { + return (long)StrictMath.tanh((double)a); + } + + static long strict_scalar_asin(long a) { + return (long)StrictMath.asin((double)a); + } + + static long strict_scalar_acos(long a) { + return (long)StrictMath.acos((double)a); + } + + static long strict_scalar_atan(long a) { + return (long)StrictMath.atan((double)a); + } + + static long strict_scalar_cbrt(long a) { + return (long)StrictMath.cbrt((double)a); + } + + static long strict_scalar_sqrt(long a) { + return (long)StrictMath.sqrt((double)a); + } + + static long strict_scalar_hypot(long a, long b) { + return (long)StrictMath.hypot((double)a, (double)b); + } + + static long strict_scalar_pow(long a, long b) { + return (long)StrictMath.pow((double)a, (double)b); + } + + static long strict_scalar_atan2(long a, long b) { + return (long)StrictMath.atan2((double)a, (double)b); + } + static long additiveIdentity() { + return (long)0; + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1516,10 +1728,19 @@ static boolean uge(long a, long b) { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; + static long zeroValue() { + return (short) 0; + } + + static long maxValue() { + return Long.MAX_VALUE; + } + + static long minValue() { + return Long.MIN_VALUE; } + @Test static void smokeTest1() { LongVector three = LongVector.broadcast(SPECIES, (byte)-3); @@ -1632,7 +1853,7 @@ static void bitwiseDivByZeroSmokeTest() { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1653,7 +1874,7 @@ static void ADDLong512VectorTests(IntFunction fa, IntFunction fb } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1710,7 +1931,7 @@ static void addLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1788,7 +2009,7 @@ static void subLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1956,7 +2177,7 @@ static void divLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3261,7 +3482,7 @@ static void MINLong512VectorTests(IntFunction fa, IntFunction fb } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3280,7 +3501,7 @@ static void minLong512VectorTests(IntFunction fa, IntFunction fb } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3301,7 +3522,7 @@ static void MAXLong512VectorTests(IntFunction fa, IntFunction fb } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3669,7 +3890,7 @@ static void SUADDAssocLong512VectorTestsMasked(IntFunction fa, IntFuncti static long ANDReduce(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3678,7 +3899,7 @@ static long ANDReduce(long[] a, int idx) { static long ANDReduceAll(long[] a) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3701,7 +3922,7 @@ static void ANDReduceLong512VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3713,7 +3934,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3722,7 +3943,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3747,7 +3968,7 @@ static void ANDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3758,7 +3979,7 @@ static void ANDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio static long ORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3767,7 +3988,7 @@ static long ORReduce(long[] a, int idx) { static long ORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3790,7 +4011,7 @@ static void ORReduceLong512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3802,7 +4023,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3811,7 +4032,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3836,7 +4057,7 @@ static void ORReduceLong512VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3847,7 +4068,7 @@ static void ORReduceLong512VectorTestsMasked(IntFunction fa, IntFunction static long XORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3856,7 +4077,7 @@ static long XORReduce(long[] a, int idx) { static long XORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3879,7 +4100,7 @@ static void XORReduceLong512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3891,7 +4112,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3900,7 +4121,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3925,7 +4146,7 @@ static void XORReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3934,18 +4155,18 @@ static void XORReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } static long ADDReduce(long[] a, int idx) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAll(long[] a) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3955,7 +4176,7 @@ static long ADDReduceAll(long[] a) { static void ADDReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3965,10 +4186,10 @@ static void ADDReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3977,19 +4198,19 @@ static void ADDReduceLong512VectorTests(IntFunction fa) { } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -4001,7 +4222,7 @@ static void ADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4011,10 +4232,10 @@ static void ADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4023,18 +4244,18 @@ static void ADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } static long MULReduce(long[] a, int idx) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAll(long[] a) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4044,7 +4265,7 @@ static long MULReduceAll(long[] a) { static void MULReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4054,10 +4275,10 @@ static void MULReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4066,19 +4287,19 @@ static void MULReduceLong512VectorTests(IntFunction fa) { } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAllMasked(long[] a, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4090,7 +4311,7 @@ static void MULReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4100,10 +4321,10 @@ static void MULReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4112,18 +4333,18 @@ static void MULReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } static long MINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4133,7 +4354,7 @@ static long MINReduceAll(long[] a) { static void MINReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4143,10 +4364,10 @@ static void MINReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4155,19 +4376,19 @@ static void MINReduceLong512VectorTests(IntFunction fa) { } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4179,7 +4400,7 @@ static void MINReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4189,10 +4410,10 @@ static void MINReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4201,18 +4422,18 @@ static void MINReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } static long MAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4222,7 +4443,7 @@ static long MAXReduceAll(long[] a) { static void MAXReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4232,10 +4453,10 @@ static void MAXReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4244,19 +4465,19 @@ static void MAXReduceLong512VectorTests(IntFunction fa) { } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4268,7 +4489,7 @@ static void MAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4278,10 +4499,10 @@ static void MAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4290,7 +4511,7 @@ static void MAXReduceLong512VectorTestsMasked(IntFunction fa, IntFunctio } static long UMINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.minUnsigned(res, a[i]); } @@ -4299,7 +4520,7 @@ static long UMINReduce(long[] a, int idx) { } static long UMINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4311,7 +4532,7 @@ static long UMINReduceAll(long[] a) { static void UMINReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4321,7 +4542,7 @@ static void UMINReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4333,7 +4554,7 @@ static void UMINReduceLong512VectorTests(IntFunction fa) { } static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.minUnsigned(res, a[i]); @@ -4343,7 +4564,7 @@ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4357,7 +4578,7 @@ static void UMINReduceLong512VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4367,7 +4588,7 @@ static void UMINReduceLong512VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4379,7 +4600,7 @@ static void UMINReduceLong512VectorTestsMasked(IntFunction fa, IntFuncti } static long UMAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.maxUnsigned(res, a[i]); } @@ -4388,7 +4609,7 @@ static long UMAXReduce(long[] a, int idx) { } static long UMAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4400,7 +4621,7 @@ static long UMAXReduceAll(long[] a) { static void UMAXReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4410,7 +4631,7 @@ static void UMAXReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4422,7 +4643,7 @@ static void UMAXReduceLong512VectorTests(IntFunction fa) { } static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.maxUnsigned(res, a[i]); @@ -4432,7 +4653,7 @@ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4446,7 +4667,7 @@ static void UMAXReduceLong512VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4456,7 +4677,7 @@ static void UMAXReduceLong512VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4468,7 +4689,7 @@ static void UMAXReduceLong512VectorTestsMasked(IntFunction fa, IntFuncti } static long FIRST_NONZEROReduce(long[] a, int idx) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4477,7 +4698,7 @@ static long FIRST_NONZEROReduce(long[] a, int idx) { } static long FIRST_NONZEROReduceAll(long[] a) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4489,7 +4710,7 @@ static long FIRST_NONZEROReduceAll(long[] a) { static void FIRST_NONZEROReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4499,7 +4720,7 @@ static void FIRST_NONZEROReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4511,7 +4732,7 @@ static void FIRST_NONZEROReduceLong512VectorTests(IntFunction fa) { } static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4521,7 +4742,7 @@ static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { } static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4535,7 +4756,7 @@ static void FIRST_NONZEROReduceLong512VectorTestsMasked(IntFunction fa, long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4545,7 +4766,7 @@ static void FIRST_NONZEROReduceLong512VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4605,7 +4826,7 @@ static void allTrueLong512VectorTests(IntFunction fm) { } static long SUADDReduce(long[] a, int idx) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4614,7 +4835,7 @@ static long SUADDReduce(long[] a, int idx) { } static long SUADDReduceAll(long[] a) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4626,7 +4847,7 @@ static long SUADDReduceAll(long[] a) { static void SUADDReduceLong512VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4636,7 +4857,7 @@ static void SUADDReduceLong512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4648,7 +4869,7 @@ static void SUADDReduceLong512VectorTests(IntFunction fa) { } static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4658,7 +4879,7 @@ static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { } static long SUADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4671,7 +4892,7 @@ static void SUADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunct long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4681,7 +4902,7 @@ static void SUADDReduceLong512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4726,7 +4947,7 @@ static void IS_DEFAULTLong512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void IS_DEFAULTMaskedLong512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4767,7 +4988,7 @@ static void IS_NEGATIVELong512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4787,7 +5008,7 @@ static void IS_NEGATIVEMaskedLong512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4806,7 +5027,7 @@ static void LTLong512VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4825,7 +5046,7 @@ static void ltLong512VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4848,7 +5069,7 @@ static void LTLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4890,7 +5111,7 @@ static void GTLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4928,7 +5149,7 @@ static void eqLong512VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4951,7 +5172,7 @@ static void EQLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4993,7 +5214,7 @@ static void NELong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5035,7 +5256,7 @@ static void LELong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5077,7 +5298,7 @@ static void GELong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5119,7 +5340,7 @@ static void ULTLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5161,7 +5382,7 @@ static void UGTLong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5203,7 +5424,7 @@ static void ULELong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5245,7 +5466,7 @@ static void UGELong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5282,7 +5503,7 @@ static void LTLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5299,7 +5520,7 @@ static void EQLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5319,7 +5540,7 @@ static void EQLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5601,7 +5822,7 @@ static void ZeroLong512VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static long[] sliceUnary(long[] a, int origin, int idx) { @@ -6032,11 +6253,11 @@ static void BITWISE_BLENDLong512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6088,11 +6309,11 @@ static void NEGMaskedLong512VectorTests(IntFunction fa, } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6432,7 +6653,7 @@ static void ltLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6448,7 +6669,7 @@ static void eqLong512VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6622,7 +6843,7 @@ static void shuffleMiscellaneousLong512VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index d5c4f3ae2459c..81f08d3b7906c 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -986,19 +986,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("long[intCornerCaseValue(i)]", (int s) -> { + withToString("Long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (long)intCornerCaseValue(i)); }) @@ -1044,15 +1044,15 @@ static long bits(long e) { } static final List> LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1500,6 +1500,218 @@ static boolean ge(long a, long b) { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long multiplicativeIdentity() { + return (long)1; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static long scalar_sin(long a) { + return (long)Math.sin((double)a); + } + + static long scalar_exp(long a) { + return (long)Math.exp((double)a); + } + + static long scalar_log1p(long a) { + return (long)Math.log1p((double)a); + } + + static long scalar_log(long a) { + return (long)Math.log((double)a); + } + + static long scalar_log10(long a) { + return (long)Math.log10((double)a); + } + + static long scalar_expm1(long a) { + return (long)Math.expm1((double)a); + } + + static long scalar_cos(long a) { + return (long)Math.cos((double)a); + } + + static long scalar_tan(long a) { + return (long)Math.tan((double)a); + } + + static long scalar_sinh(long a) { + return (long)Math.sinh((double)a); + } + + static long scalar_cosh(long a) { + return (long)Math.cosh((double)a); + } + + static long scalar_tanh(long a) { + return (long)Math.tanh((double)a); + } + + static long scalar_asin(long a) { + return (long)Math.asin((double)a); + } + + static long scalar_acos(long a) { + return (long)Math.acos((double)a); + } + + static long scalar_atan(long a) { + return (long)Math.atan((double)a); + } + + static long scalar_cbrt(long a) { + return (long)Math.cbrt((double)a); + } + + static long scalar_sqrt(long a) { + return (long)Math.sqrt((double)a); + } + + static long scalar_hypot(long a, long b) { + return (long)Math.hypot((double)a, (double)b); + } + + static long scalar_pow(long a, long b) { + return (long)Math.pow((double)a, (double)b); + } + + static long scalar_atan2(long a, long b) { + return (long)Math.atan2((double)a, (double)b); + } + + static long strict_scalar_sin(long a) { + return (long)StrictMath.sin((double)a); + } + + static long strict_scalar_exp(long a) { + return (long)StrictMath.exp((double)a); + } + + static long strict_scalar_log1p(long a) { + return (long)StrictMath.log1p((double)a); + } + + static long strict_scalar_log(long a) { + return (long)StrictMath.log((double)a); + } + + static long strict_scalar_log10(long a) { + return (long)StrictMath.log10((double)a); + } + + static long strict_scalar_expm1(long a) { + return (long)StrictMath.expm1((double)a); + } + + static long strict_scalar_cos(long a) { + return (long)StrictMath.cos((double)a); + } + + static long strict_scalar_tan(long a) { + return (long)StrictMath.tan((double)a); + } + + static long strict_scalar_sinh(long a) { + return (long)StrictMath.sinh((double)a); + } + + static long strict_scalar_cosh(long a) { + return (long)StrictMath.cosh((double)a); + } + + static long strict_scalar_tanh(long a) { + return (long)StrictMath.tanh((double)a); + } + + static long strict_scalar_asin(long a) { + return (long)StrictMath.asin((double)a); + } + + static long strict_scalar_acos(long a) { + return (long)StrictMath.acos((double)a); + } + + static long strict_scalar_atan(long a) { + return (long)StrictMath.atan((double)a); + } + + static long strict_scalar_cbrt(long a) { + return (long)StrictMath.cbrt((double)a); + } + + static long strict_scalar_sqrt(long a) { + return (long)StrictMath.sqrt((double)a); + } + + static long strict_scalar_hypot(long a, long b) { + return (long)StrictMath.hypot((double)a, (double)b); + } + + static long strict_scalar_pow(long a, long b) { + return (long)StrictMath.pow((double)a, (double)b); + } + + static long strict_scalar_atan2(long a, long b) { + return (long)StrictMath.atan2((double)a, (double)b); + } + static long additiveIdentity() { + return (long)0; + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1516,10 +1728,19 @@ static boolean uge(long a, long b) { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; + static long zeroValue() { + return (short) 0; + } + + static long maxValue() { + return Long.MAX_VALUE; + } + + static long minValue() { + return Long.MIN_VALUE; } + @Test static void smokeTest1() { LongVector three = LongVector.broadcast(SPECIES, (byte)-3); @@ -1632,7 +1853,7 @@ static void bitwiseDivByZeroSmokeTest() { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1653,7 +1874,7 @@ static void ADDLong64VectorTests(IntFunction fa, IntFunction fb) } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1710,7 +1931,7 @@ static void addLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1788,7 +2009,7 @@ static void subLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1956,7 +2177,7 @@ static void divLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunct } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3261,7 +3482,7 @@ static void MINLong64VectorTests(IntFunction fa, IntFunction fb) } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3280,7 +3501,7 @@ static void minLong64VectorTests(IntFunction fa, IntFunction fb) } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3301,7 +3522,7 @@ static void MAXLong64VectorTests(IntFunction fa, IntFunction fb) } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3669,7 +3890,7 @@ static void SUADDAssocLong64VectorTestsMasked(IntFunction fa, IntFunctio static long ANDReduce(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3678,7 +3899,7 @@ static long ANDReduce(long[] a, int idx) { static long ANDReduceAll(long[] a) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3701,7 +3922,7 @@ static void ANDReduceLong64VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3713,7 +3934,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3722,7 +3943,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3747,7 +3968,7 @@ static void ANDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3758,7 +3979,7 @@ static void ANDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction static long ORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3767,7 +3988,7 @@ static long ORReduce(long[] a, int idx) { static long ORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3790,7 +4011,7 @@ static void ORReduceLong64VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3802,7 +4023,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3811,7 +4032,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3836,7 +4057,7 @@ static void ORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction< ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3847,7 +4068,7 @@ static void ORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction< static long XORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3856,7 +4077,7 @@ static long XORReduce(long[] a, int idx) { static long XORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3879,7 +4100,7 @@ static void XORReduceLong64VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3891,7 +4112,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3900,7 +4121,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3925,7 +4146,7 @@ static void XORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3934,18 +4155,18 @@ static void XORReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } static long ADDReduce(long[] a, int idx) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAll(long[] a) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3955,7 +4176,7 @@ static long ADDReduceAll(long[] a) { static void ADDReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3965,10 +4186,10 @@ static void ADDReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3977,19 +4198,19 @@ static void ADDReduceLong64VectorTests(IntFunction fa) { } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -4001,7 +4222,7 @@ static void ADDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4011,10 +4232,10 @@ static void ADDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4023,18 +4244,18 @@ static void ADDReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } static long MULReduce(long[] a, int idx) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAll(long[] a) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4044,7 +4265,7 @@ static long MULReduceAll(long[] a) { static void MULReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4054,10 +4275,10 @@ static void MULReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4066,19 +4287,19 @@ static void MULReduceLong64VectorTests(IntFunction fa) { } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAllMasked(long[] a, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4090,7 +4311,7 @@ static void MULReduceLong64VectorTestsMasked(IntFunction fa, IntFunction long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4100,10 +4321,10 @@ static void MULReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4112,18 +4333,18 @@ static void MULReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } static long MINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4133,7 +4354,7 @@ static long MINReduceAll(long[] a) { static void MINReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4143,10 +4364,10 @@ static void MINReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4155,19 +4376,19 @@ static void MINReduceLong64VectorTests(IntFunction fa) { } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4179,7 +4400,7 @@ static void MINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4189,10 +4410,10 @@ static void MINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4201,18 +4422,18 @@ static void MINReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } static long MAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4222,7 +4443,7 @@ static long MAXReduceAll(long[] a) { static void MAXReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4232,10 +4453,10 @@ static void MAXReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4244,19 +4465,19 @@ static void MAXReduceLong64VectorTests(IntFunction fa) { } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4268,7 +4489,7 @@ static void MAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4278,10 +4499,10 @@ static void MAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4290,7 +4511,7 @@ static void MAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunction } static long UMINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.minUnsigned(res, a[i]); } @@ -4299,7 +4520,7 @@ static long UMINReduce(long[] a, int idx) { } static long UMINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4311,7 +4532,7 @@ static long UMINReduceAll(long[] a) { static void UMINReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4321,7 +4542,7 @@ static void UMINReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4333,7 +4554,7 @@ static void UMINReduceLong64VectorTests(IntFunction fa) { } static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.minUnsigned(res, a[i]); @@ -4343,7 +4564,7 @@ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4357,7 +4578,7 @@ static void UMINReduceLong64VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4367,7 +4588,7 @@ static void UMINReduceLong64VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4379,7 +4600,7 @@ static void UMINReduceLong64VectorTestsMasked(IntFunction fa, IntFunctio } static long UMAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.maxUnsigned(res, a[i]); } @@ -4388,7 +4609,7 @@ static long UMAXReduce(long[] a, int idx) { } static long UMAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4400,7 +4621,7 @@ static long UMAXReduceAll(long[] a) { static void UMAXReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4410,7 +4631,7 @@ static void UMAXReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4422,7 +4643,7 @@ static void UMAXReduceLong64VectorTests(IntFunction fa) { } static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.maxUnsigned(res, a[i]); @@ -4432,7 +4653,7 @@ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4446,7 +4667,7 @@ static void UMAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4456,7 +4677,7 @@ static void UMAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4468,7 +4689,7 @@ static void UMAXReduceLong64VectorTestsMasked(IntFunction fa, IntFunctio } static long FIRST_NONZEROReduce(long[] a, int idx) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4477,7 +4698,7 @@ static long FIRST_NONZEROReduce(long[] a, int idx) { } static long FIRST_NONZEROReduceAll(long[] a) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4489,7 +4710,7 @@ static long FIRST_NONZEROReduceAll(long[] a) { static void FIRST_NONZEROReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4499,7 +4720,7 @@ static void FIRST_NONZEROReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4511,7 +4732,7 @@ static void FIRST_NONZEROReduceLong64VectorTests(IntFunction fa) { } static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4521,7 +4742,7 @@ static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { } static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4535,7 +4756,7 @@ static void FIRST_NONZEROReduceLong64VectorTestsMasked(IntFunction fa, I long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4545,7 +4766,7 @@ static void FIRST_NONZEROReduceLong64VectorTestsMasked(IntFunction fa, I } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4605,7 +4826,7 @@ static void allTrueLong64VectorTests(IntFunction fm) { } static long SUADDReduce(long[] a, int idx) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4614,7 +4835,7 @@ static long SUADDReduce(long[] a, int idx) { } static long SUADDReduceAll(long[] a) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4626,7 +4847,7 @@ static long SUADDReduceAll(long[] a) { static void SUADDReduceLong64VectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4636,7 +4857,7 @@ static void SUADDReduceLong64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4648,7 +4869,7 @@ static void SUADDReduceLong64VectorTests(IntFunction fa) { } static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4658,7 +4879,7 @@ static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { } static long SUADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4671,7 +4892,7 @@ static void SUADDReduceLong64VectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4681,7 +4902,7 @@ static void SUADDReduceLong64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4726,7 +4947,7 @@ static void IS_DEFAULTLong64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4746,7 +4967,7 @@ static void IS_DEFAULTMaskedLong64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4767,7 +4988,7 @@ static void IS_NEGATIVELong64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4787,7 +5008,7 @@ static void IS_NEGATIVEMaskedLong64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4806,7 +5027,7 @@ static void LTLong64VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4825,7 +5046,7 @@ static void ltLong64VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4848,7 +5069,7 @@ static void LTLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4890,7 +5111,7 @@ static void GTLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4928,7 +5149,7 @@ static void eqLong64VectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4951,7 +5172,7 @@ static void EQLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4993,7 +5214,7 @@ static void NELong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5035,7 +5256,7 @@ static void LELong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5077,7 +5298,7 @@ static void GELong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5119,7 +5340,7 @@ static void ULTLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5161,7 +5382,7 @@ static void UGTLong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5203,7 +5424,7 @@ static void ULELong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5245,7 +5466,7 @@ static void UGELong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFun // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5282,7 +5503,7 @@ static void LTLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5299,7 +5520,7 @@ static void EQLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5319,7 +5540,7 @@ static void EQLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5601,7 +5822,7 @@ static void ZeroLong64VectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static long[] sliceUnary(long[] a, int origin, int idx) { @@ -6032,11 +6253,11 @@ static void BITWISE_BLENDLong64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunc } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6088,11 +6309,11 @@ static void NEGMaskedLong64VectorTests(IntFunction fa, } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6432,7 +6653,7 @@ static void ltLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFun // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6448,7 +6669,7 @@ static void eqLong64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6622,7 +6843,7 @@ static void shuffleMiscellaneousLong64VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index 027568e2588a0..d5282de01b7c8 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -991,19 +991,19 @@ static int intCornerCaseValue(int i) { } static final List> INT_LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("long[intCornerCaseValue(i)]", (int s) -> { + withToString("Long[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> (long)intCornerCaseValue(i)); }) @@ -1049,15 +1049,15 @@ static long bits(long e) { } static final List> LONG_GENERATORS = List.of( - withToString("long[-i * 5]", (int s) -> { + withToString("Long[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("long[i * 5]", (int s) -> { + withToString("Long[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("long[i + 1]", (int s) -> { + withToString("Long[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((long)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1505,6 +1505,218 @@ static boolean ge(long a, long b) { return a >= b; } + static long firstNonZero(long a, long b) { + return Long.compare(a, (long) 0) != 0 ? a : b; + } + + static long multiplicativeIdentity() { + return (long)1; + } + + static long scalar_or(long a, long b) { + return (long)(a | b); + } + + static long scalar_and(long a, long b) { + return (long)(a & b); + } + + static long scalar_xor(long a, long b) { + return (long)(a ^ b); + } + + static long scalar_add(long a, long b) { + return (long)(a + b); + } + + static long scalar_sub(long a, long b) { + return (long)(a - b); + } + + static long scalar_mul(long a, long b) { + return (long)(a * b); + } + + static long scalar_min(long a, long b) { + return (long)(Math.min(a, b)); + } + + static long scalar_max(long a, long b) { + return (long)(Math.max(a, b)); + } + + static long scalar_div(long a, long b) { + return (long)(a / b); + } + + static long scalar_fma(long a, long b, long c) { + return (long)(Math.fma(a, b, c)); + } + + static long scalar_abs(long a) { + return (long)(Math.abs(a)); + } + + static long scalar_neg(long a) { + return ((long)-a); + } + + static long scalar_sin(long a) { + return (long)Math.sin((double)a); + } + + static long scalar_exp(long a) { + return (long)Math.exp((double)a); + } + + static long scalar_log1p(long a) { + return (long)Math.log1p((double)a); + } + + static long scalar_log(long a) { + return (long)Math.log((double)a); + } + + static long scalar_log10(long a) { + return (long)Math.log10((double)a); + } + + static long scalar_expm1(long a) { + return (long)Math.expm1((double)a); + } + + static long scalar_cos(long a) { + return (long)Math.cos((double)a); + } + + static long scalar_tan(long a) { + return (long)Math.tan((double)a); + } + + static long scalar_sinh(long a) { + return (long)Math.sinh((double)a); + } + + static long scalar_cosh(long a) { + return (long)Math.cosh((double)a); + } + + static long scalar_tanh(long a) { + return (long)Math.tanh((double)a); + } + + static long scalar_asin(long a) { + return (long)Math.asin((double)a); + } + + static long scalar_acos(long a) { + return (long)Math.acos((double)a); + } + + static long scalar_atan(long a) { + return (long)Math.atan((double)a); + } + + static long scalar_cbrt(long a) { + return (long)Math.cbrt((double)a); + } + + static long scalar_sqrt(long a) { + return (long)Math.sqrt((double)a); + } + + static long scalar_hypot(long a, long b) { + return (long)Math.hypot((double)a, (double)b); + } + + static long scalar_pow(long a, long b) { + return (long)Math.pow((double)a, (double)b); + } + + static long scalar_atan2(long a, long b) { + return (long)Math.atan2((double)a, (double)b); + } + + static long strict_scalar_sin(long a) { + return (long)StrictMath.sin((double)a); + } + + static long strict_scalar_exp(long a) { + return (long)StrictMath.exp((double)a); + } + + static long strict_scalar_log1p(long a) { + return (long)StrictMath.log1p((double)a); + } + + static long strict_scalar_log(long a) { + return (long)StrictMath.log((double)a); + } + + static long strict_scalar_log10(long a) { + return (long)StrictMath.log10((double)a); + } + + static long strict_scalar_expm1(long a) { + return (long)StrictMath.expm1((double)a); + } + + static long strict_scalar_cos(long a) { + return (long)StrictMath.cos((double)a); + } + + static long strict_scalar_tan(long a) { + return (long)StrictMath.tan((double)a); + } + + static long strict_scalar_sinh(long a) { + return (long)StrictMath.sinh((double)a); + } + + static long strict_scalar_cosh(long a) { + return (long)StrictMath.cosh((double)a); + } + + static long strict_scalar_tanh(long a) { + return (long)StrictMath.tanh((double)a); + } + + static long strict_scalar_asin(long a) { + return (long)StrictMath.asin((double)a); + } + + static long strict_scalar_acos(long a) { + return (long)StrictMath.acos((double)a); + } + + static long strict_scalar_atan(long a) { + return (long)StrictMath.atan((double)a); + } + + static long strict_scalar_cbrt(long a) { + return (long)StrictMath.cbrt((double)a); + } + + static long strict_scalar_sqrt(long a) { + return (long)StrictMath.sqrt((double)a); + } + + static long strict_scalar_hypot(long a, long b) { + return (long)StrictMath.hypot((double)a, (double)b); + } + + static long strict_scalar_pow(long a, long b) { + return (long)StrictMath.pow((double)a, (double)b); + } + + static long strict_scalar_atan2(long a, long b) { + return (long)StrictMath.atan2((double)a, (double)b); + } + static long additiveIdentity() { + return (long)0; + } + + static boolean ult(long a, long b) { return Long.compareUnsigned(a, b) < 0; } @@ -1521,10 +1733,19 @@ static boolean uge(long a, long b) { return Long.compareUnsigned(a, b) >= 0; } - static long firstNonZero(long a, long b) { - return Long.compare(a, (long) 0) != 0 ? a : b; + static long zeroValue() { + return (short) 0; + } + + static long maxValue() { + return Long.MAX_VALUE; + } + + static long minValue() { + return Long.MIN_VALUE; } + @Test static void smokeTest1() { LongVector three = LongVector.broadcast(SPECIES, (byte)-3); @@ -1637,7 +1858,7 @@ static void bitwiseDivByZeroSmokeTest() { } static long ADD(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1658,7 +1879,7 @@ static void ADDLongMaxVectorTests(IntFunction fa, IntFunction fb } static long add(long a, long b) { - return (long)(a + b); + return (long)(scalar_add(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1715,7 +1936,7 @@ static void addLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long sub(long a, long b) { - return (long)(a - b); + return (long)(scalar_sub(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1793,7 +2014,7 @@ static void subLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb } static long mul(long a, long b) { - return (long)(a * b); + return (long)(scalar_mul(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -1961,7 +2182,7 @@ static void divLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunc } static long MIN(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3266,7 +3487,7 @@ static void MINLongMaxVectorTests(IntFunction fa, IntFunction fb } static long min(long a, long b) { - return (long)(Math.min(a, b)); + return (long)(scalar_min(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3285,7 +3506,7 @@ static void minLongMaxVectorTests(IntFunction fa, IntFunction fb } static long MAX(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3306,7 +3527,7 @@ static void MAXLongMaxVectorTests(IntFunction fa, IntFunction fb } static long max(long a, long b) { - return (long)(Math.max(a, b)); + return (long)(scalar_max(a, b)); } @Test(dataProvider = "longBinaryOpProvider") @@ -3674,7 +3895,7 @@ static void SUADDAssocLongMaxVectorTestsMasked(IntFunction fa, IntFuncti static long ANDReduce(long[] a, int idx) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3683,7 +3904,7 @@ static long ANDReduce(long[] a, int idx) { static long ANDReduceAll(long[] a) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3706,7 +3927,7 @@ static void ANDReduceLongMaxVectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3718,7 +3939,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { long res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3727,7 +3948,7 @@ static long ANDReduceMasked(long[] a, int idx, boolean[] mask) { static long ANDReduceAllMasked(long[] a, boolean[] mask) { long res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3752,7 +3973,7 @@ static void ANDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3763,7 +3984,7 @@ static void ANDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio static long ORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3772,7 +3993,7 @@ static long ORReduce(long[] a, int idx) { static long ORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3795,7 +4016,7 @@ static void ORReduceLongMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3807,7 +4028,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3816,7 +4037,7 @@ static long ORReduceMasked(long[] a, int idx, boolean[] mask) { static long ORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3841,7 +4062,7 @@ static void ORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3852,7 +4073,7 @@ static void ORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunction static long XORReduce(long[] a, int idx) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3861,7 +4082,7 @@ static long XORReduce(long[] a, int idx) { static long XORReduceAll(long[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3884,7 +4105,7 @@ static void XORReduceLongMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3896,7 +4117,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { long res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3905,7 +4126,7 @@ static long XORReduceMasked(long[] a, int idx, boolean[] mask) { static long XORReduceAllMasked(long[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3930,7 +4151,7 @@ static void XORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3939,18 +4160,18 @@ static void XORReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } static long ADDReduce(long[] a, int idx) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAll(long[] a) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3960,7 +4181,7 @@ static long ADDReduceAll(long[] a) { static void ADDReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3970,10 +4191,10 @@ static void ADDReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3982,19 +4203,19 @@ static void ADDReduceLongMaxVectorTests(IntFunction fa) { } static long ADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static long ADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -4006,7 +4227,7 @@ static void ADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4016,10 +4237,10 @@ static void ADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -4028,18 +4249,18 @@ static void ADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } static long MULReduce(long[] a, int idx) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAll(long[] a) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -4049,7 +4270,7 @@ static long MULReduceAll(long[] a) { static void MULReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4059,10 +4280,10 @@ static void MULReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4071,19 +4292,19 @@ static void MULReduceLongMaxVectorTests(IntFunction fa) { } static long MULReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static long MULReduceAllMasked(long[] a, boolean[] mask) { - long res = 1; + long res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4095,7 +4316,7 @@ static void MULReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 1; + long ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4105,10 +4326,10 @@ static void MULReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4117,18 +4338,18 @@ static void MULReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } static long MINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4138,7 +4359,7 @@ static long MINReduceAll(long[] a) { static void MINReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4148,10 +4369,10 @@ static void MINReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4160,19 +4381,19 @@ static void MINReduceLongMaxVectorTests(IntFunction fa) { } static long MINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static long MINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4184,7 +4405,7 @@ static void MINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4194,10 +4415,10 @@ static void MINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4206,18 +4427,18 @@ static void MINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } static long MAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4227,7 +4448,7 @@ static long MAXReduceAll(long[] a) { static void MAXReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4237,10 +4458,10 @@ static void MAXReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4249,19 +4470,19 @@ static void MAXReduceLongMaxVectorTests(IntFunction fa) { } static long MAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (long) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static long MAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (long) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4273,7 +4494,7 @@ static void MAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4283,10 +4504,10 @@ static void MAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - ra = (long) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4295,7 +4516,7 @@ static void MAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunctio } static long UMINReduce(long[] a, int idx) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.minUnsigned(res, a[i]); } @@ -4304,7 +4525,7 @@ static long UMINReduce(long[] a, int idx) { } static long UMINReduceAll(long[] a) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4316,7 +4537,7 @@ static long UMINReduceAll(long[] a) { static void UMINReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4326,7 +4547,7 @@ static void UMINReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4338,7 +4559,7 @@ static void UMINReduceLongMaxVectorTests(IntFunction fa) { } static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.minUnsigned(res, a[i]); @@ -4348,7 +4569,7 @@ static long UMINReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMINReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MAX_VALUE; + long res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4362,7 +4583,7 @@ static void UMINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MAX_VALUE; + long ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4372,7 +4593,7 @@ static void UMINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4384,7 +4605,7 @@ static void UMINReduceLongMaxVectorTestsMasked(IntFunction fa, IntFuncti } static long UMAXReduce(long[] a, int idx) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.maxUnsigned(res, a[i]); } @@ -4393,7 +4614,7 @@ static long UMAXReduce(long[] a, int idx) { } static long UMAXReduceAll(long[] a) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4405,7 +4626,7 @@ static long UMAXReduceAll(long[] a) { static void UMAXReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4415,7 +4636,7 @@ static void UMAXReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4427,7 +4648,7 @@ static void UMAXReduceLongMaxVectorTests(IntFunction fa) { } static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.maxUnsigned(res, a[i]); @@ -4437,7 +4658,7 @@ static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) { } static long UMAXReduceAllMasked(long[] a, boolean[] mask) { - long res = Long.MIN_VALUE; + long res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4451,7 +4672,7 @@ static void UMAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFuncti long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = Long.MIN_VALUE; + long ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4461,7 +4682,7 @@ static void UMAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Long.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4473,7 +4694,7 @@ static void UMAXReduceLongMaxVectorTestsMasked(IntFunction fa, IntFuncti } static long FIRST_NONZEROReduce(long[] a, int idx) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4482,7 +4703,7 @@ static long FIRST_NONZEROReduce(long[] a, int idx) { } static long FIRST_NONZEROReduceAll(long[] a) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4494,7 +4715,7 @@ static long FIRST_NONZEROReduceAll(long[] a) { static void FIRST_NONZEROReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4504,7 +4725,7 @@ static void FIRST_NONZEROReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4516,7 +4737,7 @@ static void FIRST_NONZEROReduceLongMaxVectorTests(IntFunction fa) { } static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4526,7 +4747,7 @@ static long FIRST_NONZEROReduceMasked(long[] a, int idx, boolean[] mask) { } static long FIRST_NONZEROReduceAllMasked(long[] a, boolean[] mask) { - long res = (long) 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4540,7 +4761,7 @@ static void FIRST_NONZEROReduceLongMaxVectorTestsMasked(IntFunction fa, long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = (long) 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4550,7 +4771,7 @@ static void FIRST_NONZEROReduceLongMaxVectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (long) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4610,7 +4831,7 @@ static void allTrueLongMaxVectorTests(IntFunction fm) { } static long SUADDReduce(long[] a, int idx) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4619,7 +4840,7 @@ static long SUADDReduce(long[] a, int idx) { } static long SUADDReduceAll(long[] a) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4631,7 +4852,7 @@ static long SUADDReduceAll(long[] a) { static void SUADDReduceLongMaxVectorTests(IntFunction fa) { long[] a = fa.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4641,7 +4862,7 @@ static void SUADDReduceLongMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4653,7 +4874,7 @@ static void SUADDReduceLongMaxVectorTests(IntFunction fa) { } static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (long) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4663,7 +4884,7 @@ static long SUADDReduceMasked(long[] a, int idx, boolean[] mask) { } static long SUADDReduceAllMasked(long[] a, boolean[] mask) { - long res = 0; + long res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (long) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4676,7 +4897,7 @@ static void SUADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunct long[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - long ra = 0; + long ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4686,7 +4907,7 @@ static void SUADDReduceLongMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); ra = (long) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4731,7 +4952,7 @@ static void IS_DEFAULTLongMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4751,7 +4972,7 @@ static void IS_DEFAULTMaskedLongMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4772,7 +4993,7 @@ static void IS_NEGATIVELongMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4792,7 +5013,7 @@ static void IS_NEGATIVEMaskedLongMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4811,7 +5032,7 @@ static void LTLongMaxVectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4830,7 +5051,7 @@ static void ltLongMaxVectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4853,7 +5074,7 @@ static void LTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4895,7 +5116,7 @@ static void GTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4933,7 +5154,7 @@ static void eqLongMaxVectorTests(IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4956,7 +5177,7 @@ static void EQLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4998,7 +5219,7 @@ static void NELongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -5040,7 +5261,7 @@ static void LELongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5082,7 +5303,7 @@ static void GELongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5124,7 +5345,7 @@ static void ULTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5166,7 +5387,7 @@ static void UGTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5208,7 +5429,7 @@ static void ULELongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5250,7 +5471,7 @@ static void UGELongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5287,7 +5508,7 @@ static void LTLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5304,7 +5525,7 @@ static void EQLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5324,7 +5545,7 @@ static void EQLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5606,7 +5827,7 @@ static void ZeroLongMaxVectorTests(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static long[] sliceUnary(long[] a, int origin, int idx) { @@ -6037,11 +6258,11 @@ static void BITWISE_BLENDLongMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static long NEG(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } static long neg(long a) { - return (long)(-((long)a)); + return (long)(scalar_neg((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6093,11 +6314,11 @@ static void NEGMaskedLongMaxVectorTests(IntFunction fa, } static long ABS(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } static long abs(long a) { - return (long)(Math.abs((long)a)); + return (long)(scalar_abs((long)a)); } @Test(dataProvider = "longUnaryOpProvider") @@ -6437,7 +6658,7 @@ static void ltLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFu // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6453,7 +6674,7 @@ static void eqLongMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6627,7 +6848,7 @@ static void shuffleMiscellaneousLongMaxVectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index 68357b1974b58..603589db5c1b1 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -1060,15 +1060,15 @@ static short bits(short e) { } static final List> SHORT_GENERATORS = List.of( - withToString("short[-i * 5]", (int s) -> { + withToString("Short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("short[i * 5]", (int s) -> { + withToString("Short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("short[i + 1]", (int s) -> { + withToString("Short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1518,6 +1518,218 @@ static boolean ge(short a, short b) { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)1; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static short scalar_sin(short a) { + return (short)Math.sin((double)a); + } + + static short scalar_exp(short a) { + return (short)Math.exp((double)a); + } + + static short scalar_log1p(short a) { + return (short)Math.log1p((double)a); + } + + static short scalar_log(short a) { + return (short)Math.log((double)a); + } + + static short scalar_log10(short a) { + return (short)Math.log10((double)a); + } + + static short scalar_expm1(short a) { + return (short)Math.expm1((double)a); + } + + static short scalar_cos(short a) { + return (short)Math.cos((double)a); + } + + static short scalar_tan(short a) { + return (short)Math.tan((double)a); + } + + static short scalar_sinh(short a) { + return (short)Math.sinh((double)a); + } + + static short scalar_cosh(short a) { + return (short)Math.cosh((double)a); + } + + static short scalar_tanh(short a) { + return (short)Math.tanh((double)a); + } + + static short scalar_asin(short a) { + return (short)Math.asin((double)a); + } + + static short scalar_acos(short a) { + return (short)Math.acos((double)a); + } + + static short scalar_atan(short a) { + return (short)Math.atan((double)a); + } + + static short scalar_cbrt(short a) { + return (short)Math.cbrt((double)a); + } + + static short scalar_sqrt(short a) { + return (short)Math.sqrt((double)a); + } + + static short scalar_hypot(short a, short b) { + return (short)Math.hypot((double)a, (double)b); + } + + static short scalar_pow(short a, short b) { + return (short)Math.pow((double)a, (double)b); + } + + static short scalar_atan2(short a, short b) { + return (short)Math.atan2((double)a, (double)b); + } + + static short strict_scalar_sin(short a) { + return (short)StrictMath.sin((double)a); + } + + static short strict_scalar_exp(short a) { + return (short)StrictMath.exp((double)a); + } + + static short strict_scalar_log1p(short a) { + return (short)StrictMath.log1p((double)a); + } + + static short strict_scalar_log(short a) { + return (short)StrictMath.log((double)a); + } + + static short strict_scalar_log10(short a) { + return (short)StrictMath.log10((double)a); + } + + static short strict_scalar_expm1(short a) { + return (short)StrictMath.expm1((double)a); + } + + static short strict_scalar_cos(short a) { + return (short)StrictMath.cos((double)a); + } + + static short strict_scalar_tan(short a) { + return (short)StrictMath.tan((double)a); + } + + static short strict_scalar_sinh(short a) { + return (short)StrictMath.sinh((double)a); + } + + static short strict_scalar_cosh(short a) { + return (short)StrictMath.cosh((double)a); + } + + static short strict_scalar_tanh(short a) { + return (short)StrictMath.tanh((double)a); + } + + static short strict_scalar_asin(short a) { + return (short)StrictMath.asin((double)a); + } + + static short strict_scalar_acos(short a) { + return (short)StrictMath.acos((double)a); + } + + static short strict_scalar_atan(short a) { + return (short)StrictMath.atan((double)a); + } + + static short strict_scalar_cbrt(short a) { + return (short)StrictMath.cbrt((double)a); + } + + static short strict_scalar_sqrt(short a) { + return (short)StrictMath.sqrt((double)a); + } + + static short strict_scalar_hypot(short a, short b) { + return (short)StrictMath.hypot((double)a, (double)b); + } + + static short strict_scalar_pow(short a, short b) { + return (short)StrictMath.pow((double)a, (double)b); + } + + static short strict_scalar_atan2(short a, short b) { + return (short)StrictMath.atan2((double)a, (double)b); + } + static short additiveIdentity() { + return (short)0; + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1534,10 +1746,19 @@ static boolean uge(short a, short b) { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return Short.MAX_VALUE; + } + + static short minValue() { + return Short.MIN_VALUE; } + @Test static void smokeTest1() { ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3); @@ -1650,7 +1871,7 @@ static void bitwiseDivByZeroSmokeTest() { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1671,7 +1892,7 @@ static void ADDShort128VectorTests(IntFunction fa, IntFunction } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1728,7 +1949,7 @@ static void addShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1806,7 +2027,7 @@ static void subShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1974,7 +2195,7 @@ static void divShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3197,7 +3418,7 @@ static void MINShort128VectorTests(IntFunction fa, IntFunction } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3216,7 +3437,7 @@ static void minShort128VectorTests(IntFunction fa, IntFunction } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3237,7 +3458,7 @@ static void MAXShort128VectorTests(IntFunction fa, IntFunction } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3605,7 +3826,7 @@ static void SUADDAssocShort128VectorTestsMasked(IntFunction fa, IntFunc static short ANDReduce(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3614,7 +3835,7 @@ static short ANDReduce(short[] a, int idx) { static short ANDReduceAll(short[] a) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3637,7 +3858,7 @@ static void ANDReduceShort128VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3649,7 +3870,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3658,7 +3879,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3683,7 +3904,7 @@ static void ANDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3694,7 +3915,7 @@ static void ANDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct static short ORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3703,7 +3924,7 @@ static short ORReduce(short[] a, int idx) { static short ORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3726,7 +3947,7 @@ static void ORReduceShort128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3738,7 +3959,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3747,7 +3968,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3772,7 +3993,7 @@ static void ORReduceShort128VectorTestsMasked(IntFunction fa, IntFuncti ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3783,7 +4004,7 @@ static void ORReduceShort128VectorTestsMasked(IntFunction fa, IntFuncti static short XORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3792,7 +4013,7 @@ static short XORReduce(short[] a, int idx) { static short XORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3815,7 +4036,7 @@ static void XORReduceShort128VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3827,7 +4048,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3836,7 +4057,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3861,7 +4082,7 @@ static void XORReduceShort128VectorTestsMasked(IntFunction fa, IntFunct ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3870,18 +4091,18 @@ static void XORReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } static short ADDReduce(short[] a, int idx) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAll(short[] a) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3891,7 +4112,7 @@ static short ADDReduceAll(short[] a) { static void ADDReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3901,10 +4122,10 @@ static void ADDReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3913,19 +4134,19 @@ static void ADDReduceShort128VectorTests(IntFunction fa) { } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3937,7 +4158,7 @@ static void ADDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3947,10 +4168,10 @@ static void ADDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3959,18 +4180,18 @@ static void ADDReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } static short MULReduce(short[] a, int idx) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAll(short[] a) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3980,7 +4201,7 @@ static short MULReduceAll(short[] a) { static void MULReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3990,10 +4211,10 @@ static void MULReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4002,19 +4223,19 @@ static void MULReduceShort128VectorTests(IntFunction fa) { } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAllMasked(short[] a, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4026,7 +4247,7 @@ static void MULReduceShort128VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4036,10 +4257,10 @@ static void MULReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4048,18 +4269,18 @@ static void MULReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } static short MINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4069,7 +4290,7 @@ static short MINReduceAll(short[] a) { static void MINReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4079,10 +4300,10 @@ static void MINReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4091,19 +4312,19 @@ static void MINReduceShort128VectorTests(IntFunction fa) { } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4115,7 +4336,7 @@ static void MINReduceShort128VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4125,10 +4346,10 @@ static void MINReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4137,18 +4358,18 @@ static void MINReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } static short MAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4158,7 +4379,7 @@ static short MAXReduceAll(short[] a) { static void MAXReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4168,10 +4389,10 @@ static void MAXReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4180,19 +4401,19 @@ static void MAXReduceShort128VectorTests(IntFunction fa) { } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4204,7 +4425,7 @@ static void MAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4214,10 +4435,10 @@ static void MAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4226,7 +4447,7 @@ static void MAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunct } static short UMINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.minUnsigned(res, a[i]); } @@ -4235,7 +4456,7 @@ static short UMINReduce(short[] a, int idx) { } static short UMINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4247,7 +4468,7 @@ static short UMINReduceAll(short[] a) { static void UMINReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4257,7 +4478,7 @@ static void UMINReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4269,7 +4490,7 @@ static void UMINReduceShort128VectorTests(IntFunction fa) { } static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.minUnsigned(res, a[i]); @@ -4279,7 +4500,7 @@ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4293,7 +4514,7 @@ static void UMINReduceShort128VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4303,7 +4524,7 @@ static void UMINReduceShort128VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4315,7 +4536,7 @@ static void UMINReduceShort128VectorTestsMasked(IntFunction fa, IntFunc } static short UMAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.maxUnsigned(res, a[i]); } @@ -4324,7 +4545,7 @@ static short UMAXReduce(short[] a, int idx) { } static short UMAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4336,7 +4557,7 @@ static short UMAXReduceAll(short[] a) { static void UMAXReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4346,7 +4567,7 @@ static void UMAXReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4358,7 +4579,7 @@ static void UMAXReduceShort128VectorTests(IntFunction fa) { } static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.maxUnsigned(res, a[i]); @@ -4368,7 +4589,7 @@ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4382,7 +4603,7 @@ static void UMAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4392,7 +4613,7 @@ static void UMAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4404,7 +4625,7 @@ static void UMAXReduceShort128VectorTestsMasked(IntFunction fa, IntFunc } static short FIRST_NONZEROReduce(short[] a, int idx) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4413,7 +4634,7 @@ static short FIRST_NONZEROReduce(short[] a, int idx) { } static short FIRST_NONZEROReduceAll(short[] a) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4425,7 +4646,7 @@ static short FIRST_NONZEROReduceAll(short[] a) { static void FIRST_NONZEROReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4435,7 +4656,7 @@ static void FIRST_NONZEROReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4447,7 +4668,7 @@ static void FIRST_NONZEROReduceShort128VectorTests(IntFunction fa) { } static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4457,7 +4678,7 @@ static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { } static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4471,7 +4692,7 @@ static void FIRST_NONZEROReduceShort128VectorTestsMasked(IntFunction fa short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4481,7 +4702,7 @@ static void FIRST_NONZEROReduceShort128VectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4541,7 +4762,7 @@ static void allTrueShort128VectorTests(IntFunction fm) { } static short SUADDReduce(short[] a, int idx) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4550,7 +4771,7 @@ static short SUADDReduce(short[] a, int idx) { } static short SUADDReduceAll(short[] a) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4562,7 +4783,7 @@ static short SUADDReduceAll(short[] a) { static void SUADDReduceShort128VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4572,7 +4793,7 @@ static void SUADDReduceShort128VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4584,7 +4805,7 @@ static void SUADDReduceShort128VectorTests(IntFunction fa) { } static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4594,7 +4815,7 @@ static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { } static short SUADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4607,7 +4828,7 @@ static void SUADDReduceShort128VectorTestsMasked(IntFunction fa, IntFun short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4617,7 +4838,7 @@ static void SUADDReduceShort128VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4662,7 +4883,7 @@ static void IS_DEFAULTShort128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4682,7 +4903,7 @@ static void IS_DEFAULTMaskedShort128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4703,7 +4924,7 @@ static void IS_NEGATIVEShort128VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4723,7 +4944,7 @@ static void IS_NEGATIVEMaskedShort128VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4742,7 +4963,7 @@ static void LTShort128VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4761,7 +4982,7 @@ static void ltShort128VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4784,7 +5005,7 @@ static void LTShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4826,7 +5047,7 @@ static void GTShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4864,7 +5085,7 @@ static void eqShort128VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4887,7 +5108,7 @@ static void EQShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4929,7 +5150,7 @@ static void NEShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4971,7 +5192,7 @@ static void LEShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5013,7 +5234,7 @@ static void GEShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5055,7 +5276,7 @@ static void ULTShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5097,7 +5318,7 @@ static void UGTShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5139,7 +5360,7 @@ static void ULEShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5181,7 +5402,7 @@ static void UGEShort128VectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5218,7 +5439,7 @@ static void LTShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5234,7 +5455,7 @@ static void LTShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @@ -5254,7 +5475,7 @@ static void LTShort128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5290,7 +5511,7 @@ static void EQShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5306,7 +5527,7 @@ static void EQShort128VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @@ -5326,7 +5547,7 @@ static void EQShort128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static short[] sliceUnary(short[] a, int origin, int idx) { @@ -6038,11 +6259,11 @@ static void BITWISE_BLENDShort128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFu } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6094,11 +6315,11 @@ static void NEGMaskedShort128VectorTests(IntFunction fa, } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6438,7 +6659,7 @@ static void ltShort128VectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6454,7 +6675,7 @@ static void eqShort128VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6694,7 +6915,7 @@ static void shuffleMiscellaneousShort128VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index 7a4c39b7d9c36..4f2a51012e58f 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -1060,15 +1060,15 @@ static short bits(short e) { } static final List> SHORT_GENERATORS = List.of( - withToString("short[-i * 5]", (int s) -> { + withToString("Short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("short[i * 5]", (int s) -> { + withToString("Short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("short[i + 1]", (int s) -> { + withToString("Short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1518,6 +1518,218 @@ static boolean ge(short a, short b) { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)1; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static short scalar_sin(short a) { + return (short)Math.sin((double)a); + } + + static short scalar_exp(short a) { + return (short)Math.exp((double)a); + } + + static short scalar_log1p(short a) { + return (short)Math.log1p((double)a); + } + + static short scalar_log(short a) { + return (short)Math.log((double)a); + } + + static short scalar_log10(short a) { + return (short)Math.log10((double)a); + } + + static short scalar_expm1(short a) { + return (short)Math.expm1((double)a); + } + + static short scalar_cos(short a) { + return (short)Math.cos((double)a); + } + + static short scalar_tan(short a) { + return (short)Math.tan((double)a); + } + + static short scalar_sinh(short a) { + return (short)Math.sinh((double)a); + } + + static short scalar_cosh(short a) { + return (short)Math.cosh((double)a); + } + + static short scalar_tanh(short a) { + return (short)Math.tanh((double)a); + } + + static short scalar_asin(short a) { + return (short)Math.asin((double)a); + } + + static short scalar_acos(short a) { + return (short)Math.acos((double)a); + } + + static short scalar_atan(short a) { + return (short)Math.atan((double)a); + } + + static short scalar_cbrt(short a) { + return (short)Math.cbrt((double)a); + } + + static short scalar_sqrt(short a) { + return (short)Math.sqrt((double)a); + } + + static short scalar_hypot(short a, short b) { + return (short)Math.hypot((double)a, (double)b); + } + + static short scalar_pow(short a, short b) { + return (short)Math.pow((double)a, (double)b); + } + + static short scalar_atan2(short a, short b) { + return (short)Math.atan2((double)a, (double)b); + } + + static short strict_scalar_sin(short a) { + return (short)StrictMath.sin((double)a); + } + + static short strict_scalar_exp(short a) { + return (short)StrictMath.exp((double)a); + } + + static short strict_scalar_log1p(short a) { + return (short)StrictMath.log1p((double)a); + } + + static short strict_scalar_log(short a) { + return (short)StrictMath.log((double)a); + } + + static short strict_scalar_log10(short a) { + return (short)StrictMath.log10((double)a); + } + + static short strict_scalar_expm1(short a) { + return (short)StrictMath.expm1((double)a); + } + + static short strict_scalar_cos(short a) { + return (short)StrictMath.cos((double)a); + } + + static short strict_scalar_tan(short a) { + return (short)StrictMath.tan((double)a); + } + + static short strict_scalar_sinh(short a) { + return (short)StrictMath.sinh((double)a); + } + + static short strict_scalar_cosh(short a) { + return (short)StrictMath.cosh((double)a); + } + + static short strict_scalar_tanh(short a) { + return (short)StrictMath.tanh((double)a); + } + + static short strict_scalar_asin(short a) { + return (short)StrictMath.asin((double)a); + } + + static short strict_scalar_acos(short a) { + return (short)StrictMath.acos((double)a); + } + + static short strict_scalar_atan(short a) { + return (short)StrictMath.atan((double)a); + } + + static short strict_scalar_cbrt(short a) { + return (short)StrictMath.cbrt((double)a); + } + + static short strict_scalar_sqrt(short a) { + return (short)StrictMath.sqrt((double)a); + } + + static short strict_scalar_hypot(short a, short b) { + return (short)StrictMath.hypot((double)a, (double)b); + } + + static short strict_scalar_pow(short a, short b) { + return (short)StrictMath.pow((double)a, (double)b); + } + + static short strict_scalar_atan2(short a, short b) { + return (short)StrictMath.atan2((double)a, (double)b); + } + static short additiveIdentity() { + return (short)0; + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1534,10 +1746,19 @@ static boolean uge(short a, short b) { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return Short.MAX_VALUE; + } + + static short minValue() { + return Short.MIN_VALUE; } + @Test static void smokeTest1() { ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3); @@ -1650,7 +1871,7 @@ static void bitwiseDivByZeroSmokeTest() { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1671,7 +1892,7 @@ static void ADDShort256VectorTests(IntFunction fa, IntFunction } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1728,7 +1949,7 @@ static void addShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1806,7 +2027,7 @@ static void subShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1974,7 +2195,7 @@ static void divShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3197,7 +3418,7 @@ static void MINShort256VectorTests(IntFunction fa, IntFunction } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3216,7 +3437,7 @@ static void minShort256VectorTests(IntFunction fa, IntFunction } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3237,7 +3458,7 @@ static void MAXShort256VectorTests(IntFunction fa, IntFunction } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3605,7 +3826,7 @@ static void SUADDAssocShort256VectorTestsMasked(IntFunction fa, IntFunc static short ANDReduce(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3614,7 +3835,7 @@ static short ANDReduce(short[] a, int idx) { static short ANDReduceAll(short[] a) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3637,7 +3858,7 @@ static void ANDReduceShort256VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3649,7 +3870,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3658,7 +3879,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3683,7 +3904,7 @@ static void ANDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3694,7 +3915,7 @@ static void ANDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct static short ORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3703,7 +3924,7 @@ static short ORReduce(short[] a, int idx) { static short ORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3726,7 +3947,7 @@ static void ORReduceShort256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3738,7 +3959,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3747,7 +3968,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3772,7 +3993,7 @@ static void ORReduceShort256VectorTestsMasked(IntFunction fa, IntFuncti ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3783,7 +4004,7 @@ static void ORReduceShort256VectorTestsMasked(IntFunction fa, IntFuncti static short XORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3792,7 +4013,7 @@ static short XORReduce(short[] a, int idx) { static short XORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3815,7 +4036,7 @@ static void XORReduceShort256VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3827,7 +4048,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3836,7 +4057,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3861,7 +4082,7 @@ static void XORReduceShort256VectorTestsMasked(IntFunction fa, IntFunct ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3870,18 +4091,18 @@ static void XORReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } static short ADDReduce(short[] a, int idx) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAll(short[] a) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3891,7 +4112,7 @@ static short ADDReduceAll(short[] a) { static void ADDReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3901,10 +4122,10 @@ static void ADDReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3913,19 +4134,19 @@ static void ADDReduceShort256VectorTests(IntFunction fa) { } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3937,7 +4158,7 @@ static void ADDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3947,10 +4168,10 @@ static void ADDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3959,18 +4180,18 @@ static void ADDReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } static short MULReduce(short[] a, int idx) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAll(short[] a) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3980,7 +4201,7 @@ static short MULReduceAll(short[] a) { static void MULReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3990,10 +4211,10 @@ static void MULReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4002,19 +4223,19 @@ static void MULReduceShort256VectorTests(IntFunction fa) { } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAllMasked(short[] a, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4026,7 +4247,7 @@ static void MULReduceShort256VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4036,10 +4257,10 @@ static void MULReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4048,18 +4269,18 @@ static void MULReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } static short MINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4069,7 +4290,7 @@ static short MINReduceAll(short[] a) { static void MINReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4079,10 +4300,10 @@ static void MINReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4091,19 +4312,19 @@ static void MINReduceShort256VectorTests(IntFunction fa) { } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4115,7 +4336,7 @@ static void MINReduceShort256VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4125,10 +4346,10 @@ static void MINReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4137,18 +4358,18 @@ static void MINReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } static short MAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4158,7 +4379,7 @@ static short MAXReduceAll(short[] a) { static void MAXReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4168,10 +4389,10 @@ static void MAXReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4180,19 +4401,19 @@ static void MAXReduceShort256VectorTests(IntFunction fa) { } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4204,7 +4425,7 @@ static void MAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4214,10 +4435,10 @@ static void MAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4226,7 +4447,7 @@ static void MAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunct } static short UMINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.minUnsigned(res, a[i]); } @@ -4235,7 +4456,7 @@ static short UMINReduce(short[] a, int idx) { } static short UMINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4247,7 +4468,7 @@ static short UMINReduceAll(short[] a) { static void UMINReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4257,7 +4478,7 @@ static void UMINReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4269,7 +4490,7 @@ static void UMINReduceShort256VectorTests(IntFunction fa) { } static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.minUnsigned(res, a[i]); @@ -4279,7 +4500,7 @@ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4293,7 +4514,7 @@ static void UMINReduceShort256VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4303,7 +4524,7 @@ static void UMINReduceShort256VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4315,7 +4536,7 @@ static void UMINReduceShort256VectorTestsMasked(IntFunction fa, IntFunc } static short UMAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.maxUnsigned(res, a[i]); } @@ -4324,7 +4545,7 @@ static short UMAXReduce(short[] a, int idx) { } static short UMAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4336,7 +4557,7 @@ static short UMAXReduceAll(short[] a) { static void UMAXReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4346,7 +4567,7 @@ static void UMAXReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4358,7 +4579,7 @@ static void UMAXReduceShort256VectorTests(IntFunction fa) { } static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.maxUnsigned(res, a[i]); @@ -4368,7 +4589,7 @@ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4382,7 +4603,7 @@ static void UMAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4392,7 +4613,7 @@ static void UMAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4404,7 +4625,7 @@ static void UMAXReduceShort256VectorTestsMasked(IntFunction fa, IntFunc } static short FIRST_NONZEROReduce(short[] a, int idx) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4413,7 +4634,7 @@ static short FIRST_NONZEROReduce(short[] a, int idx) { } static short FIRST_NONZEROReduceAll(short[] a) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4425,7 +4646,7 @@ static short FIRST_NONZEROReduceAll(short[] a) { static void FIRST_NONZEROReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4435,7 +4656,7 @@ static void FIRST_NONZEROReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4447,7 +4668,7 @@ static void FIRST_NONZEROReduceShort256VectorTests(IntFunction fa) { } static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4457,7 +4678,7 @@ static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { } static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4471,7 +4692,7 @@ static void FIRST_NONZEROReduceShort256VectorTestsMasked(IntFunction fa short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4481,7 +4702,7 @@ static void FIRST_NONZEROReduceShort256VectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4541,7 +4762,7 @@ static void allTrueShort256VectorTests(IntFunction fm) { } static short SUADDReduce(short[] a, int idx) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4550,7 +4771,7 @@ static short SUADDReduce(short[] a, int idx) { } static short SUADDReduceAll(short[] a) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4562,7 +4783,7 @@ static short SUADDReduceAll(short[] a) { static void SUADDReduceShort256VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4572,7 +4793,7 @@ static void SUADDReduceShort256VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4584,7 +4805,7 @@ static void SUADDReduceShort256VectorTests(IntFunction fa) { } static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4594,7 +4815,7 @@ static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { } static short SUADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4607,7 +4828,7 @@ static void SUADDReduceShort256VectorTestsMasked(IntFunction fa, IntFun short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4617,7 +4838,7 @@ static void SUADDReduceShort256VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4662,7 +4883,7 @@ static void IS_DEFAULTShort256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4682,7 +4903,7 @@ static void IS_DEFAULTMaskedShort256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4703,7 +4924,7 @@ static void IS_NEGATIVEShort256VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4723,7 +4944,7 @@ static void IS_NEGATIVEMaskedShort256VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4742,7 +4963,7 @@ static void LTShort256VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4761,7 +4982,7 @@ static void ltShort256VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4784,7 +5005,7 @@ static void LTShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4826,7 +5047,7 @@ static void GTShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4864,7 +5085,7 @@ static void eqShort256VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4887,7 +5108,7 @@ static void EQShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4929,7 +5150,7 @@ static void NEShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4971,7 +5192,7 @@ static void LEShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5013,7 +5234,7 @@ static void GEShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5055,7 +5276,7 @@ static void ULTShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5097,7 +5318,7 @@ static void UGTShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5139,7 +5360,7 @@ static void ULEShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5181,7 +5402,7 @@ static void UGEShort256VectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5218,7 +5439,7 @@ static void LTShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5234,7 +5455,7 @@ static void LTShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @@ -5254,7 +5475,7 @@ static void LTShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5290,7 +5511,7 @@ static void EQShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5306,7 +5527,7 @@ static void EQShort256VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @@ -5326,7 +5547,7 @@ static void EQShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static short[] sliceUnary(short[] a, int origin, int idx) { @@ -6038,11 +6259,11 @@ static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFu } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6094,11 +6315,11 @@ static void NEGMaskedShort256VectorTests(IntFunction fa, } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6438,7 +6659,7 @@ static void ltShort256VectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6454,7 +6675,7 @@ static void eqShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6694,7 +6915,7 @@ static void shuffleMiscellaneousShort256VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index 05d3b877a686d..76121429a0e2d 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -1060,15 +1060,15 @@ static short bits(short e) { } static final List> SHORT_GENERATORS = List.of( - withToString("short[-i * 5]", (int s) -> { + withToString("Short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("short[i * 5]", (int s) -> { + withToString("Short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("short[i + 1]", (int s) -> { + withToString("Short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1518,6 +1518,218 @@ static boolean ge(short a, short b) { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)1; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static short scalar_sin(short a) { + return (short)Math.sin((double)a); + } + + static short scalar_exp(short a) { + return (short)Math.exp((double)a); + } + + static short scalar_log1p(short a) { + return (short)Math.log1p((double)a); + } + + static short scalar_log(short a) { + return (short)Math.log((double)a); + } + + static short scalar_log10(short a) { + return (short)Math.log10((double)a); + } + + static short scalar_expm1(short a) { + return (short)Math.expm1((double)a); + } + + static short scalar_cos(short a) { + return (short)Math.cos((double)a); + } + + static short scalar_tan(short a) { + return (short)Math.tan((double)a); + } + + static short scalar_sinh(short a) { + return (short)Math.sinh((double)a); + } + + static short scalar_cosh(short a) { + return (short)Math.cosh((double)a); + } + + static short scalar_tanh(short a) { + return (short)Math.tanh((double)a); + } + + static short scalar_asin(short a) { + return (short)Math.asin((double)a); + } + + static short scalar_acos(short a) { + return (short)Math.acos((double)a); + } + + static short scalar_atan(short a) { + return (short)Math.atan((double)a); + } + + static short scalar_cbrt(short a) { + return (short)Math.cbrt((double)a); + } + + static short scalar_sqrt(short a) { + return (short)Math.sqrt((double)a); + } + + static short scalar_hypot(short a, short b) { + return (short)Math.hypot((double)a, (double)b); + } + + static short scalar_pow(short a, short b) { + return (short)Math.pow((double)a, (double)b); + } + + static short scalar_atan2(short a, short b) { + return (short)Math.atan2((double)a, (double)b); + } + + static short strict_scalar_sin(short a) { + return (short)StrictMath.sin((double)a); + } + + static short strict_scalar_exp(short a) { + return (short)StrictMath.exp((double)a); + } + + static short strict_scalar_log1p(short a) { + return (short)StrictMath.log1p((double)a); + } + + static short strict_scalar_log(short a) { + return (short)StrictMath.log((double)a); + } + + static short strict_scalar_log10(short a) { + return (short)StrictMath.log10((double)a); + } + + static short strict_scalar_expm1(short a) { + return (short)StrictMath.expm1((double)a); + } + + static short strict_scalar_cos(short a) { + return (short)StrictMath.cos((double)a); + } + + static short strict_scalar_tan(short a) { + return (short)StrictMath.tan((double)a); + } + + static short strict_scalar_sinh(short a) { + return (short)StrictMath.sinh((double)a); + } + + static short strict_scalar_cosh(short a) { + return (short)StrictMath.cosh((double)a); + } + + static short strict_scalar_tanh(short a) { + return (short)StrictMath.tanh((double)a); + } + + static short strict_scalar_asin(short a) { + return (short)StrictMath.asin((double)a); + } + + static short strict_scalar_acos(short a) { + return (short)StrictMath.acos((double)a); + } + + static short strict_scalar_atan(short a) { + return (short)StrictMath.atan((double)a); + } + + static short strict_scalar_cbrt(short a) { + return (short)StrictMath.cbrt((double)a); + } + + static short strict_scalar_sqrt(short a) { + return (short)StrictMath.sqrt((double)a); + } + + static short strict_scalar_hypot(short a, short b) { + return (short)StrictMath.hypot((double)a, (double)b); + } + + static short strict_scalar_pow(short a, short b) { + return (short)StrictMath.pow((double)a, (double)b); + } + + static short strict_scalar_atan2(short a, short b) { + return (short)StrictMath.atan2((double)a, (double)b); + } + static short additiveIdentity() { + return (short)0; + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1534,10 +1746,19 @@ static boolean uge(short a, short b) { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return Short.MAX_VALUE; + } + + static short minValue() { + return Short.MIN_VALUE; } + @Test static void smokeTest1() { ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3); @@ -1650,7 +1871,7 @@ static void bitwiseDivByZeroSmokeTest() { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1671,7 +1892,7 @@ static void ADDShort512VectorTests(IntFunction fa, IntFunction } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1728,7 +1949,7 @@ static void addShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1806,7 +2027,7 @@ static void subShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1974,7 +2195,7 @@ static void divShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3197,7 +3418,7 @@ static void MINShort512VectorTests(IntFunction fa, IntFunction } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3216,7 +3437,7 @@ static void minShort512VectorTests(IntFunction fa, IntFunction } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3237,7 +3458,7 @@ static void MAXShort512VectorTests(IntFunction fa, IntFunction } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3605,7 +3826,7 @@ static void SUADDAssocShort512VectorTestsMasked(IntFunction fa, IntFunc static short ANDReduce(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3614,7 +3835,7 @@ static short ANDReduce(short[] a, int idx) { static short ANDReduceAll(short[] a) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3637,7 +3858,7 @@ static void ANDReduceShort512VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3649,7 +3870,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3658,7 +3879,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3683,7 +3904,7 @@ static void ANDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3694,7 +3915,7 @@ static void ANDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct static short ORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3703,7 +3924,7 @@ static short ORReduce(short[] a, int idx) { static short ORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3726,7 +3947,7 @@ static void ORReduceShort512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3738,7 +3959,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3747,7 +3968,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3772,7 +3993,7 @@ static void ORReduceShort512VectorTestsMasked(IntFunction fa, IntFuncti ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3783,7 +4004,7 @@ static void ORReduceShort512VectorTestsMasked(IntFunction fa, IntFuncti static short XORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3792,7 +4013,7 @@ static short XORReduce(short[] a, int idx) { static short XORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3815,7 +4036,7 @@ static void XORReduceShort512VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3827,7 +4048,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3836,7 +4057,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3861,7 +4082,7 @@ static void XORReduceShort512VectorTestsMasked(IntFunction fa, IntFunct ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3870,18 +4091,18 @@ static void XORReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } static short ADDReduce(short[] a, int idx) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAll(short[] a) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3891,7 +4112,7 @@ static short ADDReduceAll(short[] a) { static void ADDReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3901,10 +4122,10 @@ static void ADDReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3913,19 +4134,19 @@ static void ADDReduceShort512VectorTests(IntFunction fa) { } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3937,7 +4158,7 @@ static void ADDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3947,10 +4168,10 @@ static void ADDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3959,18 +4180,18 @@ static void ADDReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } static short MULReduce(short[] a, int idx) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAll(short[] a) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3980,7 +4201,7 @@ static short MULReduceAll(short[] a) { static void MULReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3990,10 +4211,10 @@ static void MULReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4002,19 +4223,19 @@ static void MULReduceShort512VectorTests(IntFunction fa) { } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAllMasked(short[] a, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4026,7 +4247,7 @@ static void MULReduceShort512VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4036,10 +4257,10 @@ static void MULReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4048,18 +4269,18 @@ static void MULReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } static short MINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4069,7 +4290,7 @@ static short MINReduceAll(short[] a) { static void MINReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4079,10 +4300,10 @@ static void MINReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4091,19 +4312,19 @@ static void MINReduceShort512VectorTests(IntFunction fa) { } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4115,7 +4336,7 @@ static void MINReduceShort512VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4125,10 +4346,10 @@ static void MINReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4137,18 +4358,18 @@ static void MINReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } static short MAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4158,7 +4379,7 @@ static short MAXReduceAll(short[] a) { static void MAXReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4168,10 +4389,10 @@ static void MAXReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4180,19 +4401,19 @@ static void MAXReduceShort512VectorTests(IntFunction fa) { } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4204,7 +4425,7 @@ static void MAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4214,10 +4435,10 @@ static void MAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4226,7 +4447,7 @@ static void MAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunct } static short UMINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.minUnsigned(res, a[i]); } @@ -4235,7 +4456,7 @@ static short UMINReduce(short[] a, int idx) { } static short UMINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4247,7 +4468,7 @@ static short UMINReduceAll(short[] a) { static void UMINReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4257,7 +4478,7 @@ static void UMINReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4269,7 +4490,7 @@ static void UMINReduceShort512VectorTests(IntFunction fa) { } static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.minUnsigned(res, a[i]); @@ -4279,7 +4500,7 @@ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4293,7 +4514,7 @@ static void UMINReduceShort512VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4303,7 +4524,7 @@ static void UMINReduceShort512VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4315,7 +4536,7 @@ static void UMINReduceShort512VectorTestsMasked(IntFunction fa, IntFunc } static short UMAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.maxUnsigned(res, a[i]); } @@ -4324,7 +4545,7 @@ static short UMAXReduce(short[] a, int idx) { } static short UMAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4336,7 +4557,7 @@ static short UMAXReduceAll(short[] a) { static void UMAXReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4346,7 +4567,7 @@ static void UMAXReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4358,7 +4579,7 @@ static void UMAXReduceShort512VectorTests(IntFunction fa) { } static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.maxUnsigned(res, a[i]); @@ -4368,7 +4589,7 @@ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4382,7 +4603,7 @@ static void UMAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4392,7 +4613,7 @@ static void UMAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4404,7 +4625,7 @@ static void UMAXReduceShort512VectorTestsMasked(IntFunction fa, IntFunc } static short FIRST_NONZEROReduce(short[] a, int idx) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4413,7 +4634,7 @@ static short FIRST_NONZEROReduce(short[] a, int idx) { } static short FIRST_NONZEROReduceAll(short[] a) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4425,7 +4646,7 @@ static short FIRST_NONZEROReduceAll(short[] a) { static void FIRST_NONZEROReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4435,7 +4656,7 @@ static void FIRST_NONZEROReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4447,7 +4668,7 @@ static void FIRST_NONZEROReduceShort512VectorTests(IntFunction fa) { } static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4457,7 +4678,7 @@ static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { } static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4471,7 +4692,7 @@ static void FIRST_NONZEROReduceShort512VectorTestsMasked(IntFunction fa short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4481,7 +4702,7 @@ static void FIRST_NONZEROReduceShort512VectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4541,7 +4762,7 @@ static void allTrueShort512VectorTests(IntFunction fm) { } static short SUADDReduce(short[] a, int idx) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4550,7 +4771,7 @@ static short SUADDReduce(short[] a, int idx) { } static short SUADDReduceAll(short[] a) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4562,7 +4783,7 @@ static short SUADDReduceAll(short[] a) { static void SUADDReduceShort512VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4572,7 +4793,7 @@ static void SUADDReduceShort512VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4584,7 +4805,7 @@ static void SUADDReduceShort512VectorTests(IntFunction fa) { } static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4594,7 +4815,7 @@ static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { } static short SUADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4607,7 +4828,7 @@ static void SUADDReduceShort512VectorTestsMasked(IntFunction fa, IntFun short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4617,7 +4838,7 @@ static void SUADDReduceShort512VectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4662,7 +4883,7 @@ static void IS_DEFAULTShort512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4682,7 +4903,7 @@ static void IS_DEFAULTMaskedShort512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4703,7 +4924,7 @@ static void IS_NEGATIVEShort512VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4723,7 +4944,7 @@ static void IS_NEGATIVEMaskedShort512VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4742,7 +4963,7 @@ static void LTShort512VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4761,7 +4982,7 @@ static void ltShort512VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4784,7 +5005,7 @@ static void LTShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4826,7 +5047,7 @@ static void GTShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4864,7 +5085,7 @@ static void eqShort512VectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4887,7 +5108,7 @@ static void EQShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4929,7 +5150,7 @@ static void NEShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4971,7 +5192,7 @@ static void LEShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5013,7 +5234,7 @@ static void GEShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5055,7 +5276,7 @@ static void ULTShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5097,7 +5318,7 @@ static void UGTShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5139,7 +5360,7 @@ static void ULEShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5181,7 +5402,7 @@ static void UGEShort512VectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5218,7 +5439,7 @@ static void LTShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5234,7 +5455,7 @@ static void LTShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @@ -5254,7 +5475,7 @@ static void LTShort512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5290,7 +5511,7 @@ static void EQShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5306,7 +5527,7 @@ static void EQShort512VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @@ -5326,7 +5547,7 @@ static void EQShort512VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static short[] sliceUnary(short[] a, int origin, int idx) { @@ -6038,11 +6259,11 @@ static void BITWISE_BLENDShort512VectorTestsDoubleBroadcastMaskedSmokeTest(IntFu } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6094,11 +6315,11 @@ static void NEGMaskedShort512VectorTests(IntFunction fa, } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6438,7 +6659,7 @@ static void ltShort512VectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6454,7 +6675,7 @@ static void eqShort512VectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6694,7 +6915,7 @@ static void shuffleMiscellaneousShort512VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index a35915426de01..95aca19331393 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -1060,15 +1060,15 @@ static short bits(short e) { } static final List> SHORT_GENERATORS = List.of( - withToString("short[-i * 5]", (int s) -> { + withToString("Short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("short[i * 5]", (int s) -> { + withToString("Short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("short[i + 1]", (int s) -> { + withToString("Short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1518,6 +1518,218 @@ static boolean ge(short a, short b) { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)1; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static short scalar_sin(short a) { + return (short)Math.sin((double)a); + } + + static short scalar_exp(short a) { + return (short)Math.exp((double)a); + } + + static short scalar_log1p(short a) { + return (short)Math.log1p((double)a); + } + + static short scalar_log(short a) { + return (short)Math.log((double)a); + } + + static short scalar_log10(short a) { + return (short)Math.log10((double)a); + } + + static short scalar_expm1(short a) { + return (short)Math.expm1((double)a); + } + + static short scalar_cos(short a) { + return (short)Math.cos((double)a); + } + + static short scalar_tan(short a) { + return (short)Math.tan((double)a); + } + + static short scalar_sinh(short a) { + return (short)Math.sinh((double)a); + } + + static short scalar_cosh(short a) { + return (short)Math.cosh((double)a); + } + + static short scalar_tanh(short a) { + return (short)Math.tanh((double)a); + } + + static short scalar_asin(short a) { + return (short)Math.asin((double)a); + } + + static short scalar_acos(short a) { + return (short)Math.acos((double)a); + } + + static short scalar_atan(short a) { + return (short)Math.atan((double)a); + } + + static short scalar_cbrt(short a) { + return (short)Math.cbrt((double)a); + } + + static short scalar_sqrt(short a) { + return (short)Math.sqrt((double)a); + } + + static short scalar_hypot(short a, short b) { + return (short)Math.hypot((double)a, (double)b); + } + + static short scalar_pow(short a, short b) { + return (short)Math.pow((double)a, (double)b); + } + + static short scalar_atan2(short a, short b) { + return (short)Math.atan2((double)a, (double)b); + } + + static short strict_scalar_sin(short a) { + return (short)StrictMath.sin((double)a); + } + + static short strict_scalar_exp(short a) { + return (short)StrictMath.exp((double)a); + } + + static short strict_scalar_log1p(short a) { + return (short)StrictMath.log1p((double)a); + } + + static short strict_scalar_log(short a) { + return (short)StrictMath.log((double)a); + } + + static short strict_scalar_log10(short a) { + return (short)StrictMath.log10((double)a); + } + + static short strict_scalar_expm1(short a) { + return (short)StrictMath.expm1((double)a); + } + + static short strict_scalar_cos(short a) { + return (short)StrictMath.cos((double)a); + } + + static short strict_scalar_tan(short a) { + return (short)StrictMath.tan((double)a); + } + + static short strict_scalar_sinh(short a) { + return (short)StrictMath.sinh((double)a); + } + + static short strict_scalar_cosh(short a) { + return (short)StrictMath.cosh((double)a); + } + + static short strict_scalar_tanh(short a) { + return (short)StrictMath.tanh((double)a); + } + + static short strict_scalar_asin(short a) { + return (short)StrictMath.asin((double)a); + } + + static short strict_scalar_acos(short a) { + return (short)StrictMath.acos((double)a); + } + + static short strict_scalar_atan(short a) { + return (short)StrictMath.atan((double)a); + } + + static short strict_scalar_cbrt(short a) { + return (short)StrictMath.cbrt((double)a); + } + + static short strict_scalar_sqrt(short a) { + return (short)StrictMath.sqrt((double)a); + } + + static short strict_scalar_hypot(short a, short b) { + return (short)StrictMath.hypot((double)a, (double)b); + } + + static short strict_scalar_pow(short a, short b) { + return (short)StrictMath.pow((double)a, (double)b); + } + + static short strict_scalar_atan2(short a, short b) { + return (short)StrictMath.atan2((double)a, (double)b); + } + static short additiveIdentity() { + return (short)0; + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1534,10 +1746,19 @@ static boolean uge(short a, short b) { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return Short.MAX_VALUE; + } + + static short minValue() { + return Short.MIN_VALUE; } + @Test static void smokeTest1() { ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3); @@ -1650,7 +1871,7 @@ static void bitwiseDivByZeroSmokeTest() { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1671,7 +1892,7 @@ static void ADDShort64VectorTests(IntFunction fa, IntFunction } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1728,7 +1949,7 @@ static void addShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1806,7 +2027,7 @@ static void subShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1974,7 +2195,7 @@ static void divShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFun } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3197,7 +3418,7 @@ static void MINShort64VectorTests(IntFunction fa, IntFunction } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3216,7 +3437,7 @@ static void minShort64VectorTests(IntFunction fa, IntFunction } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3237,7 +3458,7 @@ static void MAXShort64VectorTests(IntFunction fa, IntFunction } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3605,7 +3826,7 @@ static void SUADDAssocShort64VectorTestsMasked(IntFunction fa, IntFunct static short ANDReduce(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3614,7 +3835,7 @@ static short ANDReduce(short[] a, int idx) { static short ANDReduceAll(short[] a) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3637,7 +3858,7 @@ static void ANDReduceShort64VectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3649,7 +3870,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3658,7 +3879,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3683,7 +3904,7 @@ static void ANDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3694,7 +3915,7 @@ static void ANDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti static short ORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3703,7 +3924,7 @@ static short ORReduce(short[] a, int idx) { static short ORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3726,7 +3947,7 @@ static void ORReduceShort64VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3738,7 +3959,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3747,7 +3968,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3772,7 +3993,7 @@ static void ORReduceShort64VectorTestsMasked(IntFunction fa, IntFunctio ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3783,7 +4004,7 @@ static void ORReduceShort64VectorTestsMasked(IntFunction fa, IntFunctio static short XORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3792,7 +4013,7 @@ static short XORReduce(short[] a, int idx) { static short XORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3815,7 +4036,7 @@ static void XORReduceShort64VectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3827,7 +4048,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3836,7 +4057,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3861,7 +4082,7 @@ static void XORReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3870,18 +4091,18 @@ static void XORReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } static short ADDReduce(short[] a, int idx) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAll(short[] a) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3891,7 +4112,7 @@ static short ADDReduceAll(short[] a) { static void ADDReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3901,10 +4122,10 @@ static void ADDReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3913,19 +4134,19 @@ static void ADDReduceShort64VectorTests(IntFunction fa) { } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3937,7 +4158,7 @@ static void ADDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3947,10 +4168,10 @@ static void ADDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3959,18 +4180,18 @@ static void ADDReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } static short MULReduce(short[] a, int idx) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAll(short[] a) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3980,7 +4201,7 @@ static short MULReduceAll(short[] a) { static void MULReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3990,10 +4211,10 @@ static void MULReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4002,19 +4223,19 @@ static void MULReduceShort64VectorTests(IntFunction fa) { } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAllMasked(short[] a, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4026,7 +4247,7 @@ static void MULReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4036,10 +4257,10 @@ static void MULReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4048,18 +4269,18 @@ static void MULReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } static short MINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4069,7 +4290,7 @@ static short MINReduceAll(short[] a) { static void MINReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4079,10 +4300,10 @@ static void MINReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4091,19 +4312,19 @@ static void MINReduceShort64VectorTests(IntFunction fa) { } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4115,7 +4336,7 @@ static void MINReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4125,10 +4346,10 @@ static void MINReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4137,18 +4358,18 @@ static void MINReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } static short MAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4158,7 +4379,7 @@ static short MAXReduceAll(short[] a) { static void MAXReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4168,10 +4389,10 @@ static void MAXReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4180,19 +4401,19 @@ static void MAXReduceShort64VectorTests(IntFunction fa) { } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4204,7 +4425,7 @@ static void MAXReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4214,10 +4435,10 @@ static void MAXReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4226,7 +4447,7 @@ static void MAXReduceShort64VectorTestsMasked(IntFunction fa, IntFuncti } static short UMINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.minUnsigned(res, a[i]); } @@ -4235,7 +4456,7 @@ static short UMINReduce(short[] a, int idx) { } static short UMINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4247,7 +4468,7 @@ static short UMINReduceAll(short[] a) { static void UMINReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4257,7 +4478,7 @@ static void UMINReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4269,7 +4490,7 @@ static void UMINReduceShort64VectorTests(IntFunction fa) { } static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.minUnsigned(res, a[i]); @@ -4279,7 +4500,7 @@ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4293,7 +4514,7 @@ static void UMINReduceShort64VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4303,7 +4524,7 @@ static void UMINReduceShort64VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4315,7 +4536,7 @@ static void UMINReduceShort64VectorTestsMasked(IntFunction fa, IntFunct } static short UMAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.maxUnsigned(res, a[i]); } @@ -4324,7 +4545,7 @@ static short UMAXReduce(short[] a, int idx) { } static short UMAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4336,7 +4557,7 @@ static short UMAXReduceAll(short[] a) { static void UMAXReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4346,7 +4567,7 @@ static void UMAXReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4358,7 +4579,7 @@ static void UMAXReduceShort64VectorTests(IntFunction fa) { } static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.maxUnsigned(res, a[i]); @@ -4368,7 +4589,7 @@ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4382,7 +4603,7 @@ static void UMAXReduceShort64VectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4392,7 +4613,7 @@ static void UMAXReduceShort64VectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4404,7 +4625,7 @@ static void UMAXReduceShort64VectorTestsMasked(IntFunction fa, IntFunct } static short FIRST_NONZEROReduce(short[] a, int idx) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4413,7 +4634,7 @@ static short FIRST_NONZEROReduce(short[] a, int idx) { } static short FIRST_NONZEROReduceAll(short[] a) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4425,7 +4646,7 @@ static short FIRST_NONZEROReduceAll(short[] a) { static void FIRST_NONZEROReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4435,7 +4656,7 @@ static void FIRST_NONZEROReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4447,7 +4668,7 @@ static void FIRST_NONZEROReduceShort64VectorTests(IntFunction fa) { } static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4457,7 +4678,7 @@ static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { } static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4471,7 +4692,7 @@ static void FIRST_NONZEROReduceShort64VectorTestsMasked(IntFunction fa, short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4481,7 +4702,7 @@ static void FIRST_NONZEROReduceShort64VectorTestsMasked(IntFunction fa, } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4541,7 +4762,7 @@ static void allTrueShort64VectorTests(IntFunction fm) { } static short SUADDReduce(short[] a, int idx) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4550,7 +4771,7 @@ static short SUADDReduce(short[] a, int idx) { } static short SUADDReduceAll(short[] a) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4562,7 +4783,7 @@ static short SUADDReduceAll(short[] a) { static void SUADDReduceShort64VectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4572,7 +4793,7 @@ static void SUADDReduceShort64VectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4584,7 +4805,7 @@ static void SUADDReduceShort64VectorTests(IntFunction fa) { } static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4594,7 +4815,7 @@ static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { } static short SUADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4607,7 +4828,7 @@ static void SUADDReduceShort64VectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4617,7 +4838,7 @@ static void SUADDReduceShort64VectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4662,7 +4883,7 @@ static void IS_DEFAULTShort64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4682,7 +4903,7 @@ static void IS_DEFAULTMaskedShort64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4703,7 +4924,7 @@ static void IS_NEGATIVEShort64VectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4723,7 +4944,7 @@ static void IS_NEGATIVEMaskedShort64VectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4742,7 +4963,7 @@ static void LTShort64VectorTests(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4761,7 +4982,7 @@ static void ltShort64VectorTests(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4784,7 +5005,7 @@ static void LTShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4826,7 +5047,7 @@ static void GTShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4864,7 +5085,7 @@ static void eqShort64VectorTests(IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4887,7 +5108,7 @@ static void EQShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4929,7 +5150,7 @@ static void NEShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4971,7 +5192,7 @@ static void LEShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5013,7 +5234,7 @@ static void GEShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5055,7 +5276,7 @@ static void ULTShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5097,7 +5318,7 @@ static void UGTShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5139,7 +5360,7 @@ static void ULEShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5181,7 +5402,7 @@ static void UGEShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5218,7 +5439,7 @@ static void LTShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5234,7 +5455,7 @@ static void LTShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @@ -5254,7 +5475,7 @@ static void LTShort64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5290,7 +5511,7 @@ static void EQShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5306,7 +5527,7 @@ static void EQShort64VectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @@ -5326,7 +5547,7 @@ static void EQShort64VectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static short[] sliceUnary(short[] a, int origin, int idx) { @@ -6038,11 +6259,11 @@ static void BITWISE_BLENDShort64VectorTestsDoubleBroadcastMaskedSmokeTest(IntFun } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6094,11 +6315,11 @@ static void NEGMaskedShort64VectorTests(IntFunction fa, } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6438,7 +6659,7 @@ static void ltShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntF // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6454,7 +6675,7 @@ static void eqShort64VectorTestsBroadcastMaskedSmokeTest(IntFunction fa // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6694,7 +6915,7 @@ static void shuffleMiscellaneousShort64VectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index df1261272a9be..e4c2a9f6c24e8 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -1065,15 +1065,15 @@ static short bits(short e) { } static final List> SHORT_GENERATORS = List.of( - withToString("short[-i * 5]", (int s) -> { + withToString("Short[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("short[i * 5]", (int s) -> { + withToString("Short[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("short[i + 1]", (int s) -> { + withToString("Short[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> (((short)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1523,6 +1523,218 @@ static boolean ge(short a, short b) { return a >= b; } + static short firstNonZero(short a, short b) { + return Short.compare(a, (short) 0) != 0 ? a : b; + } + + static short multiplicativeIdentity() { + return (short)1; + } + + static short scalar_or(short a, short b) { + return (short)(a | b); + } + + static short scalar_and(short a, short b) { + return (short)(a & b); + } + + static short scalar_xor(short a, short b) { + return (short)(a ^ b); + } + + static short scalar_add(short a, short b) { + return (short)(a + b); + } + + static short scalar_sub(short a, short b) { + return (short)(a - b); + } + + static short scalar_mul(short a, short b) { + return (short)(a * b); + } + + static short scalar_min(short a, short b) { + return (short)(Math.min(a, b)); + } + + static short scalar_max(short a, short b) { + return (short)(Math.max(a, b)); + } + + static short scalar_div(short a, short b) { + return (short)(a / b); + } + + static short scalar_fma(short a, short b, short c) { + return (short)(Math.fma(a, b, c)); + } + + static short scalar_abs(short a) { + return (short)(Math.abs(a)); + } + + static short scalar_neg(short a) { + return ((short)-a); + } + + static short scalar_sin(short a) { + return (short)Math.sin((double)a); + } + + static short scalar_exp(short a) { + return (short)Math.exp((double)a); + } + + static short scalar_log1p(short a) { + return (short)Math.log1p((double)a); + } + + static short scalar_log(short a) { + return (short)Math.log((double)a); + } + + static short scalar_log10(short a) { + return (short)Math.log10((double)a); + } + + static short scalar_expm1(short a) { + return (short)Math.expm1((double)a); + } + + static short scalar_cos(short a) { + return (short)Math.cos((double)a); + } + + static short scalar_tan(short a) { + return (short)Math.tan((double)a); + } + + static short scalar_sinh(short a) { + return (short)Math.sinh((double)a); + } + + static short scalar_cosh(short a) { + return (short)Math.cosh((double)a); + } + + static short scalar_tanh(short a) { + return (short)Math.tanh((double)a); + } + + static short scalar_asin(short a) { + return (short)Math.asin((double)a); + } + + static short scalar_acos(short a) { + return (short)Math.acos((double)a); + } + + static short scalar_atan(short a) { + return (short)Math.atan((double)a); + } + + static short scalar_cbrt(short a) { + return (short)Math.cbrt((double)a); + } + + static short scalar_sqrt(short a) { + return (short)Math.sqrt((double)a); + } + + static short scalar_hypot(short a, short b) { + return (short)Math.hypot((double)a, (double)b); + } + + static short scalar_pow(short a, short b) { + return (short)Math.pow((double)a, (double)b); + } + + static short scalar_atan2(short a, short b) { + return (short)Math.atan2((double)a, (double)b); + } + + static short strict_scalar_sin(short a) { + return (short)StrictMath.sin((double)a); + } + + static short strict_scalar_exp(short a) { + return (short)StrictMath.exp((double)a); + } + + static short strict_scalar_log1p(short a) { + return (short)StrictMath.log1p((double)a); + } + + static short strict_scalar_log(short a) { + return (short)StrictMath.log((double)a); + } + + static short strict_scalar_log10(short a) { + return (short)StrictMath.log10((double)a); + } + + static short strict_scalar_expm1(short a) { + return (short)StrictMath.expm1((double)a); + } + + static short strict_scalar_cos(short a) { + return (short)StrictMath.cos((double)a); + } + + static short strict_scalar_tan(short a) { + return (short)StrictMath.tan((double)a); + } + + static short strict_scalar_sinh(short a) { + return (short)StrictMath.sinh((double)a); + } + + static short strict_scalar_cosh(short a) { + return (short)StrictMath.cosh((double)a); + } + + static short strict_scalar_tanh(short a) { + return (short)StrictMath.tanh((double)a); + } + + static short strict_scalar_asin(short a) { + return (short)StrictMath.asin((double)a); + } + + static short strict_scalar_acos(short a) { + return (short)StrictMath.acos((double)a); + } + + static short strict_scalar_atan(short a) { + return (short)StrictMath.atan((double)a); + } + + static short strict_scalar_cbrt(short a) { + return (short)StrictMath.cbrt((double)a); + } + + static short strict_scalar_sqrt(short a) { + return (short)StrictMath.sqrt((double)a); + } + + static short strict_scalar_hypot(short a, short b) { + return (short)StrictMath.hypot((double)a, (double)b); + } + + static short strict_scalar_pow(short a, short b) { + return (short)StrictMath.pow((double)a, (double)b); + } + + static short strict_scalar_atan2(short a, short b) { + return (short)StrictMath.atan2((double)a, (double)b); + } + static short additiveIdentity() { + return (short)0; + } + + static boolean ult(short a, short b) { return Short.compareUnsigned(a, b) < 0; } @@ -1539,10 +1751,19 @@ static boolean uge(short a, short b) { return Short.compareUnsigned(a, b) >= 0; } - static short firstNonZero(short a, short b) { - return Short.compare(a, (short) 0) != 0 ? a : b; + static short zeroValue() { + return (short) 0; + } + + static short maxValue() { + return Short.MAX_VALUE; + } + + static short minValue() { + return Short.MIN_VALUE; } + @Test static void smokeTest1() { ShortVector three = ShortVector.broadcast(SPECIES, (byte)-3); @@ -1655,7 +1876,7 @@ static void bitwiseDivByZeroSmokeTest() { } static short ADD(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1676,7 +1897,7 @@ static void ADDShortMaxVectorTests(IntFunction fa, IntFunction } static short add(short a, short b) { - return (short)(a + b); + return (short)(scalar_add(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1733,7 +1954,7 @@ static void addShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short sub(short a, short b) { - return (short)(a - b); + return (short)(scalar_sub(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1811,7 +2032,7 @@ static void subShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction } static short mul(short a, short b) { - return (short)(a * b); + return (short)(scalar_mul(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -1979,7 +2200,7 @@ static void divShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFu } static short MIN(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3202,7 +3423,7 @@ static void MINShortMaxVectorTests(IntFunction fa, IntFunction } static short min(short a, short b) { - return (short)(Math.min(a, b)); + return (short)(scalar_min(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3221,7 +3442,7 @@ static void minShortMaxVectorTests(IntFunction fa, IntFunction } static short MAX(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3242,7 +3463,7 @@ static void MAXShortMaxVectorTests(IntFunction fa, IntFunction } static short max(short a, short b) { - return (short)(Math.max(a, b)); + return (short)(scalar_max(a, b)); } @Test(dataProvider = "shortBinaryOpProvider") @@ -3610,7 +3831,7 @@ static void SUADDAssocShortMaxVectorTestsMasked(IntFunction fa, IntFunc static short ANDReduce(short[] a, int idx) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3619,7 +3840,7 @@ static short ANDReduce(short[] a, int idx) { static short ANDReduceAll(short[] a) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduce(a, i); + res = scalar_and(res, ANDReduce(a, i)); } return res; @@ -3642,7 +3863,7 @@ static void ANDReduceShortMaxVectorTests(IntFunction fa) { ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND)); } } @@ -3654,7 +3875,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { short res = -1; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res &= a[i]; + res = scalar_and(res, a[i]); } return res; @@ -3663,7 +3884,7 @@ static short ANDReduceMasked(short[] a, int idx, boolean[] mask) { static short ANDReduceAllMasked(short[] a, boolean[] mask) { short res = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { - res &= ANDReduceMasked(a, i, mask); + res = scalar_and(res, ANDReduceMasked(a, i, mask)); } return res; @@ -3688,7 +3909,7 @@ static void ANDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct ra = -1; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra &= av.reduceLanes(VectorOperators.AND, vmask); + ra = scalar_and(ra, av.reduceLanes(VectorOperators.AND, vmask)); } } @@ -3699,7 +3920,7 @@ static void ANDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct static short ORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3708,7 +3929,7 @@ static short ORReduce(short[] a, int idx) { static short ORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduce(a, i); + res = scalar_or(res, ORReduce(a, i)); } return res; @@ -3731,7 +3952,7 @@ static void ORReduceShortMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR)); } } @@ -3743,7 +3964,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res |= a[i]; + res = scalar_or(res, a[i]); } return res; @@ -3752,7 +3973,7 @@ static short ORReduceMasked(short[] a, int idx, boolean[] mask) { static short ORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res |= ORReduceMasked(a, i, mask); + res = scalar_or(res, ORReduceMasked(a, i, mask)); } return res; @@ -3777,7 +3998,7 @@ static void ORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFuncti ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra |= av.reduceLanes(VectorOperators.OR, vmask); + ra = scalar_or(ra, av.reduceLanes(VectorOperators.OR, vmask)); } } @@ -3788,7 +4009,7 @@ static void ORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFuncti static short XORReduce(short[] a, int idx) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3797,7 +4018,7 @@ static short XORReduce(short[] a, int idx) { static short XORReduceAll(short[] a) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduce(a, i); + res = scalar_xor(res, XORReduce(a, i)); } return res; @@ -3820,7 +4041,7 @@ static void XORReduceShortMaxVectorTests(IntFunction fa) { ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR)); } } @@ -3832,7 +4053,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { short res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res ^= a[i]; + res = scalar_xor(res, a[i]); } return res; @@ -3841,7 +4062,7 @@ static short XORReduceMasked(short[] a, int idx, boolean[] mask) { static short XORReduceAllMasked(short[] a, boolean[] mask) { short res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { - res ^= XORReduceMasked(a, i, mask); + res = scalar_xor(res, XORReduceMasked(a, i, mask)); } return res; @@ -3866,7 +4087,7 @@ static void XORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct ra = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra ^= av.reduceLanes(VectorOperators.XOR, vmask); + ra = scalar_xor(ra, av.reduceLanes(VectorOperators.XOR, vmask)); } } @@ -3875,18 +4096,18 @@ static void XORReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } static short ADDReduce(short[] a, int idx) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAll(short[] a) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduce(a, i); + res = scalar_add(res, ADDReduce(a, i)); } return res; @@ -3896,7 +4117,7 @@ static short ADDReduceAll(short[] a) { static void ADDReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3906,10 +4127,10 @@ static void ADDReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD)); } } @@ -3918,19 +4139,19 @@ static void ADDReduceShortMaxVectorTests(IntFunction fa) { } static short ADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res += a[i]; + res = scalar_add(res, a[i]); } return res; } static short ADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res += ADDReduceMasked(a, i, mask); + res = scalar_add(res, ADDReduceMasked(a, i, mask)); } return res; @@ -3942,7 +4163,7 @@ static void ADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = additiveIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3952,10 +4173,10 @@ static void ADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = additiveIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra += av.reduceLanes(VectorOperators.ADD, vmask); + ra = scalar_add(ra, av.reduceLanes(VectorOperators.ADD, vmask)); } } @@ -3964,18 +4185,18 @@ static void ADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } static short MULReduce(short[] a, int idx) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAll(short[] a) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduce(a, i); + res = scalar_mul(res, MULReduce(a, i)); } return res; @@ -3985,7 +4206,7 @@ static short MULReduceAll(short[] a) { static void MULReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -3995,10 +4216,10 @@ static void MULReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL)); } } @@ -4007,19 +4228,19 @@ static void MULReduceShortMaxVectorTests(IntFunction fa) { } static short MULReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res *= a[i]; + res = scalar_mul(res, a[i]); } return res; } static short MULReduceAllMasked(short[] a, boolean[] mask) { - short res = 1; + short res = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res *= MULReduceMasked(a, i, mask); + res = scalar_mul(res, MULReduceMasked(a, i, mask)); } return res; @@ -4031,7 +4252,7 @@ static void MULReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 1; + short ra = multiplicativeIdentity(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4041,10 +4262,10 @@ static void MULReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 1; + ra = multiplicativeIdentity(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra *= av.reduceLanes(VectorOperators.MUL, vmask); + ra = scalar_mul(ra, av.reduceLanes(VectorOperators.MUL, vmask)); } } @@ -4053,18 +4274,18 @@ static void MULReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } static short MINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduce(a, i)); + res = scalar_min(res, MINReduce(a, i)); } return res; @@ -4074,7 +4295,7 @@ static short MINReduceAll(short[] a) { static void MINReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4084,10 +4305,10 @@ static void MINReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN)); } } @@ -4096,19 +4317,19 @@ static void MINReduceShortMaxVectorTests(IntFunction fa) { } static short MINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.min(res, a[i]); + res = scalar_min(res, a[i]); } return res; } static short MINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.min(res, MINReduceMasked(a, i, mask)); + res = scalar_min(res, MINReduceMasked(a, i, mask)); } return res; @@ -4120,7 +4341,7 @@ static void MINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4130,10 +4351,10 @@ static void MINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); + ra = scalar_min(ra, av.reduceLanes(VectorOperators.MIN, vmask)); } } @@ -4142,18 +4363,18 @@ static void MINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } static short MAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduce(a, i)); + res = scalar_max(res, MAXReduce(a, i)); } return res; @@ -4163,7 +4384,7 @@ static short MAXReduceAll(short[] a) { static void MAXReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4173,10 +4394,10 @@ static void MAXReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX)); } } @@ -4185,19 +4406,19 @@ static void MAXReduceShortMaxVectorTests(IntFunction fa) { } static short MAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res = (short) Math.max(res, a[i]); + res = scalar_max(res, a[i]); } return res; } static short MAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { - res = (short) Math.max(res, MAXReduceMasked(a, i, mask)); + res = scalar_max(res, MAXReduceMasked(a, i, mask)); } return res; @@ -4209,7 +4430,7 @@ static void MAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4219,10 +4440,10 @@ static void MAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); + ra = scalar_max(ra, av.reduceLanes(VectorOperators.MAX, vmask)); } } @@ -4231,7 +4452,7 @@ static void MAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunct } static short UMINReduce(short[] a, int idx) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.minUnsigned(res, a[i]); } @@ -4240,7 +4461,7 @@ static short UMINReduce(short[] a, int idx) { } static short UMINReduceAll(short[] a) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i)); } @@ -4252,7 +4473,7 @@ static short UMINReduceAll(short[] a) { static void UMINReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4262,7 +4483,7 @@ static void UMINReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN)); @@ -4274,7 +4495,7 @@ static void UMINReduceShortMaxVectorTests(IntFunction fa) { } static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.minUnsigned(res, a[i]); @@ -4284,7 +4505,7 @@ static short UMINReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMINReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MAX_VALUE; + short res = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask)); } @@ -4298,7 +4519,7 @@ static void UMINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MAX_VALUE; + short ra = maxValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4308,7 +4529,7 @@ static void UMINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MAX_VALUE; + ra = maxValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask)); @@ -4320,7 +4541,7 @@ static void UMINReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunc } static short UMAXReduce(short[] a, int idx) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.maxUnsigned(res, a[i]); } @@ -4329,7 +4550,7 @@ static short UMAXReduce(short[] a, int idx) { } static short UMAXReduceAll(short[] a) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i)); } @@ -4341,7 +4562,7 @@ static short UMAXReduceAll(short[] a) { static void UMAXReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4351,7 +4572,7 @@ static void UMAXReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX)); @@ -4363,7 +4584,7 @@ static void UMAXReduceShortMaxVectorTests(IntFunction fa) { } static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.maxUnsigned(res, a[i]); @@ -4373,7 +4594,7 @@ static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) { } static short UMAXReduceAllMasked(short[] a, boolean[] mask) { - short res = Short.MIN_VALUE; + short res = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask)); } @@ -4387,7 +4608,7 @@ static void UMAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunc short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = Short.MIN_VALUE; + short ra = minValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4397,7 +4618,7 @@ static void UMAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunc } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = Short.MIN_VALUE; + ra = minValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask)); @@ -4409,7 +4630,7 @@ static void UMAXReduceShortMaxVectorTestsMasked(IntFunction fa, IntFunc } static short FIRST_NONZEROReduce(short[] a, int idx) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = firstNonZero(res, a[i]); } @@ -4418,7 +4639,7 @@ static short FIRST_NONZEROReduce(short[] a, int idx) { } static short FIRST_NONZEROReduceAll(short[] a) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduce(a, i)); } @@ -4430,7 +4651,7 @@ static short FIRST_NONZEROReduceAll(short[] a) { static void FIRST_NONZEROReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4440,7 +4661,7 @@ static void FIRST_NONZEROReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO)); @@ -4452,7 +4673,7 @@ static void FIRST_NONZEROReduceShortMaxVectorTests(IntFunction fa) { } static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = firstNonZero(res, a[i]); @@ -4462,7 +4683,7 @@ static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) { } static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) { - short res = (short) 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask)); } @@ -4476,7 +4697,7 @@ static void FIRST_NONZEROReduceShortMaxVectorTestsMasked(IntFunction fa short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = (short) 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4486,7 +4707,7 @@ static void FIRST_NONZEROReduceShortMaxVectorTestsMasked(IntFunction fa } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = (short) 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask)); @@ -4546,7 +4767,7 @@ static void allTrueShortMaxVectorTests(IntFunction fm) { } static short SUADDReduce(short[] a, int idx) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); } @@ -4555,7 +4776,7 @@ static short SUADDReduce(short[] a, int idx) { } static short SUADDReduceAll(short[] a) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduce(a, i)); } @@ -4567,7 +4788,7 @@ static short SUADDReduceAll(short[] a) { static void SUADDReduceShortMaxVectorTests(IntFunction fa) { short[] a = fa.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4577,7 +4798,7 @@ static void SUADDReduceShortMaxVectorTests(IntFunction fa) { } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD)); @@ -4589,7 +4810,7 @@ static void SUADDReduceShortMaxVectorTests(IntFunction fa) { } static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = (short) VectorMath.addSaturatingUnsigned(res, a[i]); @@ -4599,7 +4820,7 @@ static short SUADDReduceMasked(short[] a, int idx, boolean[] mask) { } static short SUADDReduceAllMasked(short[] a, boolean[] mask) { - short res = 0; + short res = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { res = (short) VectorMath.addSaturatingUnsigned(res, SUADDReduceMasked(a, i, mask)); } @@ -4612,7 +4833,7 @@ static void SUADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFun short[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); - short ra = 0; + short ra = zeroValue(); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -4622,7 +4843,7 @@ static void SUADDReduceShortMaxVectorTestsMasked(IntFunction fa, IntFun } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = 0; + ra = zeroValue(); for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ra = (short) VectorMath.addSaturatingUnsigned(ra, av.reduceLanes(VectorOperators.SUADD, vmask)); @@ -4667,7 +4888,7 @@ static void IS_DEFAULTShortMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j])); } } } @@ -4687,7 +4908,7 @@ static void IS_DEFAULTMaskedShortMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j])); } } } @@ -4708,7 +4929,7 @@ static void IS_NEGATIVEShortMaxVectorTests(IntFunction fa) { // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j])); } } } @@ -4728,7 +4949,7 @@ static void IS_NEGATIVEMaskedShortMaxVectorTests(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j])); } } } @@ -4747,7 +4968,7 @@ static void LTShortMaxVectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4766,7 +4987,7 @@ static void ltShortMaxVectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j])); } } } @@ -4789,7 +5010,7 @@ static void LTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j])); } } } @@ -4831,7 +5052,7 @@ static void GTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4869,7 +5090,7 @@ static void eqShortMaxVectorTests(IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j])); } } } @@ -4892,7 +5113,7 @@ static void EQShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j])); } } } @@ -4934,7 +5155,7 @@ static void NEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j])); } } } @@ -4976,7 +5197,7 @@ static void LEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j])); } } } @@ -5018,7 +5239,7 @@ static void GEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j])); } } } @@ -5060,7 +5281,7 @@ static void ULTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j])); } } } @@ -5102,7 +5323,7 @@ static void UGTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j])); } } } @@ -5144,7 +5365,7 @@ static void ULEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j])); } } } @@ -5186,7 +5407,7 @@ static void UGEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); } } } @@ -5223,7 +5444,7 @@ static void LTShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (lt(a[i + j], b[i]))); } } } @@ -5239,7 +5460,7 @@ static void LTShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), lt(a[i + j], (short)((long)b[i]))); } } } @@ -5259,7 +5480,7 @@ static void LTShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); } } } @@ -5295,7 +5516,7 @@ static void EQShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && (eq(a[i + j], b[i]))); } } } @@ -5311,7 +5532,7 @@ static void EQShortMaxVectorTestsBroadcastLongSmokeTest(IntFunction fa, // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i])); + AssertEquals(mv.laneIsSet(j), eq(a[i + j], (short)((long)b[i]))); } } } @@ -5331,7 +5552,7 @@ static void EQShortMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction fa) { } } - Assert.assertEquals(a, r); + AssertEquals(a, r); } static short[] sliceUnary(short[] a, int origin, int idx) { @@ -6043,11 +6264,11 @@ static void BITWISE_BLENDShortMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFu } static short NEG(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } static short neg(short a) { - return (short)(-((short)a)); + return (short)(scalar_neg((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6099,11 +6320,11 @@ static void NEGMaskedShortMaxVectorTests(IntFunction fa, } static short ABS(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } static short abs(short a) { - return (short)(Math.abs((short)a)); + return (short)(scalar_abs((short)a)); } @Test(dataProvider = "shortUnaryOpProvider") @@ -6443,7 +6664,7 @@ static void ltShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, Int // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); } } } @@ -6459,7 +6680,7 @@ static void eqShortMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction f // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); } } } @@ -6699,7 +6920,7 @@ static void shuffleMiscellaneousShortMaxVectorTestsSmokeTest(BiFunction>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } } diff --git a/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java index a35c248a60b70..ab1e2c1cd44c7 100644 --- a/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 diff --git a/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java index 4668401d65389..8294ba470ebee 100644 --- a/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 diff --git a/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java index d35d3ce2e1e90..b8683d1bd2f67 100644 --- a/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 diff --git a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java index c3b1ca50fa962..74507d9015c4a 100644 --- a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 diff --git a/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java b/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java index 3f5d26820468f..57817eac97bf6 100644 --- a/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java +++ b/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2025, 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 diff --git a/test/jdk/jdk/incubator/vector/gen-template.sh b/test/jdk/jdk/incubator/vector/gen-template.sh index abc090bbdf085..440c16dd7e01c 100644 --- a/test/jdk/jdk/incubator/vector/gen-template.sh +++ b/test/jdk/jdk/incubator/vector/gen-template.sh @@ -22,7 +22,7 @@ # questions. # -generate_perf_tests=$2 +generate_perf_tests=$1 TEMPLATE_FOLDER="templates/" @@ -69,11 +69,8 @@ reduction_op_masked_func="Reduction-Masked-op-func" reduction_saturating_op="SaturatingReduction-op" reduction_saturating_op_masked="SaturatingReduction-Masked-op" unary_math_template="Unary-op-math" -unary_math_hf_template="Unary-op-hf-math" binary_math_template="Binary-op-math" -binary_math_hf_template="Binary-op-hf-math" binary_math_broadcast_template="Binary-Broadcast-op-math" -binary_math_hf_broadcast_template="Binary-Broadcast-op-hf-math" bool_reduction_scalar="BoolReduction-Scalar-op" bool_reduction_template="BoolReduction-op" with_op_template="With-Op" @@ -105,7 +102,6 @@ function replace_variables { local masked=$8 local op_name=$9 local kernel_smoke=${10} - local attrib=${11} if [ "x${kernel}" != "x" ]; then local kernel_escaped=$(echo -e "$kernel" | tr '\n' '`') @@ -122,7 +118,6 @@ function replace_variables { # if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask") local test_func="" local withMask="" - local suffix="" local tests=($(awk -F+ '{$1=$1} 1' <<< $test)) if [ "${tests[2]}" == "withMask" ]; then test=${tests[0]} @@ -137,23 +132,12 @@ function replace_variables { test_func=${tests[1]} fi - if [ "${attrib}" == "associative" ]; then - suffix=${suffix}"_ASSOC" - fi - if [ "${attrib}" == "reduction" ]; then - suffix=${suffix}"_REDUCTION" - fi - if [ "${attrib}" == "memoryoper" ]; then - suffix=${suffix}"_MEM" - fi - sed_prog=" s/\\(.*\)\<\\OPTIONAL\>/\1/g s/\[\[TEST_TYPE\]\]/${masked}/g s/\[\[TEST_OP\]\]/${op}/g s/\[\[TEST_INIT\]\]/${init}/g s/\[\[OP_NAME\]\]/${op_name}/g - s/\[\[SUFFIX\]\]/${suffix}/g " sed_prog_2="$sed_prog s/\[\[TEST\]\]/${test_func}/g @@ -201,18 +185,13 @@ function gen_op_tmpl { local op=$3 local guard="" local init="" - local attrib="" if [ $# -gt 3 ]; then guard=$4 fi - if [ $# -gt 4 ]; then + if [ $# == 5 ]; then init=$5 fi - if [ $# -gt 5 ]; then - attrib=$6 - fi - local masked="" if [[ $template == *"Masked"* ]]; then masked="Masked" @@ -247,7 +226,7 @@ function gen_op_tmpl { fi # Replace template variables in unit test files (if any) - replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke" "$attrib" + replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke" local gen_perf_tests=$generate_perf_tests if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] || @@ -261,15 +240,15 @@ function gen_op_tmpl { local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template" if [ -f $perf_vector_filename ]; then - replace_variables $perf_vector_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib" + replace_variables $perf_vector_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" elif [ -f $kernel_filename ]; then - replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib" + replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then echo "Warning: missing perf: $@" fi if [ -f $perf_scalar_filename ]; then - replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" "$attrib" + replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "" elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then echo "Warning: Missing PERF SCALAR: $perf_scalar_filename" fi @@ -284,8 +263,8 @@ function gen_binary_alu_op { function gen_binary_alu_mem_op { echo "Generating binary op $1 ($2)..." - gen_op_tmpl $binary_memop "$@" "" "" "memoryoper" - gen_op_tmpl $binary_masked_memop "$@" "" "" "memoryoper" + gen_op_tmpl $binary_memop "$@" + gen_op_tmpl $binary_masked_memop "$@" } function gen_binary_alu_bcst_op { @@ -353,8 +332,8 @@ function gen_saturating_binary_op { function gen_saturating_binary_op_associative { echo "Generating saturating binary associative op $1 ($2)..." - gen_op_tmpl $saturating_binary_assocative "$@" "" "associative" - gen_op_tmpl $saturating_binary_assocative_masked "$@" "" "associative" + gen_op_tmpl $saturating_binary_assocative "$@" + gen_op_tmpl $saturating_binary_assocative_masked "$@" } function gen_binary_op_no_masked { @@ -400,12 +379,13 @@ function gen_bool_reduction_op { gen_op_tmpl $bool_reduction_scalar "$@" gen_op_tmpl $bool_reduction_template "$@" } + function gen_saturating_reduction_op { - echo "Generating saturating reduction op $1 ($2)..." - gen_op_tmpl $reduction_scalar_func "$@" "reduction" - gen_op_tmpl $reduction_saturating_op "$@" "reduction" - gen_op_tmpl $reduction_scalar_masked_func "$@" "reduction" - gen_op_tmpl $reduction_saturating_op_masked "$@" "reduction" + echo "Generating saturating reduction op $1 ($2) ($4)..." + gen_op_tmpl $reduction_scalar_func "$@" + gen_op_tmpl $reduction_saturating_op "$@" + gen_op_tmpl $reduction_scalar_masked_func "$@" + gen_op_tmpl $reduction_saturating_op_masked "$@" } function gen_with_op { @@ -449,235 +429,202 @@ if [ $generate_perf_tests == true ]; then gen_perf_scalar_header $perf_scalar_output fi -if [ "$1" == "ALL_PRIM_TYPES" ]; then - # ALU binary ops. - # Here "ADD+add+withMask" says VectorOperator name is "ADD", and we have a dedicate method too named 'add', and add() is also available with mask variant. - gen_binary_alu_op "ADD+add+withMask" "a + b" - gen_binary_alu_op "SUB+sub+withMask" "a - b" - gen_binary_alu_op "MUL+mul+withMask" "a \* b" - gen_binary_alu_op "DIV+div+withMask" "a \/ b" "FP" - gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" - gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" - gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b" - gen_binary_alu_op "AND+and" "a \& b" "BITWISE" - gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE" - gen_binary_alu_op "OR+or" "a | b" "BITWISE" - # Missing: "OR_UNCHECKED" - gen_binary_alu_op "XOR" "a ^ b" "BITWISE" - gen_binary_alu_op "COMPRESS_BITS" "\$Boxtype\$.compress(a, b)" "intOrLong" - gen_binary_alu_op "EXPAND_BITS" "\$Boxtype\$.expand(a, b)" "intOrLong" - # Generate the broadcast versions - gen_binary_alu_bcst_op "add+withMask" "a + b" - gen_binary_alu_bcst_op "sub+withMask" "a - b" - gen_binary_alu_bcst_op "mul+withMask" "a \* b" - gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP" - gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" - gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" - gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE" - gen_binary_alu_bcst_op "AND+and" "a \& b" "BITWISE" - gen_binary_alu_bcst_long_op "OR" "a | b" "BITWISE" - gen_binary_alu_bcst_long_op "ADD" "a + b" - - # Shifts - gen_binary_alu_op "LSHL" "(a << b)" "intOrLong" - gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte" - gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short" - gen_binary_alu_op "ASHR" "(a >> b)" "intOrLong" - gen_binary_alu_op "ASHR" "(a >> (b \& 0x7))" "byte" - gen_binary_alu_op "ASHR" "(a >> (b \& 0xF))" "short" - gen_binary_alu_op "LSHR" "(a >>> b)" "intOrLong" - gen_binary_alu_op "LSHR" "((a \& 0xFF) >>> (b \& 0x7))" "byte" - gen_binary_alu_op "LSHR" "((a \& 0xFFFF) >>> (b \& 0xF))" "short" - gen_shift_op "LSHL" "(a << b)" "intOrLong" - gen_shift_op "LSHL" "(a << (b \& 7))" "byte" - gen_shift_op "LSHL" "(a << (b \& 15))" "short" - gen_shift_op "LSHR" "(a >>> b)" "intOrLong" - gen_shift_op "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte" - gen_shift_op "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short" - gen_shift_op "ASHR" "(a >> b)" "intOrLong" - gen_shift_op "ASHR" "(a >> (b \& 7))" "byte" - gen_shift_op "ASHR" "(a >> (b \& 15))" "short" - gen_binary_alu_op "ROR" "ROR_scalar(a,b)" "BITWISE" - gen_binary_alu_op "ROL" "ROL_scalar(a,b)" "BITWISE" - gen_shift_op "ROR" "ROR_scalar(a, b)" "BITWISE" - gen_shift_op "ROL" "ROL_scalar(a, b)" "BITWISE" - - # Constant Shifts - gen_shift_cst_op "LSHR" "(a >>> CONST_SHIFT)" "intOrLong" - gen_shift_cst_op "LSHR" "((a \& 0xFF) >>> CONST_SHIFT)" "byte" - gen_shift_cst_op "LSHR" "((a \& 0xFFFF) >>> CONST_SHIFT)" "short" - gen_shift_cst_op "LSHL" "(a << CONST_SHIFT)" "BITWISE" - gen_shift_cst_op "ASHR" "(a >> CONST_SHIFT)" "BITWISE" - gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE" - gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" - - # Binary operation with one memory operand - gen_binary_alu_mem_op "MIN+min+withMask", "Math.min(a, b)" - gen_binary_alu_mem_op "MAX+max+withMask", "Math.max(a, b)" - - # Masked reductions. - gen_binary_op_no_masked "MIN+min" "Math.min(a, b)" - gen_binary_op_no_masked "MAX+max" "Math.max(a, b)" - gen_binary_op "UMIN" "VectorMath.minUnsigned(a, b)" "BITWISE" - gen_binary_op "UMAX" "VectorMath.maxUnsigned(a, b)" "BITWISE" - gen_saturating_binary_op "SADD" "VectorMath.addSaturating(a, b)" "BITWISE" - gen_saturating_binary_op "SSUB" "VectorMath.subSaturating(a, b)" "BITWISE" - gen_saturating_binary_op "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" - gen_saturating_binary_op "SUSUB" "VectorMath.subSaturatingUnsigned(a, b)" "BITWISE" - gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)" - gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)" - gen_saturating_binary_op_associative "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" - - # Reductions. - gen_reduction_op "AND" "\&" "BITWISE" "-1" - gen_reduction_op "OR" "|" "BITWISE" "0" - gen_reduction_op "XOR" "^" "BITWISE" "0" - gen_reduction_op "ADD" "+" "" "0" - gen_reduction_op "MUL" "*" "" "1" - gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "\$Wideboxtype\$.\$MaxValue\$" - gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "\$Wideboxtype\$.\$MinValue\$" - gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "\$Wideboxtype\$.\$MaxValue\$" - gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "\$Wideboxtype\$.\$MinValue\$" - gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0" - - # Boolean reductions. - gen_bool_reduction_op "anyTrue" "|" "BITWISE" "false" - gen_bool_reduction_op "allTrue" "\&" "BITWISE" "true" - - # Saturating reductions. - gen_saturating_reduction_op "SUADD" "(\$type\$) VectorMath.addSaturatingUnsigned" "BITWISE" "0" - - #Insert - gen_with_op "withLane" "" "" "" - - # Tests - gen_op_tmpl $test_template "IS_DEFAULT" "bits(a)==0" - gen_op_tmpl $test_template "IS_NEGATIVE" "bits(a)<0" - gen_op_tmpl $test_template "IS_FINITE" "\$Boxtype\$.isFinite(a)" "FP" - gen_op_tmpl $test_template "IS_NAN" "\$Boxtype\$.isNaN(a)" "FP" - gen_op_tmpl $test_template "IS_INFINITE" "\$Boxtype\$.isInfinite(a)" "FP" - - # Compares - gen_compare_op "LT+lt" "lt" - gen_compare_op "GT" "gt" - gen_compare_op "EQ+eq" "eq" - gen_compare_op "NE" "neq" - gen_compare_op "LE" "le" - gen_compare_op "GE" "ge" - - gen_compare_op "ULT" "ult" "BITWISE" - gen_compare_op "UGT" "ugt" "BITWISE" - gen_compare_op "ULE" "ule" "BITWISE" - gen_compare_op "UGE" "uge" "BITWISE" - - gen_compare_bcst_op "LT" "<" - gen_compare_bcst_op "EQ" "==" - - # Blend. - gen_op_tmpl $blend "blend" "" - - # Rearrange - gen_op_tmpl $rearrange_template "rearrange" "" - - # Compress/Expand - gen_op_tmpl $compressexpand_template "compress_expand" "" - - # Get - gen_get_op "lane" "" - - # Broadcast - gen_op_tmpl $broadcast_template "broadcast" "" - - # Zero - gen_op_tmpl $zero_template "zero" "" - - # Slice - gen_op_tmpl $slice_template "sliceUnary" "" - gen_op_tmpl $slice1_template "sliceBinary" "" - gen_op_tmpl $slice1_masked_template "slice" "" - - # Unslice - gen_op_tmpl $unslice_template "unsliceUnary" "" - gen_op_tmpl $unslice1_template "unsliceBinary" "" - gen_op_tmpl $unslice1_masked_template "unslice" "" - - # Math - gen_op_tmpl $unary_math_template "SIN" "Math.sin((double)a)" "FP" - gen_op_tmpl $unary_math_template "EXP" "Math.exp((double)a)" "FP" - gen_op_tmpl $unary_math_template "LOG1P" "Math.log1p((double)a)" "FP" - gen_op_tmpl $unary_math_template "LOG" "Math.log((double)a)" "FP" - gen_op_tmpl $unary_math_template "LOG10" "Math.log10((double)a)" "FP" - gen_op_tmpl $unary_math_template "EXPM1" "Math.expm1((double)a)" "FP" - gen_op_tmpl $unary_math_template "COS" "Math.cos((double)a)" "FP" - gen_op_tmpl $unary_math_template "TAN" "Math.tan((double)a)" "FP" - gen_op_tmpl $unary_math_template "SINH" "Math.sinh((double)a)" "FP" - gen_op_tmpl $unary_math_template "COSH" "Math.cosh((double)a)" "FP" - gen_op_tmpl $unary_math_template "TANH" "Math.tanh((double)a)" "FP" - gen_op_tmpl $unary_math_template "ASIN" "Math.asin((double)a)" "FP" - gen_op_tmpl $unary_math_template "ACOS" "Math.acos((double)a)" "FP" - gen_op_tmpl $unary_math_template "ATAN" "Math.atan((double)a)" "FP" - gen_op_tmpl $unary_math_template "CBRT" "Math.cbrt((double)a)" "FP" - gen_op_tmpl $binary_math_template "HYPOT" "Math.hypot((double)a, (double)b)" "FP" - gen_op_tmpl $binary_math_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" - gen_op_tmpl $binary_math_template "ATAN2" "Math.atan2((double)a, (double)b)" "FP" - gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow((double)a, (double)b)" "FP" - - # Ternary operations. - gen_ternary_alu_op "FMA+fma" "Math.fma(a, b, c)" "FP" - gen_ternary_alu_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" - gen_ternary_alu_bcst_op "FMA" "Math.fma(a, b, c)" "FP" - gen_ternary_alu_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" - gen_ternary_alu_double_bcst_op "FMA+fma" "Math.fma(a, b, c)" "FP" - gen_ternary_alu_double_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" - - # Unary operations. - gen_unary_alu_op "NEG+neg" "-((\$type\$)a)" - gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)" - gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE" - gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE" - gen_unary_alu_op "SQRT+sqrt" "Math.sqrt((double)a)" "FP" - gen_unary_alu_op "BIT_COUNT" "\$Boxtype\$.bitCount(a)" "intOrLong" - gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFF)" "byte" - gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFFFF)" "short" - gen_unary_alu_op "TRAILING_ZEROS_COUNT" "TRAILING_ZEROS_COUNT_scalar(a)" "BITWISE" - gen_unary_alu_op "LEADING_ZEROS_COUNT" "LEADING_ZEROS_COUNT_scalar(a)" "BITWISE" - gen_unary_alu_op "REVERSE" "REVERSE_scalar(a)" "BITWISE" - gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "intOrLong" - gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "short" - gen_unary_alu_op "REVERSE_BYTES" "a" "byte" - -elif [ "$1" == "HALF_FLOAT_TYPE" ]; then - gen_binary_alu_op "ADD" "Float.floatToFloat16(Float.float16ToFloat(a) + Float.float16ToFloat(b))" "Halffloat" - gen_binary_alu_op "SUB" "Float.floatToFloat16(Float.float16ToFloat(a) - Float.float16ToFloat(b))" "Halffloat" - gen_binary_alu_op "MUL" "Float.floatToFloat16(Float.float16ToFloat(a) \* Float.float16ToFloat(b))" "Halffloat" - gen_binary_alu_op "DIV" "Float.floatToFloat16(Float.float16ToFloat(a) \/ Float.float16ToFloat(b))" "Halffloat" - gen_binary_alu_op "MAX" "Float.floatToFloat16(Math.max(Float.float16ToFloat(a), Float.float16ToFloat(b)))" "Halffloat" - gen_binary_alu_op "MIN" "Float.floatToFloat16(Math.min(Float.float16ToFloat(a), Float.float16ToFloat(b)))" "Halffloat" - gen_unary_alu_op "ABS+abs" "Math.abs(a)" "Halffloat" - gen_unary_alu_op "NEG+neg" "-a" "Halffloat" - gen_ternary_alu_op "FMA+fma" "Float.floatToFloat16(Math.fma(Float.float16ToFloat(a), Float.float16ToFloat(b), Float.float16ToFloat(c)))" "Halffloat" - gen_unary_alu_op "SQRT+sqrt" "Float.floatToFloat16((float) Math.sqrt(Float.float16ToFloat(a)))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "SIN" "Math.sin(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "EXP" "Math.exp(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "LOG1P" "Math.log1p(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "LOG" "Math.log(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "LOG10" "Math.log10(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "EXPM1" "Math.expm1(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "COS" "Math.cos(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "TAN" "Math.tan(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "SINH" "Math.sinh(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "COSH" "Math.cosh(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "TANH" "Math.tanh(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "ASIN" "Math.asin(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "ACOS" "Math.acos(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "ATAN" "Math.atan(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $unary_math_hf_template "CBRT" "Math.cbrt(Float.float16ToFloat(a))" "Halffloat" - gen_op_tmpl $binary_math_hf_template "HYPOT" "Math.hypot(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" - gen_op_tmpl $binary_math_hf_template "POW+pow" "Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" - gen_op_tmpl $binary_math_hf_template "ATAN2" "Math.atan2(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" - gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow(Float.float16ToFloat(a), Float.float16ToFloat(b))" "Halffloat" - gen_op_tmpl $blend "blend" "Halffloat" -fi +# ALU binary ops. +# Here "ADD+add+withMask" says VectorOperator name is "ADD", and we have a dedicate method too named 'add', and add() is also available with mask variant. +gen_binary_alu_op "ADD+add+withMask" "scalar_add(a, b)" +gen_binary_alu_op "SUB+sub+withMask" "scalar_sub(a, b)" +gen_binary_alu_op "MUL+mul+withMask" "scalar_mul(a, b)" +gen_binary_alu_op "DIV+div+withMask" "scalar_div(a, b)" "FP" +gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" +gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE" +gen_binary_alu_op "FIRST_NONZERO" "firstNonZero(a, b)" +gen_binary_alu_op "AND+and" "a \& b" "BITWISE" +gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE" +gen_binary_alu_op "OR+or" "a | b" "BITWISE" +# Missing: "OR_UNCHECKED" +gen_binary_alu_op "XOR" "a ^ b" "BITWISE" +gen_binary_alu_op "COMPRESS_BITS" "\$Boxtype\$.compress(a, b)" "intOrLong" +gen_binary_alu_op "EXPAND_BITS" "\$Boxtype\$.expand(a, b)" "intOrLong" +# Generate the broadcast versions +gen_binary_alu_bcst_op "add+withMask" "scalar_add(a, b)" +gen_binary_alu_bcst_op "sub+withMask" "scalar_sub(a, b)" +gen_binary_alu_bcst_op "mul+withMask" "scalar_mul(a, b)" +gen_binary_alu_bcst_op "div+withMask" "scalar_div(a, b)" "FP" +gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" +gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE" +gen_binary_alu_bcst_op "OR+or" "a | b" "BITWISE" +gen_binary_alu_bcst_op "AND+and" "a \& b" "BITWISE" +gen_binary_alu_bcst_long_op "OR" "a | b" "BITWISE" +gen_binary_alu_bcst_long_op "ADD" "scalar_add(a, b)" + +# Shifts +gen_binary_alu_op "LSHL" "(a << b)" "intOrLong" +gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte" +gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short" +gen_binary_alu_op "ASHR" "(a >> b)" "intOrLong" +gen_binary_alu_op "ASHR" "(a >> (b \& 0x7))" "byte" +gen_binary_alu_op "ASHR" "(a >> (b \& 0xF))" "short" +gen_binary_alu_op "LSHR" "(a >>> b)" "intOrLong" +gen_binary_alu_op "LSHR" "((a \& 0xFF) >>> (b \& 0x7))" "byte" +gen_binary_alu_op "LSHR" "((a \& 0xFFFF) >>> (b \& 0xF))" "short" +gen_shift_op "LSHL" "(a << b)" "intOrLong" +gen_shift_op "LSHL" "(a << (b \& 7))" "byte" +gen_shift_op "LSHL" "(a << (b \& 15))" "short" +gen_shift_op "LSHR" "(a >>> b)" "intOrLong" +gen_shift_op "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte" +gen_shift_op "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short" +gen_shift_op "ASHR" "(a >> b)" "intOrLong" +gen_shift_op "ASHR" "(a >> (b \& 7))" "byte" +gen_shift_op "ASHR" "(a >> (b \& 15))" "short" +gen_binary_alu_op "ROR" "ROR_scalar(a,b)" "BITWISE" +gen_binary_alu_op "ROL" "ROL_scalar(a,b)" "BITWISE" +gen_shift_op "ROR" "ROR_scalar(a, b)" "BITWISE" +gen_shift_op "ROL" "ROL_scalar(a, b)" "BITWISE" + +# Constant Shifts +gen_shift_cst_op "LSHR" "(a >>> CONST_SHIFT)" "intOrLong" +gen_shift_cst_op "LSHR" "((a \& 0xFF) >>> CONST_SHIFT)" "byte" +gen_shift_cst_op "LSHR" "((a \& 0xFFFF) >>> CONST_SHIFT)" "short" +gen_shift_cst_op "LSHL" "(a << CONST_SHIFT)" "BITWISE" +gen_shift_cst_op "ASHR" "(a >> CONST_SHIFT)" "BITWISE" +gen_shift_cst_op "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE" +gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" + +# Binary operation with one memory operand +gen_binary_alu_mem_op "MIN+min+withMask", "scalar_max(a, b)" +gen_binary_alu_mem_op "MAX+max+withMask", "scalar_min(a, b)" + +# Masked reductions. +gen_binary_op_no_masked "MIN+min" "scalar_min(a, b)" +gen_binary_op_no_masked "MAX+max" "scalar_max(a, b)" +gen_binary_op "UMIN" "VectorMath.minUnsigned(a, b)" "BITWISE" +gen_binary_op "UMAX" "VectorMath.maxUnsigned(a, b)" "BITWISE" +gen_saturating_binary_op "SADD" "VectorMath.addSaturating(a, b)" "BITWISE" +gen_saturating_binary_op "SSUB" "VectorMath.subSaturating(a, b)" "BITWISE" +gen_saturating_binary_op "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" +gen_saturating_binary_op "SUSUB" "VectorMath.subSaturatingUnsigned(a, b)" "BITWISE" +gen_binary_bcst_op_no_masked "MIN+min" "scalar_min(a, b)" +gen_binary_bcst_op_no_masked "MAX+max" "scalar_max(a, b)" +gen_saturating_binary_op_associative "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" + +# Reductions. +gen_reduction_op "AND" "scalar_and" "BITWISE" "-1" +gen_reduction_op "OR" "scalar_or" "BITWISE" "0" +gen_reduction_op "XOR" "scalar_xor" "BITWISE" "0" +gen_reduction_op "ADD" "scalar_add" "" "additiveIdentity()" +gen_reduction_op "MUL" "scalar_mul" "" "multiplicativeIdentity()" +gen_reduction_op_func "MIN" "scalar_min" "" "maxValue" +gen_reduction_op_func "MAX" "scalar_max" "" "minValue" +gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "maxValue" +gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "minValue" +gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "zeroValue" + +# Boolean reductions. +gen_bool_reduction_op "anyTrue" "|" "BITWISE" "false" +gen_bool_reduction_op "allTrue" "\&" "BITWISE" "true" + +# Saturating reductions. +gen_saturating_reduction_op "SUADD" "(\$type\$) VectorMath.addSaturatingUnsigned" "BITWISE" "zeroValue" + +#Insert +gen_with_op "withLane" "" "" "" + +# Tests +gen_op_tmpl $test_template "IS_DEFAULT" "bits(a)==0" +gen_op_tmpl $test_template "IS_NEGATIVE" "bits(a)<0" +gen_op_tmpl $test_template "IS_FINITE" "isFinite(a)" "FP" +gen_op_tmpl $test_template "IS_NAN" "isNaN(a)" "FP" +gen_op_tmpl $test_template "IS_INFINITE" "isInfinite(a)" "FP" + +# Compares +gen_compare_op "LT+lt" "lt" +gen_compare_op "GT" "gt" +gen_compare_op "EQ+eq" "eq" +gen_compare_op "NE" "neq" +gen_compare_op "LE" "le" +gen_compare_op "GE" "ge" + +gen_compare_op "ULT" "ult" "BITWISE" +gen_compare_op "UGT" "ugt" "BITWISE" +gen_compare_op "ULE" "ule" "BITWISE" +gen_compare_op "UGE" "uge" "BITWISE" + + +gen_compare_bcst_op "LT" "lt" +gen_compare_bcst_op "EQ" "eq" + +# Blend. +gen_op_tmpl $blend "blend" "" + +# Rearrange +gen_op_tmpl $rearrange_template "rearrange" "" + +# Compress/Expand +gen_op_tmpl $compressexpand_template "compress_expand" "" + +# Get +gen_get_op "lane" "" + +# Broadcast +gen_op_tmpl $broadcast_template "broadcast" "" + +# Zero +gen_op_tmpl $zero_template "zero" "" + +# Slice +gen_op_tmpl $slice_template "sliceUnary" "" +gen_op_tmpl $slice1_template "sliceBinary" "" +gen_op_tmpl $slice1_masked_template "slice" "" + +# Unslice +gen_op_tmpl $unslice_template "unsliceUnary" "" +gen_op_tmpl $unslice1_template "unsliceBinary" "" +gen_op_tmpl $unslice1_masked_template "unslice" "" + +# Math +gen_op_tmpl $unary_math_template "SIN" "scalar_sin(a)" "FP" +gen_op_tmpl $unary_math_template "EXP" "scalar_exp(a)" "FP" +gen_op_tmpl $unary_math_template "LOG1P" "scalar_log1p(a)" "FP" +gen_op_tmpl $unary_math_template "LOG" "scalar_log(a)" "FP" +gen_op_tmpl $unary_math_template "LOG10" "scalar_log10(a)" "FP" +gen_op_tmpl $unary_math_template "EXPM1" "scalar_expm1(a)" "FP" +gen_op_tmpl $unary_math_template "COS" "scalar_cos(a)" "FP" +gen_op_tmpl $unary_math_template "TAN" "scalar_tan(a)" "FP" +gen_op_tmpl $unary_math_template "SINH" "scalar_sinh(a)" "FP" +gen_op_tmpl $unary_math_template "COSH" "scalar_cosh(a)" "FP" +gen_op_tmpl $unary_math_template "TANH" "scalar_tanh(a)" "FP" +gen_op_tmpl $unary_math_template "ASIN" "scalar_asin(a)" "FP" +gen_op_tmpl $unary_math_template "ACOS" "scalar_acos(a)" "FP" +gen_op_tmpl $unary_math_template "ATAN" "scalar_atan(a)" "FP" +gen_op_tmpl $unary_math_template "CBRT" "scalar_cbrt(a)" "FP" +gen_op_tmpl $binary_math_template "HYPOT" "scalar_hypot(a, b)" "FP" +gen_op_tmpl $binary_math_template "POW+pow" "scalar_pow(a, b)" "FP" +gen_op_tmpl $binary_math_template "ATAN2" "scalar_atan2(a, b)" "FP" +gen_op_tmpl $binary_math_broadcast_template "POW+pow" "scalar_pow(a, b)" "FP" + +# Ternary operations. +gen_ternary_alu_op "FMA+fma" "scalar_fma(a, b, c)" "FP" +gen_ternary_alu_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" +gen_ternary_alu_bcst_op "FMA" "Math.fma(a, b, c)" "FP" +gen_ternary_alu_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" +gen_ternary_alu_double_bcst_op "FMA+fma" "Math.fma(a, b, c)" "FP" +gen_ternary_alu_double_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE" + +# Unary operations. +gen_unary_alu_op "NEG+neg" "scalar_neg((\$type\$)a)" +gen_unary_alu_op "ABS+abs" "scalar_abs((\$type\$)a)" +gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE" +gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE" +gen_unary_alu_op "SQRT+sqrt" "scalar_sqrt(a)" "FP" +gen_unary_alu_op "BIT_COUNT" "\$Boxtype\$.bitCount(a)" "intOrLong" +gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFF)" "byte" +gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFFFF)" "short" +gen_unary_alu_op "TRAILING_ZEROS_COUNT" "TRAILING_ZEROS_COUNT_scalar(a)" "BITWISE" +gen_unary_alu_op "LEADING_ZEROS_COUNT" "LEADING_ZEROS_COUNT_scalar(a)" "BITWISE" +gen_unary_alu_op "REVERSE" "REVERSE_scalar(a)" "BITWISE" +gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "intOrLong" +gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "short" +gen_unary_alu_op "REVERSE_BYTES" "a" "byte" # Miscellaneous Smoke Tests gen_op_tmpl $miscellaneous_template "MISC" "" "" diff --git a/test/jdk/jdk/incubator/vector/gen-tests.sh b/test/jdk/jdk/incubator/vector/gen-tests.sh index 9628bd48e2237..d3046758a7247 100644 --- a/test/jdk/jdk/incubator/vector/gen-tests.sh +++ b/test/jdk/jdk/incubator/vector/gen-tests.sh @@ -26,256 +26,245 @@ # You can regenerate the source files, # and you can clean them up. # FIXME: Move this script under $REPO/make/gensrc/ -generate_test_cases() { - Log false "Generating Vector API tests, $(date)\n" +case $* in +'') CLASS_FILTER='*';; +--generate*) CLASS_FILTER=${2-'*'};; +--help|*) echo "Usage: $0 [--generate [file]]"; exit 1;; +esac - # Compile SPP - Log true "Compiling SPP... " - compilation=$(${JAVAC} -d . "${JDK_SRC_HOME}/make/jdk/src/classes/build/tools/spp/Spp.java") - Log false "$compilation\n" - Log true "done\n" +. config.sh - array=() - if [ $1 == "ALL_PRIM_TYPES" ]; then - array=("byte" "short" "int" "long" "float" "double") - elif [ $1 == "HALF_FLOAT_TYPE" ]; then - array=("halffloat") - fi +# Detect whether to generate the performance tests +generate_perf_tests=false +if [ -d "$PERF_DEST" ]; then + generate_perf_tests=true +fi - # For each type - for type in ${array[@]} - do - Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" - TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" - args="-K$type -Dtype=$type -DType=$Type -DTYPE=$TYPE" +# First, generate the template file. +bash ./gen-template.sh $generate_perf_tests - Boxtype=$Type - Wideboxtype=$Boxtype - MaxValue=MAX_VALUE - MinValue=MIN_VALUE - ElementType=$Type - kind=BITWISE - VecEleType=$Type - bitstype=$type - Bitstype=$Type - Boxbitstype=$Boxtype - fptype=$type - Fptype=$Type - Boxfptype=$Boxtype - ClassType=$type - fpkind="" +Log false "Generating Vector API tests, $(date)\n" - case $type in - byte) - Wideboxtype=Byte - args="$args -KbyteOrShort" - ;; - short) - Wideboxtype=Short - args="$args -KbyteOrShort" - ;; - int) - ElementType=Int - VecEleType=Integer - Boxtype=Integer - Wideboxtype=Integer - fptype=float - Fptype=Float - Boxfptype=Float - args="$args -KintOrLong" - ;; - long) - Wideboxtype=Long - fptype=double - Fptype=Double - Boxfptype=Double - args="$args -KintOrLong" - ;; - float) - kind=FP - fpkind=FP32 - bitstype=int - Bitstype=Int - Boxbitstype=Integer - Wideboxtype=Float - MaxValue=POSITIVE_INFINITY - MinValue=NEGATIVE_INFINITY - args="$args -KfloatOrDouble" - ;; - double) - kind=FP - fpkind=FP64 - bitstype=long - Bitstype=Long - Boxbitstype=Long - Wideboxtype=Double - MaxValue=POSITIVE_INFINITY - MinValue=NEGATIVE_INFINITY - args="$args -KfloatOrDouble" - ;; - halffloat) - VecEleType=Short - ClassType=Float16 - kind=FP - fpkind=FP16 - bitstype=short - Bitstype=Short - Boxbitstype=Short - Wideboxtype=Float16 - args="$args -Dtype=short -DType=Halffloat -DTYPE=HALFFLOAT -DElementType=Halffloat" - ;; - esac +# Compile SPP +Log true "Compiling SPP... " +compilation=$(${JAVAC} -d . "${JDK_SRC_HOME}/make/jdk/src/classes/build/tools/spp/Spp.java") +Log false "$compilation\n" +Log true "done\n" - args="$args -K$fpkind -K$kind -K$Type -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype -DMaxValue=$MaxValue -DMinValue=$MinValue" - args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype -DElementType=$Type -DVecEleType=$VecEleType -DClassType=$ClassType" - args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" +# Nomenclature +# - type : refers to vector primitive lane type or carrier type. +# - Type : refers to vector box lane type. +# For each type +for type in byte short int long float double halffloat +do + Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" + TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${type})" + args="-K$type -DType=$Type -DTYPE=$TYPE" - abstractvectortype=${typeprefix}${Type}Vector - abstractvectorteststype=${typeprefix}${Type}VectorTests - abstractbitsvectortype=${typeprefix}${Bitstype}Vector - abstractfpvectortype=${typeprefix}${Fptype}Vector - args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" + VectorPrefix=$Type + Boxtype=$Type + Wideboxtype=$Boxtype + MaxValue=MAX_VALUE + MinValue=MIN_VALUE - # Generate tests for operations - # For each size - Log true "${Type}:" + kind=BITWISE + fpkind=BITWISE - for bits in 64 128 256 512 Max - do - vectortype=${typeprefix}${Type}${bits}Vector - vectorteststype=${typeprefix}${Type}${bits}VectorTests - vectorbenchtype=${typeprefix}${Type}${bits}Vector - masktype=${typeprefix}${Type}${bits}Mask - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector - shape=S${bits}Bit - Shape=S_${bits}_BIT - if [[ "${vectortype}" == "ByteMaxVector" ]]; then - args="$args -KByteMax" - fi - bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" - if [ $bits == 'Max' ]; then - bitargs="$bitargs -KMaxBit" + bitstype=$type + Bitstype=$Type + Boxbitstype=$Boxtype + + fptype=$type + Fptype=$Type + Boxfptype=$Boxtype + + case $type in + byte) + Wideboxtype=Byte + args="$args -KbyteOrShort" + ;; + short) + Wideboxtype=Short + args="$args -KbyteOrShort" + ;; + int) + Boxtype=Integer + Wideboxtype=Integer + fptype=float + Fptype=Float + Boxfptype=Float + args="$args -KintOrLong" + ;; + long) + Wideboxtype=Long + fptype=double + Fptype=Double + Boxfptype=Double + args="$args -KintOrLong" + ;; + float) + kind=FP + fpkind=FP32 + bitstype=int + Bitstype=Int + Boxbitstype=Integer + Wideboxtype=Float + MaxValue=POSITIVE_INFINITY + MinValue=NEGATIVE_INFINITY + ;; + double) + kind=FP + fpkind=FP64 + bitstype=long + Bitstype=Long + Boxbitstype=Long + Wideboxtype=Double + MaxValue=POSITIVE_INFINITY + MinValue=NEGATIVE_INFINITY + ;; + halffloat) + kind=FP + fpkind=FP16 + bitstype=short + type=short + Bitstype=Short + Boxbitstype=Short + Wideboxtype=Float16 + MaxValue=POSITIVE_INFINITY + MinValue=NEGATIVE_INFINITY + Type=Float16 + ;; + esac + + args="$args -Dtype=$type -K$kind -K$fpkind -K$Type -DBoxtype=$Boxtype -DWideboxtype=$Wideboxtype -DMaxValue=$MaxValue -DMinValue=$MinValue" + args="$args -Dbitstype=$bitstype -DBitstype=$Bitstype -DBoxbitstype=$Boxbitstype" + args="$args -Dfptype=$fptype -DFptype=$Fptype -DBoxfptype=$Boxfptype" + + abstractvectortype=${typeprefix}${VectorPrefix}Vector + abstractvectorteststype=${typeprefix}${VectorPrefix}VectorTests + abstractbitsvectortype=${typeprefix}${VectorPrefixe}Vector + abstractfpvectortype=${typeprefix}${Fptype}Vector + args="$args -Dabstractvectortype=$abstractvectortype -Dabstractvectorteststype=$abstractvectorteststype -Dabstractbitsvectortype=$abstractbitsvectortype -Dabstractfpvectortype=$abstractfpvectortype" + + # Generate tests for operations + # For each size + Log true "${Type}:" + + for bits in 64 128 256 512 Max + do + vectortype=${typeprefix}${VectorPrefix}${bits}Vector + vectorteststype=${typeprefix}${VectorPrefix}${bits}VectorTests + vectorbenchtype=${typeprefix}${VectorPrefix}${bits}Vector + masktype=${typeprefix}${Type}${bits}Mask + bitsvectortype=${typeprefix}${Bitstype}${bits}Vector + fpvectortype=${typeprefix}${Fptype}${bits}Vector + shape=S${bits}Bit + Shape=S_${bits}_BIT + if [[ "${vectortype}" == "ByteMaxVector" ]]; then + args="$args -KByteMax" + fi + bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" + if [ $bits == 'Max' ]; then + bitargs="$bitargs -KMaxBit" + fi + + # Generate jtreg tests + case $vectorteststype in + $CLASS_FILTER) + Log true " ${bits}_jtreg $vectorteststype.java" + Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " + TEST_DEST_FILE="${vectorteststype}.java" + rm -f ${TEST_DEST_FILE} + ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ + -i${TEMPLATE_FILE} \ + -o${TEST_DEST_FILE} + if [ VAR_OS_ENV==windows.cygwin ]; then + tr -d '\r' < ${TEST_DEST_FILE} > temp + mv temp ${TEST_DEST_FILE} fi + ;; + esac - # Generate jtreg tests - case $vectorteststype in + if [ $generate_perf_tests == true ]; then + # Generate jmh performance tests + case $vectorbenchtype in $CLASS_FILTER) - Log true " ${bits}_jtreg $vectorteststype.java" - Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${TEMPLATE_FILE} -o$vectorteststype.java " - TEST_DEST_FILE="${vectorteststype}.java" - rm -f ${TEST_DEST_FILE} + Log true " ${bits}_jmh $vectorbenchtype.java" + Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " + PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" + rm -f ${PERF_DEST_FILE} ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ - -i${TEMPLATE_FILE} \ - -o${TEST_DEST_FILE} - if [ VAR_OS_ENV==windows.cygwin ]; then - tr -d '\r' < ${TEST_DEST_FILE} > temp - mv temp ${TEST_DEST_FILE} - fi - ;; - esac - - if [ $generate_perf_tests == true ]; then - # Generate jmh performance tests - case $vectorbenchtype in - $CLASS_FILTER) - Log true " ${bits}_jmh $vectorbenchtype.java" - Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -i${PERF_TEMPLATE_FILE} -o${vectorteststype}Perf.java " - PERF_DEST_FILE="${PERF_DEST}/${vectorbenchtype}.java" - rm -f ${PERF_DEST_FILE} - ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ -i${PERF_TEMPLATE_FILE} \ -o${PERF_DEST_FILE} - if [ VAR_OS_ENV==windows.cygwin ]; then - tr -d '\r' < ${PERF_DEST_FILE} > temp - mv temp ${PERF_DEST_FILE} - fi - ;; - esac - fi - done - - if [ $generate_perf_tests == true ]; then - # Generate jmh performance tests - case ${Type}Scalar in - $CLASS_FILTER) - Log true " scalar ${Type}Scalar.java" - PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" - rm -f ${PERF_DEST_FILE} - ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ - -i${PERF_SCALAR_TEMPLATE_FILE} \ - -o${PERF_DEST_FILE} if [ VAR_OS_ENV==windows.cygwin ]; then tr -d '\r' < ${PERF_DEST_FILE} > temp mv temp ${PERF_DEST_FILE} fi - ;; - esac - fi - # Generate tests for loads and stores - # For each size - for bits in 64 128 256 512 Max - do - vectortype=${typeprefix}${Type}${bits}Vector - vectorteststype=${typeprefix}${Type}${bits}VectorLoadStoreTests - vectorbenchtype=${typeprefix}${Type}${bits}VectorLoadStore - masktype=${typeprefix}${Type}${bits}Mask - bitsvectortype=${typeprefix}${Bitstype}${bits}Vector - fpvectortype=${typeprefix}${Fptype}${bits}Vector - shape=S${bits}Bit - Shape=S_${bits}_BIT - if [[ "${vectortype}" == "ByteMaxVector" ]]; then - args="$args -KByteMax" - fi - bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" - if [ $bits == 'Max' ]; then - bitargs="$bitargs -KMaxBit" - fi + ;; + esac + fi + done - # Generate - case $vectorteststype in - $CLASS_FILTER) + if [ $generate_perf_tests == true ]; then + # Generate jmh performance tests + case ${Type}Scalar in + $CLASS_FILTER) + Log true " scalar ${Type}Scalar.java" + PERF_DEST_FILE="${PERF_DEST}/${Type}Scalar.java" + rm -f ${PERF_DEST_FILE} + ${JAVA} -cp . ${SPP_CLASSNAME} -nel $args \ + -i${PERF_SCALAR_TEMPLATE_FILE} \ + -o${PERF_DEST_FILE} + if [ VAR_OS_ENV==windows.cygwin ]; then + tr -d '\r' < ${PERF_DEST_FILE} > temp + mv temp ${PERF_DEST_FILE} + fi + ;; + esac + fi + + # Generate tests for loads and stores + # For each size + for bits in 64 128 256 512 Max + do + vectortype=${typeprefix}${VectorPrefix}${bits}Vector + vectorteststype=${typeprefix}${VectorPrefix}${bits}VectorLoadStoreTests + vectorbenchtype=${typeprefix}${VectorPrefix}${bits}VectorLoadStore + masktype=${typeprefix}${Type}${bits}Mask + bitsvectortype=${typeprefix}${Bitstype}${bits}Vector + fpvectortype=${typeprefix}${Fptype}${bits}Vector + shape=S${bits}Bit + Shape=S_${bits}_BIT + if [[ "${vectortype}" == "ByteMaxVector" ]]; then + args="$args -KByteMax" + fi + bitargs="$args -Dbits=$bits -Dvectortype=$vectortype -Dvectorteststype=$vectorteststype -Dvectorbenchtype=$vectorbenchtype -Dmasktype=$masktype -Dbitsvectortype=$bitsvectortype -Dfpvectortype=$fpvectortype -Dshape=$shape -DShape=$Shape" + if [ $bits == 'Max' ]; then + bitargs="$bitargs -KMaxBit" + fi + + # Generate + case $vectorteststype in + $CLASS_FILTER) Log true " ${bits}_ls $vectorteststype.java" Log false "${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs -itemplates/X-LoadStoreTest.java.template -o$vectorteststype.java " TEST_DEST_FILE="${vectorteststype}.java" rm -f ${TEST_DEST_FILE} ${JAVA} -cp . ${SPP_CLASSNAME} -nel $bitargs \ - -itemplates/X-LoadStoreTest.java.template \ - -o${TEST_DEST_FILE} + -itemplates/X-LoadStoreTest.java.template \ + -o${TEST_DEST_FILE} if [ VAR_OS_ENV==windows.cygwin ]; then tr -d '\r' < ${TEST_DEST_FILE} > temp mv temp ${TEST_DEST_FILE} fi - ;; - esac - - # TODO: Generate jmh performance tests for LoadStore variants - done - - Log true " done\n" + ;; + esac + # TODO: Generate jmh performance tests for LoadStore variants done -} - -case $* in -'') CLASS_FILTER='*';; ---generate*) CLASS_FILTER=${2-'*'};; ---help|*) echo "Usage: $0 [--generate [file]]"; exit 1;; -esac -. config.sh + Log true " done\n" -# Detect whether to generate the performance tests -generate_perf_tests=false -if [ -d "$PERF_DEST" ]; then - generate_perf_tests=true -fi +done -# First, generate the template files. -gen_type="ALL_PRIM_TYPES" -gen_half_type="HALF_FLOAT_TYPE" -bash gen-template.sh "ALL_PRIM_TYPES" $generate_perf_tests -generate_test_cases "ALL_PRIM_TYPES" -bash gen-template.sh "HALF_FLOAT_TYPE" $generate_perf_tests -generate_test_cases "HALF_FLOAT_TYPE" rm -fr build diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template deleted file mode 100644 index b0a2dcc943315..0000000000000 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Binary-op-hf-math.template +++ /dev/null @@ -1,12 +0,0 @@ - $type$[] a = fa.apply(SPECIES.length()); - $type$[] b = fb.apply(SPECIES.length()); - $type$[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, b, i); - av.lanewise(VectorOperators.[[TEST]], bv).intoArray(r, i); - } - } - diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op-func.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op-func.template index bf03a4d043059..d1ad454cf9d56 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op-func.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op-func.template @@ -2,7 +2,7 @@ $type$[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); - $type$ ra = [[TEST_INIT]]; + $type$ ra = [[TEST_INIT]](); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -12,7 +12,7 @@ } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = [[TEST_INIT]]; + ra = [[TEST_INIT]](); for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]], vmask)); diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template index f108491523ed5..bf03a4d043059 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-Masked-op.template @@ -15,7 +15,7 @@ ra = [[TEST_INIT]]; for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - ra [[TEST_OP]]= av.reduceLanes(VectorOperators.[[TEST]], vmask); + ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]], vmask)); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op-func.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op-func.template index 7082ff0795e81..85e88a023e2a7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op-func.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op-func.template @@ -1,6 +1,6 @@ $type$[] a = fa.apply(SPECIES.length()); $type$[] r = fr.apply(SPECIES.length()); - $type$ ra = [[TEST_INIT]]; + $type$ ra = [[TEST_INIT]](); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -10,7 +10,7 @@ } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = [[TEST_INIT]]; + ra = [[TEST_INIT]](); for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]])); diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template index 66250c09213a2..7082ff0795e81 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-Reduction-op.template @@ -13,7 +13,7 @@ ra = [[TEST_INIT]]; for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - ra [[TEST_OP]]= av.reduceLanes(VectorOperators.[[TEST]]); + ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]])); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-Masked-op.template index bf03a4d043059..d1ad454cf9d56 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-Masked-op.template @@ -2,7 +2,7 @@ $type$[] r = fr.apply(SPECIES.length()); boolean[] mask = fm.apply(SPECIES.length()); VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); - $type$ ra = [[TEST_INIT]]; + $type$ ra = [[TEST_INIT]](); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -12,7 +12,7 @@ } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = [[TEST_INIT]]; + ra = [[TEST_INIT]](); for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]], vmask)); diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-op.template index 7082ff0795e81..85e88a023e2a7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingReduction-op.template @@ -1,6 +1,6 @@ $type$[] a = fa.apply(SPECIES.length()); $type$[] r = fr.apply(SPECIES.length()); - $type$ ra = [[TEST_INIT]]; + $type$ ra = [[TEST_INIT]](); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0; i < a.length; i += SPECIES.length()) { @@ -10,7 +10,7 @@ } for (int ic = 0; ic < INVOC_COUNT; ic++) { - ra = [[TEST_INIT]]; + ra = [[TEST_INIT]](); for (int i = 0; i < a.length; i += SPECIES.length()) { $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); ra = [[TEST_OP]](ra, av.reduceLanes(VectorOperators.[[TEST]])); diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template deleted file mode 100644 index a1a01cefaa256..0000000000000 --- a/test/jdk/jdk/incubator/vector/templates/Kernel-Unary-op-hf-math.template +++ /dev/null @@ -1,10 +0,0 @@ - $type$[] a = fa.apply(SPECIES.length()); - $type$[] r = fr.apply(SPECIES.length()); - - for (int ic = 0; ic < INVOC_COUNT; ic++) { - for (int i = 0; i < a.length; i += SPECIES.length()) { - $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); - av.lanewise(VectorOperators.[[TEST]]).intoArray(r, i); - } - } - diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template deleted file mode 100644 index 5541acc37971c..0000000000000 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-hf-math.template +++ /dev/null @@ -1,14 +0,0 @@ - - static $type$ [[TEST]]($type$ a, $type$ b) { - return Float16.float16ToRawShortBits((Float16.valueOf((float) [[TEST_OP]]))); - } - - static $type$ strict[[TEST]]($type$ a, $type$ b) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Strict[[TEST_OP]])); - } - - @Test(dataProvider = "$type$BinaryOpProvider") - static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { -[[KERNEL]] - assertArraysEqualsWithinOneUlp(r, a, b, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); - } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template index a3d44526db958..1866c28e2ba11 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Binary-op-math.template @@ -4,7 +4,7 @@ } static $type$ strict[[TEST]]($type$ a, $type$ b) { - return ($type$)(Strict[[TEST_OP]]); + return ($type$)(strict_[[TEST_OP]]); } @Test(dataProvider = "$type$BinaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template b/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template index e3fcdf57e8301..23a730612b45a 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Broadcast.template @@ -10,7 +10,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] [[TEST_OP]] b[i]); + AssertEquals(mv.laneIsSet(j), [[TEST_OP]](a[i + j], b[i])); } } } @@ -30,7 +30,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] [[TEST_OP]] b[i])); + AssertEquals(mv.laneIsSet(j), mask[j] && ([[TEST_OP]](a[i + j], b[i]))); } } } @@ -47,7 +47,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), a[i + j] [[TEST_OP]] ($type$)((long)b[i])); + AssertEquals(mv.laneIsSet(j), [[TEST_OP]](a[i + j], ($type$)((long)b[i]))); } } } @@ -67,7 +67,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] [[TEST_OP]] ($type$)((long)b[i]))); + AssertEquals(mv.laneIsSet(j), mask[j] && ([[TEST_OP]](a[i + j],($type$)((long)b[i])))); } } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Masked.template b/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Masked.template index b34658ffc4c1b..39b03adc8df55 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Masked.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Compare-Masked.template @@ -16,7 +16,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), mask[j] && [[TEST_OP]](a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), mask[j] && [[TEST_OP]](a[i + j], b[i + j])); } } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Compare.template b/test/jdk/jdk/incubator/vector/templates/Unit-Compare.template index 47ddfaf4ab0d0..dc61af40e3b40 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Compare.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Compare.template @@ -12,7 +12,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), [[TEST_OP]](a[i + j], b[i + j])); + AssertEquals(mv.laneIsSet(j), [[TEST_OP]](a[i + j], b[i + j])); } } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template index a4c8f734e52e4..7af4d93928cd1 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Miscellaneous.template @@ -10,11 +10,11 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { -#if[Halffloat] - Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); -#else[Halffloat] - Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]); -#end[Halffloat] +#if[FP16] + AssertEquals(mv.laneIsSet(j), lt(a[i + j], b[i])); +#else[FP16] + AssertEquals(mv.laneIsSet(j), a[i + j] < b[i]); +#end[FP16] } } } @@ -30,11 +30,11 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { -#if[Halffloat] - Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); -#else[Halffloat] - Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]); -#end[Halffloat] +#if[FP16] + AssertEquals(mv.laneIsSet(j), eq(a[i + j], b[i])); +#else[FP16] + AssertEquals(mv.laneIsSet(j), a[i + j] == b[i]); +#end[FP16] } } } @@ -131,11 +131,11 @@ static long ADDReduceLong($type$[] a, int idx) { $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { -#if[Halffloat] +#if[FP16] res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); -#else[Halffloat] +#else[FP16] res += a[i]; -#end[Halffloat] +#end[FP16] } return (long)res; @@ -144,11 +144,11 @@ static long ADDReduceAllLong($type$[] a) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { -#if[Halffloat] +#if[FP16] res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLong(a, i))); -#else[Halffloat] +#else[FP16] res += ADDReduceLong(a, i); -#end[Halffloat] +#end[FP16] } return res; @@ -167,11 +167,11 @@ ra = 0; for (int i = 0; i < a.length; i++) { -#if[Halffloat] +#if[FP16] ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); -#else[Halffloat] +#else[FP16] ra += r[i]; -#end[Halffloat] +#end[FP16] } assertReductionLongArraysEquals(r, ra, a, @@ -182,11 +182,11 @@ $type$ res = 0; for (int i = idx; i < (idx + SPECIES.length()); i++) { if(mask[i % SPECIES.length()]) -#if[Halffloat] +#if[FP16] res = Float.floatToFloat16(Float.float16ToFloat(res) + Float.float16ToFloat(a[i])); -#else[Halffloat] +#else[FP16] res += a[i]; -#end[Halffloat] +#end[FP16] } return (long)res; @@ -195,11 +195,11 @@ static long ADDReduceAllLongMasked($type$[] a, boolean[] mask) { long res = 0; for (int i = 0; i < a.length; i += SPECIES.length()) { -#if[Halffloat] +#if[FP16] res = Float.floatToFloat16(Float.float16ToFloat((short)res) + Float.float16ToFloat((short)ADDReduceLongMasked(a, i, mask))); -#else[Halffloat] +#else[FP16] res += ADDReduceLongMasked(a, i, mask); -#end[Halffloat] +#end[FP16] } return res; @@ -220,11 +220,11 @@ ra = 0; for (int i = 0; i < a.length; i++) { -#if[Halffloat] +#if[FP16] ra = (long)(Float16.float16ToRawShortBits(Float16.add(Float16.shortBitsToFloat16((short)ra), Float16.shortBitsToFloat16((short)r[i])))); -#else[Halffloat] +#else[FP16] ra += r[i]; -#end[Halffloat] +#end[FP16] } assertReductionLongArraysEqualsMasked(r, ra, a, mask, @@ -382,7 +382,7 @@ int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length()); int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr)); Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash); - Assert.assertEquals(length, SPECIES.length()); + AssertEquals(length, SPECIES.length()); } } @@ -410,7 +410,7 @@ var bv = VectorShuffle.fromArray(SPECIES, b, i); boolean eq = av.equals(bv); int to = i + SPECIES.length(); - Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to)); + AssertEquals(eq, Arrays.equals(a, i, to, b, i, to)); } } @@ -424,7 +424,7 @@ var bv = SPECIES.loadMask(b, i); boolean equals = av.equals(bv); int to = i + SPECIES.length(); - Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to)); + AssertEquals(equals, Arrays.equals(a, i, to, b, i, to)); } } @@ -621,7 +621,7 @@ trueCount = vmask.trueCount(); var rmask = vmask.compress(); for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(rmask.laneIsSet(j), j < trueCount); + AssertEquals(rmask.laneIsSet(j), j < trueCount); } } } @@ -642,7 +642,7 @@ static void maskFromToLong$vectorteststype$SmokeTest(long inputLong) { var vmask = VectorMask.fromLong(SPECIES, inputLong); long outputLong = vmask.toLong(); - Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length())))))); + AssertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length())))))); } #end[!MaxBit] @@ -666,7 +666,7 @@ assert(actualMask.equals(expectedMask)); for (int j = 0; j < SPECIES.length(); j++) { int index = i + j + offset; - Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + AssertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); } } } @@ -680,7 +680,7 @@ assert(actualMask.equals(expectedMask)); for (int j = 0; j < SPECIES.length(); j++) { long index = i + j + offset; - Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); + AssertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit); } } } @@ -702,7 +702,7 @@ static void loopBound$vectorteststype$SmokeTest(int length) { int actualLoopBound = SPECIES.loopBound(length); int expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); - Assert.assertEquals(actualLoopBound, expectedLoopBound); + AssertEquals(actualLoopBound, expectedLoopBound); } @Test(dataProvider = "lengthProvider") @@ -710,14 +710,14 @@ long length = _length; long actualLoopBound = SPECIES.loopBound(length); long expectedLoopBound = length - Math.floorMod(length, SPECIES.length()); - Assert.assertEquals(actualLoopBound, expectedLoopBound); + AssertEquals(actualLoopBound, expectedLoopBound); } @Test static void ElementSize$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); int elsize = av.elementSize(); - Assert.assertEquals(elsize, $Wideboxtype$.SIZE); + AssertEquals(elsize, $Wideboxtype$.SIZE); } @Test @@ -731,14 +731,14 @@ static void ShapeWithLanes$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); VectorShape vsh = av.shape(); - VectorSpecies species = vsh.withLanes($ClassType$.class); + VectorSpecies species = vsh.withLanes({#if[FP16]?Float16.class:$type$.class}); assert(species.equals(SPECIES)); } @Test - static void ElementType$vectorteststype$SmokeTest() { + static void $Type$$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); - assert(av.species().elementType() == $ClassType$.class); + assert(av.species().elementType() == {#if[FP16]?Float16.class:$type$.class}); } @Test @@ -756,7 +756,7 @@ @Test static void WithLanes$vectorteststype$SmokeTest() { $abstractvectortype$ av = $abstractvectortype$.zero(SPECIES); - VectorSpecies species = av.species().withLanes($ClassType$.class); + VectorSpecies species = av.species().withLanes({#if[FP16]?Float16.class:$type$.class}); assert(species.equals(SPECIES)); } @@ -771,6 +771,6 @@ @Test static void MaskAllTrue$vectorteststype$SmokeTest() { for (int ic = 0; ic < INVOC_COUNT; ic++) { - Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); + AssertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length())); } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op-func.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op-func.template index 1565c9f355105..a32461e513d30 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op-func.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op-func.template @@ -1,6 +1,6 @@ static $type$ [[TEST]]ReduceMasked($type$[] a, int idx, boolean[] mask) { - $type$ res = [[TEST_INIT]]; + $type$ res = [[TEST_INIT]](); for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) res = [[TEST_OP]](res, a[i]); @@ -10,7 +10,7 @@ } static $type$ [[TEST]]ReduceAllMasked($type$[] a, boolean[] mask) { - $type$ res = [[TEST_INIT]]; + $type$ res = [[TEST_INIT]](); for (int i = 0; i < a.length; i += SPECIES.length()) { res = [[TEST_OP]](res, [[TEST]]ReduceMasked(a, i, mask)); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template index ab383e6125647..1565c9f355105 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-Masked-op.template @@ -3,7 +3,7 @@ $type$ res = [[TEST_INIT]]; for (int i = idx; i < (idx + SPECIES.length()); i++) { if (mask[i % SPECIES.length()]) - res [[TEST_OP]]= a[i]; + res = [[TEST_OP]](res, a[i]); } return res; @@ -12,7 +12,7 @@ static $type$ [[TEST]]ReduceAllMasked($type$[] a, boolean[] mask) { $type$ res = [[TEST_INIT]]; for (int i = 0; i < a.length; i += SPECIES.length()) { - res [[TEST_OP]]= [[TEST]]ReduceMasked(a, i, mask); + res = [[TEST_OP]](res, [[TEST]]ReduceMasked(a, i, mask)); } return res; diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op-func.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op-func.template index 63d154df11248..797e2043620e7 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op-func.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op-func.template @@ -1,6 +1,6 @@ static $type$ [[TEST]]Reduce($type$[] a, int idx) { - $type$ res = [[TEST_INIT]]; + $type$ res = [[TEST_INIT]](); for (int i = idx; i < (idx + SPECIES.length()); i++) { res = [[TEST_OP]](res, a[i]); } @@ -9,7 +9,7 @@ } static $type$ [[TEST]]ReduceAll($type$[] a) { - $type$ res = [[TEST_INIT]]; + $type$ res = [[TEST_INIT]](); for (int i = 0; i < a.length; i += SPECIES.length()) { res = [[TEST_OP]](res, [[TEST]]Reduce(a, i)); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template index 88586fa81294c..63d154df11248 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Reduction-Scalar-op.template @@ -2,7 +2,7 @@ static $type$ [[TEST]]Reduce($type$[] a, int idx) { $type$ res = [[TEST_INIT]]; for (int i = idx; i < (idx + SPECIES.length()); i++) { - res [[TEST_OP]]= a[i]; + res = [[TEST_OP]](res, a[i]); } return res; @@ -11,7 +11,7 @@ static $type$ [[TEST]]ReduceAll($type$[] a) { $type$ res = [[TEST_INIT]]; for (int i = 0; i < a.length; i += SPECIES.length()) { - res [[TEST_OP]]= [[TEST]]Reduce(a, i); + res = [[TEST_OP]](res, [[TEST]]Reduce(a, i)); } return res; diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Test.template b/test/jdk/jdk/incubator/vector/templates/Unit-Test.template index 080773ede1aa6..97923956a40e1 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Test.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Test.template @@ -14,7 +14,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), test[[TEST]](a[i + j])); + AssertEquals(mv.laneIsSet(j), test[[TEST]](a[i + j])); } } } @@ -34,7 +34,7 @@ // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { - Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && test[[TEST]](a[i + j])); + AssertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && test[[TEST]](a[i + j])); } } } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template deleted file mode 100644 index 5723988597902..0000000000000 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-hf-math.template +++ /dev/null @@ -1,14 +0,0 @@ - - static $type$ [[TEST]]($type$ a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) [[TEST_OP]])); - } - - static $type$ strict[[TEST]]($type$ a) { - return Float16.float16ToRawShortBits(Float16.valueOf((float) Strict[[TEST_OP]])); - } - - @Test(dataProvider = "$type$UnaryOpProvider") - static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa) { -[[KERNEL]] - assertArraysEqualsWithinOneUlp(r, a, $vectorteststype$::[[TEST]], $vectorteststype$::strict[[TEST]]); - } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template index 52293d9f614e5..f6943a0b40b26 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Unary-op-math.template @@ -4,7 +4,7 @@ } static $type$ strict[[TEST]]($type$ a) { - return ($type$)(Strict[[TEST_OP]]); + return ($type$)(strict_[[TEST_OP]]); } @Test(dataProvider = "$type$UnaryOpProvider") diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-Zero.template b/test/jdk/jdk/incubator/vector/templates/Unit-Zero.template index a277d66ae3e63..45033662d7051 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-Zero.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-Zero.template @@ -2,5 +2,5 @@ @Test(dataProvider = "$type$UnaryOpProvider") static void Zero$vectorteststype$(IntFunction<$type$[]> fa) { [[KERNEL]] - Assert.assertEquals(a, r); + AssertEquals(a, r); } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index cd4657b4db7b4..e6aaafd4eaacd 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -48,10 +48,11 @@ import jdk.incubator.vector.ByteVector; #if[Float] import jdk.incubator.vector.FloatVector; #end[Float] -#if[Halffloat] +#if[FP16] import jdk.incubator.vector.Float16; +import static jdk.incubator.vector.Float16.*; import jdk.incubator.vector.HalffloatVector; -#end[Halffloat] +#end[FP16] #if[Int] import jdk.incubator.vector.IntVector; #end[Int] @@ -83,10 +84,10 @@ public class $vectorteststype$ extends AbstractVectorTest { #if[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $ElementType$Vector.SPECIES_MAX; + $Type$Vector.SPECIES_MAX; #else[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $ElementType$Vector.SPECIES_$bits$; + $Type$Vector.SPECIES_$bits$; #end[MaxBit] static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); @@ -292,13 +293,13 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ relativeErrorFactor) { int i = 0; try { - AssertEquals(rc, fa.apply(a), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(rc) * relativeErrorFactor}); + AssertEquals(rc, fa.apply(a), {#if[FP16]?float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))):Math.ulp(rc) * relativeErrorFactor}); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(r[i]) * relativeErrorFactor}); + AssertEquals(r[i], f.apply(a, i), {#if[FP16]?float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))):Math.ulp(r[i]) * relativeErrorFactor}); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(rc)), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(rc) * relativeErrorFactor}, "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i), {#if[FP16]?Float16.float16ToRawShortBits(Float16.multiply(Float16.ulp(Float16.shortBitsToFloat16(r[i])), Float16.shortBitsToFloat16(relativeErrorFactor))):Math.ulp(r[i]) * relativeErrorFactor}, "at index #" + i); + AssertEquals(rc, fa.apply(a), {#if[FP16]?float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(rc)), shortBitsToFloat16(relativeErrorFactor))):Math.ulp(rc) * relativeErrorFactor}, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i), {#if[FP16]?float16ToShortBits(Float16.multiply(Float16.ulp(shortBitsToFloat16(r[i])), shortBitsToFloat16(relativeErrorFactor))):Math.ulp(r[i]) * relativeErrorFactor}, "at index #" + i); } } #end[FP] @@ -335,13 +336,13 @@ public class $vectorteststype$ extends AbstractVectorTest { $type$ relativeError) { int i = 0; try { - AssertEquals(rc, fa.apply(a, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))):Math.abs(rc * relativeError)}); + AssertEquals(rc, fa.apply(a, mask), {#if[FP16]?float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))):Math.abs(rc * relativeError)}); for (; i < a.length; i += SPECIES.length()) { - AssertEquals(r[i], f.apply(a, i, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))):Math.abs(r[i] * relativeError)}); + AssertEquals(r[i], f.apply(a, i, mask), {#if[FP16]?float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))):Math.abs(r[i] * relativeError)}); } } catch (AssertionError e) { - AssertEquals(rc, fa.apply(a, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(rc), Float16.shortBitsToFloat16(relativeError)))):Math.abs(rc * relativeError)}, "Final result is incorrect!"); - AssertEquals(r[i], f.apply(a, i, mask), {#if[FP16]?Float16.float16ToRawShortBits(Float16.abs(Float16.multiply(Float16.shortBitsToFloat16(r[i]), Float16.shortBitsToFloat16(relativeError)))):Math.abs(r[i] * relativeError)}, "at index #" + i); + AssertEquals(rc, fa.apply(a, mask), {#if[FP16]?float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(rc), shortBitsToFloat16(relativeError)))):Math.abs(rc * relativeError)}, "Final result is incorrect!"); + AssertEquals(r[i], f.apply(a, i, mask), {#if[FP16]?float16ToShortBits(Float16.abs(Float16.multiply(shortBitsToFloat16(r[i]), shortBitsToFloat16(relativeError)))):Math.abs(r[i] * relativeError)}, "at index #" + i); } } #end[FP] @@ -493,7 +494,7 @@ public class $vectorteststype$ extends AbstractVectorTest { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { idx = i + j; - wrapped_index = Math.floorMod({#if[FP16]?Float16.shortBitsToFloat16(order[idx]).intValue():(int)order[idx]}, 2 * vector_len); + wrapped_index = Math.floorMod({#if[FP16]?shortBitsToFloat16(order[idx]).intValue():(int)order[idx]}, 2 * vector_len); is_exceptional_idx = wrapped_index >= vector_len; oidx = is_exceptional_idx ? (wrapped_index - vector_len) : wrapped_index; AssertEquals(r[idx], (is_exceptional_idx ? b[i + oidx] : a[i + oidx])); @@ -510,7 +511,7 @@ public class $vectorteststype$ extends AbstractVectorTest { try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = {#if[FP16]?Float16.shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; + idx = {#if[FP16]?shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; wrapped_index = Integer.remainderUnsigned(idx, vector_len); AssertEquals(r[i+j], a[i+wrapped_index]); } @@ -546,7 +547,7 @@ public class $vectorteststype$ extends AbstractVectorTest { try { for (; i < a.length; i += vector_len) { for (j = 0; j < vector_len; j++) { - idx = {#if[FP16]?Float16.shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; + idx = {#if[FP16]?shortBitsToFloat16(order[i+j]).intValue():(int)order[i+j]}; wrapped_index = Integer.remainderUnsigned(idx, vector_len); if (mask[j % SPECIES.length()]) AssertEquals(r[i+j], a[i+wrapped_index]); @@ -972,9 +973,9 @@ public class $vectorteststype$ extends AbstractVectorTest { #if[FP] static boolean isWithin1Ulp($type$ actual, $type$ expected) { -#if[Halffloat] - Float16 act = Float16.shortBitsToFloat16(actual); - Float16 exp = Float16.shortBitsToFloat16(expected); +#if[FP16] + Float16 act = shortBitsToFloat16(actual); + Float16 exp = shortBitsToFloat16(expected); if (Float16.isNaN(exp) && !Float16.isNaN(act)) { return false; } else if (!Float16.isNaN(exp) && Float16.isNaN(act)) { @@ -991,7 +992,7 @@ public class $vectorteststype$ extends AbstractVectorTest { if (Float16.compare(high, exp) < 0) { return false; } -#else[Halffloat] +#else[FP16] if ($Type$.isNaN(expected) && !$Type$.isNaN(actual)) { return false; } else if (!$Type$.isNaN(expected) && $Type$.isNaN(actual)) { @@ -1008,7 +1009,7 @@ public class $vectorteststype$ extends AbstractVectorTest { if ($Type$.compare(high, expected) < 0) { return false; } -#end[Halffloat] +#end[FP16] return true; } @@ -1018,11 +1019,11 @@ public class $vectorteststype$ extends AbstractVectorTest { try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i])):mathf.apply(a[i])}) == 0 || + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?shortBitsToFloat16(mathf.apply(a[i])):mathf.apply(a[i])}) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i]))); } } catch (AssertionError e) { - Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i])):mathf.apply(a[i])}) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?shortBitsToFloat16(mathf.apply(a[i])):mathf.apply(a[i])}) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i])); } } @@ -1032,11 +1033,11 @@ public class $vectorteststype$ extends AbstractVectorTest { try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[i])):mathf.apply(a[i], b[i])}) == 0 || + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?shortBitsToFloat16(mathf.apply(a[i], b[i])):mathf.apply(a[i], b[i])}) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i]))); } } catch (AssertionError e) { - Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[i])):mathf.apply(a[i], b[i])}) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?shortBitsToFloat16(r[i]):r[i]}, {#if[FP16]?shortBitsToFloat16(mathf.apply(a[i], b[i])):mathf.apply(a[i], b[i])}) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i])); Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i])); } } @@ -1047,14 +1048,14 @@ public class $vectorteststype$ extends AbstractVectorTest { try { // Check that result is within 1 ulp of strict math or equivalent to math implementation. for (; i < a.length; i++) { - Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, - {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])):mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])}) == 0 || + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?shortBitsToFloat16(r[i]):r[i]}, + {#if[FP16]?shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])):mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])}) == 0 || isWithin1Ulp(r[i], strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]))); } } catch (AssertionError e) { - Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?Float16.shortBitsToFloat16(r[i]):r[i]}, - {#if[FP16]?Float16.shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])):mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])}) == 0, + Assert.assertTrue($Wideboxtype$.compare({#if[FP16]?shortBitsToFloat16(r[i]):r[i]}, + {#if[FP16]?shortBitsToFloat16(mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])):mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])}) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])); @@ -1250,11 +1251,11 @@ public class $vectorteststype$ extends AbstractVectorTest { } static $type$ genValue(int i) { -#if[Halffloat] - return Float16.float16ToRawShortBits(Float16.valueOf(i)); -#else[Halffloat] +#if[FP16] + return float16ToShortBits(Float16.valueOf(i)); +#else[FP16] return ($type$) i; -#end[Halffloat] +#end[FP16] } #if[!Int] @@ -1275,19 +1276,19 @@ public class $vectorteststype$ extends AbstractVectorTest { } static final List> INT_$TYPE$_GENERATORS = List.of( - withToString("$ClassType$[-i * 5]", (int s) -> { + withToString("$Wideboxtype$[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("$ClassType$[i * 5]", (int s) -> { + withToString("$Wideboxtype$[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("$ClassType$[i + 1]", (int s) -> { + withToString("$Wideboxtype$[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> ((($type$)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("$ClassType$[intCornerCaseValue(i)]", (int s) -> { + withToString("$Wideboxtype$[intCornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> ($type$)intCornerCaseValue(i)); }) @@ -1299,11 +1300,11 @@ public class $vectorteststype$ extends AbstractVectorTest { int i = 0; try { for (; i < r.length; i++) { -#if[Halffloat] +#if[FP16] AssertEquals(r[i], (int)Float.float16ToFloat(a[i+offs])); -#else[Halffloat] +#else[FP16] AssertEquals(r[i], (int)(a[i+offs])); -#end[Halffloat] +#end[FP16] } } catch (AssertionError e) { AssertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); @@ -1328,27 +1329,27 @@ public class $vectorteststype$ extends AbstractVectorTest { } static $type$ genValue(long i) { -#if[Halffloat] - return Float16.float16ToRawShortBits(Float16.valueOf(i)); -#else[Halffloat] +#if[FP16] + return float16ToShortBits(Float16.valueOf(i)); +#else[FP16] return ($type$) i; -#end[Halffloat] +#end[FP16] } static final List> LONG_$TYPE$_GENERATORS = List.of( - withToString("$ClassType$[-i * 5]", (int s) -> { + withToString("$Wideboxtype$[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("$ClassType$[i * 5]", (int s) -> { + withToString("$Wideboxtype$[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("$ClassType$[i + 1]", (int s) -> { + withToString("$Wideboxtype$[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> ((($type$)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), - withToString("$ClassType$[cornerCaseValue(i)]", (int s) -> { + withToString("$Wideboxtype$[cornerCaseValue(i)]", (int s) -> { return fill(s * BUFFER_REPS, i -> ($type$)longCornerCaseValue(i)); }) @@ -1373,11 +1374,11 @@ public class $vectorteststype$ extends AbstractVectorTest { int i = 0; try { for (; i < r.length; i++) { -#if[Halffloat] +#if[FP16] AssertEquals(r[i], (long)Float.float16ToFloat(a[i+offs])); -#else[Halffloat] +#else[FP16] AssertEquals(r[i], (long)(a[i+offs])); -#end[Halffloat] +#end[FP16] } } catch (AssertionError e) { AssertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); @@ -1389,11 +1390,11 @@ public class $vectorteststype$ extends AbstractVectorTest { int i = 0; try { for (; i < r.length; i++) { -#if[Halffloat] +#if[FP16] AssertEquals(r[i], (double)Float.float16ToFloat(a[i+offs])); -#else[Halffloat] +#else[FP16] AssertEquals(r[i], (double)(a[i+offs])); -#end[Halffloat] +#end[FP16] } } catch (AssertionError e) { AssertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]); @@ -1410,15 +1411,15 @@ public class $vectorteststype$ extends AbstractVectorTest { } static final List> $TYPE$_GENERATORS = List.of( - withToString("$ClassType$[-i * 5]", (int s) -> { + withToString("$Wideboxtype$[-i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(-i * 5)); }), - withToString("$ClassType$[i * 5]", (int s) -> { + withToString("$Wideboxtype$[i * 5]", (int s) -> { return fill(s * BUFFER_REPS, i -> genValue(i * 5)); }), - withToString("$ClassType$[i + 1]", (int s) -> { + withToString("$Wideboxtype$[i + 1]", (int s) -> { return fill(s * BUFFER_REPS, i -> ((($type$)(i + 1) == 0) ? genValue(1) : genValue(i + 1))); }), @@ -1833,12 +1834,12 @@ public class $vectorteststype$ extends AbstractVectorTest { #if[FP] #if[FP16] return switch(i % 8) { - case 0 -> Float16.float16ToRawShortBits($Wideboxtype$.MAX_VALUE); - case 1 -> Float16.float16ToRawShortBits($Wideboxtype$.MIN_VALUE); - case 2 -> Float16.float16ToRawShortBits($Wideboxtype$.NEGATIVE_INFINITY); - case 3 -> Float16.float16ToRawShortBits($Wideboxtype$.POSITIVE_INFINITY); - case 4 -> Float16.float16ToRawShortBits($Wideboxtype$.NaN); - case 5 -> Float16.float16ToRawShortBits(Float16.shortBitsToFloat16((short)0x7FFA)); + case 0 -> float16ToShortBits($Wideboxtype$.MAX_VALUE); + case 1 -> float16ToShortBits($Wideboxtype$.MIN_VALUE); + case 2 -> float16ToShortBits($Wideboxtype$.NEGATIVE_INFINITY); + case 3 -> float16ToShortBits($Wideboxtype$.POSITIVE_INFINITY); + case 4 -> float16ToShortBits($Wideboxtype$.NaN); + case 5 -> float16ToShortBits(shortBitsToFloat16((short)0x7FFA)); case 6 -> (($type$)0.0); default -> (($type$)-0.0); }; @@ -1975,44 +1976,266 @@ public class $vectorteststype$ extends AbstractVectorTest { #end[intOrLong] } #end[BITWISE] -#if[Halffloat] +#if[FP16] static boolean eq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() == bt.floatValue(); } static boolean neq(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() != bt.floatValue(); } static boolean lt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() < bt.floatValue(); } static boolean le(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() <= bt.floatValue(); } static boolean gt(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() > bt.floatValue(); } static boolean ge(short a, short b) { - Float16 at = Float16.shortBitsToFloat16(a); - Float16 bt = Float16.shortBitsToFloat16(b); + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); return at.floatValue() >= bt.floatValue(); } -#else[Halffloat] + + static $type$ firstNonZero($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 zero = shortBitsToFloat16((short)0); + return Float16.compare(at, zero) != 0 ? a : b; + } + + static $type$ multiplicativeIdentity() { + return ($type$)float16ToShortBits(Float16.valueOf(1.0f)); + } + + static $type$ scalar_add($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.add(at, bt)); + } + + static $type$ scalar_sub($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.subtract(at, bt)); + } + + static $type$ scalar_mul($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.multiply(at, bt)); + + } + static $type$ scalar_max($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.max(at, bt)); + } + + static $type$ scalar_min($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.min(at, bt)); + } + + static $type$ scalar_div($type$ a, $type$ b) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + return float16ToShortBits(Float16.divide(at, bt)); + } + + static $type$ scalar_fma($type$ a, $type$ b, $type$ c) { + Float16 at = shortBitsToFloat16(a); + Float16 bt = shortBitsToFloat16(b); + Float16 ct = shortBitsToFloat16(c); + return float16ToShortBits(Float16.fma(at, bt, ct)); + } + + static $type$ scalar_abs($type$ a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.abs(at)); + } + + static $type$ scalar_neg($type$ a) { + Float16 at = shortBitsToFloat16(a); + return float16ToShortBits(Float16.valueOf(-at.floatValue())); + } + + static $type$ scalar_sin($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_exp($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_log1p($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_log($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.log(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_log10($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_expm1($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_cos($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_tan($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_sinh($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_cosh($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_tanh($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_asin($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_acos($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_atan($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_cbrt($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_sqrt($type$ a) { + return float16ToShortBits(Float16.valueOf(Math.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ scalar_hypot($type$ a, $type$ b) { + return float16ToShortBits(Float16.valueOf(Math.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static $type$ scalar_pow($type$ a, $type$ b) { + return float16ToShortBits(Float16.valueOf(Math.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static $type$ scalar_atan2($type$ a, $type$ b) { + return float16ToShortBits(Float16.valueOf(Math.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static $type$ strict_scalar_sin($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sin(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_exp($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.exp(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_log1p($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log1p(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_log($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_log10($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.log10(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_expm1($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.expm1(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_cos($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cos(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_tan($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tan(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_sinh($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sinh(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_cosh($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cosh(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_tanh($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.tanh(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_asin($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.asin(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_acos($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.acos(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_atan($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_cbrt($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.cbrt(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_sqrt($type$ a) { + return float16ToShortBits(Float16.valueOf(StrictMath.sqrt(shortBitsToFloat16(a).doubleValue()))); + } + + static $type$ strict_scalar_hypot($type$ a, $type$ b) { + return float16ToShortBits(Float16.valueOf(StrictMath.hypot(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static $type$ strict_scalar_pow($type$ a, $type$ b) { + return float16ToShortBits(Float16.valueOf(StrictMath.pow(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } + + static $type$ strict_scalar_atan2($type$ a, $type$ b) { + return float16ToShortBits(Float16.valueOf(StrictMath.atan2(shortBitsToFloat16(a).doubleValue(), + shortBitsToFloat16(b).doubleValue()))); + } +#else[FP16] static boolean eq($type$ a, $type$ b) { return a == b; @@ -2037,7 +2260,221 @@ public class $vectorteststype$ extends AbstractVectorTest { static boolean ge($type$ a, $type$ b) { return a >= b; } -#end[Halffloat] + + static $type$ firstNonZero($type$ a, $type$ b) { + return $Wideboxtype$.compare(a, ($type$) 0) != 0 ? a : b; + } + + static $type$ multiplicativeIdentity() { + return ($type$)1; + } + +#if[BITWISE] + static $type$ scalar_or($type$ a, $type$ b) { + return ($type$)(a | b); + } + + static $type$ scalar_and($type$ a, $type$ b) { + return ($type$)(a & b); + } + + static $type$ scalar_xor($type$ a, $type$ b) { + return ($type$)(a ^ b); + } +#end[BITWISE]; + + static $type$ scalar_add($type$ a, $type$ b) { + return ($type$)(a + b); + } + + static $type$ scalar_sub($type$ a, $type$ b) { + return ($type$)(a - b); + } + + static $type$ scalar_mul($type$ a, $type$ b) { + return ($type$)(a * b); + } + + static $type$ scalar_min($type$ a, $type$ b) { + return ($type$)(Math.min(a, b)); + } + + static $type$ scalar_max($type$ a, $type$ b) { + return ($type$)(Math.max(a, b)); + } + + static $type$ scalar_div($type$ a, $type$ b) { + return ($type$)(a / b); + } + + static $type$ scalar_fma($type$ a, $type$ b, $type$ c) { + return ($type$)(Math.fma(a, b, c)); + } + + static $type$ scalar_abs($type$ a) { + return ($type$)(Math.abs(a)); + } + + static $type$ scalar_neg($type$ a) { + return (($type$)-a); + } + + static $type$ scalar_sin($type$ a) { + return ($type$)Math.sin((double)a); + } + + static $type$ scalar_exp($type$ a) { + return ($type$)Math.exp((double)a); + } + + static $type$ scalar_log1p($type$ a) { + return ($type$)Math.log1p((double)a); + } + + static $type$ scalar_log($type$ a) { + return ($type$)Math.log((double)a); + } + + static $type$ scalar_log10($type$ a) { + return ($type$)Math.log10((double)a); + } + + static $type$ scalar_expm1($type$ a) { + return ($type$)Math.expm1((double)a); + } + + static $type$ scalar_cos($type$ a) { + return ($type$)Math.cos((double)a); + } + + static $type$ scalar_tan($type$ a) { + return ($type$)Math.tan((double)a); + } + + static $type$ scalar_sinh($type$ a) { + return ($type$)Math.sinh((double)a); + } + + static $type$ scalar_cosh($type$ a) { + return ($type$)Math.cosh((double)a); + } + + static $type$ scalar_tanh($type$ a) { + return ($type$)Math.tanh((double)a); + } + + static $type$ scalar_asin($type$ a) { + return ($type$)Math.asin((double)a); + } + + static $type$ scalar_acos($type$ a) { + return ($type$)Math.acos((double)a); + } + + static $type$ scalar_atan($type$ a) { + return ($type$)Math.atan((double)a); + } + + static $type$ scalar_cbrt($type$ a) { + return ($type$)Math.cbrt((double)a); + } + + static $type$ scalar_sqrt($type$ a) { + return ($type$)Math.sqrt((double)a); + } + + static $type$ scalar_hypot($type$ a, $type$ b) { + return ($type$)Math.hypot((double)a, (double)b); + } + + static $type$ scalar_pow($type$ a, $type$ b) { + return ($type$)Math.pow((double)a, (double)b); + } + + static $type$ scalar_atan2($type$ a, $type$ b) { + return ($type$)Math.atan2((double)a, (double)b); + } + + static $type$ strict_scalar_sin($type$ a) { + return ($type$)StrictMath.sin((double)a); + } + + static $type$ strict_scalar_exp($type$ a) { + return ($type$)StrictMath.exp((double)a); + } + + static $type$ strict_scalar_log1p($type$ a) { + return ($type$)StrictMath.log1p((double)a); + } + + static $type$ strict_scalar_log($type$ a) { + return ($type$)StrictMath.log((double)a); + } + + static $type$ strict_scalar_log10($type$ a) { + return ($type$)StrictMath.log10((double)a); + } + + static $type$ strict_scalar_expm1($type$ a) { + return ($type$)StrictMath.expm1((double)a); + } + + static $type$ strict_scalar_cos($type$ a) { + return ($type$)StrictMath.cos((double)a); + } + + static $type$ strict_scalar_tan($type$ a) { + return ($type$)StrictMath.tan((double)a); + } + + static $type$ strict_scalar_sinh($type$ a) { + return ($type$)StrictMath.sinh((double)a); + } + + static $type$ strict_scalar_cosh($type$ a) { + return ($type$)StrictMath.cosh((double)a); + } + + static $type$ strict_scalar_tanh($type$ a) { + return ($type$)StrictMath.tanh((double)a); + } + + static $type$ strict_scalar_asin($type$ a) { + return ($type$)StrictMath.asin((double)a); + } + + static $type$ strict_scalar_acos($type$ a) { + return ($type$)StrictMath.acos((double)a); + } + + static $type$ strict_scalar_atan($type$ a) { + return ($type$)StrictMath.atan((double)a); + } + + static $type$ strict_scalar_cbrt($type$ a) { + return ($type$)StrictMath.cbrt((double)a); + } + + static $type$ strict_scalar_sqrt($type$ a) { + return ($type$)StrictMath.sqrt((double)a); + } + + static $type$ strict_scalar_hypot($type$ a, $type$ b) { + return ($type$)StrictMath.hypot((double)a, (double)b); + } + + static $type$ strict_scalar_pow($type$ a, $type$ b) { + return ($type$)StrictMath.pow((double)a, (double)b); + } + + static $type$ strict_scalar_atan2($type$ a, $type$ b) { + return ($type$)StrictMath.atan2((double)a, (double)b); + } +#end[FP16] + static $type$ additiveIdentity() { + return ($type$)0; + } + #if[!FP] static boolean ult($type$ a, $type$ b) { @@ -2057,29 +2494,61 @@ public class $vectorteststype$ extends AbstractVectorTest { } #end[!FP] - static $type$ firstNonZero($type$ a, $type$ b) { - return $VecEleType$.compare(a, ($type$) 0) != 0 ? a : b; + static $type$ zeroValue() { + return (short) 0; + } + + static $type$ maxValue() { + return {#if[FP16]?float16ToShortBits($Wideboxtype$.$MaxValue$):$Wideboxtype$.$MaxValue$}; + } + + static $type$ minValue() { + return {#if[FP16]?float16ToShortBits($Wideboxtype$.$MinValue$):$Wideboxtype$.$MinValue$}; } +#if[FP] +#if[FP16] + static boolean isNaN($type$ a) { + return $Wideboxtype$.isNaN(shortBitsToFloat16(a)); + } + static boolean isFinite($type$ a) { + return $Wideboxtype$.isFinite(shortBitsToFloat16(a)); + } + static boolean isInfinite($type$ a) { + return $Wideboxtype$.isInfinite(shortBitsToFloat16(a)); + } +#else[FP16] + static boolean isNaN($type$ a) { + return $Wideboxtype$.isNaN(a); + } + static boolean isFinite($type$ a) { + return $Wideboxtype$.isFinite(a); + } + static boolean isInfinite($type$ a) { + return $Wideboxtype$.isInfinite(a); + } +#end[FP16] +#end[FP] + @Test static void smokeTest1() { -#if[Halffloat] - $abstractvectortype$ three = $abstractvectortype$.broadcast(SPECIES, Float16.float16ToRawShortBits(Float16.valueOf(-3))); - $abstractvectortype$ three2 = ($abstractvectortype$) SPECIES.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); +#if[FP16] + $abstractvectortype$ three = $abstractvectortype$.broadcast(SPECIES, float16ToShortBits(Float16.valueOf(-3))); + $abstractvectortype$ three2 = ($abstractvectortype$) SPECIES.broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three2).allTrue()); - $abstractvectortype$ three3 = three2.broadcast(Float16.float16ToRawShortBits(Float16.valueOf(1))).broadcast(Float16.float16ToRawShortBits(Float16.valueOf(-3))); + $abstractvectortype$ three3 = three2.broadcast(float16ToShortBits(Float16.valueOf(1))).broadcast(float16ToShortBits(Float16.valueOf(-3))); assert(three.eq(three3).allTrue()); int scale = 2; $abstractvectortype$ higher = three.addIndex(scale); VectorMask<$Wideboxtype$> m = three.compare(VectorOperators.LE, higher); assert(m.allTrue()); - m = higher.min((Float16.float16ToRawShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); + m = higher.min((float16ToShortBits(Float16.valueOf(-1)))).test(VectorOperators.IS_NEGATIVE); assert(m.allTrue()); m = higher.test(VectorOperators.IS_FINITE); assert(m.allTrue()); $type$ max = higher.reduceLanes(VectorOperators.MAX); assert((short) Float.float16ToFloat(max) == -3 + scale * (SPECIES.length()-1)); -#else[Halffloat] +#else[FP16] $abstractvectortype$ three = $abstractvectortype$.broadcast(SPECIES, (byte)-3); $abstractvectortype$ three2 = ($abstractvectortype$) SPECIES.broadcast(-3); assert(three.eq(three2).allTrue()); @@ -2102,7 +2571,7 @@ public class $vectorteststype$ extends AbstractVectorTest { #end[FP] $type$ max = higher.reduceLanes(VectorOperators.MAX); assert(max == -3 + scale * (SPECIES.length()-1)); -#end[Halffloat] +#end[FP16] } private static $type$[] diff --git a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template index 1c255c616f2ed..2da510e6582ec 100644 --- a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template +++ b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template @@ -65,19 +65,19 @@ import java.util.function.*; public class $vectorteststype$ extends AbstractVectorLoadStoreTest { #if[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $ElementType$Vector.SPECIES_MAX; + $Type$Vector.SPECIES_MAX; #else[MaxBit] static final VectorSpecies<$Wideboxtype$> SPECIES = - $ElementType$Vector.SPECIES_$bits$; + $Type$Vector.SPECIES_$bits$; #end[MaxBit] static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); -#if[Halffloat] +#if[FP16] static final ValueLayout.OfShort ELEMENT_LAYOUT = ValueLayout.JAVA_SHORT.withByteAlignment(1); -#else[Halffloat] +#else[FP16] static final ValueLayout.Of$Type$ ELEMENT_LAYOUT = ValueLayout.JAVA_$TYPE$.withByteAlignment(1); -#end[Halffloat] +#end[FP16] #if[MaxBit] static VectorShape getMaxBit() { From 1493ef86ac8b8b45bd92d675bd56f892b0834497 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Fri, 7 Nov 2025 08:31:57 +0000 Subject: [PATCH 09/10] Fix some JTREG failures --- src/hotspot/share/opto/vectorIntrinsics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 5264f25131339..b98e6480c0ae0 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -2220,7 +2220,7 @@ bool LibraryCallKit::inline_vector_broadcast_int() { return false; } - const Type* vmask_type = gvn().type(argument(7)); + const Type* vmask_type = gvn().type(argument(8)); bool is_masked_op = vmask_type != TypePtr::NULL_PTR; if (is_masked_op) { if (mask_klass == nullptr || mask_klass->const_oop() == nullptr) { From c60d533c38dc87224da06ea5b921b81403fdbef1 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Fri, 7 Nov 2025 10:17:21 +0000 Subject: [PATCH 10/10] Some cleanups --- src/hotspot/cpu/x86/x86.ad | 1 - test/jdk/jdk/incubator/vector/Vector128ConversionTests.java | 2 +- test/jdk/jdk/incubator/vector/Vector256ConversionTests.java | 2 +- test/jdk/jdk/incubator/vector/Vector512ConversionTests.java | 2 +- test/jdk/jdk/incubator/vector/Vector64ConversionTests.java | 2 +- test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java | 2 +- 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 1b2e6d01db4ed..783ed03885840 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -25030,7 +25030,6 @@ instruct reinterpretHF2S(rRegI dst, regF src) format %{ "vmovw $dst, $src" %} ins_encode %{ __ vmovw($dst$$Register, $src$$XMMRegister); - __ movswl($dst$$Register, $dst$$Register); %} ins_pipe(pipe_slow); %} diff --git a/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java index ab1e2c1cd44c7..62e6fe9edb43f 100644 --- a/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java index 8294ba470ebee..a32272f61d7c1 100644 --- a/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java index b8683d1bd2f67..0e41ca3e59b1b 100644 --- a/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java index 74507d9015c4a..78ce795e038c7 100644 --- a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java b/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java index 57817eac97bf6..3f5d26820468f 100644 --- a/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java +++ b/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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