8293198: [vectorapi] Improve the implementation of VectorMask.indexInRange()

Reviewed-by: jbhateja, qamai, psandoz
This commit is contained in:
Xiaohong Gong 2023-02-10 01:32:05 +00:00
parent b814cfc39d
commit e245620f6f
41 changed files with 632 additions and 42 deletions

View File

@ -5689,6 +5689,18 @@ instruct vmask_gen_imm(pReg pd, immL con, rFlagsReg cr) %{
ins_pipe(pipe_slow);
%}
instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{
predicate(UseSVE > 0);
match(Set pd (VectorMaskGen (SubL src1 src2)));
effect(KILL cr);
format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %}
ins_encode %{
BasicType bt = Matcher::vector_element_basic_type(this);
__ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
%}
ins_pipe(pipe_slow);
%}
// ------------------------------ Popcount vector ------------------------------
// vector popcount - INT

View File

@ -4072,6 +4072,18 @@ instruct vmask_gen_imm(pReg pd, immL con, rFlagsReg cr) %{
ins_pipe(pipe_slow);
%}
instruct vmask_gen_sub(pReg pd, iRegL src1, iRegL src2, rFlagsReg cr) %{
predicate(UseSVE > 0);
match(Set pd (VectorMaskGen (SubL src1 src2)));
effect(KILL cr);
format %{ "vmask_gen_sub $pd, $src2, $src1\t# KILL cr" %}
ins_encode %{
BasicType bt = Matcher::vector_element_basic_type(this);
__ sve_whilelo($pd$$PRegister, __ elemType_to_regVariant(bt), $src2$$Register, $src1$$Register);
%}
ins_pipe(pipe_slow);
%}
// ------------------------------ Popcount vector ------------------------------
// vector popcount - INT

View File

@ -1211,6 +1211,16 @@ class methodHandle;
"Ljdk/internal/vm/vector/VectorSupport$Vector;") \
do_name(index_vector_op_name, "indexVector") \
\
do_intrinsic(_IndexPartiallyInUpperRange, jdk_internal_vm_vector_VectorSupport, index_partially_in_upper_range_name, index_partially_in_upper_range_sig, F_S)\
do_signature(index_partially_in_upper_range_sig, "(Ljava/lang/Class;" \
"Ljava/lang/Class;" \
"I" \
"J" \
"J" \
"Ljdk/internal/vm/vector/VectorSupport$IndexPartiallyInUpperRangeOperation;)" \
"Ljdk/internal/vm/vector/VectorSupport$VectorMask;") \
do_name(index_partially_in_upper_range_name, "indexPartiallyInUpperRange") \
\
/* (2) Bytecode intrinsics */ \
\
do_intrinsic(_park, jdk_internal_misc_Unsafe, park_name, park_signature, F_RN) \
@ -1319,7 +1329,7 @@ enum class vmIntrinsicID : int {
__IGNORE_CLASS, __IGNORE_NAME, __IGNORE_SIGNATURE, __IGNORE_ALIAS)
ID_LIMIT,
LAST_COMPILER_INLINE = _IndexVector,
LAST_COMPILER_INLINE = _IndexPartiallyInUpperRange,
FIRST_MH_SIG_POLY = _invokeGeneric,
FIRST_MH_STATIC = _linkToVirtual,
LAST_MH_SIG_POLY = _linkToNative,

View File

@ -782,6 +782,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt
case vmIntrinsics::_VectorExtract:
case vmIntrinsics::_VectorMaskOp:
case vmIntrinsics::_IndexVector:
case vmIntrinsics::_IndexPartiallyInUpperRange:
return EnableVectorSupport;
case vmIntrinsics::_blackhole:
break;

View File

