Summary
Enhancements for loading/storing a short
vector from/to a char
array, loading/storing a byte
vector from/to a boolean
array, and new vector comparison operators for unsigned comparisons with integral vectors.
Problem
The Vector API does not provide specializations for vectors whose lane element type is char
or boolean
.
Solution
Rather than adding a new class CharVector
, leverage the existing ShortVector
class by providing methods to load/store a ShortVector
from/to char
arrays.
Since a ShortVector
may be loaded from a source of unsigned data (such as a char
array), with no loss of information, it is useful to provide unsigned comparison operators. Thus signed vector lane elements may be operated on as if they are unsigned values. In general, the unsigned comparison operators are supported on all vectors whose element type is an integral type.
Rather than adding a new class BooleanVector
(or reusing VectorMask<E>
), leverage the existing ByteVector
class by providing methods to load/store a ByteVector
from/to boolean
arrays.
Specification
Please see the JavaDoc and specdiff linked here and attached:
Summarizing the main changes herein. The following methods are added to ShortVector
to load/store a short
vector from/to a char
array:
public static ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset)
public static ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset,
VectorMask<Short> m)
public static ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset,
int[] indexMap, int mapOffset)
public static ShortVector fromCharArray(VectorSpecies<Short> species,
char[] a, int offset,
int[] indexMap, int mapOffset, VectorMask<Short> m)
public final void intoCharArray(char[] a, int offset)
public final void intoCharArray(char[] a, int offset,
VectorMask<Short> m)
public final void intoCharArray(char[] a, int offset,
int[] indexMap, int mapOffset)
public final void intoCharArray(char[] a, int offset,
int[] indexMap, int mapOffset, VectorMask<Short> m)
The following methods are added to ByteVector
to load/store a byte
vector from/to a boolean
array:
public static ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset)
public static ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset,
VectorMask<Byte> m)
public static ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset,
int[] indexMap, int mapOffset)
public static ByteVector fromBooleanArray(VectorSpecies<Byte> species,
boolean[] a, int offset,
int[] indexMap, int mapOffset, VectorMask<Byte> m)
public final void intoBooleanArray(boolean[] a, int offset)
public final void intoBooleanArray(boolean[] a, int offset,
VectorMask<Byte> m)
public final void intoBooleanArray(boolean[] a, int offset,
int[] indexMap, int mapOffset)
public final void intoBooleanArray(boolean[] a, int offset,
int[] indexMap, int mapOffset, VectorMask<Byte> m)
The following operators are added as constant fields to VectorOperators
:
public static final VectorOperators.Comparison UNSIGNED_LT
public static final VectorOperators.Comparison UNSIGNED_LE
public static final VectorOperators.Comparison UNSIGNED_GT
public static final VectorOperators.Comparison UNSIGNED_GE
- csr of
-
JDK-8266317 Vector API enhancements
-
- Resolved
-