Merge
This commit is contained in:
commit
7a4f08ae32
@ -2400,6 +2400,14 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType
|
||||
} else { // NEON
|
||||
// Special cases
|
||||
switch (opcode) {
|
||||
case Op_VectorMaskCmp:
|
||||
// We don't have VectorReinterpret with bit_size less than 64 support for
|
||||
// now, even for byte type. To be refined with fully VectorCast support.
|
||||
case Op_VectorReinterpret:
|
||||
if (vlen < 2 || bit_size < 64) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Op_MulAddVS2VI:
|
||||
if (bit_size < 128) {
|
||||
return false;
|
||||
@ -2413,9 +2421,21 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Op_VectorMaskCmp:
|
||||
if (vlen < 2 || bit_size < 64) {
|
||||
return false;
|
||||
// Some types of VectorCast are not implemented for now.
|
||||
case Op_VectorCastI2X:
|
||||
if (bt == T_BYTE) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Op_VectorCastS2X:
|
||||
if (vlen < 4 || bit_size < 64) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case Op_VectorCastF2X:
|
||||
case Op_VectorCastD2X:
|
||||
if (bt == T_INT || bt == T_SHORT || bt == T_BYTE || bt == T_LONG) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -3859,6 +3859,9 @@ void C2_MacroAssembler::vector_mask_operation(int opc, Register dst, XMMRegister
|
||||
vpxor(xtmp, xtmp, xtmp, vec_enc);
|
||||
vpsubb(xtmp, xtmp, mask, vec_enc);
|
||||
vpmovmskb(tmp, xtmp, vec_enc);
|
||||
if (masklen < 64) {
|
||||
andq(tmp, (((jlong)1 << masklen) - 1));
|
||||
}
|
||||
switch(opc) {
|
||||
case Op_VectorMaskTrueCount:
|
||||
popcntq(dst, tmp);
|
||||
|
@ -109,6 +109,9 @@ define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong);
|
||||
"Highest supported AVX instructions set on x86/x64") \
|
||||
range(0, 99) \
|
||||
\
|
||||
product(bool, UseKNLSetting, false, DIAGNOSTIC, \
|
||||
"Control whether Knights platform setting should be used") \
|
||||
\
|
||||
product(bool, UseCLMUL, false, \
|
||||
"Control whether CLMUL instructions can be used on x86/x64") \
|
||||
\
|
||||
|
@ -769,6 +769,15 @@ void VM_Version::get_processor_features() {
|
||||
_features &= ~CPU_VZEROUPPER;
|
||||
_features &= ~CPU_AVX512BW;
|
||||
_features &= ~CPU_AVX512VL;
|
||||
_features &= ~CPU_AVX512DQ;
|
||||
_features &= ~CPU_AVX512_VNNI;
|
||||
_features &= ~CPU_AVX512_VAES;
|
||||
_features &= ~CPU_AVX512_VPOPCNTDQ;
|
||||
_features &= ~CPU_AVX512_VPCLMULQDQ;
|
||||
_features &= ~CPU_AVX512_VBMI;
|
||||
_features &= ~CPU_AVX512_VBMI2;
|
||||
_features &= ~CPU_CLWB;
|
||||
_features &= ~CPU_FLUSHOPT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,7 +775,7 @@ public:
|
||||
static bool is_intel() { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG'
|
||||
static bool is_zx() { assert_is_initialized(); return (_cpuid_info.std_vendor_name_0 == 0x746e6543) || (_cpuid_info.std_vendor_name_0 == 0x68532020); } // 'tneC'||'hS '
|
||||
static bool is_atom_family() { return ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x36) || (extended_cpu_model() == 0x37) || (extended_cpu_model() == 0x4D))); } //Silvermont and Centerton
|
||||
static bool is_knights_family() { return ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x57) || (extended_cpu_model() == 0x85))); } // Xeon Phi 3200/5200/7200 and Future Xeon Phi
|
||||
static bool is_knights_family() { return UseKNLSetting || ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x57) || (extended_cpu_model() == 0x85))); } // Xeon Phi 3200/5200/7200 and Future Xeon Phi
|
||||
|
||||
static bool supports_processor_topology() {
|
||||
return (_cpuid_info.std_max_function >= 0xB) &&
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "oops/oopsHierarchy.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "runtime/safepoint.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
@ -107,6 +108,19 @@ void StringDedup::threads_do(ThreadClosure* tc) {
|
||||
tc->do_thread(_processor);
|
||||
}
|
||||
|
||||
void StringDedup::forbid_deduplication(oop java_string) {
|
||||
assert(is_enabled(), "precondition");
|
||||
if (java_lang_String::deduplication_forbidden(java_string)) {
|
||||
// DCLP - we don't want a caller's access to the value array to float
|
||||
// before the check; string dedup could change the value and another
|
||||
// thread could set the flag, and this thread uses a stale value.
|
||||
OrderAccess::acquire();
|
||||
} else {
|
||||
MutexLocker ml(StringDedupIntern_lock, Mutex::_no_safepoint_check_flag);
|
||||
java_lang_String::set_deduplication_forbidden(java_string);
|
||||
}
|
||||
}
|
||||
|
||||
void StringDedup::notify_intern(oop java_string) {
|
||||
assert(is_enabled(), "precondition");
|
||||
// A String that is interned in the StringTable must not later have its
|
||||
@ -114,10 +128,7 @@ void StringDedup::notify_intern(oop java_string) {
|
||||
// can still add the byte array to the dedup table for sharing, so add the
|
||||
// string to the pending requests. Triggering request processing is left
|
||||
// to the next GC.
|
||||
{
|
||||
MutexLocker ml(StringDedupIntern_lock, Mutex::_no_safepoint_check_flag);
|
||||
java_lang_String::set_deduplication_forbidden(java_string);
|
||||
}
|
||||
forbid_deduplication(java_string);
|
||||
StorageUse* requests = Processor::storage_for_requests();
|
||||
oop* ref = requests->storage()->allocate();
|
||||
if (ref != nullptr) {
|
||||
|
@ -147,7 +147,17 @@ public:
|
||||
// precondition: is_enabled()
|
||||
static void threads_do(ThreadClosure* tc);
|
||||
|
||||
// Marks the String as not being subject to deduplication. This can be
|
||||
// used to prevent deduplication of Strings whose value array must remain
|
||||
// stable and cannot be replaced by a shared duplicate. Must be called
|
||||
// before obtaining the value array; this function provides an acquire
|
||||
// barrier.
|
||||
// precondition: is_enabled()
|
||||
// precondition: java_string is a Java String object.
|
||||
static void forbid_deduplication(oop java_string);
|
||||
|
||||
// Notify that a String is being added to the StringTable.
|
||||
// Implicity forbids deduplication of the String.
|
||||
// precondition: is_enabled()
|
||||
// precondition: java_string is a Java String object.
|
||||
static void notify_intern(oop java_string);
|
||||
|
@ -2034,7 +2034,11 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
|
||||
Node* opt = NULL;
|
||||
int true_path = is_diamond_phi();
|
||||
if( true_path != 0 ) {
|
||||
if (true_path != 0 &&
|
||||
// If one of the diamond's branch is in the process of dying then, the Phi's input for that branch might transform
|
||||
// to top. If that happens replacing the Phi with an operation that consumes the Phi's inputs will cause the Phi
|
||||
// to be replaced by top. To prevent that, delay the transformation until the branch has a chance to be removed.
|
||||
!(can_reshape && wait_for_region_igvn(phase))) {
|
||||
// Check for CMove'ing identity. If it would be unsafe,
|
||||
// handle it here. In the safe case, let Identity handle it.
|
||||
Node* unsafe_id = is_cmove_id(phase, true_path);
|
||||
|
@ -413,7 +413,7 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo
|
||||
// Move the control dependence if it is pinned to not-null block.
|
||||
// Don't change it in other cases: NULL or dominating control.
|
||||
Node* ctrl = best->in(0);
|
||||
if (get_block_for_node(ctrl) == not_null_block) {
|
||||
if (ctrl != NULL && get_block_for_node(ctrl) == not_null_block) {
|
||||
// Set it to control edge of null check.
|
||||
best->set_req(0, proj->in(0)->in(0));
|
||||
}
|
||||
|
@ -5033,19 +5033,19 @@ Node* PhaseIdealLoop::get_late_ctrl_with_anti_dep(LoadNode* n, Node* early, Node
|
||||
}
|
||||
}
|
||||
}
|
||||
// For Phis only consider Region's inputs that were reached by following the memory edges
|
||||
if (LCA != early) {
|
||||
for (uint i = 0; i < worklist.size(); i++) {
|
||||
Node* s = worklist.at(i);
|
||||
if (s->is_Phi() && C->can_alias(s->adr_type(), load_alias_idx)) {
|
||||
Node* r = s->in(0);
|
||||
for (uint j = 1; j < s->req(); j++) {
|
||||
Node* in = s->in(j);
|
||||
Node* r_in = r->in(j);
|
||||
// We can't reach any node from a Phi because we don't enqueue Phi's uses above
|
||||
if (((worklist.member(in) && !in->is_Phi()) || in == mem) && is_dominator(early, r_in)) {
|
||||
LCA = dom_lca_for_get_late_ctrl(LCA, r_in, n);
|
||||
}
|
||||
}
|
||||
// For Phis only consider Region's inputs that were reached by following the memory edges
|
||||
if (LCA != early) {
|
||||
for (uint i = 0; i < worklist.size(); i++) {
|
||||
Node* s = worklist.at(i);
|
||||
if (s->is_Phi() && C->can_alias(s->adr_type(), load_alias_idx)) {
|
||||
Node* r = s->in(0);
|
||||
for (uint j = 1; j < s->req(); j++) {
|
||||
Node* in = s->in(j);
|
||||
Node* r_in = r->in(j);
|
||||
// We can't reach any node from a Phi because we don't enqueue Phi's uses above
|
||||
if (((worklist.member(in) && !in->is_Phi()) || in == mem) && is_dominator(early, r_in)) {
|
||||
LCA = dom_lca_for_get_late_ctrl(LCA, r_in, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -876,7 +876,7 @@ class VectorMaskOpNode : public TypeNode {
|
||||
public:
|
||||
VectorMaskOpNode(Node* mask, const Type* ty, int mopc):
|
||||
TypeNode(ty, 2), _mopc(mopc) {
|
||||
assert(mask->Opcode() == Op_VectorStoreMask, "");
|
||||
assert(mask->bottom_type()->is_vect()->element_basic_type() == T_BOOLEAN, "");
|
||||
init_req(1, mask);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "compiler/compiler_globals.hpp"
|
||||
#include "gc/shared/collectedHeap.hpp"
|
||||
#include "gc/shared/gcLocker.inline.hpp"
|
||||
#include "gc/shared/stringdedup/stringDedup.hpp"
|
||||
#include "interpreter/linkResolver.hpp"
|
||||
#include "jfr/jfrEvents.hpp"
|
||||
#include "jfr/support/jfrThreadId.hpp"
|
||||
@ -2837,19 +2838,45 @@ HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN();
|
||||
JNI_END
|
||||
|
||||
|
||||
static typeArrayOop lock_gc_or_pin_string_value(JavaThread* thread, oop str) {
|
||||
if (Universe::heap()->supports_object_pinning()) {
|
||||
// Forbid deduplication before obtaining the value array, to prevent
|
||||
// deduplication from replacing the value array while setting up or in
|
||||
// the critical section. That would lead to the release operation
|
||||
// unpinning the wrong object.
|
||||
if (StringDedup::is_enabled()) {
|
||||
NoSafepointVerifier nsv;
|
||||
StringDedup::forbid_deduplication(str);
|
||||
}
|
||||
typeArrayOop s_value = java_lang_String::value(str);
|
||||
return (typeArrayOop) Universe::heap()->pin_object(thread, s_value);
|
||||
} else {
|
||||
Handle h(thread, str); // Handlize across potential safepoint.
|
||||
GCLocker::lock_critical(thread);
|
||||
return java_lang_String::value(h());
|
||||
}
|
||||
}
|
||||
|
||||
static void unlock_gc_or_unpin_string_value(JavaThread* thread, oop str) {
|
||||
if (Universe::heap()->supports_object_pinning()) {
|
||||
typeArrayOop s_value = java_lang_String::value(str);
|
||||
Universe::heap()->unpin_object(thread, s_value);
|
||||
} else {
|
||||
GCLocker::unlock_critical(thread);
|
||||
}
|
||||
}
|
||||
|
||||
JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy))
|
||||
HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(env, string, (uintptr_t *) isCopy);
|
||||
oop s = lock_gc_or_pin_object(thread, string);
|
||||
typeArrayOop s_value = java_lang_String::value(s);
|
||||
bool is_latin1 = java_lang_String::is_latin1(s);
|
||||
if (isCopy != NULL) {
|
||||
*isCopy = is_latin1 ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
oop s = JNIHandles::resolve_non_null(string);
|
||||
jchar* ret;
|
||||
if (!is_latin1) {
|
||||
if (!java_lang_String::is_latin1(s)) {
|
||||
typeArrayOop s_value = lock_gc_or_pin_string_value(thread, s);
|
||||
ret = (jchar*) s_value->base(T_CHAR);
|
||||
if (isCopy != NULL) *isCopy = JNI_FALSE;
|
||||
} else {
|
||||
// Inflate latin1 encoded string to UTF16
|
||||
typeArrayOop s_value = java_lang_String::value(s);
|
||||
int s_len = java_lang_String::length(s, s_value);
|
||||
ret = NEW_C_HEAP_ARRAY_RETURN_NULL(jchar, s_len + 1, mtInternal); // add one for zero termination
|
||||
/* JNI Specification states return NULL on OOM */
|
||||
@ -2859,6 +2886,7 @@ JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jbool
|
||||
}
|
||||
ret[s_len] = 0;
|
||||
}
|
||||
if (isCopy != NULL) *isCopy = JNI_TRUE;
|
||||
}
|
||||
HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN((uint16_t *) ret);
|
||||
return ret;
|
||||
@ -2867,15 +2895,16 @@ JNI_END
|
||||
|
||||
JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars))
|
||||
HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY(env, str, (uint16_t *) chars);
|
||||
// The str and chars arguments are ignored for UTF16 strings
|
||||
oop s = JNIHandles::resolve_non_null(str);
|
||||
bool is_latin1 = java_lang_String::is_latin1(s);
|
||||
if (is_latin1) {
|
||||
// For latin1 string, free jchar array allocated by earlier call to GetStringCritical.
|
||||
// This assumes that ReleaseStringCritical bookends GetStringCritical.
|
||||
FREE_C_HEAP_ARRAY(jchar, chars);
|
||||
} else {
|
||||
// For non-latin1 string, drop the associated gc-locker/pin.
|
||||
unlock_gc_or_unpin_string_value(thread, s);
|
||||
}
|
||||
unlock_gc_or_unpin_object(thread, str);
|
||||
HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN();
|
||||
JNI_END
|
||||
|
||||
|
@ -655,6 +655,10 @@ public class Runtime {
|
||||
* There is no guarantee that this effort will recycle any particular
|
||||
* number of unused objects, reclaim any particular amount of space, or
|
||||
* complete at any particular time, if at all, before the method returns or ever.
|
||||
* There is also no guarantee that this effort will determine
|
||||
* the change of reachability in any particular number of objects,
|
||||
* or that any particular number of {@link java.lang.ref.Reference Reference}
|
||||
* objects will be cleared and enqueued.
|
||||
* <p>
|
||||
* The name {@code gc} stands for "garbage
|
||||
* collector". The Java Virtual Machine performs this recycling
|
||||
|
@ -1872,6 +1872,11 @@ public final class System {
|
||||
* There is no guarantee that this effort will recycle any particular
|
||||
* number of unused objects, reclaim any particular amount of space, or
|
||||
* complete at any particular time, if at all, before the method returns or ever.
|
||||
* There is also no guarantee that this effort will determine
|
||||
* the change of reachability in any particular number of objects,
|
||||
* or that any particular number of {@link java.lang.ref.Reference Reference}
|
||||
* objects will be cleared and enqueued.
|
||||
*
|
||||
* <p>
|
||||
* The call {@code System.gc()} is effectively equivalent to the
|
||||
* call:
|
||||
|
@ -70,6 +70,8 @@ compiler/whitebox/MakeMethodNotCompilableTest.java 8265360 macosx-aarch64
|
||||
|
||||
compiler/codecache/jmx/PoolsIndependenceTest.java 8264632 macosx-x64
|
||||
|
||||
compiler/vectorapi/VectorCastShape128Test.java 8269952 generic-x64
|
||||
compiler/vectorapi/VectorCastShape64Test.java 8269952 generic-x64
|
||||
|
||||
#############################################################################
|
||||
|
||||
|
146
test/hotspot/jtreg/compiler/c2/TestCondAddDeadBranch.java
Normal file
146
test/hotspot/jtreg/compiler/c2/TestCondAddDeadBranch.java
Normal file
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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 8268883
|
||||
* @summary C2: assert(false) failed: unscheduable graph
|
||||
*
|
||||
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=TestCondAddDeadBranch TestCondAddDeadBranch
|
||||
*
|
||||
*/
|
||||
|
||||
public class TestCondAddDeadBranch {
|
||||
|
||||
public static final int N = 400;
|
||||
|
||||
public static long instanceCount=47540L;
|
||||
public int iFld=-41658;
|
||||
public static float fFld=95.926F;
|
||||
public static double dFld=0.15667;
|
||||
public static int iFld1=4;
|
||||
public static short sFld=5587;
|
||||
public static short sArrFld[]=new short[N];
|
||||
|
||||
static {
|
||||
init(TestCondAddDeadBranch.sArrFld, (short)-26197);
|
||||
}
|
||||
|
||||
public static long vSmallMeth_check_sum = 0;
|
||||
|
||||
public static void vSmallMeth(long l, long l1, int i) {
|
||||
vSmallMeth_check_sum += l + l1 + i;
|
||||
}
|
||||
|
||||
public static void vMeth(int i1, int i2) {
|
||||
int i3=-27774, i4=9, i5=2, i6=12, i7=0, i8=-4, i29=53186;
|
||||
long lArr[][]=new long[N][N];
|
||||
}
|
||||
|
||||
public void mainTest(String[] strArr1) {
|
||||
|
||||
short s=838;
|
||||
int i31=238, i32=-19630, i33=-1, i34=181, i35=155, i36=-8401, i37=-50, i38=-153, iArr[][]=new int[N][N];
|
||||
float f1=46.763F, fArr[]=new float[N];
|
||||
byte byArr[]=new byte[N];
|
||||
boolean bArr[]=new boolean[N];
|
||||
|
||||
init(fArr, -59.7F);
|
||||
init(byArr, (byte)63);
|
||||
init(iArr, 39165);
|
||||
|
||||
for (float f : fArr) {
|
||||
for (int smallinvoc=0; smallinvoc<62; smallinvoc++) vSmallMeth(TestCondAddDeadBranch.instanceCount = ((TestCondAddDeadBranch.instanceCount++)
|
||||
* 65430), ((iFld + iFld) * (iFld++)) + (iFld + (iFld + iFld)), -s);
|
||||
}
|
||||
TestCondAddDeadBranch.instanceCount |= -2906416119L;
|
||||
for (byte by : byArr) {
|
||||
vMeth(iFld, -8);
|
||||
iFld |= (int)TestCondAddDeadBranch.instanceCount;
|
||||
i31 = 1;
|
||||
do {
|
||||
TestCondAddDeadBranch.sFld -= (short)TestCondAddDeadBranch.iFld1;
|
||||
} while (++i31 < 63);
|
||||
}
|
||||
for (i32 = 7; i32 < 160; i32++) {
|
||||
for (i34 = 1; i34 < 164; i34 += 3) {
|
||||
try {
|
||||
iFld = (105 / i33);
|
||||
TestCondAddDeadBranch.iFld1 = (iArr[i34 + 1][i34 + 1] % iArr[i32 + 1][i34 - 1]);
|
||||
TestCondAddDeadBranch.iFld1 = (254 / i32);
|
||||
} catch (ArithmeticException a_e) {}
|
||||
}
|
||||
i33 <<= i31;
|
||||
}
|
||||
switch ((((TestCondAddDeadBranch.iFld1 >>> 1) % 5) * 5) + 60) {
|
||||
case 84:
|
||||
case 82:
|
||||
TestCondAddDeadBranch.fFld += TestCondAddDeadBranch.instanceCount;
|
||||
i36 = 1;
|
||||
break;
|
||||
case 83:
|
||||
TestCondAddDeadBranch.dFld += i32;
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("s i31 i32 = " + s + "," + i31 + "," + i32);
|
||||
System.out.println("i33 i34 i35 = " + i33 + "," + i34 + "," + i35);
|
||||
}
|
||||
|
||||
public static void main(String[] strArr) {
|
||||
TestCondAddDeadBranch _instance = new TestCondAddDeadBranch();
|
||||
for (int i = 0; i < 10; i++ ) {
|
||||
_instance.mainTest(strArr);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(short[] a, short seed) {
|
||||
for (int j = 0; j < a.length; j++) {
|
||||
a[j] = (short) ((j % 2 == 0) ? seed + j : seed - j);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(float[] a, float seed) {
|
||||
for (int j = 0; j < a.length; j++) {
|
||||
a[j] = (j % 2 == 0) ? seed + j : seed - j;
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(byte[] a, byte seed) {
|
||||
for (int j = 0; j < a.length; j++) {
|
||||
a[j] = (byte) ((j % 2 == 0) ? seed + j : seed - j);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(int[][] a, int seed) {
|
||||
for (int j = 0; j < a.length; j++) {
|
||||
init(a[j], seed);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(int[] a, int seed) {
|
||||
for (int j = 0; j < a.length; j++) {
|
||||
a[j] = (j % 2 == 0) ? seed + j : seed - j;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. 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 8269575
|
||||
* @summary C2: assert(false) failed: graph should be schedulable after JDK-8252372
|
||||
*
|
||||
* @run main/othervm -Xcomp -XX:CompileOnly=TestSunkNodeDueToBrokenAntiDependency TestSunkNodeDueToBrokenAntiDependency
|
||||
*
|
||||
*/
|
||||
|
||||
public class TestSunkNodeDueToBrokenAntiDependency {
|
||||
|
||||
public static final int N = 400;
|
||||
|
||||
public static volatile long instanceCount=-154L;
|
||||
public volatile int iArrFld[]=new int[N];
|
||||
|
||||
public void mainTest() {
|
||||
|
||||
int i8=8, i9=-3, i10=-199, i11=13, i12=8, i13=2;
|
||||
long lArr1[]=new long[N];
|
||||
|
||||
for (int i7 : iArrFld) {
|
||||
for (i8 = 1; i8 < 63; ++i8) {
|
||||
i10 = 1;
|
||||
while (++i10 < 2) {
|
||||
i7 += (int)instanceCount;
|
||||
lArr1[i10 + 1] -= 3;
|
||||
}
|
||||
i11 = 2;
|
||||
do {
|
||||
byte by2=-104;
|
||||
by2 = (byte)instanceCount;
|
||||
} while (--i11 > 0);
|
||||
i9 <<= 6;
|
||||
for (i12 = i8; 2 > i12; i12++) {
|
||||
switch (((i11 >>> 1) % 1) + 66) {
|
||||
case 66:
|
||||
instanceCount -= i13;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void main(String[] strArr) {
|
||||
TestSunkNodeDueToBrokenAntiDependency _instance = new TestSunkNodeDueToBrokenAntiDependency();
|
||||
for (int i = 0; i < 10; i++ ) {
|
||||
_instance.mainTest();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,504 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Arm Limited. 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 compiler.vectorapi;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import jdk.incubator.vector.ByteVector;
|
||||
import jdk.incubator.vector.DoubleVector;
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.IntVector;
|
||||
import jdk.incubator.vector.LongVector;
|
||||
import jdk.incubator.vector.ShortVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8268966
|
||||
* @summary AArch64: 'bad AD file' in some vector conversion tests
|
||||
* @modules jdk.incubator.vector
|
||||
* @run testng/othervm -XX:-TieredCompilation compiler.vectorapi.VectorCastShape128Test
|
||||
*/
|
||||
|
||||
|
||||
public class VectorCastShape128Test {
|
||||
|
||||
private static final VectorSpecies<Long> lspec = LongVector.SPECIES_128;
|
||||
private static final VectorSpecies<Integer> ispec = IntVector.SPECIES_128;
|
||||
private static final VectorSpecies<Short> sspec = ShortVector.SPECIES_128;
|
||||
private static final VectorSpecies<Byte> bspec = ByteVector.SPECIES_128;
|
||||
private static final VectorSpecies<Float> fspec = FloatVector.SPECIES_128;
|
||||
private static final VectorSpecies<Double> dspec = DoubleVector.SPECIES_128;
|
||||
|
||||
private static final int NUM_ITER = 50000;
|
||||
private static final int LENGTH = 512;
|
||||
private static int[] ia;
|
||||
private static int[] ib;
|
||||
private static byte[] ba;
|
||||
private static byte[] bb;
|
||||
private static short[] sa;
|
||||
private static short[] sb;
|
||||
private static long[] la;
|
||||
private static long[] lb;
|
||||
private static double[] da;
|
||||
private static double[] db;
|
||||
private static float[] fa;
|
||||
private static float[] fb;
|
||||
|
||||
private static void initialize() {
|
||||
ia = new int[LENGTH];
|
||||
ib = new int[LENGTH];
|
||||
la = new long[LENGTH];
|
||||
lb = new long[LENGTH];
|
||||
sa = new short[LENGTH];
|
||||
sb = new short[LENGTH];
|
||||
ba = new byte[LENGTH];
|
||||
bb = new byte[LENGTH];
|
||||
fa = new float[LENGTH];
|
||||
fb = new float[LENGTH];
|
||||
da = new double[LENGTH];
|
||||
db = new double[LENGTH];
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
ia[i] = r.nextInt();
|
||||
la[i] = r.nextLong();
|
||||
sa[i] = (short) r.nextInt();
|
||||
ba[i] = (byte) r.nextInt();
|
||||
fa[i] = r.nextFloat();
|
||||
da[i] = r.nextDouble();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testDoubleToByte() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToShort() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToInt() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToLong() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToFloat() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testFloatToByte() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToShort() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToInt() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToLong() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToDouble() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testIntToByte() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToShort() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToLong() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToFloat() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToDouble() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testLongToByte() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToShort() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToInt() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToFloat() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToDouble() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testShortToByte() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToInt() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToLong() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToFloat() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToDouble() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testByteToShort() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToInt() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToLong() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToFloat() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToDouble() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCastShape128() {
|
||||
initialize();
|
||||
for (int i = 0; i < NUM_ITER; i++) {
|
||||
testDoubleToByte();
|
||||
testDoubleToShort();
|
||||
testDoubleToInt();
|
||||
testDoubleToLong();
|
||||
testDoubleToFloat();
|
||||
|
||||
testFloatToByte();
|
||||
testFloatToShort();
|
||||
testFloatToInt();
|
||||
testFloatToLong();
|
||||
testFloatToDouble();
|
||||
|
||||
testLongToByte();
|
||||
testLongToShort();
|
||||
testLongToInt();
|
||||
testLongToFloat();
|
||||
testLongToDouble();
|
||||
|
||||
testIntToByte();
|
||||
testIntToShort();
|
||||
testIntToLong();
|
||||
testIntToFloat();
|
||||
testIntToDouble();
|
||||
|
||||
testShortToByte();
|
||||
testShortToInt();
|
||||
testShortToLong();
|
||||
testShortToFloat();
|
||||
testShortToDouble();
|
||||
|
||||
testByteToShort();
|
||||
testByteToInt();
|
||||
testByteToLong();
|
||||
testByteToFloat();
|
||||
testByteToDouble();
|
||||
}
|
||||
}
|
||||
}
|
504
test/hotspot/jtreg/compiler/vectorapi/VectorCastShape64Test.java
Normal file
504
test/hotspot/jtreg/compiler/vectorapi/VectorCastShape64Test.java
Normal file
@ -0,0 +1,504 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Arm Limited. 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 compiler.vectorapi;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import jdk.incubator.vector.ByteVector;
|
||||
import jdk.incubator.vector.DoubleVector;
|
||||
import jdk.incubator.vector.FloatVector;
|
||||
import jdk.incubator.vector.IntVector;
|
||||
import jdk.incubator.vector.LongVector;
|
||||
import jdk.incubator.vector.ShortVector;
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8268966
|
||||
* @summary AArch64: 'bad AD file' in some vector conversion tests
|
||||
* @modules jdk.incubator.vector
|
||||
* @run testng/othervm -XX:-TieredCompilation compiler.vectorapi.VectorCastShape64Test
|
||||
*/
|
||||
|
||||
|
||||
public class VectorCastShape64Test {
|
||||
|
||||
private static final VectorSpecies<Long> lspec = LongVector.SPECIES_64;
|
||||
private static final VectorSpecies<Integer> ispec = IntVector.SPECIES_64;
|
||||
private static final VectorSpecies<Short> sspec = ShortVector.SPECIES_64;
|
||||
private static final VectorSpecies<Byte> bspec = ByteVector.SPECIES_64;
|
||||
private static final VectorSpecies<Float> fspec = FloatVector.SPECIES_64;
|
||||
private static final VectorSpecies<Double> dspec = DoubleVector.SPECIES_64;
|
||||
|
||||
private static final int NUM_ITER = 50000;
|
||||
private static final int LENGTH = 512;
|
||||
private static int[] ia;
|
||||
private static int[] ib;
|
||||
private static byte[] ba;
|
||||
private static byte[] bb;
|
||||
private static short[] sa;
|
||||
private static short[] sb;
|
||||
private static long[] la;
|
||||
private static long[] lb;
|
||||
private static double[] da;
|
||||
private static double[] db;
|
||||
private static float[] fa;
|
||||
private static float[] fb;
|
||||
|
||||
private static void initialize() {
|
||||
ia = new int[LENGTH];
|
||||
ib = new int[LENGTH];
|
||||
la = new long[LENGTH];
|
||||
lb = new long[LENGTH];
|
||||
sa = new short[LENGTH];
|
||||
sb = new short[LENGTH];
|
||||
ba = new byte[LENGTH];
|
||||
bb = new byte[LENGTH];
|
||||
fa = new float[LENGTH];
|
||||
fb = new float[LENGTH];
|
||||
da = new double[LENGTH];
|
||||
db = new double[LENGTH];
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < LENGTH; i++) {
|
||||
ia[i] = r.nextInt();
|
||||
la[i] = r.nextLong();
|
||||
sa[i] = (short) r.nextInt();
|
||||
ba[i] = (byte) r.nextInt();
|
||||
fa[i] = r.nextFloat();
|
||||
da[i] = r.nextDouble();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testDoubleToByte() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToShort() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToInt() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToLong() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testDoubleToFloat() {
|
||||
for (int i = 0; i < dspec.loopBound(LENGTH); i += dspec.length()) {
|
||||
DoubleVector va = DoubleVector.fromArray(dspec, da, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(dspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) da[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testFloatToByte() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToShort() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToInt() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToLong() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testFloatToDouble() {
|
||||
for (int i = 0; i < fspec.loopBound(LENGTH); i += fspec.length()) {
|
||||
FloatVector va = FloatVector.fromArray(fspec, fa, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(fspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) fa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testIntToByte() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToShort() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToLong() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToFloat() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testIntToDouble() {
|
||||
for (int i = 0; i < ispec.loopBound(LENGTH); i += ispec.length()) {
|
||||
IntVector va = IntVector.fromArray(ispec, ia, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(ispec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) ia[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testLongToByte() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToShort() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToInt() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToFloat() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testLongToDouble() {
|
||||
for (int i = 0; i < lspec.loopBound(LENGTH); i += lspec.length()) {
|
||||
LongVector va = LongVector.fromArray(lspec, la, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(lspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) la[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testShortToByte() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
ByteVector vb = (ByteVector) va.castShape(bspec, 0);
|
||||
vb.intoArray(bb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), bspec.length()); j++) {
|
||||
Assert.assertEquals(bb[j], (byte) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToInt() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToLong() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToFloat() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testShortToDouble() {
|
||||
for (int i = 0; i < sspec.loopBound(LENGTH); i += sspec.length()) {
|
||||
ShortVector va = ShortVector.fromArray(sspec, sa, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(sspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) sa[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void testByteToShort() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
ShortVector vb = (ShortVector) va.castShape(sspec, 0);
|
||||
vb.intoArray(sb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), sspec.length()); j++) {
|
||||
Assert.assertEquals(sb[j], (short) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToInt() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
IntVector vb = (IntVector) va.castShape(ispec, 0);
|
||||
vb.intoArray(ib, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), ispec.length()); j++) {
|
||||
Assert.assertEquals(ib[j], (int) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToLong() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
LongVector vb = (LongVector) va.castShape(lspec, 0);
|
||||
vb.intoArray(lb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), lspec.length()); j++) {
|
||||
Assert.assertEquals(lb[j], (long) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToFloat() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
FloatVector vb = (FloatVector) va.castShape(fspec, 0);
|
||||
vb.intoArray(fb, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), fspec.length()); j++) {
|
||||
Assert.assertEquals(fb[j], (float) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testByteToDouble() {
|
||||
for (int i = 0; i < bspec.loopBound(LENGTH); i += bspec.length()) {
|
||||
ByteVector va = ByteVector.fromArray(bspec, ba, i);
|
||||
DoubleVector vb = (DoubleVector) va.castShape(dspec, 0);
|
||||
vb.intoArray(db, 0);
|
||||
|
||||
for (int j = 0; j < Math.min(bspec.length(), dspec.length()); j++) {
|
||||
Assert.assertEquals(db[j], (double) ba[j + i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCastShape64() {
|
||||
initialize();
|
||||
for (int i = 0; i < NUM_ITER; i++) {
|
||||
testDoubleToByte();
|
||||
testDoubleToShort();
|
||||
testDoubleToInt();
|
||||
testDoubleToLong();
|
||||
testDoubleToFloat();
|
||||
|
||||
testFloatToByte();
|
||||
testFloatToShort();
|
||||
testFloatToInt();
|
||||
testFloatToLong();
|
||||
testFloatToDouble();
|
||||
|
||||
testLongToByte();
|
||||
testLongToShort();
|
||||
testLongToInt();
|
||||
testLongToFloat();
|
||||
testLongToDouble();
|
||||
|
||||
testIntToByte();
|
||||
testIntToShort();
|
||||
testIntToLong();
|
||||
testIntToFloat();
|
||||
testIntToDouble();
|
||||
|
||||
testShortToByte();
|
||||
testShortToInt();
|
||||
testShortToLong();
|
||||
testShortToFloat();
|
||||
testShortToDouble();
|
||||
|
||||
testByteToShort();
|
||||
testByteToInt();
|
||||
testByteToLong();
|
||||
testByteToFloat();
|
||||
testByteToDouble();
|
||||
}
|
||||
}
|
||||
}
|
@ -211,6 +211,21 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5230,55 +5245,77 @@ public class Byte128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountByte128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte128VectorTests::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 maskLastTrueByte128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte128VectorTests::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 maskFirstTrueByte128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte128VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5230,55 +5245,77 @@ public class Byte256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountByte256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte256VectorTests::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 maskLastTrueByte256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte256VectorTests::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 maskFirstTrueByte256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte256VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5230,55 +5245,77 @@ public class Byte512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountByte512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte512VectorTests::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 maskLastTrueByte512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte512VectorTests::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 maskFirstTrueByte512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte512VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5230,55 +5245,77 @@ public class Byte64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountByte64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte64VectorTests::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 maskLastTrueByte64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte64VectorTests::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 maskFirstTrueByte64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Byte64VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -216,6 +216,21 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(byte[] r, byte[] a, byte element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5235,55 +5250,77 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::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 maskLastTrueByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::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 maskFirstTrueByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,6 +211,21 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4781,55 +4796,77 @@ public class Double128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountDouble128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double128VectorTests::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 maskLastTrueDouble128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double128VectorTests::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 maskFirstTrueDouble128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double128VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4781,55 +4796,77 @@ public class Double256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double256VectorTests::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 maskLastTrueDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double256VectorTests::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 maskFirstTrueDouble256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double256VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4781,55 +4796,77 @@ public class Double512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountDouble512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double512VectorTests::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 maskLastTrueDouble512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double512VectorTests::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 maskFirstTrueDouble512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double512VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4781,55 +4796,77 @@ public class Double64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountDouble64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double64VectorTests::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 maskLastTrueDouble64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double64VectorTests::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 maskFirstTrueDouble64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Double64VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -216,6 +216,21 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(double[] r, double[] a, double element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4786,55 +4801,77 @@ public class DoubleMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::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 maskLastTrueDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::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 maskFirstTrueDoubleMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, DoubleMaxVectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,6 +211,21 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(float[] r, float[] a, float element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4759,55 +4774,77 @@ public class Float128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float128VectorTests::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 maskLastTrueFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float128VectorTests::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 maskFirstTrueFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float128VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(float[] r, float[] a, float element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4759,55 +4774,77 @@ public class Float256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountFloat256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float256VectorTests::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 maskLastTrueFloat256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float256VectorTests::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 maskFirstTrueFloat256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float256VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(float[] r, float[] a, float element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4759,55 +4774,77 @@ public class Float512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountFloat512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float512VectorTests::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 maskLastTrueFloat512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float512VectorTests::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 maskFirstTrueFloat512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float512VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(float[] r, float[] a, float element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4759,55 +4774,77 @@ public class Float64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountFloat64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float64VectorTests::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 maskLastTrueFloat64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float64VectorTests::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 maskFirstTrueFloat64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Float64VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -216,6 +216,21 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(float[] r, float[] a, float element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -4764,55 +4779,77 @@ public class FloatMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountFloatMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, FloatMaxVectorTests::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 maskLastTrueFloatMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, FloatMaxVectorTests::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 maskFirstTrueFloatMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, FloatMaxVectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,6 +211,21 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(int[] r, int[] a, int element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5184,55 +5199,77 @@ public class Int128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int128VectorTests::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 maskLastTrueInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int128VectorTests::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 maskFirstTrueInt128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int128VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(int[] r, int[] a, int element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5184,55 +5199,77 @@ public class Int256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountInt256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int256VectorTests::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 maskLastTrueInt256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int256VectorTests::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 maskFirstTrueInt256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int256VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(int[] r, int[] a, int element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5184,55 +5199,77 @@ public class Int512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountInt512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int512VectorTests::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 maskLastTrueInt512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int512VectorTests::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 maskFirstTrueInt512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int512VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(int[] r, int[] a, int element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5184,55 +5199,77 @@ public class Int64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountInt64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int64VectorTests::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 maskLastTrueInt64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int64VectorTests::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 maskFirstTrueInt64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Int64VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -216,6 +216,21 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(int[] r, int[] a, int element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5189,55 +5204,77 @@ public class IntMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountIntMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::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 maskLastTrueIntMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::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 maskFirstTrueIntMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,6 +168,21 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(long[] r, long[] a, long element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5068,55 +5083,77 @@ public class Long128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountLong128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long128VectorTests::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 maskLastTrueLong128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long128VectorTests::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 maskFirstTrueLong128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long128VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -168,6 +168,21 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(long[] r, long[] a, long element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5068,55 +5083,77 @@ public class Long256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long256VectorTests::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 maskLastTrueLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long256VectorTests::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 maskFirstTrueLong256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long256VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -168,6 +168,21 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(long[] r, long[] a, long element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5068,55 +5083,77 @@ public class Long512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountLong512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long512VectorTests::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 maskLastTrueLong512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long512VectorTests::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 maskFirstTrueLong512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long512VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -168,6 +168,21 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(long[] r, long[] a, long element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5068,55 +5083,77 @@ public class Long64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long64VectorTests::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 maskLastTrueLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long64VectorTests::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 maskFirstTrueLong64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Long64VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -173,6 +173,21 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(long[] r, long[] a, long element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5073,55 +5088,77 @@ public class LongMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::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 maskLastTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::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 maskFirstTrueLongMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, LongMaxVectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,6 +211,21 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(short[] r, short[] a, short element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5209,55 +5224,77 @@ public class Short128VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountShort128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short128VectorTests::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 maskLastTrueShort128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short128VectorTests::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 maskFirstTrueShort128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short128VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(short[] r, short[] a, short element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5209,55 +5224,77 @@ public class Short256VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short256VectorTests::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 maskLastTrueShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short256VectorTests::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 maskFirstTrueShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(short[] r, short[] a, short element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5209,55 +5224,77 @@ public class Short512VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountShort512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short512VectorTests::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 maskLastTrueShort512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short512VectorTests::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 maskFirstTrueShort512VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short512VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -211,6 +211,21 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(short[] r, short[] a, short element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5209,55 +5224,77 @@ public class Short64VectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short64VectorTests::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 maskLastTrueShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short64VectorTests::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 maskFirstTrueShort64VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, Short64VectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
|
@ -216,6 +216,21 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals(short[] r, short[] a, short element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
@ -5214,55 +5229,77 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCountShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::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 maskLastTrueShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::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 maskFirstTrueShortMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, ShortMaxVectorTests::maskFirstTrue);
|
||||
}
|
||||
|
||||
|
||||
|
@ -411,55 +411,77 @@
|
||||
}
|
||||
}
|
||||
|
||||
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 maskTrueCount$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int tcount = vmask.trueCount();
|
||||
int expectedTcount = 0;
|
||||
for (int j = i; j < i + SPECIES.length(); j++) {
|
||||
expectedTcount += a[j] ? 1 : 0;
|
||||
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();
|
||||
}
|
||||
Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, $vectorteststype$::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 maskLastTrue$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ltrue = vmask.lastTrue();
|
||||
int j = i + SPECIES.length() - 1;
|
||||
for (; j >= i; j--) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedLtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +
|
||||
", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, $vectorteststype$::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 maskFirstTrue$vectorteststype$SmokeTest(IntFunction<boolean[]> fa) {
|
||||
boolean[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
var vmask = SPECIES.loadMask(a, i);
|
||||
int ftrue = vmask.firstTrue();
|
||||
int j = i;
|
||||
for (; j < i + SPECIES.length() ; j++) {
|
||||
if (a[j]) break;
|
||||
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();
|
||||
}
|
||||
int expectedFtrue = j - i;
|
||||
|
||||
Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +
|
||||
", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);
|
||||
}
|
||||
|
||||
assertMaskReductionArraysEquals(r, a, $vectorteststype$::maskFirstTrue);
|
||||
}
|
||||
|
||||
#if[!MaxBit]
|
||||
|
@ -242,6 +242,21 @@ public class $vectorteststype$ extends AbstractVectorTest {
|
||||
}
|
||||
}
|
||||
|
||||
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 assertInsertArraysEquals($type$[] r, $type$[] a, $type$ element, int index) {
|
||||
int i = 0;
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user