@ -725,6 +725,8 @@ bool LibraryCallKit::try_to_inline(int predicate) {
return inline_vector_compress_expand();
case vmIntrinsics::_IndexVector:
return inline_index_vector();
case vmIntrinsics::_IndexPartiallyInUpperRange:
return inline_index_partially_in_upper_range();
case vmIntrinsics::_getObjectSize:
return inline_getObjectSize();

View File

@ -357,6 +357,7 @@ class LibraryCallKit : public GraphKit {
bool inline_vector_insert();
bool inline_vector_compress_expand();
bool inline_index_vector();
bool inline_index_partially_in_upper_range();
Node* gen_call_to_svml(int vector_api_op_id, BasicType bt, int num_elem, Node* opd1, Node* opd2);

View File

@ -3006,3 +3006,131 @@ bool LibraryCallKit::inline_index_vector() {
C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt))));
return true;
}
// public static
// <E,
// M extends VectorMask<E>>
// M indexPartiallyInUpperRange(Class<? extends M> mClass, Class<E> eClass, int length,
// long offset, long limit,
// IndexPartiallyInUpperRangeOperation<E, M> defaultImpl)
bool LibraryCallKit::inline_index_partially_in_upper_range() {
const TypeInstPtr* mask_klass = gvn().type(argument(0))->isa_instptr();
const TypeInstPtr* elem_klass = gvn().type(argument(1))->isa_instptr();
const TypeInt* vlen = gvn().type(argument(2))->isa_int();
if (mask_klass == NULL || elem_klass == NULL || vlen == NULL ||
mask_klass->const_oop() == NULL || elem_klass->const_oop() == NULL || !vlen->is_con()) {
if (C->print_intrinsics()) {
tty->print_cr(" ** missing constant: mclass=%s etype=%s vlen=%s",
NodeClassNames[argument(0)->Opcode()],
NodeClassNames[argument(1)->Opcode()],
NodeClassNames[argument(2)->Opcode()]);
}
return false; // not enough info for intrinsification
}
if (!is_klass_initialized(mask_klass)) {
if (C->print_intrinsics()) {
tty->print_cr(" ** klass argument not initialized");
}
return false;
}
ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type();
if (!elem_type->is_primitive_type()) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not a primitive bt=%d", elem_type->basic_type());
}
return false; // should be primitive type
}
int num_elem = vlen->get_con();
BasicType elem_bt = elem_type->basic_type();
// Check whether the necessary ops are supported by current hardware.
bool supports_mask_gen = arch_supports_vector(Op_VectorMaskGen, num_elem, elem_bt, VecMaskUseStore);
if (!supports_mask_gen) {
if (!arch_supports_vector(Op_VectorLoadConst, num_elem, elem_bt, VecMaskNotUsed) ||
!arch_supports_vector(VectorNode::replicate_opcode(elem_bt), num_elem, elem_bt, VecMaskNotUsed) ||
!arch_supports_vector(Op_VectorMaskCmp, num_elem, elem_bt, VecMaskUseStore)) {
if (C->print_intrinsics()) {
tty->print_cr(" ** not supported: vlen=%d etype=%s", num_elem, type2name(elem_bt));
}
return false; // not supported
}
// Check whether the scalar cast operation is supported by current hardware.
if (elem_bt != T_LONG) {
int cast_op = is_integral_type(elem_bt) ? Op_ConvL2I
: (elem_bt == T_FLOAT ? Op_ConvL2F : Op_ConvL2D);
if (!Matcher::match_rule_supported(cast_op)) {
if (C->print_intrinsics()) {
tty->print_cr(" ** Rejected op (%s) because architecture does not support it",
NodeClassNames[cast_op]);
}
return false; // not supported
}
}
}
Node* offset = argument(3);
Node* limit = argument(5);
if (offset == NULL || limit == NULL) {
if (C->print_intrinsics()) {
tty->print_cr(" ** offset or limit argument is NULL");
}
return false; // not supported
}
ciKlass* box_klass = mask_klass->const_oop()->as_instance()->java_lang_Class_klass();
assert(is_vector_mask(box_klass), "argument(0) should be a mask class");
const TypeInstPtr* box_type = TypeInstPtr::make_exact(TypePtr::NotNull, box_klass);
// We assume "offset > 0 && limit >= offset && limit - offset < num_elem".
// So directly get indexLimit with "indexLimit = limit - offset".
Node* indexLimit = gvn().transform(new SubLNode(limit, offset));
Node* mask = NULL;
if (supports_mask_gen) {
mask = gvn().transform(VectorMaskGenNode::make(indexLimit, elem_bt, num_elem));
} else {
// Generate the vector mask based on "mask = iota < indexLimit".
// Broadcast "indexLimit" to a vector.
switch (elem_bt) {
case T_BOOLEAN: // fall-through
case T_BYTE: // fall-through
case T_SHORT: // fall-through
case T_CHAR: // fall-through
case T_INT: {
indexLimit = gvn().transform(new ConvL2INode(indexLimit));
break;
}
case T_DOUBLE: {
indexLimit = gvn().transform(new ConvL2DNode(indexLimit));
break;
}
case T_FLOAT: {
indexLimit = gvn().transform(new ConvL2FNode(indexLimit));
break;
}
case T_LONG: {
// no conversion needed
break;
}
default: fatal("%s", type2name(elem_bt));
}
indexLimit = gvn().transform(VectorNode::scalar2vector(indexLimit, num_elem, Type::get_const_basic_type(elem_bt)));
// Load the "iota" vector.
const TypeVect* vt = TypeVect::make(elem_bt, num_elem);
Node* iota = gvn().transform(new VectorLoadConstNode(gvn().makecon(TypeInt::ZERO), vt));
// Compute the vector mask with "mask = iota < indexLimit".
ConINode* pred_node = (ConINode*)gvn().makecon(TypeInt::make(BoolTest::lt));
const TypeVect* vmask_type = TypeVect::makemask(elem_bt, num_elem);
mask = gvn().transform(new VectorMaskCmpNode(BoolTest::lt, iota, indexLimit, pred_node, vmask_type));
}
Node* vbox = box_vector(mask, box_type, elem_bt, num_elem);
set_result(vbox);
C->set_max_vector_size(MAX2(C->max_vector_size(), (uint)(num_elem * type2aelembytes(elem_bt))));
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -210,6 +210,23 @@ public class VectorSupport {
return defaultImpl.fromBits(bits, s);
}
/* ============================================================================ */
public interface IndexPartiallyInUpperRangeOperation<E,
M extends VectorMask<E>> {
M apply(long offset, long limit);
}
@IntrinsicCandidate
public static
<E,
M extends VectorMask<E>>
M indexPartiallyInUpperRange(Class<? extends M> mClass, Class<E> eClass,
int length, long offset, long limit,
IndexPartiallyInUpperRangeOperation<E, M> defaultImpl) {
assert isNonCapturingLambda(defaultImpl) : defaultImpl;
return defaultImpl.apply(offset, limit);
}
/* ============================================================================ */
public interface ShuffleIotaOperation<S extends VectorSpecies<?>,
SH extends VectorShuffle<?>> {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -195,24 +195,51 @@ abstract class AbstractMask<E> extends VectorMask<E> {
return res;
}
@Override
/*package-private*/
@ForceInline
public VectorMask<E> indexInRange(int offset, int limit) {
VectorMask<E> indexPartiallyInRange(int offset, int limit) {
int vlength = length();
Vector<E> iota = vectorSpecies().zero().addIndex(1);
VectorMask<E> badMask = checkIndex0(offset, limit, iota, vlength);
return this.andNot(badMask);
return badMask.not();
}
/*package-private*/
@ForceInline
VectorMask<E> indexPartiallyInRange(long offset, long limit) {
int vlength = length();
Vector<E> iota = vectorSpecies().zero().addIndex(1);
VectorMask<E> badMask = checkIndex0(offset, limit, iota, vlength);
return badMask.not();
}
@Override
@ForceInline
public VectorMask<E> indexInRange(long offset, long limit) {
int vlength = length();
Vector<E> iota = vectorSpecies().zero().addIndex(1);
VectorMask<E> badMask = checkIndex0(offset, limit, iota, vlength);
return this.andNot(badMask);
public VectorMask<E> indexInRange(int offset, int limit) {
if (offset < 0) {
return this.and(indexPartiallyInRange(offset, limit));
} else if (offset >= limit) {
return vectorSpecies().maskAll(false);
} else if (limit - offset >= length()) {
return this;
}
return this.and(indexPartiallyInUpperRange(offset, limit));
}
@ForceInline
public VectorMask<E> indexInRange(long offset, long limit) {
if (offset < 0) {
return this.and(indexPartiallyInRange(offset, limit));
} else if (offset >= limit) {
return vectorSpecies().maskAll(false);
} else if (limit - offset >= length()) {
return this;
}
return this.and(indexPartiallyInUpperRange(offset, limit));
}
abstract VectorMask<E> indexPartiallyInUpperRange(long offset, long limit);
/*package-private*/
@ForceInline
AbstractVector<E>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -685,6 +685,15 @@ final class Byte128Vector extends ByteVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Byte128Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Byte128Mask) VectorSupport.indexPartiallyInUpperRange(
Byte128Mask.class, byte.class, VLENGTH, offset, limit,
(o, l) -> (Byte128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -717,6 +717,15 @@ final class Byte256Vector extends ByteVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Byte256Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Byte256Mask) VectorSupport.indexPartiallyInUpperRange(
Byte256Mask.class, byte.class, VLENGTH, offset, limit,
(o, l) -> (Byte256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -781,6 +781,15 @@ final class Byte512Vector extends ByteVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Byte512Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Byte512Mask) VectorSupport.indexPartiallyInUpperRange(
Byte512Mask.class, byte.class, VLENGTH, offset, limit,
(o, l) -> (Byte512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -669,6 +669,15 @@ final class Byte64Vector extends ByteVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Byte64Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Byte64Mask) VectorSupport.indexPartiallyInUpperRange(
Byte64Mask.class, byte.class, VLENGTH, offset, limit,
(o, l) -> (Byte64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -655,6 +655,15 @@ final class ByteMaxVector extends ByteVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
ByteMaxMask indexPartiallyInUpperRange(long offset, long limit) {
return (ByteMaxMask) VectorSupport.indexPartiallyInUpperRange(
ByteMaxMask.class, byte.class, VLENGTH, offset, limit,
(o, l) -> (ByteMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -646,6 +646,15 @@ final class Double128Vector extends DoubleVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Double128Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Double128Mask) VectorSupport.indexPartiallyInUpperRange(
Double128Mask.class, double.class, VLENGTH, offset, limit,
(o, l) -> (Double128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -650,6 +650,15 @@ final class Double256Vector extends DoubleVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Double256Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Double256Mask) VectorSupport.indexPartiallyInUpperRange(
Double256Mask.class, double.class, VLENGTH, offset, limit,
(o, l) -> (Double256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -658,6 +658,15 @@ final class Double512Vector extends DoubleVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Double512Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Double512Mask) VectorSupport.indexPartiallyInUpperRange(
Double512Mask.class, double.class, VLENGTH, offset, limit,
(o, l) -> (Double512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -644,6 +644,15 @@ final class Double64Vector extends DoubleVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Double64Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Double64Mask) VectorSupport.indexPartiallyInUpperRange(
Double64Mask.class, double.class, VLENGTH, offset, limit,
(o, l) -> (Double64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -643,6 +643,15 @@ final class DoubleMaxVector extends DoubleVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
DoubleMaxMask indexPartiallyInUpperRange(long offset, long limit) {
return (DoubleMaxMask) VectorSupport.indexPartiallyInUpperRange(
DoubleMaxMask.class, double.class, VLENGTH, offset, limit,
(o, l) -> (DoubleMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -650,6 +650,15 @@ final class Float128Vector extends FloatVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Float128Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Float128Mask) VectorSupport.indexPartiallyInUpperRange(
Float128Mask.class, float.class, VLENGTH, offset, limit,
(o, l) -> (Float128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -658,6 +658,15 @@ final class Float256Vector extends FloatVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Float256Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Float256Mask) VectorSupport.indexPartiallyInUpperRange(
Float256Mask.class, float.class, VLENGTH, offset, limit,
(o, l) -> (Float256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -674,6 +674,15 @@ final class Float512Vector extends FloatVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Float512Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Float512Mask) VectorSupport.indexPartiallyInUpperRange(
Float512Mask.class, float.class, VLENGTH, offset, limit,
(o, l) -> (Float512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -646,6 +646,15 @@ final class Float64Vector extends FloatVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Float64Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Float64Mask) VectorSupport.indexPartiallyInUpperRange(
Float64Mask.class, float.class, VLENGTH, offset, limit,
(o, l) -> (Float64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -643,6 +643,15 @@ final class FloatMaxVector extends FloatVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
FloatMaxMask indexPartiallyInUpperRange(long offset, long limit) {
return (FloatMaxMask) VectorSupport.indexPartiallyInUpperRange(
FloatMaxMask.class, float.class, VLENGTH, offset, limit,
(o, l) -> (FloatMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -661,6 +661,15 @@ final class Int128Vector extends IntVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Int128Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Int128Mask) VectorSupport.indexPartiallyInUpperRange(
Int128Mask.class, int.class, VLENGTH, offset, limit,
(o, l) -> (Int128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -669,6 +669,15 @@ final class Int256Vector extends IntVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Int256Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Int256Mask) VectorSupport.indexPartiallyInUpperRange(
Int256Mask.class, int.class, VLENGTH, offset, limit,
(o, l) -> (Int256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -685,6 +685,15 @@ final class Int512Vector extends IntVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Int512Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Int512Mask) VectorSupport.indexPartiallyInUpperRange(
Int512Mask.class, int.class, VLENGTH, offset, limit,
(o, l) -> (Int512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -657,6 +657,15 @@ final class Int64Vector extends IntVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Int64Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Int64Mask) VectorSupport.indexPartiallyInUpperRange(
Int64Mask.class, int.class, VLENGTH, offset, limit,
(o, l) -> (Int64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -655,6 +655,15 @@ final class IntMaxVector extends IntVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
IntMaxMask indexPartiallyInUpperRange(long offset, long limit) {
return (IntMaxMask) VectorSupport.indexPartiallyInUpperRange(
IntMaxMask.class, int.class, VLENGTH, offset, limit,
(o, l) -> (IntMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -647,6 +647,15 @@ final class Long128Vector extends LongVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Long128Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Long128Mask) VectorSupport.indexPartiallyInUpperRange(
Long128Mask.class, long.class, VLENGTH, offset, limit,
(o, l) -> (Long128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -651,6 +651,15 @@ final class Long256Vector extends LongVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Long256Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Long256Mask) VectorSupport.indexPartiallyInUpperRange(
Long256Mask.class, long.class, VLENGTH, offset, limit,
(o, l) -> (Long256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -659,6 +659,15 @@ final class Long512Vector extends LongVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Long512Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Long512Mask) VectorSupport.indexPartiallyInUpperRange(
Long512Mask.class, long.class, VLENGTH, offset, limit,
(o, l) -> (Long512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -645,6 +645,15 @@ final class Long64Vector extends LongVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Long64Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Long64Mask) VectorSupport.indexPartiallyInUpperRange(
Long64Mask.class, long.class, VLENGTH, offset, limit,
(o, l) -> (Long64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -645,6 +645,15 @@ final class LongMaxVector extends LongVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
LongMaxMask indexPartiallyInUpperRange(long offset, long limit) {
return (LongMaxMask) VectorSupport.indexPartiallyInUpperRange(
LongMaxMask.class, long.class, VLENGTH, offset, limit,
(o, l) -> (LongMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -669,6 +669,15 @@ final class Short128Vector extends ShortVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Short128Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Short128Mask) VectorSupport.indexPartiallyInUpperRange(
Short128Mask.class, short.class, VLENGTH, offset, limit,
(o, l) -> (Short128Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -685,6 +685,15 @@ final class Short256Vector extends ShortVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Short256Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Short256Mask) VectorSupport.indexPartiallyInUpperRange(
Short256Mask.class, short.class, VLENGTH, offset, limit,
(o, l) -> (Short256Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -717,6 +717,15 @@ final class Short512Vector extends ShortVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Short512Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Short512Mask) VectorSupport.indexPartiallyInUpperRange(
Short512Mask.class, short.class, VLENGTH, offset, limit,
(o, l) -> (Short512Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -661,6 +661,15 @@ final class Short64Vector extends ShortVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
Short64Mask indexPartiallyInUpperRange(long offset, long limit) {
return (Short64Mask) VectorSupport.indexPartiallyInUpperRange(
Short64Mask.class, short.class, VLENGTH, offset, limit,
(o, l) -> (Short64Mask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -655,6 +655,15 @@ final class ShortMaxVector extends ShortVector {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
ShortMaxMask indexPartiallyInUpperRange(long offset, long limit) {
return (ShortMaxMask) VectorSupport.indexPartiallyInUpperRange(
ShortMaxMask.class, short.class, VLENGTH, offset, limit,
(o, l) -> (ShortMaxMask) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -928,6 +928,15 @@ final class $vectortype$ extends $abstractvectortype$ {
return xor(m.not());
}
@Override
@ForceInline
/*package-private*/
$masktype$ indexPartiallyInUpperRange(long offset, long limit) {
return ($masktype$) VectorSupport.indexPartiallyInUpperRange(
$masktype$.class, $type$.class, VLENGTH, offset, limit,
(o, l) -> ($masktype$) TRUE_MASK.indexPartiallyInRange(o, l));
}
// Unary operations
@Override

View File

@ -0,0 +1,101 @@
//
// Copyright (c) 2023, 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 org.openjdk.bench.jdk.incubator.vector;
import java.util.concurrent.TimeUnit;
import jdk.incubator.vector.*;
import org.openjdk.jmh.annotations.*;
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 3, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"})
public class IndexInRangeBenchmark {
@Param({"7", "256", "259", "512"})
private int size;
private boolean[] mask;
private static final VectorSpecies<Byte> bspecies = VectorSpecies.ofLargestShape(byte.class);
private static final VectorSpecies<Short> sspecies = VectorSpecies.ofLargestShape(short.class);
private static final VectorSpecies<Integer> ispecies = VectorSpecies.ofLargestShape(int.class);
private static final VectorSpecies<Long> lspecies = VectorSpecies.ofLargestShape(long.class);
private static final VectorSpecies<Float> fspecies = VectorSpecies.ofLargestShape(float.class);
private static final VectorSpecies<Double> dspecies = VectorSpecies.ofLargestShape(double.class);
@Setup(Level.Trial)
public void Setup() {
mask = new boolean[512];
}
@Benchmark
public void byteIndexInRange() {
for (int i = 0; i < size; i += bspecies.length()) {
var m = bspecies.indexInRange(i, size);
m.intoArray(mask, i);
}
}
@Benchmark
public void shortIndexInRange() {
for (int i = 0; i < size; i += sspecies.length()) {
var m = sspecies.indexInRange(i, size);
m.intoArray(mask, i);
}
}
@Benchmark
public void intIndexInRange() {
for (int i = 0; i < size; i += ispecies.length()) {
var m = ispecies.indexInRange(i, size);
m.intoArray(mask, i);
}
}
@Benchmark
public void longIndexInRange() {
for (int i = 0; i < size; i += lspecies.length()) {
var m = lspecies.indexInRange(i, size);
m.intoArray(mask, i);
}
}
@Benchmark
public void floatIndexInRange() {
for (int i = 0; i < size; i += fspecies.length()) {
var m = fspecies.indexInRange(i, size);
m.intoArray(mask, i);
}
}
@Benchmark
public void doubleIndexInRange() {
for (int i = 0; i < size; i += dspecies.length()) {
var m = dspecies.indexInRange(i, size);
m.intoArray(mask, i);
}
}
}